		 var player = null;
		
		
		function playerReady(obj)
		{
		 player = gid(obj.id);
		player.addControllerListener('ITEM', 'itemMonitor');
		};
		
		function loadNplay(idx)
		{
		player.sendEvent('ITEM',0);
		player.sendEvent('PLAY','true');
		};
		
      function itemMonitor(obj)
      {
	  var lo=player.getPlaylist()[obj.index].title;
	  var myArray = lo.split('*');
	  var videoid=myArray[0];
	  var per_videoid=videoid-1;
	  var pageid=myArray[1];
	  var suraid=myArray[2];
	  var verseid=myArray[3];
	  var TAR = document.getElementById('hany').options[document.getElementById('hany').selectedIndex].value;
	  ///////////
	  setCookie('cook_id',videoid,365);
	  	if ($("#q").hasClass('current')) 
			{
	  		
			$.scrollTo( '#'+videoid, 1000, {duration:2000,offset:-300} );
			}
			if ($("#g").hasClass('current')) 
			{
	  		
			$.scrollTo( '#g'+videoid, 1000, {duration:2000,offset:-300} );
			}
			
			if ($("#d").hasClass('current')) 
			{
			$.scrollTo( '#t'+videoid, 1000, {duration:2000,offset:-300} );
			}
			if ($("#k").hasClass('current')) 
			{
			$.scrollTo( '#k'+videoid, 1000, {duration:2000,offset:-300} );
			}
			if ($("#m").hasClass('current')) 
			{
			$.scrollTo( '#m'+videoid, 1000, {duration:2000,offset:-300} );
			}
		////////

	  if ($("#QuranPartNo option:selected").val()!=pageid)
	  {
		  $("select#QuranPartNo option[selected]").removeAttr("selected");
		  $("select#QuranPartNo option[value="+pageid+"]").attr("selected", "selected");
		  $("#pageno").html(pageid);
		  $("#pageno_k").html(pageid);
		  $("#pageno_m").html(pageid);
		  $("#pageno_t").html(pageid);
		  ///////////////
		  //////// Quran Tab /////////
			if ($("#q").hasClass('current')) 
			{
			$("#quran").load("ajax_a.php?ShowByid=1&quranid="+videoid);
			$("#ma3any").load("ajax_ma3any.php?ShowByid=1&quranid="+videoid);
			}
			//////// Tafseer Tab ////////
			if ($("#t").hasClass('current')) 
			{
			$("#tafseer").load("tafser_details_a.php?quranid="+videoid+"&go="+$("#go option:selected").val()+"&ShowNo=1");
			}
			
			//////// E3rab Tab /////////
			if ($("#e").hasClass('current')) 
			{
			$("#e3rab").load("e3rab_details.php?quranid="+videoid+"&e3r="+$("#e3r option:selected").val()+"&ShowNo=1");
			}
			//////// Trgma Tab /////////
			if ($("#g").hasClass('current')) 
			{
			$("#trgma_quran").load("quran_trgma_a.php?ShowByid=1&quranid="+videoid);
			$("#trgma_d").load("ajax_trgma.php?Action="+TAR+"&ShowByid=1&quranid="+videoid);
			}
			//////// Keraat Tab /////////
			if ($("#k").hasClass('current')) 
			{
			$("#k_quran").load("quran_keraat_a.php?ShowByid=1&quranid="+videoid); 
			$("#ker").load("ajax_keraat.php?ShowByid=1&quranid="+videoid);
			}
			//////// Motshabehat Tab /////////
			if ($("#m").hasClass('current')) 
			{
			$("#m_quran").load("quran_mot_a.php?ShowByid=1&quranid="+videoid);
			$("#mot").load("ajax_motashabeh.php?ShowByid=1&quranid="+videoid);
												
			}
			
	  }
	  ///////////
	  if ($("#QuranSuraNo option:selected").val()!=suraid)
	  {
		  $("select#QuranSuraNo option[selected]").removeAttr("selected");
		  $("select#QuranSuraNo option[value="+suraid+"]").attr("selected", "selected");
		  /////
		  $.getJSON("ajax3.php?ShowBySuraNo=1&SuraNo="+suraid, function(j)
			{
      		var options = '';
      		for (var i = 0; i < j.length; i++) 
			{
        		options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>';
     		}
      		$("select#QuranVerseNo").html(options);
    		});
	  }
	  else
	  {
		$("select#QuranVerseNo option[selected]").removeAttr("selected");
		$("select#QuranVerseNo option[value="+verseid+"]").attr("selected", "selected");  
	  }
	  ////////////
		
	  if (!$("#"+videoid).hasClass('ayaSelected')) 
	  {      
	  	$('#'+per_videoid).removeClass('ayaSelected');  
		$("#"+videoid).addClass('ayaSelected');    
	  } 
	   if (!$("#i"+videoid).hasClass('ayaSelected')) 
	  {      
	  	$('#i'+per_videoid).removeClass('ayaSelected');  
		$("#i"+videoid).addClass('ayaSelected');    
	  } 
	  if (!$("#t"+videoid).hasClass('ayaSelected')) 
	  {      
	  	$('#t'+per_videoid).removeClass('ayaSelected');  
		$("#t"+videoid).addClass('ayaSelected');    
	  } 
	  if (!$("#g"+videoid).hasClass('ayaSelected')) 
	  {      
	  	$('#g'+per_videoid).removeClass('ayaSelected');  
		$("#g"+videoid).addClass('ayaSelected');    
	  } 
	  if ($("#k").hasClass('current')) 
	{
	  if (!$("#k"+videoid).hasClass('ayaSelected')) 
	  {      
	  	$('#k'+per_videoid).removeClass('ayaSelected');  
		$("#k"+videoid).addClass('ayaSelected');    
	  }
	}
	if ($("#m").hasClass('current')) 
	{
	  if (!$("#m"+videoid).hasClass('ayaSelected')) 
	  {      
	  	$('#m'+per_videoid).removeClass('ayaSelected');  
		$("#m"+videoid).addClass('ayaSelected');    
	  }
	}
/////
      };


      function gid(name)
      {
        return document.getElementById(name);
      };





  var flashvars =
      {
        'file':                         'playlist.php?con=yes&rec=Sounds&quranid=1',
        'stretching':                   'exactfit',
        'id':                           'playerId',
        'autostart':                    'false',
		'width':						'157',
		'height':						'20',
		'repeat':						'list',
		'skin':							'simple.swf',
		'item':							'0',
		'shuffle':						'false'
      };

      var params =
      {
        'allowscriptaccess':            'always',
        'allowfullscreen':              'true',
        'bgcolor':                      '#FFFFFF'
      };

      var attributes =
      {
        'id':                           'playerId',
        'name':                         'playerId'
      };

      swfobject.embedSWF('player-viral.swf', 'placeholder', '157', '20', '9.0.124', false, flashvars, params, attributes);
	  /////////////////////
