function fnull(){

}
function checkout (){
	top.location.href='/bin/Cart?op=ckout';
}

var now = new Date();
gfixDate(now);
now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000); 

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 toplightboxrefresh() {
	if (ggsession && ggusert) {
		// logged in
             	if (parent.content.left){
             		parent.content.left.location= "/user/search.shtml";
            	} else {
                        	parent.content.location= "/user/search.shtml";
            	}
	} else 	if(frames['content']){
                       	parent.content.location= "/user/search.shtml";
	} else {
		document.location.href="/user/search.shtml";
	}


	if (frames['content']){
		frames['content'].location = "/bin/Cklb?ref=/bin/Search?n~1^fmt~list";
	} else {
		 parent.location = "/bin/Cklb?ref=/bin/Search?n~1^fmt~list";
	}
}

function topcartrefresh() {

	if (ggsession && ggusert) {
		// logged in
             	if (parent.content.left){
             		parent.content.left.location= "/bin/Cart?op~view";
            	} else {
                        	top.location= "/bin/Cklb?ref=/bin/Cart?op~view";
            	}
	} else 	if(frames['content']){
                       	parent.content.location= "/bin/Cart?op~view";
	} else {
		document.location.href="/bin/Cklb?ref=/bin/Cart?op~view";
	}


	if (frames['content']){
		frames['content'].location = "/bin/Cklb?ref=/bin/Cart?op~view";
	} else {
		 parent.location = "/bin/Cklb?ref=/bin/Cart?op~view";
	}

}

var ggsession = ggetCookie("gmpsess");
var ggusert = ggetCookie("usert");

function openIFrame(IFrameID, URL){
	var tobj = MM_findObj("player");
	tobj.location.href=URL;
}

function playsong(psid,psartist,psalbum,pssong,psplaymode,psimage,poll_id) {
	var psurl = '/musicplayer.shtml?artist=' + psartist;
	if(poll_id){psurl += '&poll_id=' + poll_id;}
	psurl += '&id=' + psid + '&albumname=' + psalbum + '&song=' + pssong + '&playmode=' + psplaymode + '&im=' + psimage;
	var newwin = window.open(psurl,"musicplayer",'width=420,height=435,resizable=0,scrollbars=no,menubar=no,status=no' );
	if (!newwin.opener) newwin.opener=parent;
	if (newwin.focus) newwin.focus();
	
} 

function sendFeedBack(){
	document.feedback.submit();
	return;
}

function topsearchrefresh() {
	if (ggsession && ggusert) {
	// logged in
                if (parent.content.left){
                        parent.content.left.location= "/user/search.shtml";
                } else {
                        parent.content.location= "/user/search.shtml";
                }
	} else 	if(frames['content']){
                       	parent.content.location= "/user/search.shtml";
	} else {
		document.location.href="/user/search.shtml";
	}
}


function topsearchrefreshpower() {
	if (parent == top){
		parent.frames[1].location = "/bin/Cklb?ref=/user/search_advanced.shtml";
	} else { 
		parent.location = "/bin/Cklb?ref=/user/search_advanced.shtml";
	}
}

function topsearchconcept() {
	if (parent == top){
		parent.frames[1].location = "/bin/Cklb?ref=/search_concept.shtml";
	} else { 
		parent.location = "/bin/Cklb?ref=/search_concept.shtml";
	}
}

function tload(dref)
{
	if(parent.thetop.href != dref){
		parent.thetop.location=dref;
	}
}

function siderefresh()
{
parent.left.location.replace('/bin/Search?n=1&fmt=list');

}

function csiderefresh(id)
{
	xcurrentdate = new Date();
  xcore = xcurrentdate.getSeconds();
  if (id){
  parent.left.location.replace('/bin/Cart?op=view&lc='+ id + '&random=' + xcore);
  }
  else {
  parent.left.location.replace('/bin/Cart?op=view' + '&random=' + xcore);
  }
}

function lccsiderefresh(id)
{
parent.left.location.replace('/bin/Cart?op=view&lc=1');
}


function VersionNavigateur(Netscape, Explorer) {
  if ((navigator.appVersion.substring(0,3) >= Netscape && navigator.appName == 'Netscape') ||      
      (navigator.appVersion.substring(0,3) >= Explorer && navigator.appName.substring(0,9) == 'Microsoft'))
    return true;
else return false;
}
function netie(net, ie) {
  if ((navigator.appVersion.substring(0,3) >= net && navigator.appName == 'Netscape' && net != -1) || (navigator.appVersion.substring(0,3) >= ie && navigator.appName.substring(0,9) == 'Microsoft' && ie != -1))
    return true;
else return false;
}

function cceditWindow()
{
  ccedit_window =
    window.open("https://bin/Profile?cc=1","ccedit","width=500,height=320,status=1");
}





