//libreria de funciones ajax 

function changeEstadoFoto(idFoto, estado){
	
			
			var url = 'procesa_ajax.php';
			var params = 'opc=cestadoFoto&id='+idFoto+'&estado='+estado;
    		var ajax = new Ajax.Request( url, {
                                      method:"get",
    								  parameters: params
									 
									  }
     		);
			
}



function cambioOrdenFoto(idFoto, nvoOrden){
	
						
			var url = 'procesa_ajax.php';
			var params = 'opc=cordenFoto&id='+idFoto+'&nvoOrden='+nvoOrden;
    		var ajax = new Ajax.Request( url, {
                                      method:"get",
    								  parameters: params
									 
									  }
     		);
			
}

function cambioOrdenPropiedad(idProp, nvoOrden, criterio){
	
					
			var url = 'procesa_ajax.php';
			var params = 'opc=cordenProp&id='+idProp+'&nvoOrden='+nvoOrden+'&criterio='+criterio;
    		var ajax = new Ajax.Request( url, {
                                      method:"get",
    								  parameters: params,
									  onComplete : procesarRespuestacambioOrdenPropiedad
									 }
     		);
			
}


function procesarRespuestacambioOrdenPropiedad( resp ) {
	
	
	$("alerta").innerHTML = resp.responseText;
	
	
	}


function mostrarFoto(num){
			estilo=document.all?'block':'table-row'
			if(document.getElementById('propiedades').getElementsByTagName('tr')[num].style.display=='none'){
				document.getElementById('propiedades').getElementsByTagName('tr')[num].style.display=estilo;
				$('f'+num).innerHTML = '[-]';
				$('foto'+(num+1)).value = '';
			
			}else{
					$('f'+num).innerHTML = '[+]';
					//document.getElementById('propiedades').getElementsByTagName('tr')[num].style.display='none';
					for(i=num ; i<=8 ; i++){
								document.getElementById('propiedades').getElementsByTagName('tr')[i].style.display='none';
								$('foto'+i).value = '';
								$('f'+i).innerHTML = '[+]';
						}
					
			}
			
			
	}
	
	
function changeEstadoProp(idProp, estado){
	
							
			var url = 'procesa_ajax.php';
			var params = 'opc=cestadoProp&id='+idProp+'&estado='+estado;
    		var ajax = new Ajax.Request( url, {
                                      method:"get",
    								  parameters: params,
									  onComplete : procesarRespuestachangeEstadoProp
									 
									  }
     		);
			
}
	
function procesarRespuestachangeEstadoProp( resp ){
	
	
	var datos = resp.responseText;
	var array_datos = datos.split("##");
	
	$('e'+array_datos[1]).innerHTML = array_datos[0];
	
	}	
	
	
	
function asignaContratacionAPaquete(idPaquete, idContratacion){
	
						
			var url = 'procesa_ajax.php';
			var params = 'opc=asig_promo_paquete&idPaquete='+idPaquete+'&idCont='+idContratacion;
    		var ajax = new Ajax.Request( url, {
                                      method:"get",
    								  parameters: params
									  									 
									  }
     		);
			
}



function _getPaquetesClickeados(form){
	var ids = new String("");
	for (i=0;i<form.elements.length;i++)
		  if(form.elements[i].type == "checkbox" &&  form.elements[i].checked==1)	
				ids = ids+','+form.elements[i].name;
	return ids;

}

function habilitarPaquetes(form,estado){
				
			var ids = _getPaquetesClickeados(form);
			var url = 'procesa_ajax.php';
			var params = 'opc=estado_paquetes&ids='+ids+'&estado='+estado;
    		var ajax = new Ajax.Request( url, {
                                      method:"get",
    								  parameters: params,
									  onComplete: procesarRespuestaHabilitarPaquetes									 
									  }
     		);
			
}


function procesarRespuestaHabilitarPaquetes( resp ){
	
	document.location.reload();	
}



/**
* Esta funcion recibe un string de ids a mover (ids), el sentido(1=agregar, 0= eliminar),
* idAgencia (idPaq) y tipo (tipo de servicio)
* Actualiza los datos de la base de datos
*/



function actualizaBDMoveServ(ids,sentido,idPaq){
			
			
			var url = 'procesa_ajax.php';
			var params = 'opc=serv&ids='+ids+'&idAge='+idPaq+'&sentido='+sentido;
    		var ajax = new Ajax.Request( url, {
                                      method:"get",
    								  parameters: params
									  								 
									  }
     		);
			
}

