function desconectar(){
	var vHref = location.href;
	var vHost = location.host;
	
	var vUrl = ( vHref.substring(vHref.lastIndexOf(vHost)+vHost.length,vHref.length));
	vUrl=vUrl.replace("&","%26");
	//alert(vUrl);
	vUrl= "/web/accion/private.jsp?scd=OUT&url_retorno=" + vUrl;
	window.location.href=vUrl;
}

/* función que activa o desactiva los campos para facturación a empresa */
function changePayMethod()
{

	if (document.change.pay_method_id.options[document.change.pay_method_id.selectedIndex].value == "3")
	{
		document.change.entidad.disabled=false;
		document.change.entidad.style.background="#FFFFFF";
		document.change.oficina.disabled=false;
		document.change.oficina.style.background="#FFFFFF";
		document.change.dc.disabled=false;
		document.change.dc.style.background="#FFFFFF";
		document.change.cuenta.disabled=false;
		document.change.cuenta.style.background="#FFFFFF";
	}
	else
	{
		document.change.entidad.disabled=true;
		document.change.entidad.style.background="#F5F5F5";
		document.change.oficina.disabled=true;
		document.change.oficina.style.background="#F5F5F5";
		document.change.dc.disabled=true;
		document.change.dc.style.background="#F5F5F5";
		document.change.cuenta.disabled=true;
		document.change.cuenta.style.background="#F5F5F5";
	}
	
	//mirar que metodo de pago hay y habilitar CCC en ese caso	
}


function codifica_password(psw){

	return hex_md5(psw);
}

/*FUNCIONA CON EL V4 ORIGINAL DEVUELVE LA MISMA CLAVE CODIFICADA*/

//function codifica_password(psw){
//
//	hash = str_sha1(psw);
//	
//	result = "";
//	
//	for (index=1;index<=hash.length;index++){
//			
//		oChar = hash.substring(index-1,index);
//		
//		if (oChar.charCodeAt(0) < 10)
//			result = result + "00" + oChar.charCodeAt(0);
//		else if (oChar.charCodeAt(0) < 100)
//			result = result + "0" + oChar.charCodeAt(0);
//		else if (oChar.charCodeAt(0) < 1000)
//			result = result + oChar.charCodeAt(0);
//			
//	}
//
//	return result;
//}


function ltrim ( s ) 
{ 
	return s.replace( /^\s*/, "" ) 
} 

function rtrim ( s ) 
{ 
	return s.replace( /\s*$/, "" ); 
} 

function trim ( s ) 
{ 
	return rtrim(ltrim(s)); 
} 