	horas = new Array();
	/**
	Calendario para los comboselects
	*/

	ahora      = new Date();
	ahoraDay   = ahora.getDate();
	ahoraMonth = ahora.getMonth();
	ahoraYear  = ahora.getYear();

	if (ahoraYear < 2000)
        ahoraYear += 1900;

	function cuantosDias(mes, anyo) {
		var cuantosDias = 31;
		if (mes == "ABR" || mes == "JUN" || mes == "SEP" || mes == "NOV")
			cuantosDias = 30;
		if (mes == "FEB" && (anyo/4) != Math.floor(anyo/4))
			cuantosDias = 28;
		if (mes == "FEB" && (anyo/4) == Math.floor(anyo/4))
			cuantosDias = 29;
		return cuantosDias;
	}

	function asignaDias(comboDias,comboMeses,comboAnyos) {
		Month = comboMeses[comboMeses.selectedIndex].text;
		Year = comboAnyos[comboAnyos.selectedIndex].text;

		diasEnMes = cuantosDias(Month, Year);
		if(comboDias.name == 'usu_nacimiento_d'){
			diasAhora = comboDias.length-1;
			dif = diasEnMes-diasAhora-1;
		}else{
			diasAhora = comboDias.length;
			dif = diasEnMes-diasAhora;
		}	
		if (diasAhora > diasEnMes){
			for (i=0; i<(diasAhora-diasEnMes); i++){
				comboDias.options[comboDias.options.length - 1] = null
			}
		}
		if (diasEnMes > diasAhora){
			for (i=0; i<(dif); i++)           {
				sumaOpcion = new Option(comboDias.options.length + 1);
				comboDias.options[comboDias.options.length]=sumaOpcion;
			}
		}
	   if (comboDias.selectedIndex < 0)
	   comboDias.selectedIndex = 0;
	 }

	function ponDia(comboDias1,comboMeses1,comboAnyos1){		
		comboDias = eval("comboDias1");
		comboMeses = eval("comboMeses1");
		comboAnyos = eval("comboAnyos1");
		comboAnyos[0].selected = true;
		comboMeses[ahoraMonth].selected = true;
		asignaDias(comboDias1,comboMeses1,comboAnyos1);	
		comboDias[ahoraDay-1].selected = true;
	}


/**
 * Sets/unsets the pointer in browse mode
 *
 * @param   object   the table row
 * @param   object   the color to use for this row
 * @param   object   the background color
 *
 * @return  boolean  whether pointer is set or not
 */


function setPointer(theRow, thePointerColor, theNormalBgColor)
{
    var theCells = null;

    if (thePointerColor == '' || typeof(theRow.style) == 'undefined') {
        return false;
    }
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }

    var rowCellsCnt  = theCells.length;
    var currentColor = null;
    var newColor     = null;
    // Opera does not return valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[0].getAttribute) != 'undefined' && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor = theCells[0].getAttribute('bgcolor');
        newColor     = (currentColor.toLowerCase() == thePointerColor.toLowerCase())
                     ? theNormalBgColor
                     : thePointerColor;
        for (var c = 0; c < rowCellsCnt; c++) {
            theCells[c].setAttribute('bgcolor', newColor, 0);
        } // end for
    }
    else {
        currentColor = theCells[0].style.backgroundColor;
        newColor     = (currentColor.toLowerCase() == thePointerColor.toLowerCase())
                     ? theNormalBgColor
                     : thePointerColor;
        for (var c = 0; c < rowCellsCnt; c++) {
            theCells[c].style.backgroundColor = newColor;
        }
    }

    return true;
} // end of the 'setPointer()' function

function proxima_pagina(resultpage,theForm){
	theForm = eval("theForm");
	theForm.resultpage.value = resultpage;
	theForm.method ='get';
	theForm.submit();

}

function proxima_pagina_2(resultpage,theForm){
	theForm = eval("theForm");
	theForm.resultpage.value = resultpage;
	theForm.method ='post';
	theForm.submit();

}
function front_reeviar(cadena,pagesize){
	theForm = document.frm_paginado;
	theForm.action = 'productos.php?pagesize='+pagesize+cadena; 
	theForm.method ='post';
	theForm.submit();
}

