//------------------------------------
// VALIDACION DE CORREO BOLSA DE TRABAJO
//------------------------------------
function validaMantenedorURK(form)
{
	if(form.regionfac.value != "-1" )
    {
		if(document.getElementById('ciudades1').value != "-1" )
		{
			form.comunafac.value = document.getElementById('ciudades1').value;
		}
		else
		{
			alert('El Campo Comuna en Facturacion se Encuentra Vacio');
        	return(false);
		}
    }
    else
    {
    	alert('El Campo Region en Facturacion se Encuentra Vacio');
        form.regionfac.focus();
        return(false);	
    }
	
	if(form.region.value != "-1" )
    {
		if(document.getElementById('ciudades2').value != "-1" )
		{
			form.comuna.value = document.getElementById('ciudades2').value;
		}
		else
		{
			alert('El Campo Comuna se Encuentra Vacio');
        	return(false);
		}
    }
    else
    {
    	alert('El Campo Region se Encuentra Vacio');
        form.region.focus();
        return(false);	
    }

    form.submit();
}
//------------------------------------
// VALIDACION DE CORREO BOLSA DE TRABAJO
//------------------------------------
function validaCorreoBolsaRK(form)
{
    if (form.nombre.value=="")
    {
	alert('El Campo Nombre se Encuentra Vacio');
	form.nombre.focus();
	return(false);
    }
    if (form.apellidos.value=="")
    {
	alert('El Campo Apellidos se Encuentra Vacio');
	form.apellidos.focus();
	return(false);
    }
    if (form.domicilio.value=="")
    {
	alert('El Campo Domicilio se Encuentra Vacio');
	form.domicilio.focus();
	return(false);
    }
    if (form.telefono.value=="")
    {
	alert('El Campo Telefono se Encuentra Vacio');
	form.telefono.focus();
	return(false);
    }
    if (form.fax.value=="")
    {
	alert('El Campo Fax se Encuentra Vacio');
	form.fax.focus();
	return(false);
    }
    if (ValidarEmail(form.email.value)==false){
    	form.email.focus();
        return(false);
    }
    muestraVentanasDIV();
    form.submit();
}
function muestraVentanasDIV()
{
	document.getElementById('muestrabolsa').style.display="none";
	document.getElementById('imgloading').style.display="";
	return;
}
//------------------------------------
// VALIDACION DE DATOS DE ENVIO
//------------------------------------
function IngresaDatosEnvio(form)
{	
	if (form.nombre.value==""){
    	alert('El Campo Nombre se Encuentra Vacio');
        form.nombre.focus();
        return(false);
    }
	if (form.apellidos.value==""){
    	alert('El Campo Apellidos se Encuentra Vacio');
        form.apellidos.focus();
        return(false);
    }
    if (form.direccion.value==""){
    	alert('El Campo Direccion se Encuentra Vacio');
        form.direccion.focus();
        return(false);
    }    
	if(form.pais.value == 36)
	{		
		if (document.getElementById('regiones').value == "-1")
		{
			alert('El Campo Region/Estado se Encuentra Vacio');
			form.regiones.focus();
			return(false);
    	}
		if (document.getElementById('ciudades').value == "-1")
		{
			alert('El Campo Ciudad se Encuentra Vacio');
			form.ciudades.focus();
			return(false);
    	}
		form.region.value = document.getElementById('regiones').value;
		form.ciudad.value = document.getElementById('ciudades').value;
	}
	else
	{
		if (document.getElementById('regiones').value == "")
		{
			alert('El Campo Region/Estado se Encuentra Vacio');
			form.regiones.focus();
			return(false);
    	}
		if (document.getElementById('ciudades').value == "")
		{
			alert('El Campo Ciudad se Encuentra Vacio');
			form.ciudades.focus();
			return(false);
    	}
		form.region.value = document.getElementById('regiones').value;
		form.ciudad.value = document.getElementById('ciudades').value;		
	}
	if(form.pais.value != 36)
	{
		if (form.codpostal.value=="")
		{
			alert('El Campo Codigo Postal se Encuentra Vacio');
			form.codpostal.focus();
			return(false);
    	}
	}
    if (document.getElementById('opactivo').value == 1)
    {
    	if (form.razonsocial_fac.value=="")
    	{
	    	alert('El Campo Razon Social Postal se Encuentra Vacio');
	        form.razonsocial_fac.focus();
	        return(false);
    	}
    	if (form.rut.value=="")
    	{
	    	alert('El Campo R.U.T. se Encuentra Vacio');
	        form.rut.focus();
	        return(false);
    	}	
    	if (form.giro_fac.value=="")
    	{
	    	alert('El Campo Giro se Encuentra Vacio');
	        form.giro_fac.focus();
	        return(false);
    	}
    	if (form.direccion_fac.value=="")
    	{
	    	alert('El Campo Direccion se Encuentra Vacio');
	        form.direccion_fac.focus();
	        return(false);
    	}
    	if (form.fono_fac.value=="")
    	{
	    	alert('El Campo Telefono se Encuentra Vacio');
	        form.fono_fac.focus();
	        return(false);
    	}
    	if (form.nombre_contacto_fac.value=="")
    	{
	    	alert('El Campo Nombre del Contacto se Encuentra Vacio');
	        form.nombre_contacto_fac.focus();
	        return(false);
    	}
		if (ValidarEmail(form.email_contacto_fac.value)==false)
		{
    		form.email_contacto_fac.focus();
        	return(false);
    	}
    	if (form.fono_contacto_fac.value=="")
    	{
	    	alert('El Campo Fono del Contacto se Encuentra Vacio');
	        form.fono_contacto_fac.focus();
	        return(false);
    	}
    	if (form.cargo_contacto_fac.value=="")
    	{
	    	alert('El Campo Cargo del Contacto se Encuentra Vacio');
	        form.cargo_contacto_fac.focus();
	        return(false);
    	}
    }
	//------------------------------------------
	form.submit();
}
//------------------------------------
// VALIDACION DE CORREO KACTUS
//------------------------------------
function validaCorreoKactus(form)
{
    if (form.asunto.value==""){
    	alert('El Campo Asunto se Encuentra Vacio');
        form.asunto.focus();
        return(false);
    }
    if (form.nombre.value==""){
    	alert('El Campo Nombre se Encuentra Vacio');
        form.nombre.focus();
        return(false);
    }
    if (ValidarEmail(form.email.value)==false){
    	form.email.focus();
        return(false);
    }
    if (form.mensaje.value==""){
    	alert('El Campo Mensaje se Encuentra Vacio');
        form.mensaje.focus();
        return(false);
    }
    form.submit();
}
//------------------------------------
// VALIDACION DE NEWSLETTER
//------------------------------------
function validaNewsletter(form)
{
    if (ValidarEmail(form.email.value)==false){
    	form.email.focus();
        return(false);
    }
    form.submit();
}
//------------------------------------
// VALIDACION DE UN NUEVO PRODUCTO
//------------------------------------
function validaCreaProducto(form)
{    		
    if (form.titulo1.value=="")
    {
    	alert('El Campo Titulo(ES) se Encuentra Vacio');
        form.titulo1.focus();
        return(false);
    }
    if (form.titulo2.value=="")
    {
    	alert('El Campo Titulo(US) se Encuentra Vacio');
        form.titulo2.focus();
        return(false);
    }
	if (form.list2.length == 0)
    {
    	alert('Debe Seleccionar una Categoria');        
        return(false);
    }

    form.comboBoxHidden.value="";
    lista=form.list2;
    if (lista.length != 0 )
    {
    	var comboBox = document.getElementById('list2');
		for (x=0; x<(lista.length); x++)
    	{
			form.comboBoxHidden.value=form.comboBoxHidden.value + comboBox.options[x].value+ ",";
    	}
    }
	
	form.comboBoxHidden2.value="";
    lista=form.list4;
    if (lista.length != 0 )
    {
    	var comboBox = document.getElementById('list4');
		for (x=0; x<(lista.length); x++)
    	{
			form.comboBoxHidden2.value=form.comboBoxHidden2.value + comboBox.options[x].value+ ",";
    	}
    }
	document.getElementById('BotonSetea').style.display="none";
	document.getElementById('BotonEnvia').style.display="";
}
//------------------------------------
// VALIDACION DE MODIFICAR UN PRODUCTO
//------------------------------------
function validaModificaProducto(form)
{    		
	form.xcategoria.value = document.getElementById('categoria').value;
	form.xsubcategoria.value = document.getElementById('subcategoria').value;	
    if (form.titulo1.value=="")
    {
    	alert('El Campo Titulo(ES) se Encuentra Vacio');
        form.titulo1.focus();
        return(false);
    }
    if (form.titulo2.value=="")
    {
    	alert('El Campo Titulo(US) se Encuentra Vacio');
        form.titulo2.focus();
        return(false);
    }
}
//------------------------------------
// VALIDACION DE UN NUEVO USUARIO
//------------------------------------
function validaCreaUsuario(form)
{
	if (form.nombre.value=="")
    {
    	alert('El Campo Nombre se Encuentra Vacio');
        form.nombre.focus();
        return(false);
    }
    if (form.apaterno.value=="")
    {
    	alert('El Campo Apellido Paterno se Encuentra Vacio');
        form.apaterno.focus();
        return(false);
    }
    if (ValidarEmail(form.email.value)==false)
    {
    	form.email.focus();
        return(false);
    }
    if ( form.pais.value=="" || form.pais.value=="-1" )
    {
    	alert('Seleccione un Pais');
        form.pais.focus();
        return(false);
    }
    if ( form.pais.value=="36")
    {	
    	/*if ( form.tconvenio.value == 0)
		{
			form.tconvenio.value = 0;
			form.nomconvenio.value = "";
		}*/
    }
    if(form.clave.value=="")
    {
    	alert('El Campo Clave se Encuentra Vacio');
        form.clave.focus();
        return(false);
    }
    if(form.clave2.value=="")
    {
    	alert('El Campo Clave se Encuentra Vacio');
        form.clave2.focus();
        return(false);
    }
    if(form.clave.value != form.clave2.value)
    {
    	alert('Las Claves no son Iguales....\nVuelva a ingresarlas');
    	form.clave.value="";
    	form.clave2.value="";
        form.clave.focus();
        return(false);
    }
    form.submit();
}
//------------------------------------
// VALIDACION DE MODIFICAR UN USUARIO
//------------------------------------
function validaModificaUsuario(form)
{    
	if(form.cambiar1.checked == true)
	{
		form.cambiar1.value=1;
		form.region.value = document.getElementById('regiones').value;	
		form.ciudad.value = document.getElementById('ciudades').value;	
	}
	if (form.nombre.value=="")
    {
    	alert('El Campo Nombre se Encuentra Vacio');
        form.nombre.focus();
        return(false);
    }
    if (form.apaterno.value=="")
    {
    	alert('El Campo Apellido Paterno se Encuentra Vacio');
        form.apaterno.focus();
        return(false);
    }
    if (form.amaterno.value=="")
    {
    	alert('El Campo Apellido Materno se Encuentra Vacio');
        form.amaterno.focus();
        return(false);
    }	
    if (ValidarEmail(form.email.value)==false)
    {
    	form.email.focus();
        return(false);
    }
    if (form.direccion.value=="")
    {
    	alert('El Campo Direccion se Encuentra Vacio');
        form.direccion.focus();
        return(false);
    }
    if(form.cambiar1.checked == true)
	{	
	    if ( form.pais.value=="" || form.pais.value=="-1" )
	    {
	    	alert('Seleccione un Pais');
	        form.pais.focus();
	        return(false);
	    }
	    if ( form.region.value=="" || form.region.value=="-1" )
	    {
	    	alert('Seleccione una Region');
	        form.regiones.focus();
	        return(false);
	    }
	    if ( form.ciudad.value=="" || form.ciudad.value=="-1" )
	    {
	    	alert('Seleccione una Ciudad');
	        form.ciudades.focus();
	        return(false);
	    }
	}
    if (form.numero.value=="")
    {
    	alert('El Campo Telefono se Encuentra Vacio');
        form.numero.focus();
        return(false);
    }    
    if(form.opcliente[0].checked == true)
	{	
		if( form.opconvenio[0].checked == true )
		{
			if(form.tipconvenio.value == -1)
			{
				alert('Seleccione un Tipo de Convenio');
				form.tipconvenio.focus();
        		return(false);
			}
		}
	}
    if(form.clave.value=="")
    {
    	alert('El Campo Clave se Encuentra Vacio');
        form.clave.focus();
        return(false);
    }
    if(form.clave2.value=="")
    {
    	alert('El Campo Clave se Encuentra Vacio');
        form.clave2.focus();
        return(false);
    }
    if(form.clave.value != form.clave2.value)
    {
    	alert('Las Claves no son Iguales....\nVuelva a ingresarlas');
    	form.clave.value="";
    	form.clave2.value="";
        form.clave.focus();
        return(false);
    }
    form.submit();
}
//------------------------------------
// VALIDACION DE MODIFICAR DIRECCION DESPACHO
//------------------------------------
function validaModificaDatoEnvio(form)
{    
	if(form.pais.value != "-1" )
	{
		form.region.value = document.getElementById('regiones').value;	
		form.ciudad.value = document.getElementById('ciudades').value;	
	}
	if (form.nombre.value=="")
    {
    	alert('El Campo Nombre se Encuentra Vacio');
        form.nombre.focus();
        return(false);
    }
    if (form.apaterno.value=="")
    {
    	alert('El Campo Apellido Paterno se Encuentra Vacio');
        form.apaterno.focus();
        return(false);
    }
    if (form.amaterno.value=="")
    {
    	alert('El Campo Apellido Materno se Encuentra Vacio');
        form.amaterno.focus();
        return(false);
    }	
    if (form.direccion.value=="")
    {
    	alert('El Campo Direccion se Encuentra Vacio');
        form.direccion.focus();
        return(false);
    }
    if ( form.pais.value=="-1" )
    {
    	alert('Seleccione un Pais');
        form.pais.focus();
        return(false);
    }
    if (form.zippostal.value=="")
    {
    	alert('El Campo Codigo Postal se Encuentra Vacio');
        form.zippostal.focus();
        return(false);
    }
    if ( form.pais.value=="36" )
    {
    	if (form.rut.value=="")
	    {
	    	alert('El Campo Rut se Encuentra Vacio');
	        form.rut.focus();
	        return(false);
	    }	
	    if (form.giro.value=="")
	    {
	    	alert('El Campo Giro se Encuentra Vacio');
	        form.giro.focus();
	        return(false);
	    }
    }
    form.submit();
}
//---------------------------------------
// VALIDACION DE IDENTIFICAR A UN USUARIO
//---------------------------------------
function validaIdentificaUsuario(form)
{    
    if (ValidarEmail(form.email.value)==false)
    {
    	form.email.focus();
        return(false);
    }
    if(form.clave.value=="")
    {
    	alert('El Campo Clave se Encuentra Vacio');
        form.clave2.focus();
        return(false);
    }
    form.submit();
}
//--------------------------------------------------
// FUNCIONES QUE VALIDAN DATOS DE LOS FORMULARIOS
//--------------------------------------------------
function ValidarRut(rut1, rut2){
 var rut = rut1+'-'+rut2;
 var Error = "El Campo Rut esta vacio o es erroneo\n"
 + "Revíselo, por favor.";
if (rut == "-" )
{
   alert(Error);
   return false;
}
else
{
   //inicializamos variables
   sumatorio=0;
   numero=0;
   multiplicador=1;
   cosas=rut.split("-");
   letra=cosas[1].toUpperCase() ;
   rut=cosas[0];
   longitud=rut.length-1;
   //Empezamos la ronda
   for(a=longitud;a>=0;a--)
   {
     multiplicador+=1
     if(multiplicador==8){multiplicador=2}
     //Vamos obteniendo el número que se dividirá por 11
     numero2=parseInt(rut.charAt(a));
     numero=numero2*multiplicador;
     sumatorio+=numero;
   }
   //hallamos el dígito
   resto=sumatorio%11;
   if(resto>0){resto=11-resto}
   if(resto==10)
   {
    digito="K"
   }
   else{digito=resto}
   if(!letra)
   {
    alert("El dígito es "+digito);
    return false;
   }
   else
   {
    if(letra && letra!=digito)
    {
      alert("El Rut no es válido");
      return false;
    }
   else
   {
     //alert("El Rut es Válido");
     return true;
   }
  }
 }
}
/* fin de funcion validar Rut */


