var strFoco="";
var intImgSel=1;
//****************************************
function fNull(){intInven=0;}
//****************************************
function fCambiarFilaColor (intCual,intCuantos,strColor){
	i=1;
	while (i<=intCuantos){
		eval("fila"+i+"_"+intCual+".bgColor='"+strColor+"'");
		i++;
	}
}
//****************************************
function fImprimirYCerrar (){
	top.focus(); 
	window.print();
	self.close();
}
//****************************************
function fCambiarImg(istrNombre,istrImagen){document[istrNombre].src = istrImagen;}
//****************************************************
function ventana(vurl,valto,vancho)
{
  var str = "height=" + valto + ",innerHeight=" + valto;
  str += ",width=" + vancho + ",innerWidth=" + vancho;
  var nombre;
  nombre="_blank";
  if (window.screen) {
    var ah = screen.availHeight - 30;
    var aw = screen.availWidth - 10;

    var xc = (aw - vancho) / 2;
    var yc = (ah - valto) / 2;

    str += ",left=" + xc + ",screenX=" + xc;
    str += ",top=" + yc + ",screenY=" + yc;
    
  }
	window.open(vurl,'external',str,'height='+valto+',innerHeight='+valto+',width='+vancho+',innerWidth='+vancho).focus();
}
//*****************************************************
function fValidarLetras(checkStr,Donde,Foco,Acentos) { 
	if (Acentos == 1){var checkOK = fM("ControlCaracteresAcentos"); 
	}else{var checkOK = fM("ControlCaracteres"); }
	var allValid = true; 
	for (i = 0; i < checkStr.length; i++) { 
		ch = checkStr.charAt(i); 
		for (j = 0; j < checkOK.length; j++) 
			if (ch == checkOK.charAt(j)) 
			break; 
			if (j == checkOK.length) { 
				allValid = false; 
				break; 
			} 
		} 
	if (!allValid) { 
		if (Donde==""){
			alert(fM("HaIntroducidoLetrasRaras"));
			if (Foco != ""){ eval("document." + Foco + ".select()"); }
		}
		else{
			alert(fM("SeHanEncontradoCaracteresRaros") + Donde);
			if (Foco != ""){ eval("document." + Foco + ".select()"); }
		}
		return (false); 
	}
	else{return (true);}
}
//****************************************************
function fValidarCorreo(valor){
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(valor)){return true;} 
	else { alert(fM("CorreoMal")); return false ;}
}
//******************************************
function fCapaTexto (strCapa,strVer)
{	MM_showHideLayers (strCapa,'',strVer);
}
//****************************************************
function trim(cadena){ 
	for(i=0; i<cadena.length; ){
	if(cadena.charAt(i)==" ")
	cadena=cadena.substring(i+1, cadena.length);
	else break; }
	for(i=cadena.length-1; i>=0; i=cadena.length-1){
	if(cadena.charAt(i)==" ") cadena=cadena.substring(0,i);
	else break; }
	return cadena;
}
//****************************************
function fSoloNumero(intAlert) {
	if (((window.event.keyCode<48)||(window.event.keyCode>57))&& (window.event.keyCode!=8)) {  
		window.event.keyCode=""; 
		if (intAlert==1){alert(fM("SoloNumeros"));return false;}
		else{return false;}
	}
}
//****************************************
function fValidarLoginPass (){
if (document.frmLogin.txtLogin.value=="")
{	alert(fM("IntroduzcaLogin"));
document.frmLogin.txtLogin.focus();
return;
}
else
{	if (document.frmLogin.txtLogin.value.lastIndexOf("'")!=-1 || document.frmLogin.txtLogin.value.lastIndexOf("=")!=-1 || document.frmLogin.txtLogin.value.lastIndexOf("/")!=-1 || document.frmLogin.txtLogin.value.lastIndexOf("%")!=-1 || document.frmLogin.txtLogin.value.lastIndexOf(".")!=-1 || document.frmLogin.txtLogin.value.lastIndexOf(",")!=-1)
{	alert(fM("LoginIncorrecto"));
document.frmLogin.txtLogin.focus();
return;
}
}
if (document.frmLogin.txtClave.value=="")
{	alert(fM("IntroduzcaClave"));
document.frmLogin.txtClave.focus();
return;
}
else
{	if (document.frmLogin.txtClave.value.lastIndexOf("'")!=-1 || document.frmLogin.txtClave.value.lastIndexOf("=")!=-1 || document.frmLogin.txtClave.value.lastIndexOf("/")!=-1 || document.frmLogin.txtClave.value.lastIndexOf("%")!=-1 || document.frmLogin.txtClave.value.lastIndexOf(".")!=-1 || document.frmLogin.txtClave.value.lastIndexOf(",")!=-1)
{	alert(fM("ClaveIncorrecta"));
document.frmLogin.txtClave.focus();
return;
}
}
document.frmLogin.submit();
document.frmLogin.txtClave.value="";
document.frmLogin.txtLogin.value="";
}

//*****************************************
function fValidarEmailInvitado (){
    if (document.frmInvitado.txtEmailInvitado.value==""){    
        alert(fM("IntroduzcaEmail"));
        document.frmInvitado.txtEmailInvitado.focus();
        return;
    }else{    
        if(!fValidarCorreo(document.frmInvitado.txtEmailInvitado.value)){
            document.frmInvitado.txtEmailInvitado.focus();
            return;
        }
    }
    document.frmInvitado.submit();    
}