function front_ver_detalle(key){
	theForm = document.frm_paginado;
	theForm.idproducto.value = key;
	theForm.ocasion.value = '';
	theForm.precios.value = '';
	theForm.buscar.value = '';
	theForm.action = 'detalle_producto.php';
	theForm.method ='get';
	theForm.submit();
}

function b_prodcuto_cat(categoria){
	theForm = document.frm_m_izq;
	theForm.buscar.value= '';
	theForm.precios.selectedIndex = 0;
	theForm.ocasion.selectedIndex = 0;
	theForm.idcategoria.value = categoria;
	theForm.action = 'productos.php'; 
	theForm.method ='get';
	theForm.submit();
}

function b_producto_oca(){
	theForm = document.frm_m_izq;
	if(theForm.ocasion.selectedIndex > 0){
		ocasion = theForm.ocasion[theForm.ocasion.selectedIndex].value;
		theForm.buscar.value= '';
		theForm.precios.selectedIndex = 0;
		theForm.action = 'productos.php?ocasion='+ocasion; 
		theForm.method ='post';
		theForm.submit();
	}
}

function b_producto_precio(){
	theForm = document.frm_m_izq;
	if(theForm.precios.selectedIndex > 0){
		precios = theForm.precios[theForm.precios.selectedIndex].value;
		theForm.ocasion.selectedIndex = 0;
		theForm.action = 'productos.php?precios='+precios; 
		theForm.method ='post';
		theForm.submit();
	}
}

function b_producto(cadena_busqueda){
	theForm = document.frm_m_izq;
	if(theForm.buscar.value.length > 3){
		theForm.precios.selectedIndex = 0;
		theForm.ocasion.selectedIndex = 0;
		buscar = theForm.buscar.value;
		theForm.action = 'productos.php?buscar='+buscar; 
		theForm.method ='post';
		theForm.submit();
	}else{
		alert('Debe ingresar mas de tres caracteres ');
	}
}

function buscador_enter(e){
	var charCode;	
	theForm = document.frm_m_izq;
	if (navigator.appName == "Mozilla" || navigator.appName == "Netscape"){ //Verifica que tipo de navegador
		charCode = e.which; // leo la tecla que ingreso
	}
	else		//navegador explorer
		charCode = e.keyCode; // leo la tecla que ingrese
	if(charCode == 13){
		if(theForm.buscar.value.length > 3){
			theForm.action = 'productos.php'; 
			theForm.method ='get';
			theForm.submit();
		}else{
			alert('Debe ingresar mas de tres caracteres ');
			return false;
		}
	}
}

function buscar_ocaflo(){
	theForm = document.frm_ocaflo;
	if(theForm.oca_flo.selectedIndex > 0){
		if(theForm.oca_flo.selectedIndex == '1') document.location.href = 'productos.php?idocasion=999999'; 
		if(theForm.oca_flo.selectedIndex == '2') document.location.href = 'productos.php?idflores=999999'; 
	}
}

function b_productos_d_p(key){
	theForm = document.frm_m_der;
	theForm.resultpage.value='0';
	theForm.precio_d.value= key;
	theForm.precios.value= '';
	theForm.ocasion.value= '';
	theForm.action = window.location.href; 
	theForm.method ='get';
	theForm.submit();
}

function b_productos_d(key){
	theForm = document.frm_m_der;
	theForm.resultpage.value='0';

	theForm.ocasion_d.value= key;
	theForm.precios.value= '';
	theForm.ocasion.value= '';
	theForm.action = window.location.href; 
	theForm.method ='get';
	theForm.submit();
}


function ir_categoria(cat_id){
	theForm = document.frm_back_categ;
	theForm.idcategoria.value = cat_id;
	theForm.action = 'productos.php';
	theForm.method ='get';
	theForm.submit();
}

