function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}


function setReadOnly (field, id_field)
{
   if (field.value != '')
   {
   	 var field_value = field.value;
   	 var track_array=field_value.split("|");

   	 id_field.value = track_array[1];
   	 field.readOnly = true;
   }
}

function confirmDelTrack(frm, cmd)
{
  if (confirm("Are you sure you want to delete this track from the playlist?"))
  {
   frm.action = cmd;
   frm.submit();
   return true;
  }
  else
  {
  	return false;
  }
}

function SiteLoader(fl){
  	var x,y;
  	if (self.innerHeight) {// all except Explorer
    	x = self.innerWidth;
    	y = self.innerHeight;
  	} else if (document.documentElement && document.documentElement.clientHeight) {// Explorer 6 Strict Mode
   		x = document.documentElement.clientWidth;
   		y = document.documentElement.clientHeight;
  	} else if (document.body) {// other Explorers
   		x = document.body.clientWidth;
   		y = document.body.clientHeight;
  	}
	
	var table=document.getElementById('loaderback');
	var el=document.getElementById('loader');
	if(null!=el) {
		var top = (y/2) - 50;
		var left = (x/2) - 200;
		if( left<=0 ) left = 10;
		table.style.display=(fl==1)?'block':'none';
		table.style.width = screen.width + "px"
		table.style.height = screen.height + "px";
		el.style.visibility = (fl==1)?'visible':'hidden';
		el.style.display = (fl==1)?'block':'none';
		el.style.left = left + "px"
		el.style.top = top + "px";
		document.body.scroll=(fl==1)?'no':'';
	}
}

function generatePDF()
{
	SiteLoader(1);
	document.forms['playlist_options'].submit();
	
}

function tstLoader()
{
	SiteLoader(1);
	document.forms['tstloader'].submit();
	
}

function toggleDiv (id) {
    var ele = document.getElementById (id);
    ele.style.display = (ele.style.display=='block') ? 'none' : 'block';
}

function toggleRow (id, theImg) {
    var ele = document.getElementById (id);
    
    if (ele.style.display=='block')
    {
      ele.style.display = 'none';
      document.getElementById(theImg).src = "img/ico_plus.gif";
    }
    else
    {
      ele.style.display = 'block';
      document.getElementById(theImg).src = "img/ico_min.gif";
    }
}

function cancelReport(id)
{
	var ele = document.getElementById (id);
    ele.style.display = (ele.style.display=='block') ? 'none' : 'block';
  document.forms['report_track'].elements['report'].checked = false;
}

function popupTerms() {
  window.open('../terms.php' , 'PLG', 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=0,width=400,height=550');
}

function doPrintRegistration()
{
	window.print();
	window.close();
}

function CopyPlusSelect() 
{ 
 var dataVal = document.getElementById('copytext'); 
 var copyText = dataVal.innerHTML; 
 if (window.clipboardData) { // IE send-to-clipboard method. 
      window.clipboardData.setData('Text', copyText); 

 } else if (window.netscape) { 
      // You have to sign the code to enable this or allow the action in about:config by changing user_pref("signed.applets.codebase_principal_support", true); 
      netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); 

      // Store support string in an object. 
      var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString); 
      if (!str) return false; 
      str.data=copyText; 

      // Make transferable. 
      var trans = Components.classes["@mozilla.org/widget/transferable;1"].createInstance(Components.interfaces.nsITransferable); 
      if (!trans) return false; 

      // Specify what datatypes we want to obtain, which is text in this case. 
      trans.addDataFlavor("text/unicode"); 
      trans.setTransferData("text/unicode",str,copyText.length*2); 

      var clipid=Components.interfaces.nsIClipboard; 
      var clip = Components.classes["@mozilla.org/widget/clipboard;1"].getService(clipid); 
      if (!clip) return false; 

      clip.setData(trans,null,clipid.kGlobalClipboard); 
 } 
} 

function ShowRow (id, hide)
{
    if (hide == 1)
    {
       document.getElementById("row" + id).style.display = 'none';
    }
    else
    {
        try { document.getElementById("row" + id).style.display = 'table-row'; }
        catch(e) { document.getElementById("row" + id).style.display = 'block'; }        
    }
}

function RunTopBanner()
{
    document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="509" height="272">\n');
    document.write('<param name="movie" value="img/top_inlog_dev.swf">\n');
    document.write('<param name="quality" value="high">\n');
    document.write('<embed src="img/top_inlog_dev.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="509" height="272"></embed></object>\n');

}

function ShowContent (id, doImg)
{
    if (document.getElementById("row" + id).style.display != 'none')
    {
        document.getElementById("row" + id).style.display = 'none';
        if (doImg == 1)
        {
          document.getElementById("sign" + id).src = "img/ico_plus.gif";
        }
    }
    else
    {
        try { document.getElementById("row" + id).style.display = 'table-row'; }
        catch(e) { document.getElementById("row" + id).style.display = 'block'; }        
        if (doImg == 1)
        {
          document.getElementById("sign" + id).src = "img/ico_min.gif";
        }

    }
}
