
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

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+' Esta vacio o no es valido.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\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+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' está incompleto.\n'; }
  } if (errors) alert('Revise por favor los siguientes campos del formulario:\n'+errors);
  document.MM_returnValue = (errors == '');
}
// validar usuarios
function validarData()
	{
		formulario = document.nuevosUsr;
		if(formulario.nombre.value == '')
		{
			alert('Debe ingresar su nombre');
			formulario.nombre.focus();
			return false;
		}
		if(formulario.apellido.value == '')
		{
			alert('Debe ingresar su apellido');
			formulario.apellido.focus();
			return false;
		}
		if(formulario.empresa.value == '')
		{
			alert('Debe ingresar el nombre de su empresa');
			formulario.empresa.focus();
			return false;
		}
		if(formulario.cargo.value == '')//////////////////////////////////////////////////
		{
			alert('Debe ingresar su cargo');
			formulario.cargo.focus();
			return false;
		}
		if(formulario.rubro.value == ''){
			alert('Debe seleccionar un Rubro');
			formulario.rubro.focus();
			return false;
		}
		if(formulario.telefono.value == '')
		{
			alert('El campo Telefono esta vacio');
			formulario.telefono.focus();
			return false;
		}
		if(formulario.direccion.value == '')
		{
			alert('El campo Direccion esta vacio');
			formulario.direccion.focus();
			return false;
		}
		if(formulario.email.value == '')
		{
			alert('El campo E-mail esta vacio');
			formulario.email.focus();
			return false;
		}
		
		if(!verCorreo(formulario.email.value)) {
			alert('La dirección de e-mail no es válida');
			formulario.email.focus();
			return false;
			}
		function verCorreo(cadena)
		{
			marca=0;
			for(i=0; i<cadena.length; i++)
			{
				if(cadena.charAt(i)=='@')
				{
					marca=1;
					break;
				}
				if(i==cadena.length) return false;
			}
			if(marca)
			{
				for(n=i+1; n<cadena.length; n++)
				if(cadena.charAt(n)=='.') return true;
			}
		//}
			//return false;
		}
		
		if(formulario.web.value == '')
		{
			alert('Por favor ingrese su sitio web');
			formulario.web.focus();
			return false;
		}
		
		
		if(formulario.persona.value == '')
		{
			alert('Por favor ingrese su nombre de usuario');
			formulario.persona.focus();
			return false;
		}
		if (formulario.persona.value.length < 4) 
		{
			alert('Su nombre de usuario debe contener al menos 4 caracteres');
			formulario.persona.focus();
			return false;
		}
		if (formulario.persona.value.length> 15)
		{
			alert('Su nombre de usuario puede coneneter 15 caracteres de maximo');
			formulario.persona.focus();
			return false;
		}
		//Validacion de username
		var valid = "abcdefghijklmnopqrstuvwxyz_-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
		var ok = "yes";
		var temp;
		for (var i=0; i<formulario.persona.value.length; i++) 
		{
			temp = "" + formulario.persona.value.substring(i, i+1);
			if (valid.indexOf(temp) == "-1") ok = "no";
		}
		if (ok == "no") 
		{
			alert("Su nombre de usuario contiene caracteres invalidos, solamente numeros y letras sin incluir la ñ");
			formulario.persona.focus();
			formulario.persona.select();
			return false;
		}
		//fin de validacion de username
		if(formulario.password.value == '')
		{
			alert('Por favor ingrese su contraseña');
			formulario.password.focus();
			return false;
		}
		if(formulario.password.value != formulario.password2.value)
		{
			alert('Su password y confirmacion del mismo no coinciden');
			formulario.password2.focus();
			return false;
		}
		if (formulario.password.value.length < 4) 
		{
			alert('Su password debe contener al menos 4 caracteres');
			formulario.password.focus();
			return false;
		}
		if (formulario.password.value.length> 15)
		{
			alert('Su password puede coneneter 15 caracteres de maximo');
			formulario.password.focus();
			return false;
		}
		//Validacion de Password
		var valid = "abcdefghijklmnopqrstuvwxyz_-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
		var ok = "yes";
		var temp;
		for (var i=0; i<formulario.password.value.length; i++) 
		{
			temp = "" + formulario.password.value.substring(i, i+1);
			if (valid.indexOf(temp) == "-1") ok = "no";
		}
		if (ok == "no") 
		{
			alert("Su contraseña contiene caracteres invalidos, solamente numeros y letras sin incluir la ñ");
			formulario.password.focus();
			formulario.password.select();
			return false;
		}
	}
	
	
	
	startList = function() {
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("nav");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" over";
  				}
 				 node.onmouseout=function() {
  					this.className=this.className.replace(" over", "");
   				}
   			}
 		 }
	 }
}
window.onload=startList;
	

	
	
	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;
}

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 enviar() {
document.check.submit();
}
function buscar() {
document.busc.submit();
}

