function getUrlPath(str){
            pos = str.indexOf("//");
            pos = str.indexOf("/",pos+2);
            relative = str.substring(pos);
            pos= relative.indexOf("?");
            return relative.substring(0, pos);
}

function getUrlQueryString(str){
            pos = str.indexOf("//");
            pos = str.indexOf("/",pos+2);
            relative = str.substring(pos);
            pos= relative.indexOf("?");
            return relative.substring(pos);
}

function f_logout(){
	setCookie("orguseridp","0",null);
 	setCookie("orghash","0",null);
 	setCookie("orgnickp","0",null);
 	setCookie("orguserid","0",null);
 	setCookie("orgpago","0",null);
 	setCookie("pr_categ","",null);
 	setCookie("member","1",null);
	location.href=(top.location.pathname+top.location.search); 
}


function setLog(){

 ck = getCookieValue("orguserid"); 
 
 urlPath= self.location.pathname;
 urlQueryString= self.location.search;
 try{
   if(oldUrl!=null){
   	urlPath= getUrlPath(oldUrl);
   	urlQueryString= getUrlQueryString(oldUrl);

   }
 }
 catch(Exception){
 }
 var site = getSiteCode();
 if (ck==null||ck.length < 4 ){ 	
	document.write("<a target=\"_top\" href=\"/"+site+"/loginmp\" class=hpcateg id=\"MENU:ENTRAR\">Ingresar</a>");
 } else {
 	document.write("<a target=\"_top\" href=\"/"+site+"/logoutmp\" class=hpcateg id=\"MENU:SALIR\">Salir</a>");

 }
}

function setReg(){

 ck = getCookieValue("orguserid"); 
 
 urlPath= self.location.pathname;
 urlQueryString= self.location.search;
 try{
   if(oldUrl!=null){
   	urlPath= getUrlPath(oldUrl);
   	urlQueryString= getUrlQueryString(oldUrl);

   }
 }
 catch(Exception){
 }
 var site = getSiteCode();
 if (ck==null||ck.length < 4 ){ 	
	document.write("<a target=\"_top\" href=\"/"+site+"/registration\" class=hpcateg id=\"MENU:ENTRAR\">¡Inscríbete, es gratis!</a>");
 } else {
 	document.write("");

 }
}

function getTrackCookie(){
  if(getCookieValue("clicked")== null || getCookieValue("clicked")=="0"){	
  	var value = getCookieValue("track_info");
  	if(value!=null){
  		arrayKeys = value.split(":");   	
  		var out = "/jm/ml.track.me?save_ck=N";
  		for (i=1; i < arrayKeys.length; i++)
    		out += "&k"+i+"="+arrayKeys[i];
		var img = new Image().src = out;
	  	setCookie("clicked","1",null);
  	}
  }
}
  
function getSiteCode(){
var path = self.location.pathname;
var site;
if(path.indexOf("chile")>0){
	site = "mlc";
}else if(path.indexOf("argentina")>0){
	site = "mla";
}else if(path.indexOf("colombia")>0){
	site = "mco";
}else if(path.indexOf("venezuela")>0){
	site = "mlv";
}else if(path.indexOf("uruguay")>0){
	site = "mlu";
}else if(path.indexOf("brasil")>0){
	site = "mlb";
}else if(path.indexOf("panama")>0){
	site = "mpa";
}else if(path.indexOf("costarica")>0){
	site = "mcr";
}else if(path.indexOf("dominicana")>0){
	site = "mrd";
}else if(path.indexOf("peru")>0){
	site = "mpe";
}else if(path.indexOf("mexico")>0){
	site = "mlm";
}else if(path.indexOf("ecuador")>0){
	site = "mec";
}  
return site;
}