/* Inicio de funcion validar E-Mail */
function ValidarEmail(Email)
{
	var Formato = /^([\w-\.])+@([\w-]+\.)+([a-z]){2,4}$/;
	var Comparacion = Formato.test(Email);
	if(Comparacion == false)
	{
	      alert("El correo ingresado no es válido");
	      return false;
	}
	return true;
}
/* fin de funcion validar E-Mail */


/* inicio de funcion validar WEB */
function ValidarWeb(Web)
{
 var Error = "La dirección web introducida es inválida.\n"
 + "Revísela, por favor.";
 if (Web == "")
 {
   return true;
 }
 else
 {
  if( Web.substring(0, 7) != 'http://' || Web.indexOf('.') < 0)
  {
    alert(Error);
    return false;
  }
  else
  {
    return true;
  }
 }
}
/* fin de funcion validar WEB */

//---------------------------------------------------------
//--  Funcion para Confirmar la Accion
//---------------------------------------------------------
function confirmaAccion(pregunta,pagina)
{
	var entrar = confirm(pregunta)
	if ( entrar==true )
	{
			location.href=pagina
	}
}
//---------------------------------------------------------
//--  Funcion para Zoom Imagen (Efecto de Lupa)
//---------------------------------------------------------
var ie=document.all
var ns6=document.getElementById&&!document.all

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat" && !window.opera)? document.documentElement : document.body
}

