function Quran()
{
var Jsurah=new Array(1,2,2,3,4,4,5,6,7,8,9,11,12,15,17,18,21,23,25,27,29,33,36,39,41,46,51,58,67,78);
var Jverse=new Array(0,142,253,93,24,148,82,111,88,40,93,6,53,0,0,75,0,0,21,56,46,31,28,32,47,0,31,0,0,0);
var Sverse=new Array(7,286,199,176,120,165,206,75,129,109,123,111,43,52,99,128,111,110,98,134,112,78,118,64,77,227,93,88,69,60,34,30,73,54,45,83,182,88,75,85,54,53,91,59,37,35,38,29,18,45,60,49,62,55,78,95,29,22,24,13,14,11,11,18,12,12,30,52,51,44,28,28,20,56,40,31,49,39,46,42,29,19,36,25,22,17,19,26,30,20,15,21,11,8,8,19,5,8,8,11,11,8,3,9,5,4,7,3,6,3,5,4,5,6);
var sid=1;
var vid=1;
var rid=0;
var tid=7;
var playlist=0;
var qurl='http://www.versebyversequran.com/data/';
var reciters=new Array("AbdulSamad_64kbps_QuranExplorer.Com","Abdul_Basit_Murattal_192kbps","Abdullah_Basfar_192kbps","Abu Bakr Ash-Shaatree_128kbps","Ahmed_ibn_Ali_al-Ajamy_64kbps_QuranExplorer.Com","Alafasy_128kbps","English/Ibrahim_Walk_192kbps_TEST","Ghamadi_40kbps","Hani_Rifai_192kbps","Hudhaify_128kbps","Hudhaify_32kbps","Husary_128kbps","Menshawi_16kbps","Menshawi_32kbps","Muhammad_Ayyoub_128kbps","Muhammad_Ayyoub_32kbps","Saood bin Ibraaheem Ash-Shuraym_128kbps","warsh/Abdulbasit_Abdussamad");

	this.runSubmit = function() {
          translation=1;
          recitation=1;
          translit=0;
	  if(!$('recitation').checked)
            recitation=0;
	  if(!$('translation').checked)
            translation=0;
	  if($('translit').checked)
            translit=1;
	  document.location="quran.php?surah="+sid+"&verse="+vid+"&trans="+((tid+1)*translation)+"&translit="+translit+"&reciter="+((rid+1)*recitation);
        }

    this.Initiate = function() {
      var myrecite=readCookie('ptqauto');
      if(readCookie('ptqauto')!=null)
        if(readCookie('ptqauto')=="false"){
	  $('auto').checked=false;
        }
      if(readCookie('ptqarabic')!=null)
        if(readCookie('ptqarabic')=="false"){
	  $('arabic').checked=false;
        }
      /*if(readCookie('ptqtranslit')!=null)
        if(readCookie('ptqtranslit')=="true"){
	  $('translit').checked=true;
        }
      if(readCookie('ptqtrans')!=null){
        if(readCookie('ptqtrans')*1<0){
	  $('translation').checked=false;
          $('trans').disabled=!$('translation').checked;
        }else{
          $('trans').selectedIndex=readCookie('ptqtrans')*1;
        }
      }
      if(readCookie('ptqreciter')!=null){
        if(readCookie('ptqreciter')*1<0){
	  $('recitation').checked=false;
          $('reciter').disabled=!$('recitation').checked;
        }else{
          $('reciter').selectedIndex=readCookie('ptqreciter')*1;
        }
      }*/

      this.print();
    };

    this.doRecite = function() {
if(!$('recitation').checked)
  return;
wimpy_clearPlaylist();
if(sid>99)
mysid=""+sid;
else
{
if(sid>9)
mysid="0"+sid;
else
mysid="00"+sid;
}

if(vid>99)
myvid=""+vid;
else
{
if(vid>9)
myvid="0"+vid;
else
myvid="00"+vid;
}

   /*if((vid==1)&&(sid>1)&&(sid!=9)){
     playlist=2;
     wimpy_addTrack(true,qurl+reciters[rid]+'/001001'+'.mp3', '', '');
     wimpy_addTrack(false,qurl+reciters[rid]+'/'+mysid+myvid+'.mp3', '', '');
   }else{
     playlist=1;*/
     wimpy_addTrack(true,qurl+reciters[rid]+'/'+mysid+myvid+'.mp3', '', '');
     $('replay').style.visibility = 'visible';
   //}

    };

    this.updatePlayList = function() {
       playlist--;
    };
    this.getPlayList = function() {
       return playlist;
    };

    this.advance = function(incr) {
     vid+=incr;
     if((vid>verses.length)&&(sid==114)){
       vid-=incr;
       return false;
     }
     if((vid<1)&&(sid==1)){
       vid-=incr;
       return false;
     }
     if((vid>verses.length)&&(sid<114)){
       vid=1;
       sid++;
       this.runSubmit();
     }
     if((vid<1)&&(sid>1)){
       sid--;
       vid=Sverse[sid-1];
       this.runSubmit();
     }
     return true;
    };
    this.print = function() {
     if($('arabic').checked)
       $('Txt_arabic').innerHTML=verses[vid-1];
     if($('translit').checked)
       $('Txt_translit').innerHTML=translits[vid-1];
     if(tid>0)
       $('Txt_trans').innerHTML=transs[vid-1];
     $('verse').selectedIndex=vid-1;
    };
    this.changeJuz = function() {
	sid=Jsurah[$('juz').selectedIndex];
	$('surah').selectedIndex=sid-1;
        this.clearVerses();
        this.populateVerses();
	$('verse').selectedIndex=Jverse[$('juz').selectedIndex];
	vid=$('verse').selectedIndex+1;
        this.runSubmit();
    };
    this.changeSurah = function() {
	sid=$('surah').selectedIndex+1;
        this.fixJuz();
        this.clearVerses();
        this.populateVerses();
        this.runSubmit();
    };
    this.fixJuz = function() {
	sid=$('surah').selectedIndex+1;
	$('juz').selectedIndex=29;
	for(var i = 0; i <30; i++){
		if(Jsurah[i]>sid){
		$('juz').selectedIndex=i-1;
		break;
		}
		if(Jsurah[i]==sid){
		 if(Jverse[i]>1){
		   $('juz').selectedIndex=i; //-1;
		   break;
 		 }else{
		   $('juz').selectedIndex=i;
 		   break;
                 }
                }
	}
    };

    this.changeVerse = function() {
	vid=$('verse').selectedIndex+1;
        this.print();
        this.doRecite();
    };
    this.setJuz = function(newJid) {
	$('juz').selectedIndex=newJid;
    };
    this.setSurah = function(newSid) {
        sid=newSid;
	$('surah').selectedIndex=sid-1;
	this.fixJuz();
        this.clearVerses();
        this.populateVerses();
    };
    this.setVerse = function(newVid) {
        vid=newVid;
	$('verse').selectedIndex=vid-1;
    };
    this.clearVerses = function(){
        vid=1;
	$('verse').options.length = 0;
    };
    this.setReciters = function(newRid) {
        if(newRid>0){
	rid=newRid-1;
	$('reciter').selectedIndex=rid;
        }else{
	  $('recitation').checked=false;
          $('reciter').disabled=!$('recitation').checked;
        }
    };
    this.setTranslators = function(newTid) {
        if(newTid>0){
	tid=newTid-1;
	$('trans').selectedIndex=tid;
        }else{
	  $('translation').checked=false;
          $('trans').disabled=!$('translation').checked;
        }
    };
    this.setReciter = function() {
	rid=$('reciter').selectedIndex;
        setCookie('ptqreciter', (rid+1) , 356, '/', '', '');
    };
    this.setTrans = function() {
	tid=$('trans').selectedIndex;
        setCookie('ptqtrans', (tid+1) , 356, '/', '', '');
        this.runSubmit();
    };
    this.setRecitation = function() {
       if($('recitation').checked)
       setCookie('ptqreciter', ($('reciter').selectedIndex+1) , 356, '/', '', '');
       else
       setCookie('ptqreciter', 0 , 356, '/', '', '');
       $('reciter').disabled=!$('recitation').checked;
    };
    this.setTranslation = function() {
       if($('translation').checked)
       setCookie('ptqtrans', ($('trans').selectedIndex+1) , 356, '/', '', '');
       else
       setCookie('ptqtrans', 0 , 356, '/', '', '');
       $('trans').disabled=!$('translation').checked;
       if($('translation').checked)
          this.runSubmit();
       if(!$('translation').checked)
         $('Txt_trans').innerHTML="";
    };
    this.setTranslit = function() {
       setCookie('ptqtranslit', $('translit').checked , 356, '/', '', '');
       if($('translit').checked)
          this.runSubmit();
       if(!$('translit').checked)
         $('Txt_translit').innerHTML="";
    };
    this.setArabic = function() {
       setCookie('ptqarabic', $('arabic').checked , 356, '/', '', '');
       if(!$('arabic').checked)
         $('Txt_arabic').innerHTML="";
    };
    this.setAuto = function() {
       setCookie('ptqauto', $('auto').checked , 356, '/', '', '');
    };
    this.populateVerses = function(){
	//if(sid>1)
	   firstverse=1;
	//else
	 //  firstverse=0;

	for(var i = firstverse; i <= Sverse[sid-1]; i++)
	{

	    var optn = document.createElement("OPTION");
	    optn.text = i;
	    optn.value = i;

		try {
		    $('verse').add(optn); 
		}
		catch (ex) {
			if(i==0)
		    	$('verse').add(optn, null);  
			else{
			    var optn_Old = $('verse').options[i];
			    $('verse').add(optn, optn_Old);
			}
		}
	}
    }

}


function ttable()
{
window.open('images/Tablee.gif', 'TTable', 'width=600,height=793,resizable=no');
}

function $(v,o) { return((typeof(o)=='object'?o:document).getElementById(v)); }
function $S(o) { return((typeof(o)=='object'?o:$(o)).style); }

    function advance(incr){
      if(q.advance(incr)){
        q.print();
        q.doRecite();
      }
    }

function handleTrackDone(returnedObject){
	
   isWimpyPlaying=false;
      if($('auto').checked){
        if(q.getPlayList()>1){
            q.updatePlayList();
        }else{
	      if(q.advance(1)){
	        q.print();
	        setTimeout("q.doRecite()",500);
              }
        }
      }

}

function handleWimpyInit(retval){
   setTimeout("q.doRecite()",1000);
}

