if (document.getElementById){ 
document.write('<style type="text/css">\n')
document.write('.submenu{display: none;}\n')
document.write('</style>\n')
}
if (document.getElementById){ 
document.write('<style type="text/css">\n')
document.write('.desplegarNota{display:none; color:#000000; text-decoration:none;font-weight:normal;}\n')
document.write('.desplegarNota2{display:block;color:#000000; text-decoration:none;font-weight:normal;}\n')
document.write('</style>\n')
}
if (document.getElementById){ 
document.write('<style type="text/css">\n')
document.write('.desplegarBuscador{display:none;}\n')
document.write('.desplegarBuscador2{display:block;}\n')
document.write('</style>\n')
}
function desplegarNota(obj){
	if(document.getElementById){
		var el = document.getElementById(obj);
		if(el.className != "desplegarNota2"){ el.className = "desplegarNota2";
		}else{el.className = "desplegarNota";}
	}	
}
function desplegarBuscador(obj){
	if(document.getElementById){
		var el = document.getElementById(obj);
		if(el.className != "desplegarBuscador2"){ el.className = "desplegarBuscador2";
		document.images['imgBuscador'].src = '../imagenes/buscador_menos.gif';
		}else{el.className = "desplegarBuscador";
		document.images['imgBuscador'].src = '../imagenes/buscador_mas.gif';}
	}	
}
function SwitchMenu(id){
	var tb = document.getElementById(id);
	var img = 'img_'+id;
	var rutaAmpliar = 'imagenes/item_mas.gif';
	var rutaContraer = 'imagenes/item_menos.gif';
	
	if(tb.style.display == "block"){
		tb.style.display = "none";
		document.images[img].src = rutaAmpliar;
		document.images[img].setAttribute('alt','Maximizar');
	}else{
		tb.style.display = "block";
		document.images[img].src = rutaContraer;
		document.images[img].setAttribute('alt','Minimizar');

	}
}
function expandir(id){
	var tb = document.getElementById(id);
	if(tb.style.display == "block"){
		tb.style.display = "none";
	}else{
		tb.style.display = "block";
	}
}

function openWindow(url,frame){
	window.open(url,frame,'');
}

function openPopUp(url, name){
	window.open(url,'name','width=350, height=350, scrollbars=yes, left=410, top=180');
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

// validacion de formularios
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' debe contener una dirección de mail.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' debe contener un número.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' debe contener un número entre '+min+' y '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' es necesario.\n'; }
  } if (errors) alert('Los siguientes errores han ocurrido:\n'+errors);
  document.MM_returnValue = (errors == '');
}
function controlArchivo(CampoArchivo){
	
	var campo = this.document.getElementById(CampoArchivo).value;
	var ar = this.document.getElementById('archivo');
	if(campo){
	var miString = campo.split('\\');
	var largo = miString.length;
	var archivo = miString[largo-1];
	ar.value=archivo;
	var punto = 0;
	var error=0;
	var especiales = 0;
	
	//nos fijamos si hay archivo
	
	if (miString[largo-1] == '') {
		alert("Debe especificar un archivo.");
		return false
	}
	// nos fijamos si las barras no son invertidas
	for(i=0;i<campo.length;i++){
		var chr = campo.charAt(i);
		if(chr=="/"){
			error=error+1;
		}else{
			error = error;
		}
	}
	if(error>0){
		alert("El separador de directorios debe ser \\");
		return false;
	}
	
	// nos fijamos si hay punto
	for(a=0;a<archivo.length;a++){
		var chr = archivo.charAt(a);
		if(chr=="."){
			punto=punto+1;
		}
	}
	
	if(punto==0 || punto>1){
		alert("Debe especificar un archivo");
		return false;
	}
	// controlamos caracteres especiales
	
	for(i=0;i<campo.length;i++){
		var chr = campo.charAt(i);
		if(chr=="/"){
			especiales=especiales+1;
		}
		if(chr=="?"){
			especiales=especiales+1;
		}
		if(chr=="*"){
			especiales=especiales+1;
		}
		if(chr=="<"){
			especiales=especiales+1;
		}
		if(chr==">"){
			especiales=especiales+1;
		}
		if(chr=="\""){
			especiales=especiales+1;
		}
		if(chr=="|"){
			especiales=especiales+1;
		}
	}
	if(especiales>0){
		alert("No debe usar caractéres especiales");
		return false;
	}
	// nos fijamos en la extensión
	arrayArchivo = archivo.split('.');
	largoArchivo = arrayArchivo.length;
	extension =  arrayArchivo[largoArchivo-1];
	extensionl = extension.length;
	
	if(extensionl>4 || extensionl<2){
		alert("Debe especificar un archivo.");
		return false;
	}
	}
}