/**
* Esta funcion recibe un string de ids a mover (ids), el sentido(1=agregar, 0= eliminar),
* idPaquete (idPaq) y tipo (tipo de servicio)
* Actualiza los datos de la base de datos
*/



function actualizaBDMoveServPaq(ids,sentido,idPaq){
			
			
			var url = 'procesa_ajax.php';
			var params = 'opc=servPaq&ids='+ids+'&idPaquete='+idPaq+'&sentido='+sentido;
    		var ajax = new Ajax.Request( url, {
                                      method:"get",
    								  parameters: params
									  								 
									  }
     		);
			
}


function changePago(idPaq,estado){
				
			
			var url = 'procesa_ajax.php';
			var params = 'opc=cambio_pago&idPaquete='+idPaq+'&estado='+estado;
    		var ajax = new Ajax.Request( url, {
                                      method:"get",
    								  parameters: params
									
									  }
     		);
			
}



function changeAclaracion(idPaq,estado){
				
			
			var url = 'procesa_ajax.php';
			var params = 'opc=cambio_aclaracion&idPaquete='+idPaq+'&estado='+estado;
    		var ajax = new Ajax.Request( url, {
                                      method:"get",
    								  parameters: params
									  //onComplete: test
									  }
     		);
			
}

/*
function test (resp){
	
	alert(resp.responseText);
}*/



function mostrarLoad(){
		
	$('cargando').innerHTML = '<img src="images/bigrotation2.gif" border="0"><br/>Procesando, por favor aguarde ... ';
	
}




/**
* Esta funcion recibe un string de ids a mover (ids), el sentido(1=agregar, 0= eliminar),
* idPaquete (idPaq) 
* Actualiza los datos de la base de datos 
*
*/


function actualizaBDMoveDest(ids,sentido,idPaq){
				
			
			
			var url = 'procesa_ajax.php';
			var params = 'opc=dest&ids='+ids+'&idPaquete='+idPaq+'&sentido='+sentido;
    		var ajax = new Ajax.Request( url, {
                                      method:"get",
    								  parameters: params
									  								 
									  }
     		);
			
}


function moveServ(fbox, tbox, idAge,  sentido) {
		
		var arrFbox = new Array();
		var arrTbox = new Array();
		var arrLookup = new Array();
		var i;
		
		for (i = 0; i < tbox.options.length; i++) {
			arrLookup[tbox.options[i].text] = tbox.options[i].value;
			arrTbox[i] = tbox.options[i].text;
		}
		
		var fLength = 0;
		var tLength = arrTbox.length;
		
		for(i = 0; i < fbox.options.length; i++) {
			arrLookup[fbox.options[i].text] = fbox.options[i].value;
			if (fbox.options[i].selected && fbox.options[i].value != "") {
				arrTbox[tLength] = fbox.options[i].text;
				tLength++;
			}
			else {
				arrFbox[fLength] = fbox.options[i].text;
				fLength++;
		   }
		}
		
		arrFbox.sort();
		arrTbox.sort();
		
		fbox.length = 0;
		tbox.length = 0;
		var c;
		
		
		//quita los ids del origen
		for(c = 0; c < arrFbox.length; c++) {
			var no = new Option();
			no.value = arrLookup[arrFbox[c]];
			no.text = arrFbox[c];
			fbox[c] = no;
		}
		
		var ids = Array();
		//agrega los ids al destino
		for(c = 0; c < arrTbox.length; c++) {
			var no = new Option();
			no.value = arrLookup[arrTbox[c]];
			ids[c] =  arrLookup[arrTbox[c]];
			no.text = arrTbox[c];
			tbox[c] = no;
		   }
		   

		   idsjoin = ids.join(',');  
		   //aca llamo a la funcion ajax que guarda en la base
		   actualizaBDMoveServ(idsjoin,sentido,idAge)
		   
		    
		   
}

function mostrarAddFoto(){
	
	if( $('ffile').className=='show'){
		
		
		$('ffile').className="noshow";
		//$('fnom').className="noshow";
		//$('fdesc').className="noshow";
		$('fbut').className="noshow";	
		//$('tnom').value='';
		//$('tdes').value='';
		$('tfile').value='';
		$('alert').className="noshow";
		$('talert').className="noshow";
		
	}else{
		
		
		$('ffile').className="show";
		//$('fnom').className="show";
		//$('fdesc').className="show";
		$('fbut').className="show";
		$('alert').className="show";
		$('talert').className="show";
	
	
	}
}








