function getCookieKey(cual,name) {
var result = "";
var myCookie = document.cookie + ";";
var searchName = name + "=";
var desde = myCookie.indexOf(cual);
if(desde == -1)
result = "";
else{
var startOfCookie = myCookie.indexOf(searchName,desde);
var endOfCookie;
if (startOfCookie != -1){
startOfCookie += searchName.length;
if(name == "PAIS" || cual == "weather")// Si busco la cookie de Pais de El Sitio
endOfCookie = myCookie.indexOf(";", startOfCookie);// Entonces el valor termina con un
else
endOfCookie = myCookie.indexOf("&", startOfCookie);// Si no el valor termina con &

result = unescape(myCookie.substring(startOfCookie, endOfCookie));
}else
result = "";
}
 mas = true;
i = 0;
while(mas){
i = result.indexOf("+",i+1);
if(i == -1)
mas = false;
else{
tmp = result.substring(0,i);
tm1 = result.substring(i+1);
result = tmp + " " + tm1;
}
}
return result;
}

function getCookie (name)
{
	var search = name + "=";
	if (document.cookie.length > 0) { // if there are any cookies
		offset = document.cookie.indexOf(search);
		if (offset != -1) { // if cookie exists
			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;
			return unescape(document.cookie.substring(offset, end));
		 }
	 }
}

function getcode()
{
	p = getCookieKey("elsitio%5Finfo","PAIS");
	if(p=="argentina")
		c = "ar";
	if(p=="chile")
		c = "cl";
	if(p=="mexico")
		c = "mx";
	if(p=="global")
		c = "gl";
	if(p=="uruguay")
		c = "uy";
	if(p=="usa")
		c = "us";
	if(p=="brasil")
		c = "br";
	if(p=="chile")
		c = "cl";
	if(p=="colombia")
		c = "co";
	if(p=="venezuela")
		c = "ve";
	if(p=="espania")
		c = "es";
	if(p=="mx_monterrey")
		c = "mx-mty";
	if(p==""){
		c = "gl";
		p = "global";
	}
	return(c);
}