function enlarge(which, e, position, imgwidth, imgheight){
if (ie||ns6){
crossobj=document.getElementById? document.getElementById("showimage") : document.all.showimage
if (position=="center"){
pgyoffset=ns6? parseInt(pageYOffset) : parseInt(ietruebody().scrollTop)
horzpos=ns6? pageXOffset+window.innerWidth/2-imgwidth/2 : ietruebody().scrollLeft+ietruebody().clientWidth/2-imgwidth/2
vertpos=ns6? pgyoffset+window.innerHeight/2-imgheight/2 : pgyoffset+ietruebody().clientHeight/2-imgheight/2
if (window.opera && window.innerHeight) //compensate for Opera toolbar
vertpos=pgyoffset+window.innerHeight/2-imgheight/2
vertpos=Math.max(pgyoffset, vertpos)
}
else{
var horzpos=ns6? pageXOffset+e.clientX : ietruebody().scrollLeft+event.clientX
var vertpos=ns6? pageYOffset+e.clientY : ietruebody().scrollTop+event.clientY
}
crossobj.style.left=horzpos+"px"
crossobj.style.top=vertpos+"px"

crossobj.innerHTML='<div align="right" id="dragbar"><span id="closetext" onClick="closepreview()">Close</span> </div><img src="'+which+'">'
crossobj.style.visibility="visible"
return false
}
else //if NOT IE 4+ or NS 6+, simply display image in full browser window
return true
}

