var current_id = 'none';
var comments_main_swf = 'none';
var is_songs_page = 'none';
function SetLow()
{
 lo_quality = 1;
}
function sendEvent(typ,prm) { 
  thisMovie("p").sendEvent(typ,prm); 
};
var duration;
var old_req_percent=-1;
var _alert;
var flo;
function getUpdate(typ,pr1,pr2,swf) 
{ 
//alert(is_songs_page);
if(current_id != 'none' && is_songs_page !='none')
{
var ssss=comments_main_swf + " - " + swf;
//alert(ssss);
  if(swf==comments_main_swf)
 {
 //alert(current_id);
 try
  {
  //sendEvent("stop");
  }
  catch(e)
  {
  }
  var tmp = document.getElementById(current_id); if (tmp) tmp.className = "play";
  current_id = 'none';
  //double_id = 'none';
 }
} 
var client = new XMLHttpRequest();
if(typ == 'state' && pr1 == 2) {

  }

  if(typ == 'time')
  {
  var percent =(pr1/duration)*100;
  var percent = Math.round(percent);


  if(old_req_percent == percent)
	{
	return;
	}
	else
	{
	//alert(percent);
	
	old_req_percent = percent;
	flo = percent % 20;
	//if(flo == 0)alert(percent);
	if(flo == 0)
	{
       //alert('percent=' + percent + '&trackid=' + stat_id);
	var cl = new XMLHttpRequest();
	var client_target = '/system/loficount.php?st=0&percent=' + percent + '&trackid=' + stat_id; 
	//alert(client_target);
	cl.open("GET", client_target);
	cl.send();
	}
	}
  
  }

};
function thisMovie(movieName) {

	if(navigator.appName.indexOf("Microsoft") != -1) {
		return window[movieName];
	} else {
		return document[movieName];
		
	}
	
};
function HandleClick(file, file_lo, id, l, is_icon)
{
//alert(id);
var reg=/(\d+$)/ 
stat_id=reg.exec(id)[0];
//alert(stat_id);
//alert(file);
is_icon = is_icon || 0;
//alert(is_icon);
if(is_songs_page !='none') 
{
try
{
thisMovie(comments_main_swf).sendEvent("stop");
}
catch(e)
{
}
} 
if (id == current_id) 
{
sendEvent('stop');
current_id = 'none';
var tmp = document.getElementById(id); 
if(tmp)tmp.className="play";

} 
else 
{
duration = l;
CreatePlayer(file, file_lo, id);
var tmp = document.getElementById(current_id); 

if(tmp)tmp.className="play";
current_id = id;
var tmp = document.getElementById(id); 
if(tmp) tmp.className="pause";
}
}
function CreatePlayer(file, file_lo, id) {
  if(lo_quality)
  {
   file=file_lo;
  }
  //alert(file);
  var so = new SWFObject('/system/mplayer/mediaplayer.swf','p','1','1','8');
  so.addParam('allowscriptaccess','always');
  so.addParam('allowfullscreen','true');
  so.addVariable('height','1');
  so.addVariable('width','1');
  so.addVariable('file',file);
  so.addVariable('javascriptid','p');
  so.addVariable('callback','/system/callback.php');
  so.addVariable('usefullscreen','false');
  so.addVariable('enablejs','true');
  so.addVariable('autostart','true');
  so.addVariable('volume','100');
  so.write('pldiv');
  //alert(so);
  //var tmp = document.getElementById("p"); if(tmp) {  tmp.style.visibility="hidden"} 
}
