function getCookie_esp(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));
}
	

if (document.location.host == ("www-origin.hoycinema.com")) {
	//if (document.referrer != "" && document.referrer != "undefined" && document.referrer != null && document.referrer.indexOf("-origin.") > 0)
	if (document.referrer != "" && document.referrer != "undefined" && document.referrer != null)
	{//Si hay referer
		if  (!document.referrer.indexOf("-origin.") > 0)
		{//Si referer no es -origin.
			var cook = getCookie_esp("lastAccessed");
	
			//if (cook != "" && cook != "undefined" && cook != null && cook.indexOf("-origin") > 0) {
			if (cook.indexOf("-origin") > 0)
			{//Si la cookia es de -origin
				var curCookie = "lastAccessed=www.hoycinema.com; expires=Fri, 31-Dec-2010 00:00:00 GMT;path=/;domain=.hoycinema.com";
				document.cookie = curCookie;
	
			}
			//Redirecciono la pagina.
			pagina = document.location.href.replace("www-origin.","www.");
			document.location.href=pagina;
		}
	}
}
else {

	if(document.location.host != "www.hoycinema.com" && document.location.host != "www1.hoycinema.com" && document.location.host != "www2.hoycinema.com") {	
	
			var curCookie = "lastAccessed=" + escape(document.location.host) + "; expires=Fri, 31-Dec-2010 00:00:00 GMT;path=/;domain=.hoycinema.com";
			document.cookie = curCookie;
	}else{
	
	var cook = getCookie_esp("lastAccessed");
		
		vengode = document.referrer;

		//ESTO NO VALE PARA NADA PORQUE SI NO NOS ENLAZAN NO SE VE.
		/*if(vengode.indexOf("ozu.") > 0) {
			vengode_c = "ozu.hoyinversion.com";
		} else{ 
			vengode_c = "";
		}*/

		if(vengode.indexOf("elcorreodigital.") > 0) {
			vengode_c = "elcorreodigital.hoycinema.com";
		} else if(vengode.indexOf("diariovasco.") > 0) {
			vengode_c = "diariovasco.hoycinema.com";
		} else if(vengode.indexOf("laverdad.") > 0) {
			vengode_c = "laverdad.hoycinema.com";
		} else if(vengode.indexOf("nortecastilla.") > 0) {
			vengode_c = "nortecastilla.hoycinema.com";
		} else if(vengode.indexOf("hoy.") > 0) {
			vengode_c = "hoy.hoycinema.com";
		} else if(vengode.indexOf("larioja.") > 0) {
			vengode_c = "larioja.hoycinema.com";
		} else if(vengode.indexOf("diariosur.") > 0) {
			vengode_c = "diariosur.hoycinema.com";
		} else if(vengode.indexOf("eldiariomontanes.") > 0) {
			vengode_c = "eldiariomontanes.hoycinema.com";
		} else if(vengode.indexOf("ideal.") > 0) {
			vengode_c = "ideal.hoycinema.com";
		} else if(vengode.indexOf("elcomerciodigital.") > 0) {
			vengode_c = "elcomerciodigital.hoycinema.com";
		} else if(vengode.indexOf("lasprovincias.") > 0) {
			vengode_c = "lasprovincias.hoycinema.com";
		} else if(vengode.indexOf("ozu.") > 0) {
			vengode_c = "ozu.hoycinema.com";
		} else if(vengode.indexOf("abc.") > 0) {
			vengode_c = "abc.hoycinema.com";
		} else if(vengode.indexOf("lavoz") > 0) {
    			vengode_c = "lavozdigital.hoycinema.com";
		} else if(vengode.indexOf("hoyinversion.") > 0) {
			vengode_c = "www.hoycinema.com";
		} else{ 
			vengode_c = "";
		}
			if (vengode_c!="") {
				var curCookie = "lastAccessed=" + vengode_c + "; expires=Fri, 31-Dec-2011 00:00:00 GMT;path=/;domain=.hoycinema.com";
				document.cookie = curCookie;
			}
			
		
	}

}
	var urlportal_c = "http://" + getCookie_esp("lastAccessed");
	var mi_url_c = "http://" + getCookie_esp("lastAccessed");
	var nombre =document.location.href.split('/');
	var inicio = document.location.href.indexOf(nombre[3]);
	var pagina = document.location.href.substring(inicio, document.location.href.length);

	//if( !(document.location.href.indexOf("www.hoycinema.com") >0) )
	if(!(document.location.href.indexOf("www.hoycinema.com") >0 || document.location.href.indexOf("www1.hoycinema.com") >0 || document.location.href.indexOf("www2.hoycinema.com") >0 || document.location.href.indexOf("www-origin.hoycinema.com") >0))
	{
		//alert("1");
		document.location.href="http://www.hoycinema.com/"+pagina;
		//window.location="http://www.hoycinema.com/"+pagina;
	}