function closepreview(){
crossobj.style.visibility="hidden"
}

function drag_drop(e){
if (ie&&dragapproved){
crossobj.style.left=tempx+event.clientX-offsetx+"px"
crossobj.style.top=tempy+event.clientY-offsety+"px"
}
else if (ns6&&dragapproved){
crossobj.style.left=tempx+e.clientX-offsetx+"px"
crossobj.style.top=tempy+e.clientY-offsety+"px"
}
return false
}

function initializedrag(e){
if (ie&&event.srcElement.id=="dragbar"||ns6&&e.target.id=="dragbar"){
offsetx=ie? event.clientX : e.clientX
offsety=ie? event.clientY : e.clientY

tempx=parseInt(crossobj.style.left)
tempy=parseInt(crossobj.style.top)

dragapproved=true
document.onmousemove=drag_drop
}
}

document.onmousedown=initializedrag
document.onmouseup=new Function("dragapproved=false")


//------------------------------------------------------------
function activaVentanaBA(obj)
{
if(obj.checked){
	document.form.avanzada.value=1;
	document.getElementById('box1').style.display="";
	}
    else{
	document.form.avanzada.value=2;
	document.getElementById('box1').style.display="none";
	}
}
//------------------------------------------------------------
function cambiaDisplay(obj)
{	
	if(obj.value == 1)
	{
		document.getElementById("opconvenio1").disabled=false;
		document.getElementById("opconvenio2").disabled=false;
		document.getElementById("opconvenio3").disabled=false;
	}
	if(obj.value == 0)
	{		
		document.getElementById("opconvenio1").disabled=true;
		document.getElementById("opconvenio2").disabled=true;
		document.getElementById("opconvenio3").disabled=true;
	}
}
//------------------------------------------------------------
function cambiaDisplay2(nameobj,obj)
{	
	if(obj.value == 0)
	{
		document.getElementById(nameobj).disabled=false;
	}
	if(obj.value == 10)
	{
		document.getElementById(nameobj).disabled=true;
	}
	if(obj.value == 11)
	{
		document.getElementById(nameobj).disabled=true;
	}
}
//-------------------------------------------------------------
function cambiar_color_overXX(celda,color)
{ 
	celda.style.backgroundColor=color;
} 

