
function DeleteCookie (name) {
		window.document.cookie = name + "=" +
		"; expires=Thu, 01-Jan-70 00:00:01 GMT; path=/";
}

function SetCookie(name, val) {

	var exp = new Date();
	var cookieTimeToLive = exp.getTime() + (24 * 60 * 60 * 1000);
	exp.setTime(cookieTimeToLive);

	//Modificado JMdlCB 2004-07-30
	//leo y reseteo todas las cookies para 
	//evitar que se pierdan por el camino
	var galletita = window.document.cookie;
	var arreglo = galletita.split(";");
	var i = 0;
	var nombre ="";
	var cant = arreglo.length;
	for(i==0;i<= (cant-1); i++) {
		nombre = arreglo[i].split("=");
		DeleteCookie(nombre[0]);	
	}
	window.document.cookie = name + "=" + escape(val) + "; expires=" + exp.toGMTString()+"; path=/";
	for(i=0;i<=(cant-1); i++) {
		nombre = arreglo[i].split("=");
		if(nombre[0].replace(/ /g, "") != name) {
			window.document.cookie = arreglo[i] + "; expires=" + exp.toGMTString()+"; path=/";
		} 
	}
	return(0);
}

function getCookie(name)
{
	var cookie = "";
	var all_cookies = document.cookie;
	var label = name + "=";

	var offset = all_cookies.indexOf(label);
	if (offset != -1)
	{
		var start = offset + label.length;
		var end = all_cookies.indexOf(";", start);
		if (end == -1)
		{
			end = all_cookies.length;
		}

		cookie = all_cookies.substring(start, end);
	}

	cookie = unescape(cookie);
	return cookie;
}

function GetCookieLP(cookie_name) 
{

	var cookie = document.cookie;
	var script_cookie_name = getScriptName() + "/" + cookie_name;
	script_cookie_name = script_cookie_name.substring(1);
	var index = cookie.indexOf(script_cookie_name + "=");
	if (-1 == index) 
	{
		return "";
	}

	index = cookie.indexOf("=", index);
	if (-1 == index)
	{
		return "";
	}

	var endstr = cookie.indexOf(";", index);
	if (-1 == endstr) 
	{
		endstr = cookie.length;
	}

	var cookie_value = unescape(cookie.substring(index + 1, endstr));
	if (cookie_value == null || cookie_value == "null" || cookie_value == "" || cookie_value.indexOf("undefined") >= 0 || cookie_value.lastIndexOf("=") == cookie_value.length - 1) 
	{
		cookie_value = "";
	}
	
	return cookie_value;
}

function getScriptName()
{
	var path = location.pathname;
	path = path.substring(0, path.indexOf('.') + 4);
	return path;
}
function TemplateSearchVid(){
	vidStr=getCookie("uservid");
	vidStr = vidStr.toLowerCase();
	fn = "default2.htm";
	if(vidStr == "publish:8"){
		fn = "defaultFullservice.htm";
	}
	if(vidStr == "publish:4"){
		fn = "defaultLegal.htm";
	}
	if(vidStr == "publish:7"){
		fn = "defaultAuditoria.htm";
	}

	return fn;
}
function TemplateContentVid(){
	vidStr=getCookie("uservid");
	vidStr = vidStr.toLowerCase();
	fn = "defaultFullServiceContenido.htm";
	if(vidStr == "publish:8"){
		fn = "defaultFullServiceContenido.htm";
	}
	if(vidStr == "publish:4"){
		fn = "defaultLegalContenido.htm";
	}
	if(vidStr == "publish:7"){
		fn = "defaultAuditoriaContenido.htm";
	}

	return fn;
}