//****************************************
function fValidarOlvido (){
if (document.frmOlvido.txtLogin.value==""){    
    alert(fM("IntroduzcaLogin"));
    document.frmOlvido.txtLogin.focus();
    return;
}else{    
    if (document.frmOlvido.txtLogin.value.lastIndexOf("'")!=-1 || document.frmOlvido.txtLogin.value.lastIndexOf("=")!=-1 || document.frmOlvido.txtLogin.value.lastIndexOf("/")!=-1 || document.frmOlvido.txtLogin.value.lastIndexOf("%")!=-1 || document.frmOlvido.txtLogin.value.lastIndexOf(".")!=-1 || document.frmOlvido.txtLogin.value.lastIndexOf(",")!=-1){    
        alert(fM("LoginIncorrecto"));
        document.frmOlvido.txtLogin.focus();
        return;
    }
}
if (document.frmOlvido.txtEmail.value==""){    
    alert(fM("IntroduzcaEmail"));
    document.frmOlvido.txtEmail.focus();
    return;
}else{    
    if(!fValidarCorreo(document.frmOlvido.txtEmail.value)){
        document.frmOlvido.txtEmail.focus();
        return;
    }
}
document.frmOlvido.submit();
document.frmOlvido.txtClave.value="";
document.frmOlvido.txtEmail.value="";
}

//****************************************
function fNoEscribir(intAlert) {
	if (((window.event.keyCode>=0) && (window.event.keyCode<=47))||((window.event.keyCode>=58)&& (window.event.keyCode<=64)) || ((window.event.keyCode>=91)&& (window.event.keyCode<95)) || (window.event.keyCode==96) || (window.event.keyCode>122) ) {  
		window.event.keyCode=""; 
		if (intAlert==1){alert(fM("NoIntroducirCaracteresExtranos"));return;}
		else{return;}
	}
}
//****************************************
function fSoloNumero(intAlert) {
	if (((window.event.keyCode<48)||(window.event.keyCode>57))&& (window.event.keyCode!=8)) {  
		window.event.keyCode=""; 
		if (intAlert==1){alert(fM("SoloNumeros"));return false;}
		else{return false;}
	}
}
//***************************************************************
function fConectarse1(e) {
    tecla = (document.all)?e.keyCode:e.which;
    if (tecla==8 || tecla==0) { return true; } 
    if (tecla==13){ fValidarLoginPass (); }
    patron = /\d/;
    return patron.test(String.fromCharCode(tecla));
}
//***************************************************************
function fConectarse2(e) {
    tecla = (document.all)?e.keyCode:e.which;
    if ( tecla!=8 && tecla!=13 && ((tecla>0 && tecla<=47) || (tecla>=58 && tecla<=64) || (tecla>=91 && tecla<95) || tecla==96 || tecla>122 )) {
        return false;
    }
    if (tecla==13){ 
        fValidarLoginPass (); 
    }else{
        return true;
    }
}
//****************************************
function fSoloDecimal(intAlert) {
	if (((window.event.keyCode<48)||(window.event.keyCode>57))&& (window.event.keyCode!=8)&& (window.event.keyCode!=46)) {  
		window.event.keyCode=""; 
		if (intAlert==1){alert(fM("SoloNumerosConDecimales"));return false;}
		else{return false;}
	}
}
//****************************************
/*function fIntro(intAlert) {
	alert(window.event.keyCode);
    if (window.event.keyCode!=13){
		if (((window.event.keyCode>=0) && (window.event.keyCode<=47))||((window.event.keyCode>=58)&& (window.event.keyCode<=64)) || ((window.event.keyCode>=91)&& (window.event.keyCode<95)) || (window.event.keyCode==96) || (window.event.keyCode>122) ) {  
			window.event.keyCode=""; 
			if (intAlert==1){alert(fM("NoIntroducirCaracteresExtranos"));return;}
			else{return;}
		}
	}else{fValidarLoginPass();}
}*/
//***************************************************************
function fIntro(e) {
    tecla = (document.all)?e.keyCode:e.which;
    if (tecla==13){
       fValidarLoginPass ();
    }else{ return; }
}
//*************************************
function textCounter(maxlimit,elemento){	
if (elemento.value.length > maxlimit){elemento.value = elemento.value.substring(0, maxlimit);}
}
//**************************************
function fBuscarArticulos (){
	if(document.frmBuscar.txtBuscar.value==""){alert("Introduzca las palabras que desea buscar");return;}
	document.frmBuscar.submit();
}
//**************************************
function fValidarCantConsumible (intCodRef,intCodC,intCodSC){
	intCantidad = eval('document.frmReferencias.txtUnidades'+intCodRef+'.value');
	intUdsMins = eval('document.frmReferencias.hdnUM'+intCodRef+'.value');
	if (intCantidad == "" || intCantidad == "0"){alert("Introduzca la cantidad");return;}
	if (isNaN(intCantidad)){alert("Introduzca la cantidad");return;}
	if (intUdsMins=="" || intUdsMins == "0"){intUdsMins=1;}
	if (parseInt(intCantidad) % parseInt(intUdsMins) != 0){alert("La cantidad ha de ser un multiplo de las unidades mínimas");return;}
	location.href='../catalogo/index.asp?pg=13&CodC='+intCodC+'&CodSC='+intCodSC+'&CodRef='+intCodRef+'&Cantidad='+intCantidad;
}
//**************************************
function fCalcularTotal (){
	intPrecio = document.frmPedido.PrecioRef.value;
	intCantidad = document.frmPedido.txtCantidad.value;
	if (intCantidad != ""){
		intTotal = intPrecio * intCantidad;
		document.frmPedido.txtTotal.value = intTotal + " €";
	}else{
		document.frmPedido.txtTotal.value = "";
	}
}
//**************************************
function fVerDetalle (strEstado){
    MM_showHideLayers('dDetalleRegalo','',strEstado);
}
//**************************************
function fVerOcultarCapa (strEstado,strCapa){
    MM_showHideLayers(strCapa,'',strEstado);
}