function changeValor(id){
	
		changePago(id,1);	
	
		$('condicion').removeAttribute('disabled');
		$('precio').removeAttribute('disabled');
		$('cond').removeAttribute('disabled');
		$('mone').removeAttribute('disabled');
		
		$('cuadrot').className="disable";	
		$('condi').setAttribute('disabled','disabled');
		$('agregar').setAttribute('disabled','disabled');
		
		
		selects = $('cuadro_tarifario').getElementsByTagName('select');
		for(i=0; i<selects.length; i++){
			
			selects[i].setAttribute('disabled','disabled');
		}
		inputs = $('cuadro_tarifario').getElementsByTagName('input');
		for(i=0; i<inputs.length; i++){
			
			inputs[i].setAttribute('disabled','disabled');
		}
		
		
}

function changeCuadro(id){
	
		changePago(id,0);
		
		$('condicion').setAttribute('disabled','disabled');
		$('precio').setAttribute('disabled','disabled');
		$('cond').setAttribute('disabled','disabled');
		$('mone').setAttribute('disabled','disabled');
		
		$('cuadrot').className="able";	
		$('agregar').removeAttribute('disabled');
		$('condi').removeAttribute('disabled');
		
		selects = $('cuadro_tarifario').getElementsByTagName('select');
		for(i=0;i<selects.length;i++){
			
			selects[i].removeAttribute('disabled');
		}
		
		inputs = $('cuadro_tarifario').getElementsByTagName('input');
		for(i=0;i<inputs.length;i++){
			//if(inputs[i].type=='checkbox' && inputs[i].checked)
				inputs[i].removeAttribute('disabled');
		}
		
}

function changeFecha(idPaq){
	
	changeAclaracion(idPaq,1);
	$('vigen').setAttribute('disabled','disabled');
	$('vigen').value='';
	$('sel3').removeAttribute('disabled');
	$('boton_calendario').removeAttribute('disabled');
}

function changeTextual(idPaq){
	
	
	changeAclaracion(idPaq,0);
	$('sel3').setAttribute('disabled','disabled');
	$('sel3').value='';
	$('vigen').removeAttribute('disabled');
	$('boton_calendario').setAttribute('disabled','disabled');
}



function mostrarRecordarPass(){
	
	
	$('lrpass').className="show";	
	$('trpass').className="show";
	$('brpass').className="show";
	
	
	
}

function EsEntero(valor){

	 var re = /^(-)?[0-9]*$/;
     if (!re.test(valor)) {
         return false
     }
     return true;
 }




function guardarValoresTablaTarifaria(idPaquete){
	
	
			//levanto los nombres de las columnas
			var cols = new Array();	
			k=0;
			for(i=2;i<=6;i++){
				if( $('col'+i).checked )
					cols[k] = $('val_col'+i).value;
					k++;
			}
			columnas = cols.join(',');
			columnas = reemplazar(columnas);
			
			
			///verificacion de los valores ingresados (SOLO NUMEROS)
			ok = true;
			k=0;
			var errors = new Array();
			for(i=2;i<=6;i++){ //barro las columnas
				for(j=1;j<=10;j++){
					if( $('fila'+j).checked && i>=2 ){
						if ( $('col'+i).checked ){
							if($('fila'+j+'col'+i).value!="" && !EsEntero($('fila'+j+'col'+i).value)){
									ok = false;
									errors[k] = $('fila'+j+'col'+i).value;
									k++;
							}
						}					
						
					}else{
							
							if($('fila'+j+'col'+i).value!="" && !EsEntero($('fila'+j+'col'+i).value)){ 
								ok = false; 
								errors[k] = $('fila'+j+'col'+i).value;
								k++;
								
							}
						}			
				}
			}		
					
			if(!ok){
				err = errors.join(' , ');
				alert('Todos los valores ingresados en la tabla tarifaria deben ser numericos, sin puntos, espacios ni simbolos monetarios.\nRevise estos valores:\n\n'+err);
				return false;				
			}
			
				
			
			//levanto los valores de las filas, las corto por la cantidad de cols
			var fils = new Array();
			k=0;
			for(i=1;i<=6;i++){ //barro las columnas
				for(j=1;j<=10;j++){
					if( $('fila'+j).checked && i>=2 ){
						if ( $('col'+i).checked )
							fils[k] = $('fila'+j+'col'+i).value;
						k++;
						
					}else{
							fils[k] = $('fila'+j+'col'+i).value;
							k++;
					}			
				}
			}
			filas = fils.join(',');
			//remplazo de caracteres especiales
			filas = reemplazar(filas);
			
					
			var url = 'procesa_ajax.php';
			var params = 'opc=guardar_tarifas&columnas='+columnas+'&valores='+filas+'&idPaquete='+idPaquete;
    		var ajax = new Ajax.Request( url, {
                                      method:"get",
    								  parameters: params,
    								  onLoading: mostrarLoad,
    								  onComplete: procesarGuardarDatos
									  }
     		);
	return true;
}


