//Para poder usar el método soloUnClick, se debe usar primero este para inicializar la variable que controlará la cantidad
//de clicks.
function getUnSoloClickIValue()
{
	return 0;
}

function soloUnClick(clicked)
{
	if(clicked == 1) return true;
    else return false;
}

function chgClass (objName, className)
{
	document.getElementById(objName).className = className;
}

function abrirPopUp(url, ancho, alto, modo)
{
    var popUp = null;
	var config = "width="+ancho+",height="+alto+",top=0,left=0";
    if (modo == "MODAL")
    {
        config = config + ",resizable=no,toolbar=no,location=no,scrollbars=yes,menubar=no";
    }
    else
    {
        if (modo=="TOOLBAR_MENUBAR")
        {
            config = config + ",resizable=no,toolbar=yes,location=no,scrollbars=yes,menubar=yes";
        } else {
	        if (modo=="SCROLL")
	        {
	            config = config + ",resizable=no,toolbar=no,location=no,scrollbars=yes,menubar=no";
	        }
        }
    }
	popUp = window.open(url, 'popUp', config);
	popUp.focus();
}

function abrirPopUpCentrado(url, ancho, alto, modo)
{
	
	var winW = 800, winH = 600;

	if (parseInt(navigator.appVersion)>3) {
	 	if (navigator.appName=="Netscape") {
	  		winW = window.innerWidth;
	  		winH = window.innerHeight;
	 	}
	 	if (navigator.appName.indexOf("Microsoft")!=-1) {
	  		winW = document.body.offsetWidth;
	  		winH = document.body.offsetHeight;
	 	}
	}

    var top = (winH/2)-(alto/2);
    var left = (winW/2)-(ancho/2);
    var popUp = null;
	var config = "width="+ancho+",height="+alto+",top="+top+",left="+left;
    if (modo == "MODAL")
    {
        config = config + ",resizable=no,toolbar=no,location=no,scrollbars=yes,menubar=no";
    }
    else
    {
        if (modo=="TOOLBAR_MENUBAR")
        {
            config = config + ",resizable=no,toolbar=yes,location=no,scrollbars=yes,menubar=yes";
        }
    }
	popUp = window.open(url, 'popUp', config);
	popUp.focus();
}

function abrirPopUpCentrado(url, ancho, alto, modo)
{
	
	var winW = 800, winH = 600;

	if (parseInt(navigator.appVersion)>3) {
	 	if (navigator.appName=="Netscape") {
	  		winW = window.innerWidth;
	  		winH = window.innerHeight;
	 	}
	 	if (navigator.appName.indexOf("Microsoft")!=-1) {
	  		winW = document.body.offsetWidth;
	  		winH = document.body.offsetHeight;
	 	}
	}

    var top = (winH/2)-(alto/2);
    var left = (winW/2)-(ancho/2);
    var popUp = null;
	var config = "width="+ancho+",height="+alto+",top="+top+",left="+left;
    if (modo == "MODAL")
    {
        config = config + ",resizable=no,toolbar=no,location=no,scrollbars=yes,menubar=no";
    }
    else
    {
        if (modo=="TOOLBAR_MENUBAR")
        {
            config = config + ",resizable=no,toolbar=yes,location=no,scrollbars=yes,menubar=yes";
        }
    }
	popUp = window.open(url, 'popUp', config);
	popUp.focus();
}


/* PageFlow mtoConsultaListasUsuario y mtoCarritoDetalle */

function seleccionarTodos( valor )
{
    for(num = 0; num < document.forms["listaCompraUsuarioForm"].length; num++)
        if (document.forms["listaCompraUsuarioForm"].elements[num].type == 'checkbox')
            document.forms["listaCompraUsuarioForm"].elements[num].checked = valor;
            
    return true;
}


function esNumeroPositivo(szNumber)
{
    for(i=0;i<szNumber.length;i++)
        if(!(szNumber.charAt(i)>='0' && szNumber.charAt(i)<='9')) 
            return false;
    
    return true;
}

function trimAll(sString)
{
    while (sString.substring(0,1) == ' ')
        sString = sString.substring(1, sString.length);
    while (sString.substring(sString.length-1, sString.length) == ' ')
        sString = sString.substring(0,sString.length-1);

    return sString;
}

function mostrarAlerta( mensaje )
{
    alert( mensaje.replace("<span>","").replace("</span>","") );
    
    return true;
}