function ventanica(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function ventanaP(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


/*ESTA SIN USO*/
 var capa 
  function cambio(idCapa){ 
  if (document.layers) capa = eval("document." + idCapa); 
  if (document.all) capa = eval(idCapa + ".style"); 
  if (document.getElementById) capa = eval('document.getElementById("' + idCapa + '").style');if ((capa.visibility == "hidden") || (capa.visibility == "hide")){ 
  capa.visibility = (document.layers) ? "show" : "visible" ; 
  }else{ 
  capa.visibility = (document.layers) ? "hide" : "hidden" ; 
  } 
  } 
  /**/

 function mostrar(enla, etik) {
  obj = document.getElementById(etik);
  obj.style.display = (obj.style.display == 'block') ? 'none' : 'block';
  enla.innerHTML = (enla.innerHTML == '[-]') ? '[+]' : '[-]';
}


// -- DHTML OCULTA/MUESTRA
function muestra(div){
	laBase = document.getElementById(div);
	laBase.style.display = (laBase.style.display == 'block') ? 'none' : 'block';
}
// -- AJAX INFORMACION UTIL
function crearInstancia(){
	XMLHttp = false;

	if(window.XMLHttpRequest){
		return new XMLHttpRequest();
	} else if(window.ActiveXObject){
		var versiones = ["Msxml2.XMLHTTP.7.0", "Msxml2.XMLHTTP.6.0", "Msxml2.XMLHTTP.5.0", "Msxml2.XMLHTTP.4.0", "Msxml2.XMLHTTP.3.0", "MSXML.XMLHTTP", "Microsoft.XMLHTTP"];
		for(var i=0;i<versiones.length;i++){
			try{
				XMLHttp = new ActiveXObject(versiones[i]);
				if(XMLHttp){
					return XMLHttp;
					break;
				}
			} catch(e){};
		}
	}
} 

req = crearInstancia();

function info(data, contenedor){
	muestra(contenedor)
	
	document.getElementById(contenedor).innerHTML = "<div style='padding:15px; text-align:center; top:408px; left:247px; z-index:10; position:fixed; position:absolute; width:432px; height:395px; background-color:#FFFFFF; border:1px solid #cccccc; color:#006699;'><img src='imgs/bullets/cargando.gif' alt='Cargando' /><br /><br /><b>Cargando...</b></div>";

	if(req){
		url = data;
		req.onreadystatechange = manejarEstado;
		req.open('GET', url, true);
		req.send(null);
	}

	function manejarEstado(){

		if(req.readyState == 4){
			if(req.status == 200){
				var respuesta = req.responseText;
				document.getElementById(contenedor).innerHTML=respuesta;
			} else {
				alert('Error al recibir respuesta' + req.statusText);
			}
		}
	}


}

// -- AJAX BUSQUEDA DE HOTELES
function crearInstancia(){
	XMLHttp = false;

	if(window.XMLHttpRequest){
		return new XMLHttpRequest();
	} else if(window.ActiveXObject){
		var versiones = ["Msxml2.XMLHTTP.7.0", "Msxml2.XMLHTTP.6.0", "Msxml2.XMLHTTP.5.0", "Msxml2.XMLHTTP.4.0", "Msxml2.XMLHTTP.3.0", "MSXML.XMLHTTP", "Microsoft.XMLHTTP"];
		for(var i=0;i<versiones.length;i++){
			try{
				XMLHttp = new ActiveXObject(versiones[i]);
				if(XMLHttp){
					return XMLHttp;
					break;
				}
			} catch(e){};
		}
	}
} 

req = crearInstancia();

function ajax(url,metodo,contenedor){
	//muestra(contenedor)
	
	document.getElementById(contenedor).innerHTML = "<div style='margin:0 auto'><img src='imgs/bullets/cargando.gif' alt='Cargando' /><br /><br /><b>Cargando...</b></div>";

	if(req){
		//url = data;
		req.onreadystatechange = manejarEstado;
		req.open(metodo, url, true);
		req.send(null);
	}

	function manejarEstado(){

		if(req.readyState == 4){
			if(req.status == 200){
				var respuesta = req.responseText;
				document.getElementById(contenedor).innerHTML=respuesta;
			} else {
				alert('Error al recibir respuesta' + req.statusText);
			}
		}
	}


}