function v()
{
	var c=0;

	if( document.getElementById('ci').value=="" )
	{
		document.getElementById("ci_no_aceptado").style.display = "block";
		document.getElementById("ci_aceptado"   ).style.display = "none";
		c++;
	}else if( document.getElementById('ci').value!="" )
	{
		document.getElementById("ci_no_aceptado").style.display = "none";
		document.getElementById("ci_aceptado"   ).style.display = "block";
	}


	if( document.getElementById('hi').value=="" )
	{
		document.getElementById("hi_no_aceptado").style.display = "block";
		document.getElementById("hi_aceptado"   ).style.display = "none";
		c++;
	}else if( document.getElementById('hi').value!="" )
	{
		document.getElementById("hi_no_aceptado").style.display = "none";
		document.getElementById("hi_aceptado"   ).style.display = "block";
	}

	if( c==0 ) //todo esta bien
	{
		trabajador_ajax( document.getElementById('ci').value );
		//document.l.submit();
	}
}


function operacion( nro_producto , id_catalogo, operacion , precio )
{
	valor = parseInt( document.getElementById(id_catalogo).innerHTML );
	if( operacion=="+" )
	{
		//Verificando q no se pase del precio TOPE
		var _total_ = explode (" ", document.getElementById('total_bsf').innerHTML) 
		_total_     = _total_[0]; //233.455,45
		_total_     = str_replace (".", "", _total_);
		_total_     = parseFloat( str_replace (",", ".", _total_) );
		_total_     = _total_ + parseFloat(precio);


		if( parseFloat(_total_) <= parseFloat(document.getElementById('__costo_max__').value) )
		{
			document.getElementById(id_catalogo).innerHTML  = valor+1;
			document.getElementById(id_catalogo).style.color="#000000";
			document.getElementById(id_catalogo).style.fontWeight="bold";


			//Sumar al total del carrito
			document.getElementById('total_bsf').innerHTML = operacion_carrito( precio , "+" );
	
			//Suma uno a la cantidad pedida
			document.getElementById( "cantidad"+nro_producto ).value = parseInt(document.getElementById( "cantidad"+nro_producto ).value) + 1;
		}
	}
	if( operacion=="-" &&  valor > 0 )
	{
		document.getElementById(id_catalogo).innerHTML  = valor-1;
		if( valor-1==0 )
		{
			document.getElementById(id_catalogo).style.color="#ff0000";
			document.getElementById(id_catalogo).style.fontWeight="normal";
		}

		//Restar al total del carrito
		document.getElementById('total_bsf').innerHTML = operacion_carrito( precio , "-" );

		//Resta uno a la cantidad soli
		document.getElementById( "cantidad"+nro_producto ).value = parseInt(document.getElementById( "cantidad"+nro_producto ).value) - 1;
	}
}

function operacion_carrito( precio , operador)
{	
	var total = explode (" ", document.getElementById('total_bsf').innerHTML) 
	total = total[0]; //233.455,45
	total = str_replace (".", "", total);
	total = parseFloat( str_replace (",", ".", total) );
	if( operador=="+" )
		total = total + parseFloat(precio);
	if( operador=="-" )
		total = total - parseFloat(precio);
	total = number_format(total, 2 , ",", "." ) ;

	//Muestra el total en carrito de compra
	return total+" BsF.";
}