/* Fin de PaegFlow mtoConsultaListasUsuario */

/* Pageflow de supermercado */

function concatenarInfoLinea(linea, href)
{
    var href2;
    href2 = href + "&cantidad=" + document.getElementById("cantidad"+linea).value;
    return href2;
}
function concatenarInfoLineaPromo(linea, href)
{
    href2 = href + "&cantidad=" + document.getElementById("cantidadPromo"+linea).value;
    return href2;
}

/* Fin de Pageflow de supermercado */

/* PageFlow de mtoPasoPorCaja */

function modifica(value)
{
	if (value==1)
    {
 		document.getElementById("domicilio").style.display="inline";
 		document.getElementById("planta").style.display="none";
	} 
    else 
    {
        document.getElementById("domicilio").style.display="none";
        document.getElementById("planta").style.display="inline";
	}
}

function seleccionarCeldaPasoPorCaja(valor)
{
    document.getElementById("celdaId").value=valor;
}

/* Fin de PageFlow mtoPasoPorCaja */

/* PageFlow de mtoCarritoCaprabo */

function actualitzar()
{
    document.getElementById('actualitzar').className="btActualizarRojo"
    document.getElementsByName('passar_caixa')[0].className="btPasarPorCajaGris";
    document.getElementsByName('passar_caixa')[1].className="btPasarPorCajaGris";
    document.getElementsByName('passar_caixa')[0].disabled=true;
    document.getElementsByName('passar_caixa')[1].disabled=true;
    document.getElementById('actualitzar').disabled=false;    
}

function cambia_fondo(id, familia)
{
    if (familia=="otros")
    {
        document.getElementById(id+"_otros").className="bkmaxEstalviRojoClaro";
        document.getElementById(id+"_caprabo").className="";
    }
    else
    {
     document.getElementById(id+"_caprabo").className="bkmaxEstalviAzulClaro";
     document.getElementById(id+"_otros").className="";
    }
}


/* Fin de PageFlow mtoCarritoCaprabo */

/* PageFlow de mtoCarritoDetalle */

function activarBotonActualizar()
{
    document.getElementById("bActualizarUp").style.display="inline";
    document.getElementById("bActualizarDown").style.display="inline";
}

/* Fin de PageFlow de mtoCarritoDetalle */

/* PageFlow de ayuda */

function printit()
{  
    if (window.print)
        window.print();
    else
    {
        var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
        document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
        WebBrowser1.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box    
        WebBrowser1.outerHTML = "";  
    }
}

/* Fin de PageFlow de ayuda */

/* PageFlow de mtoUsuario */

function checkNifEstado()
{
    var tipoCliente = document.getElementById("tipoClienteP").checked;
    
    if (tipoCliente)
    {
        document.getElementById("textoNIF").readOnly=true;
        document.getElementById("textoNIF").value="";
        document.getElementById("labelNIF").className="carroTextOff";
        document.getElementById("asterisco").className="carroTextOff";
    }
    else
    {
        document.getElementById("textoNIF").readOnly=false;
        document.getElementById("labelNIF").className="opsLateral";
        document.getElementById("asterisco").className="opsTopRojo";
    }
    
    return 1;
}

/* Fin de PageFlow de mtoUsuario */

/* PageFlow de mtoComentarioCarritoLinea y mtoCarritoDetalle */

function maximaLongitud(texto,maxlong)
{
    var in_value, out_value;

    if (texto.value.length > maxlong)
    {
        in_value = texto.value;
        out_value = in_value.substring(0,maxlong);
        texto.value = out_value;
        
        return false;
    }
  
  return true;
}

/* Fin de PageFlows */

function disableButtonAndSubmit(formulario) {
    var documento = document.forms[formulario];
    for(num = 0; num < documento.length; num++) {
        if (documento.elements[num].type == 'button') {
            documento.elements[num].disabled = true;
        }
    }
            
    documento.submit();
}

/* Mostrar u ocultar los elementos divName mediante estilos css */
function mostrarOcultarFiscal(solicito, divName){
    if(solicito.checked) {
        showObject(solicito, divName);
    } else {
        hideObject(solicito, divName);
    }
}
function showObject(solicito, divName){
    document.getElementById(divName).className = 'opsLateralShow';
}
function hideObject(solicito, divName){
    document.getElementById(divName).className = 'opsLateralHide';
}

