var ns4 = (document.layers)? 1 : 0 ;
var ie = (document.all)? 1 : 0 ;
var usr = navigator.userAgent
var objns6 = (usr.indexOf('Netscape6')!=-1)? 1 : 0 ;
var ns = (document.getElementById)? 1 : 0 ;
var isMac = (navigator.userAgent.indexOf('Mac')!=-1) ;
var brsr = (navigator.appName.indexOf("Netscape")!=-1) ;

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_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}
function loadfocus()
{
  if ((navigator.appName== "Netscape" && parseInt(navigator.appVersion) >= 4)|| (navigator.appName.indexOf("Microsoft") != -1 && parseInt(navigator.appVersion) > 3))
    browserVer = '1';
  else
    browserVer = '2';
  if (browserVer == 1)
	window.focus();
  return true;
}
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_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 getParameter(str, name) {
  var res = "";
  if (str.indexOf("?")!=-1) {
    str = str.substring(str.indexOf("?")+1, str.length);
    if (str.indexOf(name)!=-1) {
      if (str.indexOf("&"+name, str.indexOf(name)+name.length)!=-1)
        res = str.substring(str.indexOf("&"+name)+name.length+1, str.indexOf("&"+name))
   	  else
        res = str.substring(str.indexOf(name)+name.length+1, str.length);
      if (res.indexOf("&")!=-1)
        res = res.substring(0,res.indexOf("&"));
   	}
  }
  return res;
}
function showImage(id, src) {
  if (ie)
   	document.all[id].src = src;
  else if (ns)
	document.getElementById(id).src = src;
}
function showElement(id) {
  if(ie)
   	document.all[id].style.visibility = "visible";
  else if (ns)
   	document.getElementById(id).style.visibility = "visible";
}
function hideElement(id) {
  if(ie)
   	document.all[id].style.visibility = "hidden";
  else if (ns)
   	document.getElementById(id).style.visibility = "hidden";
}
function showhideElement(id) {
  if (ie) {
    if (document.all[id].style.visibility == "hidden")
      document.all[id].style.visibility = "visible";
    else
      document.all[id].style.visibility = "hidden";
  }
  else if (ns) {
    if (document.getElementById(id).style.visibility == "hidden")
  	   document.getElementById(id).style.visibility = "visible";
    else
  	   document.getElementById(id).style.visibility = "hidden";
  }
}

function showMessage(id, text) {
  if(ie)
   	document.all[id].innerHTML = text;
  else if (ns)
   	document.getElementById(id).innerHTML = text;
  showElement(id);
}

function showImagePopup(scriptName,section,ind,width,height) {
  width = (width>750)?750:width;
  height = (height>500)?500:height;
  width+=50;
  height+=150;
  width = (width<250)?250:width;
  height = (height<200)?200:height;
  win = window.open('big_image.htm?script='+scriptName+'&section='+section
	+'&ind='+ind,'_blank','width='+width+',height='
	+height+',left=17,top=17,statusbar=no,toolbar=no,scrollbars= never,navbar=no');
  win.focus();
}

function showBig(img,width,height,title) {
  width+=100;
  height+=130;
  win = window.open('big.htm?img='+img+((typeof(title)!='undefined')?'&title='+title:''),'_blank','width='+width+',height='
	+height+',left=17,top=17,statusbar=no,toolbar=no,scrollbars=yes,navbar=no');
  win.focus();
}

function play(ind) {
  win = window.open('musicpop.htm?ind='+ind,'chocolate_musicpop','width=250,height=200,left=17,top=17,statusbar=no,toolbar=no,scrollbars= never,navbar=no');
  win.focus();
}

function XMradio() {
  win = window.open('xm_radio.htm','xm_radio','width=350,height=250,left=17,top=17,statusbar=no,toolbar=no,scrollbars= never,navbar=no');
  win.focus();
}

function troubadour_show() {
  win = window.open('troubadour_show.htm','troubadour_show','width=520,height=465,left=17,top=17,statusbar=no,toolbar=no,scrollbars= never,navbar=no');
  win.focus();
}

function sendmusic(ind) {
  win = window.open('sendmusic.htm','chocolate_sendmusicpop','width=430,height=385,left=17,top=17,statusbar=no,toolbar=no,scrollbars= never,navbar=no');
  win.focus();
}

function send(ind) {
  win = window.open('send.htm','chocolate_sendpop','width=430,height=385,left=17,top=17,statusbar=no,toolbar=no,scrollbars= never,navbar=no');
  win.focus();
}

function setBookmark() {
  if (window.sidebar) { 
    window.sidebar.addPanel(document.title, document.location.href, ""); 
  }
  else if( document.all ) {
    window.external.AddFavorite(document.location.href, document.title);
  }
  else if( window.opera && window.print ) {
    return true;
  }
}

function get_cookie(Name) {
  var search = Name + "="
  var returnvalue = "";
  if (document.cookie.length > 0) {
    offset = document.cookie.indexOf(search)
    // if cookie exists
    if (offset != -1) { 
      offset += search.length
      // set index of beginning of value
      end = document.cookie.indexOf(";", offset);
      // set index of end of cookie value
      if (end == -1) end = document.cookie.length;
      returnvalue=unescape(document.cookie.substring(offset, end))
      }
   }
  return returnvalue;
}

function showAd() {
  if (get_cookie('showAd')=='') {
//    showBig('images/ad_april.jpg',533,400,'');
//	document.cookie = 'showAd=false;';
  }
}