function reemplazar(text){  	
  text = text.replace(/[áàäâå]/g, 'a');
  text = text.replace(/[éèëê]/g, 'e');
  text = text.replace(/[íìïî]/g, 'i');
  text = text.replace(/[óòöô]/g, 'o');
  text = text.replace(/[úùüû]/g, 'u');
  text = text.replace(/[Á]/,"A");
  text = text.replace(/[É]/,"E");
  text = text.replace(/[Í]/,"I");
  text = text.replace(/[Ó]/,"O");
  text = text.replace(/[Ú]/,"U");
  text = text.replace(/[Ñ]/,"N");
  text = text.replace(/[ýÿ]/g, 'y');
  text = text.replace(/[ñ]/g, 'n');
  text = text.replace(/[ç]/g, 'c');
 // text = text.replace(/['"]/g, '');
  //text = text.replace(/[^a-zA-Z0-9-]/g, ' '); //text = text.replace(/\W/g, ' ');
  //text = text.replace(/\s+/g, '_');
  //text = text.replace(/(_)$/g, '');
  //text = text.replace(/^(_)/g, '');  
  return text;
	
}




function procesarGuardarDatos (resp){
	
	//resp.responseText;
	
	$('cargando').innerHTML = 'Los valores se guardaron correctamente';
	return true;
	
}






function habilitarCol(check, ncol){
	
	if(check.checked){
		$('val_col'+ncol).removeAttribute('disabled');
		for(i=1;i<=10;i++){
		  if( $('fila'+i).checked ) 	
			$('fila'+i+'col'+ncol).removeAttribute('disabled');	
		}
	}else{
		$('val_col'+ncol).setAttribute('disabled','disabled');
		for(i=1;i<=10;i++){
			//if( ! $('fila'+i).checked )
				$('fila'+i+'col'+ncol).setAttribute('disabled','disabled');
		}
	}
}



function habilitarFil(check, nfil){
	
	
	for(i=1;i<=6;i++){
		if(check.checked)
		  if(i>=2){	
			if( $('col'+i).checked )
				$('fila'+nfil+'col'+i).removeAttribute('disabled');
		  }else
		  	$('fila'+nfil+'col'+i).removeAttribute('disabled');
		  	
		else
			//if(i>=2){
			 // if( !$('col'+i).checked )
				$('fila'+nfil+'col'+i).setAttribute('disabled','disabled');
			//}else
			//	$('fila'+nfil+'col'+i).setAttribute('disabled','disabled');
	}
}
	


//calcula el importe a pagar con dato del periodo y valor del abono
function recalcular(oPeriodo, idPack){
	
	periodo = oPeriodo.value;
	
	/** esto debe ser mantenido si cambian las pormociones por cantidad **/
	if(periodo == 6) periodo--;
	if(periodo == 12) periodo=9;
	
	
	num = new Number($(idPack).value * periodo);
	 $('total').innerHTML = '$'+num.toFixed(2);
	 $('monto').value = num.toFixed(2);
}

//calcula el importe a pagar con dato del periodo y valor del abono
function recalcularRenovacion(oPeriodo, valor){
	
	periodo = oPeriodo.value;
	
	/** esto debe ser mantenido si cambian las pormociones por cantidad **/
	if(periodo == 6) periodo--;
	if(periodo == 12) periodo=9;
	
	
	num = new Number(valor * periodo);
	 $('total').innerHTML = '$'+num.toFixed(2);
	
}

function EsEmail(w_email) {
	
	var test = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	var emailReg = new RegExp(test);

	return emailReg.test(w_email);
}


///// Validaciones