function cambiar_color_outXX(celda,color)
{ 
	celda.style.backgroundColor=color;
}
//-------------------------------------------------------------
function cambiar_color_over(celda)
{ 
	celda.style.backgroundColor="#DDDBCE";
} 

function cambiar_color_out(celda)
{ 
	celda.style.backgroundColor="#F5F3E6";
}
//-------------------------------------------------------------
function cambiar_color_overX(celda)
{ 
	celda.style.backgroundColor="#EDEDE3";
} 

function cambiar_color_outX(celda)
{ 
	celda.style.backgroundColor="#CEDEBD";
}
//-------------------------------------------------------------
function expandir_contraer_div(objetoid)
{			
	var objeto=document.getElementById(objetoid)	
	if (objeto.style.display=="none") 
	{
			objeto.style.display=""			
	}
	else
	{
			objeto.style.display="none"
	}
}
//-------------------------------------------------------------		
function CambioImg(ImgName) 
{                       
	imagen1=new Image
	imagen1.src="img/carpeta_closed.gif"
	imagen2=new Image
	imagen2.src="img/carpeta_open.gif"
	if (document.images[ImgName].src==imagen2.src)
	{ 
			document.images[ImgName].src=imagen1.src;
	}
	else 
	{
			document.images[ImgName].src=imagen2.src;
	}
}
//-------------------------------------------------------------
//---Funcion para Roll Over de Imagenes 
//-------------------------------------------------------------
function encima(id,imagen)
{
	document.getElementById(id).src=imagen;
}
function fuera(id,imagen)
{
	document.getElementById(id).src=imagen;
}
//--------------------------------------------------------------
function permiteSoloNum(e)
{
	key=(document.all) ? e.keyCode : e.which;
	if( (key < 48 || key > 57) && ( key != 8 ) && ( key != 13 ) )
	{			
		return false;
	}
	return true;
}//fin funcion
//--------------------------------------------------------------
function Abrir_ventana(pagina)
{
	window.open(pagina,"","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=YES,resizable=no,width=520,height=400,top=85,left=40");	
}
//--------------------------------------------------------------
function enviaInfoCant(pos,cant)
{
	alert('POS:'+pos+'     CANT:'+cant);
	location.href='../cambiaCant_producto.php?pos=' + pos + '&cant=' + cant;
}
//--------------------------------------------------------------
function agregaTR()
{
	mytable     = document.getElementById('tablapesoprecio');
	Contador	= mytable.rows.length + 1;
	mytablebody = document.createElement("tbody");
	mycurrent_row = document.createElement("tr");
	//for(var i = 0; i < 3; i++)
	//{
	//----- Primer TD
		mycurrent_cell = document.createElement("td");
		currenttext = document.createTextNode("");
		mycurrent_cell.innerHTML = " * ";
		mycurrent_cell.appendChild(currenttext);
		mycurrent_row.appendChild(mycurrent_cell);
	//----- Segundo TD
		mycurrent_cell = document.createElement("td");
			code = document.createElement('input');
			code.type = 'text';
			code.name = 'peso' + Contador;
			code.id = 'peso' + Contador;
			code.size = 10;
			code.className = 'txt_campos';
		mycurrent_cell.appendChild(code);
		mycurrent_row.appendChild(mycurrent_cell);
	//----- Tercer TD
		mycurrent_cell = document.createElement("td");
			code = document.createElement('input');
			code.type = 'text';
			code.name = 'precio' + Contador;
			code.id = 'precio' + Contador;
			code.size = 10;
			code.className = 'txt_campos';
		mycurrent_cell.appendChild(code);
		mycurrent_row.appendChild(mycurrent_cell);
	//}
	mytablebody.appendChild(mycurrent_row);
	mytable.appendChild(mytablebody);
	document.getElementById('chequear').value = 1;	
}
//------------------------------------
// MANTENEDOR ZONAS
//------------------------------------
function validaMantenedorZona(form)
{    		
	//alert(document.getElementById('pesox').value);
	//document.form.peso2.value = document.getElementById('pesox').value;
	//document.form.precio2.value = document.getElementById('preciox').value;
	document.getElementById('resto').value = "";
	Contador	= document.getElementById('tablapesoprecio').rows.length;
	for(var i=0; i < Contador; i++)	
	{
		document.getElementById('resto').value = document.getElementById('resto').value + document.getElementById('peso' + (i+1)).value + ":" + document.getElementById('precio' + (i+1)).value + ",";
	}
	form.submit();
}
//------------------------------------
// ACTUALIZA DIV CARRITO COMPRA
//------------------------------------
function ReCargarDiv()
{
	var numero = parseInt(document.getElementById("numeroproducto").innerHTML);
	numero++;
	document.getElementById("numeroproducto").innerHTML="";
	document.getElementById("numeroproducto").innerHTML=numero;
	document.getElementById("imgCarrito").innerHTML="";
	document.getElementById("imgCarrito").innerHTML='<img src="img/ico_carrito_rojo.gif" alt="Ver Mi Canasto" border="0">';
	document.getElementById('trC1').className = "TextoFormulario2";
	document.getElementById('trC2').className = "TextoFormulario2";
	document.getElementById('trC3').className = "TextoFormulario2";
}
//------------------------------------
// CARGA NUEVO ESTILO A UN FORMULARIO
//------------------------------------
function CambiaClass()
{
	document.getElementById('nombre').className = "InputCeldaFormulario1";
	document.getElementById('apellidos').className = "InputCeldaFormulario1";
	document.getElementById('direccion').className = "InputCeldaFormulario1";
	document.getElementById('n1pais').style.display="none";
	document.getElementById('n2pais').style.display="";
	document.getElementById('n1regiones').style.display="none";
	document.getElementById('Div_Regiones').style.display="";
	document.getElementById('n1ciudad').style.display="none";
	document.getElementById('Div_Ciudades').style.display="";
	document.getElementById('codpostal').className = "InputCeldaFormulario1";
	document.getElementById('razonsocial_fac').className = "InputCeldaFormulario1";
	document.getElementById('rut').className = "InputCeldaFormulario1";
	document.getElementById('digito').className = "InputCeldaFormulario1";
	document.getElementById('giro_fac').className = "InputCeldaFormulario1";
	document.getElementById('direccion_fac').className = "InputCeldaFormulario1";
	document.getElementById('fono_fac').className = "InputCeldaFormulario1";
	document.getElementById('nombre_contacto_fac').className = "InputCeldaFormulario1";
	document.getElementById('email_contacto_fac').className = "InputCeldaFormulario1";
	document.getElementById('fono_contacto_fac').className = "InputCeldaFormulario1";
	document.getElementById('cargo_contacto_fac').className = "InputCeldaFormulario1";
	document.getElementById('botonMod').style.display="none";
	document.getElementById('botonCon').style.display="";
	document.getElementById('botonCon1').style.display="none";
}
function muestraFactura(obj)
{
	if(obj.checked == true && obj.value == 1)
	{
		document.getElementById('factura').style.display = "";
		document.getElementById('opactivo').value = 1;		
	}
	else
	{
		document.getElementById('factura').style.display = "none";
		document.getElementById('opactivo').value = 0;
		
		/* datos factura */
			document.getElementById('razonsocial_fac').value = "";
			document.getElementById('rut').value = "";
			document.getElementById('digito').value = "";
			document.getElementById('giro_fac').value = "";
			document.getElementById('direccion_fac').value = "";
			document.getElementById('fono_fac').value = "";
			document.getElementById('nombre_contacto_fac').value = "";
			document.getElementById('email_contacto_fac').value = "";
			document.getElementById('fono_contacto_fac').value = "";
			document.getElementById('cargo_contacto_fac').value = "";
		/* fin datos factura */
	}
	CambiaClass();
	return;		
}
function imprSelec(nombre)
{
  var ficha = document.getElementById(nombre);
  var ventimp = window.open(' ', 'popimpr');
  ventimp.document.write( ficha.innerHTML );
  ventimp.document.close();
  ventimp.print( );
  ventimp.close();
}
function cargaValoresForm(tope)
{
	var TotalCompra=0;
	var TotalProd=0;
	for(i=0;i<tope;i++)
	{
		TotalProd = document.getElementById('cantidad'+i).value * document.getElementById('precio'+i).value;
		document.getElementById('totalprod'+i).value = TotalProd;
		TotalCompra = TotalCompra + TotalProd;
		TotalProd = 0;
	}
	document.getElementById('totalcarrito').value = TotalCompra;
	return false;
}
function cargaDivContenedor(objAct,nobjs)
{
	nobjs = nobjs + 1;
	for(i=1;i<nobjs;i++)
	{
		if(i == objAct)
		{
			document.getElementById('obj'+i).style.display="";
			document.getElementById('liobj'+i).className = "currentContenedor";	
		}
		else
		{
			document.getElementById('obj'+i).style.display="none";
			document.getElementById('liobj'+i).className = "";
		}
	}
	return;
}