function validar_frm_registro(opt){
	theForm = document.frm_registro;
	if(theForm.usu_nombres.value){
		if(theForm.usu_apellidos.value){
			if(theForm.usu_sexo[0].checked || theForm.usu_sexo[1].checked){
				if(theForm.usu_email.value && /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(theForm.usu_email.value)){
					if(theForm.usu_password.value && theForm.usu_password1.value && opt == '1'){
						if(theForm.usu_password.value == theForm.usu_password1.value){
							if(theForm.usu_pais.selectedIndex > 0){
								if(opt == '1'){
									theForm.insertar.value = '1';
								}else{
									theForm.modificar.value = '1';
								}
								theForm.action = 'proceso_usuario.php';
								theForm.submit();
							}else{
								alert('Debe de ingresar el Pais...');
							}
						}else{
							alert('Debe de ingresar la confirmación del Password igual al Password...');
						}
					}else{
						if(opt == '2'){
							if(theForm.usu_password.value){
								if(theForm.usu_password.value != theForm.usu_password1.value){
									alert('Debe de ingresar la confirmación del Password igual al Password...');
									return false;
								}
							}
							theForm.modificar.value = '1';
							theForm.action = 'proceso_usuario.php';
							theForm.submit();
							return true;
						}

						if(!theForm.usu_password.value){
							alert('Debe de ingresar su Password...');
						}else
							if(!theForm.usu_password1.value){
								alert('Debe de ingresar la confirmación del Password...');
							}
					}
				}else{
					if(!theForm.usu_email.value)
						alert('Debe de ingresar su Email...');
					else
						alert('Debe de ingresar a un email correcto...');
				}
			}else{
				alert('Debe de seleccionar el sexo...');
			}
		}else{
			alert('Debe de ingresar su apellido...');
		}
	}else{
		alert('Debe de ingresar su nombre...');
	}
}

function validar_frm_ocontrasena(){
	theForm = document.frm_ocontrasena;
	if(theForm.usu_email.value){
		theForm.modificarcontrasena.value = '1';
		theForm.action = 'proceso_usuario.php';
		theForm.submit();
	}else{
		alert('Debe de ingresar email...');
	}
}

function agregar_c(pro_id){
	theForm = document.frm_from_carrito;
	if(theForm.cantidad)
		if(theForm.cantidad.value && parseInt(theForm.cantidad.value) > 0){
			theForm.insertar.value = '1';
			theForm.idproducto.value = pro_id;
			theForm.action = 'proceso_carrito.php';
			theForm.submit();
		}else{
			alert('Debe de ingresar la cantidad...');
		}

}

function eliminar_c(car_key){
	theForm = document.frm_carrito_compras;
	theForm.car_key.value = car_key;
	theForm.eliminar.value = '1';
	theForm.action = 'proceso_carrito.php';
	theForm.submit();	
}

function cantidadesmayorcero(){
	theForm = document.frm_carrito_compras;
	if(theForm.elements['cantidad[]'].length){
		for(i=0;i<theForm.elements['cantidad[]'].length;i++){
			if(parseInt(theForm.elements['cantidad[]'][i].value) <= 0)
				return false;
		}
	}else{
		if(parseInt(theForm.elements['cantidad[]'].value) > 0){
			return true;
		}else{
			return false;
		}
	}
	return true;
}

function actualizar_c(car_key){
	if(cantidadesmayorcero()){
		theForm = document.frm_carrito_compras;
		theForm.car_key.value = car_key;
		theForm.actualizar.value = '1';
		theForm.action = 'proceso_carrito.php';
		theForm.submit();	
	}else{
		alert("Debe de ingresar la cantidad de sus productos mayor a cero");
	}
}

function nocero(e,objForm){
	if(objForm.value.length == 1 && parseInt(objForm.value)== 0){
		alert("Se debe ingresar una cantidad mayor que cero !!");
		objForm.value = 1;
		return false;
	}
}

function justNumbers(e,el){
	el.value = el.value.replace(/[\D]/g,'');
}