function displaymessage(aya,sur)
{
var RECU = document.getElementById('rec').options[document.getElementById('rec').selectedIndex].value;
var CONT = document.getElementById('continous').options[document.getElementById('continous').selectedIndex].value;
var TAR = document.getElementById('hany').options[document.getElementById('hany').selectedIndex].value;
player.sendEvent('STOP');
player.sendEvent('LOAD', {file:'dummy.flv'});
player.sendEvent('LOAD', {file:'playlist.php?rec='+RECU+'&con='+CONT+'&verse='+aya+'&sura='+sur});
			
			//////// Quran Tab /////////
			if ($("#q").hasClass('current')) 
			{
			$("#quran").load("ajax_a.php?ShowByVerseNo=1&SuraNo="+sur+"&VerseNo="+aya);
			}
			
			//////// Trgma Tab /////////
			if ($("#g").hasClass('current')) 
			{
			$("#trgma_quran").load("quran_trgma_a.php?ShowByVerseNo=1&SuraNo="+sur+"&VerseNo="+aya);
			$("#trgma_d").load("ajax_trgma.php?Action="+TAR+"&ShowByVerseNo=1&SuraNo="+sur+"&VerseNo="+aya);
			}
			//////// Keraat Tab /////////
			if ($("#k").hasClass('current')) 
			{
			$("#k_quran").load("quran_keraat_a.php?ShowByVerseNo=1&SuraNo="+sur+"&VerseNo="+aya); 
			
			}
			//////// Motshabehat Tab /////////
			if ($("#m").hasClass('current')) 
			{
			$("#m_quran").load("quran_mot_a.php?ShowByVerseNo=1&SuraNo="+sur+"&VerseNo="+aya);								
			}

///////// Change Sura name
$("select#QuranSuraNo option[selected]").removeAttr("selected");
$("select#QuranSuraNo option[value="+sur+"]").attr("selected", "selected");

///////// End Change Sura name
////
$.getJSON("ajax3.php?ShowByVerseNo=1&SuraNo="+sur+"&VerseNo="+aya, function(j){
      var options = '';
      for (var i = 0; i < j.length; i++) {
		 options += '<option value="' + j[i].optionValue + '" ' + j[i].selected + '="' + j[i].selected + '">' + j[i].optionDisplay + '</option>';
      }
      $("select#QuranVerseNo").html(options);
    });
////
}
//////////////
function displaya_search(aya,sur)
{
var RECU = document.getElementById('rec').options[document.getElementById('rec').selectedIndex].value;

var TAR = document.getElementById('hany').options[document.getElementById('hany').selectedIndex].value;
player.sendEvent('STOP');
player.sendEvent('LOAD', {file:'dummy.flv'});
player.sendEvent('LOAD', {file:'playlist.php?rec='+RECU+'&con=no&verse='+aya+'&sura='+sur});
//
$("select#QuranSuraNo option[selected]").removeAttr("selected");
$("select#QuranSuraNo option[value="+sur+"]").attr("selected", "selected");
////
$("select#continous option[value=no]").attr("selected", "selected");
////
$.getJSON("ajax3.php?ShowByVerseNo=1&SuraNo="+sur+"&VerseNo="+aya, function(j){
      var options = '';
      for (var i = 0; i < j.length; i++) {
		 options += '<option value="' + j[i].optionValue + '" ' + j[i].selected + '="' + j[i].selected + '">' + j[i].optionDisplay + '</option>';
      }
      $("select#QuranVerseNo").html(options);
    });
////
 										$.ajax({
   													type: "POST",
   													url: "ajax2.php",
   													data: "VerseNo="+aya+"&Sura="+sur,
   													success: function(p_no){
    															$("select#QuranPartNo option[selected]").removeAttr("selected");
																$("select#QuranPartNo option[value="+p_no+"]").attr("selected", "selected");
																										
																			}
 											});
////	
}
//////////////
function displayaya(aya,sur,ch_id)
{
var RECU = document.getElementById('rec').options[document.getElementById('rec').selectedIndex].value;

player.sendEvent('STOP');
player.sendEvent('LOAD', {file:'dummy.flv'});
player.sendEvent('LOAD', {file:'playlist.php?rec='+RECU+'&con=no&verse='+aya+'&sura='+sur});


////
$("select#QuranSuraNo option[selected]").removeAttr("selected");
$("select#QuranSuraNo option[value="+sur+"]").attr("selected", "selected");
///////////
$.ajax({
   									type: "POST",
   									url: "ajax2.php",
   									data: "SuraNo="+sur,
   									success: function(p_no){
    															$("select#QuranPartNo option[selected]").removeAttr("selected");
																$("select#QuranPartNo option[value="+p_no+"]").attr("selected", "selected");
																$("#pageno").html(p_no);
																$("#pageno_k").html(p_no);
																$("#pageno_m").html(p_no);
																$("#pageno_t").html(p_no);
	
   															}
 								});						
/////////
$.getJSON("ajax3.php?ShowByVerseNo=1&SuraNo="+sur+"&VerseNo="+aya, function(j){
      var options = '';
      for (var i = 0; i < j.length; i++) {
		 options += '<option value="' + j[i].optionValue + '" ' + j[i].selected + '="' + j[i].selected + '">' + j[i].optionDisplay + '</option>';
      }
      $("select#QuranVerseNo").html(options);
    });
////
////
}
/////// change font style fun. //////

	function setStyle(obj,style,value){ 
	var browser=navigator.appName;
	if (style=='font-size' & browser=='Netscape')
		{
		style='font-size';
		}
	else if (style=='font-size')
		{
		style='font';
		} 
	document.getElementById(obj).style[style]= value;
	} 
/////// change Tagweed color fun. //////

	function setStyletag(obj,style,value){ 
		
	$("."+obj).css(style,value);
	} 