function validarHotel(){
	
	if($("nombre").value==""){
		alert("Debe indicar el nombre del hotel");
		$("nombre").style.border='1px #ff0000 solid';
		return false;
	}else
		$("nombre").style.border='1px #B1B1B1 solid';
	
	
	if($("razon").value==""){
		alert("Debe indicar la razon social");
		$("razon").style.border='1px #ff0000 solid';
		return false;
	}else
		$("razon").style.border='1px #B1B1B1 solid';	
		
	
	if($("contacto").value==""){
		alert("Debe indicar un contacto en el hotel");
		$("contacto").style.border='1px #ff0000 solid';
		return false;
	}else
		$("contacto").style.border='1px #B1B1B1 solid';
	
		
	
	if($("emailr").value==""){
			alert("Debe indicar un email de reservas");
			$("emailr").style.border='1px #ff0000 solid';
			return false;
	}else
		$("emailr").style.border='1px #B1B1B1 solid';
		
				
	
	if($("emailr").value!=""){
		if(!EsEmail($("emailr").value)){
			alert("Debe indicar un email valido para las reservas");
			$("emailr").style.border='1px #ff0000 solid';
			return false;
		}else
		$("emailr").style.border='1px #B1B1B1 solid';
	}

	if($("emailc").value==""){
			alert("Debe indicar un email de contactos");
			$("emailc").style.border='1px #ff0000 solid';
			return false;
	}else
		$("emailc").style.border='1px #B1B1B1 solid';
	
	if($("emailc").value!=""){
		if(!EsEmail($("emailc").value)){
			alert("Debe indicar un email valido para contactos");
			$("emailc").style.border='1px #ff0000 solid';
			return false;
		}
		else
		$("emailc").style.border='1px #B1B1B1 solid';
	}
	
			
	if($("dir").value==""){
		alert("Debe indicar la direccion del hotel");
		$("dir").style.border='1px #ff0000 solid';
		return false;
	}else
		$("dir").style.border='1px #B1B1B1 solid';
		
		
	if($("cp").value==""){
		alert("Debe indicar codigo postal");
		$("cp").style.border='1px #ff0000 solid';
		return false;
	}else
		$("cp").style.border='1px #B1B1B1 solid';		
		
	if($("loc").value==""){
		alert("Debe indicar la localidad");
		$("loc").style.border='1px #ff0000 solid';
		return false;
	}else
		$("loc").style.border='1px #B1B1B1 solid';		
		
	if($("prov").value==""){
		alert("Debe indicar la provincia");
		$("prov").style.border='1px #ff0000 solid';
		return false;
	}else
		$("prov").style.border='1px #B1B1B1 solid';		
		

	if($("contacto").value==""){
		alert("Debe indicar un contacto en el hotel");
		$("contacto").style.border='1px #ff0000 solid';
		return false;
	}else
		$("contacto").style.border='1px #B1B1B1 solid';			
		
	
	if($("desc").value==""){
		alert("Debe indicar una descripcion del hotel");
		$("desc").style.border='1px #ff0000 solid';
		return false;
	}else
		$("desc").style.border='1px #B1B1B1 solid';
		
		
	if($("ubic").value==""){
		alert("Debe indicar la ubicacion del hotel");
		$("ubic").style.border='1px #ff0000 solid';
		return false;
	}else
		$("ubic").style.border='1px #B1B1B1 solid';
	
	return true;	
	
}

function validarFacturacion(){
	
	if($("dirf").value==""){
		alert("Debe indicar la direccion de facturacion");
		$("dirf").style.border='1px #ff0000 solid';
		return false;
	}else
		$("dirf").style.border='1px #B1B1B1 solid';
		
		
	if($("cpf").value==""){
		alert("Debe indicar codigo postal de facturacion");
		$("cpf").style.border='1px #ff0000 solid';
		return false;
	}else
		$("cpf").style.border='1px #B1B1B1 solid';		
		
	if($("locf").value==""){
		alert("Debe indicar la localidad de facturacion");
		$("locf").style.border='1px #ff0000 solid';
		return false;
	}else
		$("locf").style.border='1px #B1B1B1 solid';		
		
	if($("provf").value==""){
		alert("Debe indicar la provincia de facturacion");
		$("provf").style.border='1px #ff0000 solid';
		return false;
	}else
		$("provf").style.border='1px #B1B1B1 solid';			
		
		
	if($("cuit").value==""){
		alert("Debe indicar el CUIT del hotel");
		$("cuit").style.border='1px #ff0000 solid';
		return false;
	}else
		$("cuit").style.border='1px #B1B1B1 solid';
		
	if($("iva").value==""){
		alert("Debe indicar la condicion frente al IVA");
		$("iva").style.border='1px #ff0000 solid';
		return false;
	}else
		$("iva").style.border='1px #B1B1B1 solid';	
	
	return true;	
		
}