function eliminar(text,url) { 
	var text = unescape(text);
	var txt = "";
	for(i=0;i<text.length;i++){
		var chr = text.charAt(i);
		if(chr=="+"){
			chr=" ";
		}
	txt = txt+chr;
	}
	var re = /\\/g;
	txt = txt.replace(re,"");
	var x=window.confirm(txt);
	if (x) {
		window.open(url,'_top','');
	}
}
function refresh(url){
    window.location.href = url;
}

function uno(src,color_entrada) { 
    src.bgColor=color_entrada;src.style.cursor="pointer"; 
} 
function dos(src,color_default) { 
    src.bgColor=color_default;src.style.cursor="default"; 
} 

function validarFechas(){
	// inico
	var fechaInicio = document.historial.fecha1.value;
	var fechaFinalizacion = document.historial.fecha2.value;
	
	var arrayInicio = fechaInicio.split('-');
	var diaI = arrayInicio[0];
	var mesI = arrayInicio[1];
	var anioI = arrayInicio[2];
	var dateI = new Date(anioI,mesI,diaI);
	
	var arrayFin = fechaFinalizacion.split('-');
	var diaF = arrayFin[0];
	var mesF = arrayFin[1];
	var anioF = arrayFin[2];
	var dateF = new Date(anioF,mesF,diaF);
	
	var fecha = new Date();
	var fechaActual = new Date(fecha.getYear(),parseInt(fecha.getMonth()+1),fecha.getDate());
	
	var mensajeError ="";
	var error = false;
	
	if(dateI>dateF){
		mensajeError="La fecha desde debe ser menor a la fecha hasta";
		error=true;
	}
	if(dateI>fechaActual || dateF > fechaActual){
		mensajeError="Las fechas deben ser mayor a la fecha actual";
		error=true;
	}
	if(error){
		alert(mensajeError);
		return false;
	}
	
}

function seleccionMultiple(){
	var selec = document.historial.monedas.options;

	var string = "";
	var error = false;
	var b=0;
	for(i=0;i<selec.length;i++){
		if(selec[i].selected == true){
			string+=selec[i].value+'_';
			b++;
		}
 	}
	if(b==0){
		alert("Debe seleccionar por lo menos una moneda");
		return false;
	}else{
		document.historial.moneda.value = string;
		return true;
	}
}
function seleccionAtributo(){
	var selec = document.ingreso.ac.options;
	
	var string = "";
	var error = false;
	for(i=0;i<document.ingreso.ac.length;i++){
		if(document.ingreso.ac[i].checked == true){
			string+=document.ingreso.ac[i].value+'|';
			string+=document.getElementById("sel_"+document.ingreso.ac[i].value).value+'_';
		}
 	}
	document.ingreso.atributo.value=string;
}

function desplegarArchivo(){
	
	var tr2 = document.getElementById("ar2");
	var oculto = document.ingreso.modifica;
	if(tr2.style.display == 'block'){
		tr2.style.display = 'none'
		oculto.value="0";
	}else{
		tr2.style.display = 'block'
		oculto.value="1";
	}
}

