var NS = (navigator.appName.indexOf("Netscape")!=-1);
var MS = (navigator.appName.indexOf("Microsoft")!=-1);
var VER=parseInt(navigator.appVersion);
var CSS=((MS&&VER>=4)||(NS&&VER>=5));
var NS4=(NS&&VER==4);
var NS6=(NS&&VER==5);
var IE4=(MS&&VER==4);
var IE5=(MS&&VER==5);
var IE6=(MS&&VER==6);
var ver4= (VER>=4&&(MS||NS));
var ver5=((MS&&VER>=5)||(NS&&VER>=5));

/**
* Toggles the check state of a group of boxes
*
* Checkboxes must have an id attribute in the form cb0, cb1...
* @param The number of box to 'check'
*/
function checkAll( objid ) 
{
	var reverse = false;

	if (MS) var id_pre = 'itemslist.';
	else var id_pre= '';	
	
	if ( IE4 ) {
		whichEl = eval(id_pre+objid);
	} else {
		whichEl = document.getElementById(id_pre+objid);
	}	
	
	if (whichEl.checked == true) reverse = true;
	else reverse = false;
	
	if ( IE4 ) {
		whichEl = eval('itemslist');
	} else {
		whichEl = document.getElementById('itemslist');
	}
		
	var c = whichEl.length;
	for (i=0; i < c; i++) 
	if (whichEl.elements[i].type=='checkbox' && !whichEl.elements[i].disabled)
	{
			whichEl.elements[i].checked = reverse;
	}
}

function checkRelease(objid, key, count, pref ) 
{
	var reverse = false;

	if (MS) var id_pre = 'itemslist.';
	else var id_pre= '';	
	
	if ( IE4 ) {
		whichEl = eval(id_pre+objid);
	} else {
		whichEl = document.getElementById(id_pre+objid);
	}	
	
	if (whichEl.checked == true) reverse = true;
	else reverse = false;
	
	if ( IE4 ) {
		whichEl = eval('itemslist');
	} else {
		whichEl = document.getElementById('itemslist');
	}
	
	var val=reverse;
	for (k=0;k<count;k++)
	{
		whichEl.elements['track_'+key+'_'+k].checked=val;
	}
}

function IsOK(message)
{
	return confirm(message);
}

function setCookie(name, value, expires, path, domain, secure) 
{ 
        var curCookie = name + "=" + escape(value) + 
                ((expires) ? "; expires=" + expires.toGMTString() : "") + 
                ((path) ? "; path=" + path : "") + 
                ((domain) ? "; domain=" + domain : "") + 
                ((secure) ? "; secure" : "") 
        document.cookie = curCookie 
} 

function getCookie(name) 
{ 
   var prefix = name + "=" 
   var cookieStartIndex = document.cookie.indexOf(prefix) 
   if (cookieStartIndex == -1) 
      return null 
   var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length) 
   if (cookieEndIndex == -1) 
      cookieEndIndex = document.cookie.length 
   return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex)) 
} 

function show(el,i)
{
	change_pict(el);
	expandEl_btrintop(el);
	expandEl_btrinbot(el);
	var k;
	for (k=0;k < i;k++)
	{
		expandEl_btc201(el+'_'+k);
	}
	for (k=0;k < i-1;k++)
	{
		expandEl_btrin(el+'_'+k);
	}
}

function change_pict(el) 
{
  if ( !CSS ) return;
  if (MS) var img = 'itemslist.img_';
  else var img = 'img_';
  if ( IE4 ) {
    whichEl = eval(img + el);
  } else {
    whichEl = document.getElementById(img + el);
  }
  if (whichEl ) {
  	if ((/arrowdnbig\.gif/.test(whichEl.src)) )
    {
      whichEl.src = "i/arrowupbig.gif";
    }
    else {
      whichEl.src = "i/arrowdnbig.gif";
    }
  }
}

function expandEl_btrintop(el) 
{
  if ( !CSS ) return;
  if ( IE4 ) {
    whichEl = eval("btrintop_" + el);
  } else {
    whichEl = document.getElementById("btrintop_" + el);
  }
  if (whichEl ) {
    if ( whichEl.style.display != "") {
      whichEl.style.display = "";
    }
    else {
      whichEl.style.display = "none";
    }
  }
}

function expandEl_btc201(el) 
{
  if ( !CSS ) return;
  if ( IE4 ) {
    whichEl = eval("btc201_" + el);
  } else {
    whichEl = document.getElementById("btc201_" + el);
  }
  if (whichEl ) {
    if ( whichEl.style.display != "") {
      whichEl.style.display = "";
    }
    else {
      whichEl.style.display = "none";
    }
  }
}

function expandEl_btrin(el) 
{
  if ( !CSS ) return;
  if ( IE4 ) {
    whichEl = eval("btrin_" + el);
  } else {
    whichEl = document.getElementById("btrin_" + el);
  }
  if (whichEl ) {
    if ( whichEl.style.display != "") {
      whichEl.style.display = "";
    }
    else {
      whichEl.style.display = "none";
    }
  }
}

function expandEl_btrinbot(el) 
{
  if ( !CSS ) return;
  if ( IE4 ) {
    whichEl = eval("btrinbot_" + el);
  } else {
    whichEl = document.getElementById("btrinbot_" + el);
  }
  if (whichEl ) {
    if ( whichEl.style.display != "") {
      whichEl.style.display = "";
    }
    else {
      whichEl.style.display = "none";
    }
  }
}



function coverVisibleCheck()
{
	mode = getCookie('music_covers_show')
	if (!mode) {mode='true';}
	

	if ( IE4 ) {
		coverareaEl = eval('coverarea');
		cover_flagEl = eval('cover_flag');
	} else {
		coverareaEl = document.getElementById('coverarea');
		cover_flagEl = document.getElementById('cover_flag');
	}
	
	
	if (coverareaEl)
	{
		for (i=0; i < coverareaEl.length; i++) {
			if (mode=="true") {
				cover_flagEl.checked = 1;
				coverareaEl[i].style.display = 'block';
			}else{
				cover_flagEl.checked = 0;
				coverareaEl[i].style.display = 'none';
			}		
		}
	}else{
		if (mode=="true") {
			cover_flagEl.checked = 1;
			coverareaEl.style.display = 'block';
		}else{
			cover_flagEl.checked = 0;
			coverareaEl.style.display = 'none';
		}		
	}
}

function CoverVisible(checkbox)
{
	setCookie('music_covers_show', checkbox.checked);
	
	if ( IE4 ) {
		coverareaEl = eval('coverarea');
	} else {
		coverareaEl = document.getElementById('coverarea');
	}	
	
	if (coverareaEl.length)
	{
		for (i=0; i < coverareaEl.length; i++) {
			if (checkbox.checked) {
				coverareaEl[i].style.display = 'block';
			}
			else
			{
				coverareaEl[i].style.display = 'none';
			}		
		}
	}
	else
	{
			if (checkbox.checked) {
				coverareaEl.style.display = 'block';
			}
			else
			{
				coverareaEl.style.display = 'none';
			}		
	}
}

function strrep($myvar)
{
	$thisEl = document.getElementById($myvar);
	//document.write($thisEl);
	$thisEl.className = 'btc201_a';
	//$myvar.outerHTML='<img src="i/ico11.gif" width="32" height="32" alt="" />';
}