function validarLogin(){
	
	
	if($("pass").value!=""){	
		if($("pass").value != $("repass").value){
			alert("La contraseña y la verificacion de la misma, no coinciden");
			$("repass").style.border='1px #ff0000 solid';
			return false;
		}else
			$("repass").style.border='1px #B1B1B1 solid';
	}else
		$("repass").style.border='1px #B1B1B1 solid';
	
	return true;
	
}


function validarDatosPerfil(){
	
  if(!validarHotel()) return false;		
  if(!validarFacturacion()) return false;				
  if(!validarLogin()) return false;					
  
  return true;
	
}


function validarDatosAcercaPaquete(){
	
	if($("titulo").value==""){
		alert("El titulo de la oferta es obligatoria");
		$("titulo").style.border='1px #ff0000 solid';
		return false;
	}else
		$("titulo").style.border='1px #B1B1B1 solid';
			
	
	if($('valorch').checked){	
	
		if($("condicion").value==""){
			alert("Debe indicar una condicion para el precio");
			$("condicion").style.border='1px #ff0000 solid';
			return false;
		}else
			$("condicion").style.border='1px #B1B1B1 solid';
			
				
		if($("precio").value==""){
			alert("El precio de la oferta es obligatoria");
			$("precio").style.border='1px #ff0000 solid';
			return false;
		}else
			$("precio").style.border='1px #B1B1B1 solid';
	
		if(!EsEntero($("precio").value)){
			alert("El precio de la oferta debe ser un valor entero, sin puntos, comas ni simbolos monetarios.");
			$("precio").style.border='1px #ff0000 solid';
			return false;
		}else
			$("precio").style.border='1px #B1B1B1 solid';	
						
		if($("cond").value==""){
				alert("Debe indicar las condiciones del precio de la oferta");
				$("cond").style.border='1px #ff0000 solid';
				return false;
		}else
				$("cond").style.border='1px #B1B1B1 solid';
	}else{
		if($("condi").value==""){
				alert("Debe indicar la aclaracion del precio");
				$("condi").style.border='1px #ff0000 solid';
				return false;
		}else
				$("condi").style.border='1px #B1B1B1 solid';
	}
	
	if($('fecha').checked){ 	
		if($("sel3").value==""){
				alert("Debe indicar la fecha de vigencia de la oferta");
				$("sel3").style.border='1px #ff0000 solid';
				return false;
		}else
				$("sel3").style.border='1px #B1B1B1 solid';
	}else
		if($("vigen").value==""){
					alert("Debe aclarar la vigencia de la oferta.");
					$("vigen").style.border='1px #ff0000 solid';
					return false;
				}else
					$("vigen").style.border='1px #B1B1B1 solid';
			
		
	if($("temporada").value==""){
		alert("Debe indicar la temporada para la oferta");
		$("temporada").style.border='1px #ff0000 solid';
		return false;
	}else
		$("temporada").style.border='1px #B1B1B1 solid';
		
		
	
	
	return true;
	
	
}


function validarDatosPaquete(){
	
	return validarDatosAcercaPaquete();
	
}





function validarSoporte(){
	
	
	if($("nombre").value==""){
		alert("Debe indicar un Nombre y Apellido");
		return false;	
	}
	
	
	if($("email").value==""){
			alert("Debes indicar un email para contactarte");
			return false;
	}
	
	if($("email").value!=""){
		if(!EsEmail($("email").value)){
			alert("Debes indicar un email valido");
			return false;
		}
	}
	
	if($("desc").value==""){
		alert("Debes indicar la descripcion del problema");
		return false;	
	}
	
	
	
	return true;
}



function validarSugerencia(){
	
	
	if($("nombre").value==""){
		alert("Debe indicar un Nombre y Apellido");
		return false;	
	}
	
	
	if($("email").value==""){
			alert("Debes indicar un email para contactarte");
			return false;
	}
	
	if($("email").value!=""){
		if(!EsEmail($("email").value)){
			alert("Debes indicar un email valido");
			return false;
		}
	}
	
	if($("desc").value==""){
		alert("Debes indicar la descripcion del problema");
		return false;	
	}
	
	
	
	return true;
}