// all new functions

function delfromlb(id) {
  var sess = ggetCookie("gmpsess");
  if (! confirm('are you sure you want to delete this song from your playlist?') )
    return;

	if (parent.lb) {
	      parent.lb.location = '/bin/ExLbDel?rid=' + id + '&sess_id=' + sess;
	} else {
				self.location = '/bin/Cklb?sess_id=' + sess;
  }
}

function addlb(id) {
var sess = ggetCookie("gmpsess");
	
	if (parent.lb) {
			if(sess){
	         var theurl= '/bin/ExLbAdd?id=' + id + '&sess_id=' + sess;
			}
			else{
	         var theurl= '/bin/ExLbAdd?id=' + id;
			}
			parent.lb.location=theurl;
		} else {
			if(sess){
				var theurl= '/bin/Cklb?atlb=' + id + '&sess_id=' + sess;
			}
			else{
				var theurl= '/bin/Cklb?atlb=' + id;
			}
			self.location=theurl;
		}
}

function addcart2(id) {
var sess = ggetCookie("gmpsess");

		if (parent.lb) {	
			if(sess){
				parent.lb.location = '/bin/Cart?op=add&id=' + id + '&fmt=index&sess_id=' + sess;
			}
		else{
				parent.lb.location = '/bin/Cart?op=add&id=' + id + '&fmt=index';
		}
			parent.com.location = '/user/cart_menu.shtml';

		} else {
			if(sess){
			var theurl= '/bin/Cklb?atct=' + id + '&sess_id=' + sess;
			}
			else{
			var theurl= '/bin/Cklb?atct=' + id;
			}
			self.location=theurl;
		}
}


function gsetCookie(name, value, expiredays, path, domain, secure) {
  var ExpireDate = new Date ();
  path = '/';
  ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));
  var curCookie = name + "=" + escape(value) +
      ((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString()) +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");


  document.cookie = curCookie;
}

function gsetCookie2(name2,value2) {
        gsetCookie(name2, value2, null, '/', gGetCookieDom());
}


// name - name of the desired cookie
// * return string containing value of specified cookie or null if cookie does not exist
function ggetCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}

// name - name of the cookie
// [path] - path of the cookie (must be same as path used to create cookie)
// [domain] - domain of the cookie (must be same as domain used to create cookie)
// * path and domain default if assigned null or omitted if no explicit argument proceeds

function gdeleteCookie(name, path, domain) {
  if (ggetCookie(name)) {
    document.cookie = name + "=" + 
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

// date - any instance of the Date object
// * hand all instances of the Date object to this function for "repairs"
function gfixDate(date) {
  var base = new Date(0);
  var skew = base.getTime();
  if (skew > 0)
    date.setTime(date.getTime() - skew);
}

function gGetQV(variable) {
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("="); 
    if (pair[0] == variable) {    
      return pair[1];         
    }                
  }  
  return false;
}
 
function checkRef() {
 var portal = getQV('portal');
 if (portal){
 var portalcookie = getCookie('portal');
  if (portalcookie != portal){
    setCookie('portal',portal,'','/');
  }
 } 
}

function gGetCookieDom(){
var thisdomain = document.domain;
var setdom = thisdomain.replace(/^(www|tools)\./, '');
return '.'+setdom;
}

function gSetBackpage() {
var thispage = location.href;
gsetCookie('backpage', thispage, '', '/', gGetCookieDom());
}



function gsetuser() {

  return;

/*
	var gwhichuserset = ggetCookie("gwhichuser");
	if(typeof gwhichuser != 'undefined' && gwhichuser) {
		gsetCookie("gwhichuser","",now);
	} else {
		gsetCookie("gwhichuser",document.l.username.value,now);
	}
  */
}


function getVars() {
        params = new Object;

        if (! document.location.href.split('?')[1])
                return;

        var varArray = document.location.href.split('?')[1].split('&');


        for(var x=0; x<varArray.length; x++)
        {
                var tmp = varArray[x].split('=');
                if (tmp[0] && tmp[1]) {
                        tmp[1] = tmp[1].replace(/\+/g,' ');
                        params[unescape(tmp[0])] =  unescape(tmp[1]) ;
                }
        }
};


function launchwin(url){
    newwin = window.open(url,"newwindow","height=600,width=660,alwaysLowered=0,alwaysRaised=0,channelmode=0,dependent=1,directories=0,fullscreen=0,hotkeys=1,location=0,menubar=0,resizable=1,scrollbars=1,status=1,toolbar=0,z-lock=0,screenX=0,screeny=0,left=40,top=40");
      if (!newwin.opener) newwin.opener=parent;
        if (newwin.focus) newwin.focus();
}