function accionMultiple(){
	var selec = document.listado.ac.options;
	var accion = document.listado.accion.value;
	
	var string = "";
	var error = false;
	var b=0;
	for(i=0;i<document.listado.ac.length;i++){
		if(document.listado.ac[i].checked == true){
			string+=document.listado.ac[i].value+'_';
			b++;
		}
 	}
	if(accion ==""){
		alert("Debe seleccionar una acción.");
		return false;
	}else if(b==0){
		alert("Debe seleccionar por lo menos un registro.");
		return false;
	}else{
		document.listado.acciones.value = string;
		if(accion=="papelera"){
			var x=window.confirm("Está seguro que quiere enviar " + b +" registros a la papelera de reciclaje?");
			if (x) {
				return true;
			}else{
				return false;
			}
		}else if (accion=="eliminar"){
			var x=window.confirm("La eliminación será definitiva.\nEstá seguro que quiere eliminar " + b +" registros?");
			if (x) {
				return true;
			}else{
				return false;
			}
		}else if (accion=="baja"){
			var x=window.confirm("La baja será definitiva.\nEstá seguro que quiere dar de baja " + b +" registros?");
			if (x) {
				return true;
			}else{
				return false;
			}
		}else if (accion=="eliminarchequeo"){
			var x=window.confirm("La eliminación será definitiva.\nEstá seguro que quiere eliminar " + b +" registros?");
			if (x) {
				return true;
			}else{
				return false;
			}
		}else if (accion=="eliminarmensaje"){
			var x=window.confirm("La eliminación será definitiva.\nEstá seguro que quiere eliminar " + b +" registros?");
			if (x) {
				return true;
			}else{
				return false;
			}
		}else if (accion=="eliminarvalor"){
			var x=window.confirm("La eliminación será definitiva.\nEstá seguro que quiere eliminar " + b +" registros?");
			if (x) {
				return true;
			}else{
				return false;
			}
		}else{
			return true;
		}
	}
}
function controlNombreArchivo(CampoArchivo){
	
	var archivo = this.document.getElementById(CampoArchivo).value;
	var punto = 0;
	var error=0;
	var especiales = 0;

	// nos fijamos si hay punto
	for(a=0;a<archivo.length;a++){
		var chr = archivo.charAt(a);
		if(chr=="."){
			punto=punto+1;
		}
	}
	
	if(punto==0 || punto>1){
		alert("Debe especificar un nombre de archivo correcto.");
		return false;
	}
	// controlamos caracteres especiales
	
	for(i=0;i<archivo.length;i++){
		var chr = archivo.charAt(i);
		if(chr=="/"){
			especiales=especiales+1;
		}
		if(chr=="?"){
			especiales=especiales+1;
		}
		if(chr=="*"){
			especiales=especiales+1;
		}
		if(chr=="<"){
			especiales=especiales+1;
		}
		if(chr==">"){
			especiales=especiales+1;
		}
		if(chr=="\""){
			especiales=especiales+1;
		}
		if(chr=="|"){
			especiales=especiales+1;
		}
		if(chr=="'"){
			especiales=especiales+1;
		}
	}
	if(especiales>0){
		alert("No debe usar caractéres especiales");
		return false;
	}
	// nos fijamos en la extensión
	arrayArchivo = archivo.split('.');
	largoArchivo = arrayArchivo.length;
	extension =  arrayArchivo[largoArchivo-1];
	extensionl = extension.length;
	
	if(extensionl>4 || extensionl<2){
		alert("Debe especificar un nombre de archivo correcto.");
		return false;
	}
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function controlCalificar(){
	var cal = document.calificar.calificacion.value;
	if(cal=="0"){
		alert("Estimado: debe seleccionar un número para poder calificar al producto.");
		return false;
	}else{
		return true;
	}
}
function controlCal(){
	var a1 = document.listado.cal_1.value;
	var a2 = document.listado.cal_2.value;
	var a3 = document.listado.cal_3.value;
	var a4 = document.listado.cal_4.value;
	var a5 = document.listado.cal_5.value;
	var error =0;
	if(isNaN(a1) || isNaN(a2) || isNaN(a3) || isNaN(a4) || isNaN(a5)){
		error=1;
	}
	if(error!=0){
		alert("Los valores a modificar deben contener números");
		return false;
	}
}

function controlPrecio(){
	var precio = document.ingreso.Precio.value;
	var descuento = document.ingreso.Descuento.value;
	var stock =  document.ingreso.Stock.value;
	var error = 0;
	var strError ="";
	if(precio==""){
		strError+="- Se necesita un precio.\n";
	}
	if(stock==""){
		strError+="- Se necesita un stock.\n";
	}
	if(isNaN(precio)){
		strError+="- El precio debe ser un número.\n";
	}else{
		if(precio<0){
			strError+="- El precio debe ser un número positivo.\n";
		}
	}
	if(isNaN(stock)){
		strError+="- El stock debe ser un número.\n";
	}else{
		if(stock<0){
			strError+="- El stock debe ser un número positivo.\n";
		}
	}
	if(isNaN(descuento)){
		strError+="- El descuento debe ser un número.\n";
	}else{
		if(descuento<0 || descuento>100){
			strError+="- El descuento debe ser un número entre 0 y 100.\n";
		}
	}
	if(strError!=""){
		alert(strError);
		return false;
	}
}
function editarCompra(){
	var monto = document.cambios.monto.value;
	var envio = document.cambios.envio.value;
	var error = "Han ocurrido errores:\n";
		if(monto==""){
			error+= "- Monto no debe estar vacio\n";
		}else{
			if(isNaN(monto)){
				error+="- El monto debe ser un número.\n";
			}else{
				if(monto<0){
					error+="- El monto debe ser superior a 0.\n";
				}
			}
		}
		if(envio==""){
			error+= "- Monto no debe estar vacio\n";
		}else{
			if(isNaN(envio)){
				error+="- El monto debe ser un número.\n";
			}else{
				if(envio<0){
					error+="- El monto debe ser superior a 0.\n";
				}
			}
		}
	var ar = document.cambios.elements;
	var errorPrecio = 0;
	var errorPrecio2 = 0;
	var errorPrecio3 = 0;
	for(i=0;i<ar.length;i++){
		var precio = ar[i].name.substring(0,6);
		if(precio=="precio"){
			if(ar[i].value==""){
				errorPrecio++;
				
			}else{
				if(isNaN(ar[i].value)){
					errorPrecio2++;
				}else{
					if(ar[i].value<0){
						errorPrecio3++;
					}
				}
			}
		}
	}
	if(errorPrecio>0){
		error+="- Los campos de los precios deben estar llenos.\n";
	}	
	if(errorPrecio2>0){
		error+="- Los campos de los precios deben ser números.\n";
	}	
	if(errorPrecio3>0){
		error+="- Los campos de los precios deben ser mayores a 0.\n";
	}	
	if(error!="Han ocurrido errores:\n"){
		alert(error);
		return false;
	}else{
		document.cambios.submit();
	}
}
function ejecutarBuscador(){
	var palabra = document.buscador.p.value;
	if(palabra==""){
		alert("Por favor ingrese una palabra clave");
	}else if(palabra.length<=2){
		alert("La palabra clave debe poseer por lo menos 2 caractéres");
	}else{
		document.buscador.submit();
	}
}
function ejecutarBuscadorProductos(){
	var palabra = document.productos.p.value;
	if(palabra==""){
		alert("Por favor ingrese una palabra clave");
	}else if(palabra.length<=2){
		alert("La palabra clave debe poseer por lo menos 2 caractéres");
	}else{
		document.productos.c.value=0;
		document.productos.submit();
	}
}
function ejecutarBuscadorEspecializado(){
	var palabra = document.busqueda.p.value;
	var autor = document.busqueda.a.value;
	var error="";
	if(palabra!=""){
		 if(palabra.length<=2){
			error+="La palabra clave debe poseer por lo menos 2 caractéres\n";
		 }
	}
	if(autor!=""){
		 if(autor.length<=2){
			error+="El autor debe poseer por lo menos 2 caractéres\n";
		 }
	}
	if(document.busqueda.o.value==0 &
	   document.busqueda.t.value==0 &
	   document.busqueda.b.value==0 &
	   document.busqueda.tc.value==0 &
	   document.busqueda.indice.value==0 &
	   document.busqueda.p.value=="" &
	   document.busqueda.a.value==""){
		error+="Debe seleccionar por lo menos un criterio\n";
	}
	if(error!=""){
		alert(error);
		return false;
	}
}

function marcarContenido(){
	var check = false;
	for (i=0;i<document.listado.c.length;i++){
		if(document.listado.c[i].checked){
			check = true;
		}
	}
	if(!check){
		alert("Por favor marque un contenido");
		return false;
	}else{
		return true;
	}
}
function controlBanner(){
	var error = "Ocurrieron errores:\n";
	var titulo = document.ingreso.titulo.value;
	var popup = document.ingreso.popup.checked;
	var ancho = document.ingreso.ancho.value;
	var alto = document.ingreso.alto.value;
	
	if(titulo==""){
		error+="- Ingrese un título identificatorio.\n";
	}
	if(popup){
		if(ancho==""){
			error+="- Ingrese el ancho del Pop Up.\n";
		}else{
			if(isNaN(ancho)){
				error+="- El ancho del Pop Up debe ser un número.\n";
			}else{
				if(ancho<=0){
						error+="- El ancho del Pop Up debe ser mayor a 0.\n";
				}
			}
		}
		if(alto==""){
			error+="- Ingrese el largo del Pop Up.\n";
		}else{
			if(isNaN(alto)){
				error+="- El largo del Pop Up debe ser un número.\n";
			}else{
				if(alto<=0){
						error+="- El largo del Pop Up debe ser mayor a 0.\n";
				}
			}
		}
	}
	if(error!="Ocurrieron errores:\n"){
		alert(error);
		return false;
	}else{
		return true;
	}
}
function controlRotacion(){
	var error = "Ocurrieron errores:\n";
	var rotar = document.ingreso.rotar.checked;
	var tiempo = document.ingreso.tiempo.value;
	if(rotar){
		if(tiempo==""){
			error+="- Ingrese el tiempo de rotación.\n";
		}else{
			if(isNaN(tiempo)){
				error+="- El tiempo de rotación debe ser un número.\n";
			}else{
				if(tiempo<=0){
						error+="- El tiempo de rotación debe ser mayor a 0.\n";
				}
			}
		}
	}
	if(error!="Ocurrieron errores:\n"){
		alert(error);
		return false;
	}else{
		return true;
	}
}
function seleccionarIngrediente(quien){
	var i1 = document.listado.idIngrediente1;	
	var i2 = document.listado.idIngrediente2;	
	var i3 = document.listado.idIngrediente3;	
	var i4 = document.listado.idIngrediente4;	
	switch(quien){
		case 1:i2.value="-";i3.value="-";i4.value="-";
		document.listado.idIngrediente.value = i1.value;
		break;
		case 2:i1.value="-";i3.value="-";i4.value="-";
		document.listado.idIngrediente.value = i2.value;break;
		case 3:i1.value="-";i2.value="-";i4.value="-";
		document.listado.idIngrediente.value = i3.value;break;
		case 4:i2.value="-";i3.value="-";i1.value="-";
		document.listado.idIngrediente.value = i4.value;break;
}
}
function controlIngredientes(){
	var i1 = document.listado.idIngrediente1.value;	
	var i2 = document.listado.idIngrediente2.value;	
	var i3 = document.listado.idIngrediente3.value;	
	var i4 = document.listado.idIngrediente4.value;
	var re = document.listado.idReceta.value;
	if(i1=="-" & i2=="-" & i3=="-" & i4=="-" & (re==0 || re=="")){
		alert("Seleccione un ingrdiente o receta");
		return false;
	}
	if(document.listado.idUnidad.value!=0){
			if(document.listado.cantidad.value==0 & document.listado.cantidad2.value==0){
				alert("Debe seleccionar una cantidad.");
				return false;
			}
	}
	if(document.listado.idUnidad.value==0 & document.listado.idReceta.value==0){
			if(document.listado.cantidad.value!=0 || document.listado.cantidad2.value!=0){
				alert("Debe seleccionar una unidad.");
				return false;
			}
	}
	if(document.listado.idReceta.value!=0){
			if(document.listado.idReceta.value==document.listado.receta.value){
				alert("No puede agregar una receta igual a la receta actual.");
				return false;
			}
	}
}

function controlNutricion(){
	var form = document.ingreso.elements;
	var error = "Han ocurrido errores:\n";
	var titulo1 = document.ingreso.Titulo_Singular.value;
	var titulo2 = document.ingreso.Titulo_Plural.value;
	var precio = document.ingreso.Precio.value;
	var errorN = 0;
	var valor="";
	if(titulo1==""){error+="- Ingrese el título en singular\n";}
	if(titulo2==""){error+="- Ingrese el título en plural\n";}
	if(precio==""){error+="- Ingrese el precio\n";}else{if(isNaN(precio)){error+="- El precio debe ser un número\n";}}
	for(i=0;i<form.length;i++){
		var p = form[i].name;
		var ar = p.split('_');
		if(ar[0]=="n"){
			if(form[i].value!=""){
				if(isNaN(form[i].value)){
					errorN+=1;
				}else{
					valor+=ar[1]+"_"+form[i].value+"|";
				}
			}
		}
	}
	if(errorN>0){
		error+="- Los valores eneregéticos deben ser números\n";
	}else{
		document.ingreso.valores.value = valor;
	}
	if(error!="Han ocurrido errores:\n"){
		alert(error);
		return false;
	}
}

function imprimirMedida(){
	document.ingreso.mostrar.value = document.ingreso.medida.value;
	switch(document.ingreso.medida.value){
	case "kg":document.ingreso.mostrar2.value = "gr";break;
	case "lt":document.ingreso.mostrar2.value = "ml";break;
	default: document.ingreso.mostrar2.value = document.ingreso.medida.value;
	}
}
function guardarSeleccion(){
	document.listado.guardar.value=1;
	document.listado.submit();
}
function enviarProciones(){
	var porcion = document.porciones.Porcion.value;
	if(porcion==""){
		alert("Debe ingresar un número de porciones.");
	}else{
		if(isNaN(porcion)){
			alert("El valor de las porciones debe ser un número.");
		}else{
			if(porcion<=1){
				alert("El valor de las porciones debe ser mayor a 1.");
			}else{
				document.porciones.submit();
			}
		}
	}
}

function controlUnidades(){
	var singular = document.ingreso.Titulo_Singular.value;
	var plural = document.ingreso.Titulo_Plural.value;
	var gr = document.ingreso.gr.value;
	var ml = document.ingreso.ml.value;
	var ud = document.ingreso.ud.value;
	var error = "Han ocurrido errores:\n";
	if(singular==""){error+="- Debe ingresar un título en singular.\n";}
	if(plural==""){error+="- Debe ingresar un título en plural.\n";}
	if(gr==0 & ml==0 & ud==0){
		error+="- Debe seleccionar por lo menos una medida.\n";
	}
	if(error!="Han ocurrido errores:\n"){
		alert(error);
		return false;
	}
}

function controlMenu(){
	// inico
	var fechaInicio = document.ingreso.fechaM.value;
	var fechaFinalizacion = document.ingreso.fechaM2.value;
	
	var arrayInicio = fechaInicio.split('-');
	var diaI = arrayInicio[0];
	var mesI = arrayInicio[1];
	var anioI = arrayInicio[2];
	var dateI = new Date(anioI,mesI,diaI);
	var datep = new Date(anioI,mesI,diaI+7);
	
	var arrayFin = fechaFinalizacion.split('-');
	var diaF = arrayFin[0];
	var mesF = arrayFin[1];
	var anioF = arrayFin[2];
	var dateF = new Date(anioF,mesF,diaF);
	
	//var fecha = new Date();
	//var fechaActual = new Date(fecha.getYear(),parseInt(fecha.getMonth()+1),fecha.getDate());
	
	var mensajeError ="Han ocurrido errores:\n";
	var error = false;
	
	if(dateI>=dateF){
		mensajeError+="La fecha Desde debe ser menor a la fecha Hasta.\n";
	}
	if(mensajeError!="Han ocurrido errores:\n"){
		alert(mensajeError);
		return false;
	}
	
}

function buscadorVentas(){
	var fechaInicio = document.ingreso.fecha1.value;
	var fechaFinalizacion = document.ingreso.fecha2.value;
	
	var arrayInicio = fechaInicio.split('/');
	var diaI = arrayInicio[0];
	var mesI = arrayInicio[1];
	var anioI = arrayInicio[2];
	var dateI = new Date(anioI,mesI,diaI);
	
	var arrayFin = fechaFinalizacion.split('/');
	var diaF = arrayFin[0];
	var mesF = arrayFin[1];
	var anioF = arrayFin[2];
	var dateII = new Date(anioF,mesF,diaF);
	
	var pre1 = document.ingreso.monto1.value;
	var pre2 = document.ingreso.monto2.value;
	var usuario = document.ingreso.usuario.value;
	var error = "Han ocurrido errores:\n";
	
	if(dateII<dateI){
		error+="La primera fecha debe ser menor a la segunda fecha.\n";
	}
	if(pre1!=""){
		if(pre2==""){
			error+="- Debe completar el segundo precio.\n";
		}else{
			if(isNaN(pre2)){
				error+="- El segundo precio debe ser un número.\n";
			}else{
				if(pre2<0){
					error+="- El segundo precio debe ser mayor a 0.\n";
				}
			}
		}
	}
	if(pre2!=""){
		if(pre1==""){
			error+="- Debe completar el primer precio precio.\n";
		}else{
			if(isNaN(pre1)){
				error+="- El primer precio debe ser un número.\n";
			}else{
				if(pre1<0){
					error+="- El primer precio debe ser mayor a 0.\n";
				}
			}
		}
	}
	if(pre2!="" & pre1!=""){
		if(pre1>=pre2){
			error+="- El primer precio debe ser menor al segundo precio.\n";
		}
	}
	
	if(usuario!="" && usuario.length<6){
		error+="El nombre de usuario debe contener 6 o más caracteres";
	}
	if(error!="Han ocurrido errores:\n"){
		alert(error);
		return false;
	}else{
		return true;
	}
}

function configuracionPopUp(){
	var error = "";
	if(document.ingreso.popup.checked==true){
		if(document.ingreso.url.value==""){
			error+="- Debe ingresar una url.\n";
		}
		if(document.ingreso.ancho.value==""){
			error+="- Debe ingresar el ancho.\n";
		}else{
			if(isNaN(document.ingreso.ancho.value)){
				error+="- El ancho debe ser un número.\n";
			}
		}
		if(document.ingreso.alto.value==""){
			error+="- Debe ingresar el alto.\n";
		}else{
			if(isNaN(document.ingreso.alto.value)){
				error+="- El ancho debe ser un número.\n";
			}
		}
	}
	if(error==""){
		document.ingreso.submit();
	}else{
		alert(error);
	}
}
function configuracionEquivalencias(){
	var error = "";
		if(document.ingreso.urlEq.value==""){
			error+="- Debe ingresar una url.\n";
		}
		if(document.ingreso.anchoEq.value==""){
			error+="- Debe ingresar el ancho.\n";
		}else{
			if(isNaN(document.ingreso.anchoEq.value)){
				error+="- El ancho debe ser un número.\n";
			}
		}
		if(document.ingreso.altoEq.value==""){
			error+="- Debe ingresar el alto.\n";
		}else{
			if(isNaN(document.ingreso.altoEq.value)){
				error+="- El ancho debe ser un número.\n";
			}
		}
	if(error==""){
		document.ingreso.submit();
	}else{
		alert(error);
	}
}
function suscribir(){
	var email = document.suscripcion.eemail.value;
	var error="";
	if(email==""){
			error = "- Debe ingresar una dirección de email";
	}else{
		var p=email.indexOf('@');
		if(p<1){
			error+="- El email debe ser una dirección correcta.\n";
		}
	}
	if(error!=""){
		alert(error);
	}else{
		document.suscripcion.submit();
	}
}
versionNav = navigator.appVersion;
function AfficheHomePage(){
	//if (versionNav.indexOf("MSIE 5") > -1 || versionNav.indexOf("MSIE 6") > -1){
		document.write(' <a href="#" onClick="HomePage(this);return(false);">Mi página de inicio</a>');
	//}
}
function HomePage(obj){
	obj.style.behavior='url(#default#homepage)';
	obj.setHomePage('http://www.cocinaymas.com/');
}

function seleccionarLink(){
	var id = document.seleccion.contenido.value;
	var tipo = document.seleccion.tipo.value;
	var links ="";
	switch(tipo){
		case "Subsecciones":
			links = "subseccion.php?in=1&sb="+id;
		break;
		case "Notas":
			links = "nota.php?in=1&id="+id;
		break;
		case "Galerias":
			links = "galeria.php?in=1&id="+id;
		break;
		case "Diccionarios":
			links = "diccionario.php?in=1&id="+id;
		break;
		case "Indices":
			links = "indice.php?in=1&id="+id;
		break;
		case "Frases":
			links = "frase.php?in=1&id="+id;
		break;
		case "Recetas":
			links = "receta.php?in=1&id="+id;
		break;
		case "Escuelas":
			links = "escuela.php?in=1&id="+id;
		break;
		case "Comercios":
			links = "comercio.php?in=1&id="+id;
		break;
		case "Promociones":
			links = "promocion.php?in=1&id="+id;
		break;
		case "Productos":
			links = "producto.php?in=1&id="+id;
		break;
	}
	window.parent.document.ingreso.url.value=links;
	window.parent.document.ingreso.url.style.background = "#FAF3DF";
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