function paginador(numero)
{	
	for( i=1; i<=document.getElementById("total_paginas").value ; i++ )
	{
		document.getElementById("p"+i).style.display          = "none";

		//Paginador arriba
		document.getElementById("arriba"+"pagina"+i).style.fontWeight  = "normal";
		document.getElementById("arriba"+"pagina"+i).style.color       = "#000000";
		document.getElementById("arriba"+"pagina"+i).style.fontSize    = "1em";

		//Paginador abajo
		document.getElementById("abajo"+"pagina"+i).style.fontWeight  = "normal";
		document.getElementById("abajo"+"pagina"+i).style.color       = "#000000";
		document.getElementById("abajo"+"pagina"+i).style.fontSize    = "1em";
	}
	document.getElementById(     "p"+numero).style.display     = "block";

	//Paginador arriba
	document.getElementById("arriba"+"pagina"+numero).style.fontWeight  = "bold";
	document.getElementById("arriba"+"pagina"+numero).style.color       = "#930000";
	document.getElementById("arriba"+"pagina"+numero).style.fontSize    = "1.3em";

	//Paginador abajo
	document.getElementById("abajo"+"pagina"+numero).style.fontWeight  = "bold";
	document.getElementById("abajo"+"pagina"+numero).style.color       = "#930000";
	document.getElementById("abajo"+"pagina"+numero).style.fontSize    = "1.3em";		

	//Modificando el Siguiente y Anterior
	var siguiente=0,anterior=0;
	if( parseInt(numero)==1 )
	{
		anterior=1;
		siguiente=2;
	}else
	if( parseInt(numero)==parseInt(document.getElementById("total_paginas").value) )
	{
		anterior  = parseInt(document.getElementById("total_paginas").value)-1;
		siguiente = parseInt(document.getElementById("total_paginas").value);
	}else
	{
		anterior  = parseInt(numero)-1;
		siguiente = parseInt(numero)+1;
	}
	document.getElementById("arriba_anterior").innerHTML = "<a href='javascript:paginador("+anterior+")'><img src='imgs/atras4.png' border='0'>&nbsp;Anterior</a>";
	document.getElementById("arriba_siguiente").innerHTML= "<a href='javascript:paginador("+siguiente+")'>Siguiente&nbsp;<img src='imgs/siguiente4.png' border='0'></a>";


	document.getElementById("abajo_anterior").innerHTML = "<a href='javascript:paginador("+anterior+")'><img src='imgs/atras4.png' border='0'>&nbsp;Anterior</a>";
	document.getElementById("abajo_siguiente").innerHTML= "<a href='javascript:paginador("+siguiente+")'>Siguiente&nbsp;<img src='imgs/siguiente4.png' border='0'></a>";
}

function Aceptar()
{
	alert("1")
}

function Cancelar()
{
	alert("0")
}


function formato_campo(fld,e,t) {
   
    var aux = aux2 = '';
    var i = j = 0;

    if(t==1)
        var strCheck = '0123456789';
    if(t==2)
        var strCheck = 'AaBbCcDdEeFfGgHhIiJjKkLlÃƒÂ‘ÃƒÂ±NnMmOoPpQqRrSsTtUuVvWwXxYyZzÃƒÂ¡ÃƒÂ ÃƒÂ©ÃƒÂ‰ÃƒÂ­ÃƒÂ ÃƒÂ³ÃƒÂ“ÃƒÂºÃƒÂš ';

    if(t==3)
        var strCheck = '0123456789-ext';
    if(t==4)
        var strCheck = '0123456789';
   
    var whichCode = (window.Event) ? e.which : e.keyCode;
    if (whichCode == 13) return true; // Enter

    if (whichCode == 8) return true; // Enter
    if (whichCode == 0) return true; // Enter
    if(t==4){
        if(fld.value==""){
            aux_old=0;
            aux_old2=0;
        }

        if(fld_old=="0")
            fld_old=fld;
        else{
            if(fld_old==fld){
                if (whichCode == 46 && aux_old==0){
                aux_old=1;
                return true;

                }
                if (whichCode == 45 && aux_old2==0 && fld.value==""){
                aux_old2=1;
                return true;
                }
            }else{

                fld_old=fld;
                aux_old=0;
                aux_old2=0;
                if (whichCode == 46 && aux_old==0){
                aux_old=1;
                return true;
                }

                if (whichCode == 45 && aux_old2==0 && fld.value==""){
                aux_old2=1;
                return true;
                }
            }
        }
    }

    key = String.fromCharCode(whichCode); // Get key value from key code
    if (strCheck.indexOf(key) == -1) return false; // Not a valid key
    fld.value += aux2.charAt(i);
} 
