function writeCadastrese( ck ) {
	if(ck!='') document.write('<a class="xf" target="_top" href="/usuario/default.html">Su Conta</a>');			
	else document.write('<a class="xf" target="_top" href="/usuario/cadastro.html">Registrate grátis</a>');
	
}
function writeUserMenu( ck , item ) {
	if(item=='user') {
	
		if(ck!='') { 		
			
			var nome1 = ck.indexOf("nome_usuario="),
				nome2 = ck.indexOf("&apelido");
				
			if (nome2 == -1) nome2 = ck.indexOf("&email");					
				
			var nomeUser = ck.substring(nome1, nome2).replace("nome_usuario=", "");
			
			for (x=0;x < nomeUser.length;x++)
				nomeUser = nomeUser.replace("+", "&nbsp;");
				
			document.write('Hola <a href="/usuario/conta.html" rel="nofollow">' + nomeUser + '</a>');		
		}	
		else document.write('<a href="/usuario/default.html" rel="nofollow" >Regístrese</a>');	  

	}	
	else if(item=='sair') {
	
		if(ck!='') { 	
			document.write('<li><a href="/usuario/default.html?msg=4" rel="nofollow" >Salir</a></li>');
		}	
	
	}	
	
}

function getCookie(c_name) {
	if (document.cookie.length>0) {
	  	  c_start=document.cookie.indexOf(c_name + "=");
		  if (c_start!=-1) { 
		    c_start = c_start + c_name.length + 1;
		    c_end = document.cookie.indexOf(";", c_start);
		    if (c_end==-1) c_end = document.cookie.length;
		    return unescape(document.cookie.substring(c_start,c_end));
		  } 
	}
	return "";
}
function writeUser( ck ) {
	if(ck!='') { 		
		
		var nome1 = ck.indexOf("nome_usuario="),
			nome2 = ck.indexOf("&apelido");

		if (nome2 == -1) nome2 = ck.indexOf("&email");	

		var nomeUser = ck.substring(nome1, nome2).replace("nome_usuario=", "").replace(/\+/g, "&nbsp;");
		document.write('<span class="xb">Olá <strong>' + nomeUser +'</strong></span>');		
	}	
	else document.write('<span class="xb">¡Hola, Consumidor! <a class="xf" target="_top" href="/usuario/default.html">Accese su cuenta.</a></span>');	  
}
//##########################   Validação das Buscas       ########################
//Função padrão de validação de busca.
function validaBusca(idbox){
	var box=document.getElementById(idbox);
	box.value = trim(box.value);
	if(box.value==''){
		alert('Por favor, introduzca un producto o servicio para realizar la búsqueda.');
		return false;
	}else
		return true;
}
//Expressão regular para retirar e validar os espaços em branco.
function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
//################################################################################