function esInteger(e, objForm,limit_cant_x_producto) {
		var charCode;
		if (navigator.appName == "Mozilla" || navigator.appName == "Netscape"){ //Verifica que tipo de navegador
			charCode = e.which; // leo la tecla que ingreso
		}
		else		//navegador explorer
			charCode = e.keyCode; // leo la tecla que ingrese
		//alert(charCode);	
		
		if (charCode > 31 && (charCode < 48 || charCode > 57 || charCode==8)  ) { // Chequeamos que sea un numero comparandolo con los valores ASCII
			return false;
		}else{
			if((objForm.value.length == 0 && charCode == 48)  ){
				alert("Se debe ingresar una cantidad mayor que cero");
				objForm.value = 1;
				return false;
			}

			if(objForm.value.length == 1 && parseInt(objForm.value)== 0){
				alert("Se debe ingresar una cantidad mayor que cero !!");
				objForm.value = 1;
				objForm.value = 1;
				return false;
			}
			
			if(objForm.name == "cantidad[]"){
				cant_permitida = 	parseInt(limit_cant_x_producto);
				if(parseInt(objForm.value) > cant_permitida){
					alert("Estimado cliente, para cantidades mayores a "+cant_permitida+" unidades, Ud. podrá adquirir el producto negociando directamente con su vendedor!!");
					objForm.value = 1; 
					objForm.value=cant_permitida;
					return false;
				}
			}	
		}

		return true;
	}

	function storeCaret(text) { 
	   if (text.createTextRange) { 
		text.caretPos = document.selection.createRange().duplicate(); } 
	}

	function textCounter(field, countfield, maxlimit) { 
	   if (field.value.length > maxlimit) 
		field.value = field.value.substring(0, maxlimit); 
	   else 
		countfield.value = maxlimit - field.value.length; 
	  } 

	function esFloat(e) {
				var charCode;
					if (navigator.appName == "Mozilla" || navigator.appName == "Netscape"){ //Verifica que tipo de navegador
						charCode = e.which; // leo la tecla que ingreso
					}
					else		//navegador explorer
						charCode = e.keyCode; // leo la tecla que ingrese

					if (charCode > 31 && (charCode < 46 || charCode > 57 || charCode==8) ) { // Chequeamos que sea un numero comparandolo con los valores ASCII
							//alert("Se debe ingresar sólo números !!");
							return false;
					}
					return true;
	}

	function open_window(url,name,param) {
		l=100;
		t=100;
		param+=',left='+l+',top='+t;
		newWindow = window.open(url,name,param);
	}

	function validar_user_email(){
		theForm = document.frm_emmail;
		if(theForm.usu_email.value && /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(theForm.usu_email.value)){
			if(theForm.usu_password.value){
				theForm.consultar.value = 1;
				theForm.submit();

			}else{
				alert("Debe de ingresar el password");
			}
		}else{
			if(!theForm.usu_email.value)
				alert("Debe de ingresar su email");
			else
				alert("Debe de ingresar un email valido");
		}
	}

	function validar_login(){
		theForm = document.frm_email;
		if(theForm.usu_email.value && /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(theForm.usu_email.value)){
			if(theForm.usu_password.value){
				theForm.action = 'proceso_usuario.php';
				theForm.method ='post';
				theForm.submit();
				return true;
			}else{
				alert("Debe de ingresar el password");
			}
		}else{
			if(!theForm.usu_email.value)
				alert("Debe de ingresar su email");
			else
				alert("Debe de ingresar un email valido");
		}
		return false;
	}

	function validar_frm_datos_envio(){
		theForm = document.frm_datos_envio;
		if(theForm.ord_nombres.value){
			if(theForm.ord_apellidos.value){
				if(theForm.ord_sexo[0].checked || theForm.ord_sexo[1].checked){
					if(theForm.ord_email.value &&  /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(theForm.ord_email.value)){
						if(theForm.ord_pais.selectedIndex > 0){
							if(theForm.ord_fechaentrega_a.selectedIndex > 0 && theForm.ord_fechaentrega_m.selectedIndex > 0 && theForm.ord_fechaentrega_d.selectedIndex > 0){
								anio_operacion = (theForm.ord_fechaentrega_a[theForm.ord_fechaentrega_a.selectedIndex].value);
								mes_operacion = theForm.ord_fechaentrega_m[theForm.ord_fechaentrega_m.selectedIndex].value;
								dia_operacion = parseInt(theForm.ord_fechaentrega_d.selectedIndex);
								dia_operacion_v = theForm.ord_fechaentrega_d[theForm.ord_fechaentrega_d.selectedIndex].value;
								fecoper = new Date(anio_operacion,mes_operacion-1,dia_operacion_v,23,59,59);
								fectope = new Date();
								if(fecoper < fectope){
									alert("Debe de seleccionar como mínimo la fecha actual para la entrega");	
									return false;
								}
								//if(theForm.ord_horaentrega.selectedIndex > 0){
									if(theForm.ord_direccionentrega.value){
										if(theForm.ord_distritoentrega.selectedIndex > 0 ){
											if(theForm.ord_personentrega.value ){
												if(theForm.ord_mensaje.value ){
													if(theForm.ord_flagfactura.checked){
														if(!theForm.ord_razonsocial.value){alert("Debe de ingresar la razón social");return false;}
														if(!theForm.ord_ruc.value){alert("Debe su número de RUC");return false;}
													}


													var forma_pago=false;
													var ok = false;
													for(i=0;i<theForm.ord_formapago.length;i++){if(theForm.ord_formapago[i].checked) forma_pago=true;}
													if(forma_pago){
														if(theForm.ord_formapago[1].checked){
															if(theForm.PAN.value=='') alert('Debe ingresar el número de tarjeta');
															else if(theForm.EXPIRYMONTH.value=='' || theForm.EXPIRYYEAR.value=='') alert('Seleccione el año y mes de vencimiento de la tarjeta');
															else{
																ok=true;
															}
														}else if(theForm.ord_formapago[2].checked){
															if(theForm.tarjeta_titular.value=='') alert('Ingrese el nombre del titular de la tarjeta');
															else if(theForm.titular_dni.value=='') alert('Ingrese el DNI del titular de la tarjeta');
															else if(theForm.tarjeta_codigo.value=='') alert('Ingrese el código de verificación de la tarjeta');
															else if(theForm.PAN.value=='') alert('Debe ingresar el número de tarjeta');
															else if(theForm.EXPIRYMONTH.value=='' || theForm.EXPIRYYEAR.value=='') alert('Seleccione el año y mes de vencimiento de la tarjeta');
															else{
																ok=true;
															}
														}else if(theForm.ord_formapago[3].checked){
															if(theForm.tarjeta_titular.value=='') alert('Ingrese el nombre del titular de la tarjeta');
															else if(theForm.titular_dni.value=='') alert('Ingrese el DNI del titular de la tarjeta');
															else if(theForm.PAN.value=='') alert('Debe ingresar el número de tarjeta');
															else if(theForm.EXPIRYMONTH.value=='' || theForm.EXPIRYYEAR.value=='') alert('Seleccione el mes y año de vencimiento de la tarjeta');
															else{
																ok=true;
															}
														}else{
															ok=true;
														}
														if(ok){
														//if(confirm("Esta a punto de entrar a una zona segura, ¿desea continuar? ")){
															theForm.insertar.value = 1;
															theForm.submit();
														//}
														}
													}


													}else{
													alert("Debe de ingresar el mensaje");
												}
											}else{
												alert("Debe de ingresar la persona a entregar");
											}
										}else{
											alert("Debe de seleccionar el distrito de entrega");
										}
									}else{
										alert("Debe de ingresar la dirección de entrega");
									}
								/*}else{
									alert("Debe de seleccionar la hora  de entrega");
								}*/
							}else{
								alert("Debe de seleccionar la fecha de entrega");
							}
						}else{
							alert("Debe de ingresar su país");
						}
					}else{
						if(!theForm.ord_email.value)
							alert("Debe de ingresar su email");
						else
							alert("Debe de ingresar un email valido");
					}
				}else{
					alert("Debe de seleccionar su sexo");
				}
			}else{
				alert("Debe de ingresar sus apellidos");
			}
		}else{
			alert("Debe de ingresar sus nombres");
		}

	}

	function enabled_rsruc(){
		theForm = document.frm_datos_envio;
		if(theForm.ord_flagfactura.checked){
			theForm.ord_razonsocial.disabled = false;
			theForm.ord_ruc.disabled = false;
		}else{
			theForm.ord_razonsocial.disabled = true;
			theForm.ord_ruc.disabled = true;
		}
	}

	function popupVisa (URL){ 
		window.open(URL,"ventana1","width=606, height=402, scrollbars=yes, menubar=no, location=no, resizable=no") 
	} 