//valida la compra de abonos
function validarCompraPaquetesPanel(){
	
	if($("email").value==""){
			alert("Debe indicar un email");
			return false;
	}
	
	if($("email").value!=""){
		if(!EsEmail($("email").value)){
			alert("Debe indicar un email valido");
			return false;
		}
	}

	if($("tel").value==""){
			alert("Debe indicar un telefono");
			return false;
	}
	
	if($("pack").value==""){
			alert("Debe seleccionar uno de los abonos");
			return false;
	}
	
	
	if(!$("pf").checked && !$("tb").checked && !$("dm").checked && !$("tc").checked){
			alert("Debe indicar la forma de pago de su preferencia");
			return false;
	}
	
	
return true;
}


//valida la renovacion de abonos
function validarRenovacionPaquetesPanel(){
	
	if($("email").value==""){
			alert("Debe indicar un email");
			return false;
	}
	
	if($("email").value!=""){
		if(!EsEmail($("email").value)){
			alert("Debe indicar un email valido");
			return false;
		}
	}

	if($("tel").value==""){
			alert("Debe indicar un telefono");
			return false;
	}
	
	if($("pack").value==""){
			alert("Debe seleccionar el tiempo de vigencia del paquete");
			return false;
	}
	
	
	if(!$("pf").checked && !$("tb").checked && !$("dm").checked && !$("tc").checked){
			alert("Debe indicar la forma de pago de su preferencia");
			return false;
	}
	
	
	
	
return true;
}




//valida la compra de abonos

function validarCompra(){
	
	
	if($("nombre").value==""){
			alert("Debe indicar nombre y apellido");
			return false;
	}
	
	if($("nempresa").value==""){
			alert("Debe indicar el nombre del establecimiento");
			return false;
	}
	
	if($("telefono").value==""){
			alert("Debe indicar un telefono");
			return false;
	}
	
	if($("pack").value==""){
			alert("Debe seleccionar uno de los abonos");
			return false;
	}
		
	
	if($("email").value==""){
			alert("Debe indicar un email");
			return false;
	}
	
	if($("email").value!=""){
		if(!EsEmail($("email").value)){
			alert("Debe indicar un email valido");
			return false;
		}
	}
	
	if($("categoria").value==""){
			alert("Debe indicar la categoria");
			return false;
	}
	
	if($("ubicacion").value==""){
			alert("Debe indicar la ubicacion");
			return false;
	}
	
	
	if($("rsocial").value==""){
			alert("Debe indicar la razon social");
			return false;
	}
	
	
	
	if($("rsocial").value==""){
			alert("Debe indicar la razon social");
			return false;
	}
	
	
	if($("calle").value==""){
			alert("Debe indicar la calle");
			return false;
	}
	
	if($("cuit").value==""){
			alert("Debe indicar su cuit");
			return false;
	}
	
	if($("ciudad").value==""){
			alert("Debe indicar la ciudad");
			return false;
	}
	
	
	if($("provincia").value==""){
			alert("Debe indicar la provincia");
			return false;
	}
	
	if($("cp").value==""){
			alert("Debe indicar el codigo postal");
			return false;
	}
	
	
	
	if($("user").value==""){
			alert("Debe indicar un nombre de usuario. Ud. podra acceder a su panel de control con el nombre de usuario que escoja aqui");
			return false;
	}
	
	if($("pass").value==""){
			alert("Debe indicar una contraseña de entre 6 a 12 digitos.  Utilice numeros y letras mayusculas y minusculas");
			return false;
	}
	
	var pass = new String( $("pass").value );
	if(pass.length < 6 || pass.length > 12){
			alert("La contrasña debe tener entre 6 y 12 digitos.  Utilice numeros y letras mayusculas y minusculas");
			return false;
	}

	
	if($("pass").value != $("repass").value){
			alert("La contrasña no coincide con la verificacion de la misma");
			return false;
	}
	
	
	if(!$("terminos").checked ){
			alert("Debe estar de acuerdo con nuestro terminos y condiciones");
			return false;
	}
			
	if(!$("pf").checked && !$("tb").checked && !$("dm").checked && !$("tc").checked){
			alert("Debe indicar la forma de pago de su preferencia");
			return false;
	}
	
	
	return true;
}


