	horas = new Array();
	horas["domingo"] = [{value:"09:00 a 11:00", text:"09:00 a 11:00"},
						{value:"11:00 a 13:00", text:"11:00 a 13:00"}
						];
	
	horas["lunes_viernes"]= [{value:"09:00 a 11:00", text:"09:00 a 11:00"},
						{value:"11:00 a 13:00", text:"11:00 a 13:00"},
						{value:"13:00 a 15:00", text:"13:00 a 15:00"},
						{value:"15:00 a 17:00", text:"15:00 a 17:00"},
						{value:"17:00 a 19:00", text:"17:00 a 19:00"}
						];

	horas["sabado"]= [{value:"09:00 a 11:00", text:"09:00 a 11:00"},
						{value:"11:00 a 13:00", text:"11:00 a 13:00"},
						{value:"13:00 a 15:00", text:"13:00 a 15:00"},
						{value:"15:00 a 17:00", text:"15:00 a 17:00"}
						];
	var path = '/'; //change
	function sethoras(elemSelect,elemSelectm_a,elemSelectm_m,elemSelectm_d){
		if(elemSelectm_m.selectedIndex && elemSelectm_d.selectedIndex && elemSelectm_a.selectedIndex){
			fecha_sel_d = elemSelectm_d.selectedIndex;
			fecha_sel_m = parseInt(elemSelectm_m[elemSelectm_m.selectedIndex].value)-1;
			fecha_sel_a = parseInt(elemSelectm_a[elemSelectm_a.selectedIndex].value);
		
			fecha = new Date(fecha_sel_a,fecha_sel_m,fecha_sel_d);
			n_dia = fecha.getDay();
			elemSelect.length = 1
			if (n_dia == 0){ 
				var mn = horas['domingo'];
			}else{ 
				if(n_dia == 6)
					var mn = horas["sabado"];
				else{
					var mn = horas["lunes_viernes"];
				}
			}
			//elemSelect.options[i] = new Option(mn[i].text, mn[i].value);
			for (var i = 0; i < mn.length; i++) {
				elemSelect.options[i+1] = new Option(mn[i].text, mn[i].value);
			}
		}
	}
	/**
	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);
		diasAhora = comboDias.length-1;

		if (parseInt(diasAhora) > parseInt(diasEnMes)){
			diferencia_dias = diasAhora - diasEnMes;	
			
			for (i=0; i<(diferencia_dias); i++){
				comboDias.options[comboDias.options.length - 1] = null
			}
		}
		if (diasEnMes > diasAhora){
			diferencia_dias = diasEnMes-diasAhora;
			for (i=0; i<(diferencia_dias); i++)           {
				sumaOpcion = new Option(comboDias.options.length);
				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_pagina1(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 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_nombre.value){
		if(theForm.usu_apellidos.value){
			if(theForm.usu_email.value && /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(theForm.usu_email.value)){
					if(( opt == '2')||(theForm.usu_clave.value && theForm.usu_clave.value.length > 3 )){
						if(theForm.usu_distrito.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 seleccionar el Distrito..');
						}
					}else{
						if(!theForm.usu_clave.value){
							alert('Debe de ingresar su Password...');
						}else{
							alert('Debe de ingresar como mínimo 4 caracteres en el passwod...');
						}
					}
				}else{
					if(!theForm.usu_email.value)
						alert('Debe de ingresar su Email...');
					else
						alert('Debe de ingresar un Email correcto...');
				}
		}else{
			alert('Debe de ingresar sus apellidos...');
		}
	}else{
		alert('Debe de ingresar sus nombres...');
	}
}

function validar_frm_ocontrasena(){
	theForm = document.frm_ocontrasena;
	if(theForm.usu_email.value &&  /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(theForm.usu_email.value)){
		theForm.modificarcontrasena.value = '1';
		theForm.action = 'proceso_usuario.php';
		theForm.submit();
	}else{
		if(!theForm.usu_email.value){
			alert('Debe de ingresar email...');
			return false;
		}else{
		   alert('Debe de ingresar email correcto...');
			return false;
		}
	}
}

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 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 esIntero(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 < 48 || charCode > 57 || charCode==8) ) { // Chequeamos que sea un numero comparandolo con los valores ASCII
						
						return false;
				}
				return true;
}
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_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_clave.value){
				//alert(window.location.href);
				//theForm.redir.value = window.location.href;
				//self.location.pathname
				//if(self.location.pathname)
				theForm.action = path+'proceso_usuario.php';
				theForm.method ='post';
				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");
		}
		return false;
	}
	
	function activar_otros(){
		theForm = document.frm_registro;
		
		if(theForm.modelo.selectedIndex == 0 || theForm.modelo[theForm.modelo.selectedIndex].value != 'Otros'){
			theForm.usu_modelo_otros.disabled = true
		}else{
			theForm.usu_modelo_otros.disabled = false
		}
		
	}

	function tienetoyota(){
		theForm = document.frm_registro;
		if(theForm.estoyota[1].checked){
			theForm.anho.disabled = true
			theForm.modelo.disabled = true
			theForm.adquirido_como.disabled = true
			activar_otros();
				
		}
		if(theForm.estoyota[0].checked){
			theForm.anho.disabled = false
			theForm.modelo.disabled = false
			theForm.adquirido_como.disabled = false
			activar_otros();
			
		}
	}

	function popup (URL){ 
		window.open(URL,"ventana1","width=260, height=227, scrollbars=no, menubar=no, location=no, resizable=no") 
		} 