function validar_formulario(type)
{
	switch(type)
	{
		case "contact":
			var NOMBRE=document.getElementById("NOMBRE").value; 
			if(!NOMBRE) { alert("Escribe tu nombre completo!"); document.getElementById('NOMBRE').focus(); return false; }
			var EMAIL=document.getElementById("EMAIL").value; 
			if(!EMAIL) { alert("Escribe un correo electrónico!"); document.getElementById('EMAIL').focus(); return false; }
			else if(!validarEmail(EMAIL)) { alert("El correo electrónico escrito es incorrecto!"); document.getElementById('EMAIL').focus(); return false; }
			var MENSAJE=document.getElementById("MENSAJE").value; 
			if(!MENSAJE) { alert("Escribe un mensaje!"); document.getElementById('MENSAJE').focus(); return false; }
			document.getElementById("BUTTON_CONTACT").value="Espere...enviando";
			document.getElementById("BUTTON_CONTACT").disabled=true;
			load_options('contact_send');
			return false;
		break;
		case "register":
			var USUARIO=document.getElementById("USUARIO").value; 
			if(!USUARIO) { alert("Escribe un nombre de usuario!"); document.getElementById('USUARIO').focus(); return false; }
			var PASSWORD=document.getElementById("PASSWORD").value; 
			if(!PASSWORD) { alert("Escribe una contraseña!"); document.getElementById('PASSWORD').focus(); return false; }
			var PASSWORD_CONFIRM=document.getElementById("PASSWORD_CONFIRM").value; 
			if(!PASSWORD_CONFIRM) { alert("Confirme contraseña!"); document.getElementById('PASSWORD_CONFIRM').focus(); return false; }
			if(PASSWORD!=PASSWORD_CONFIRM) 
			{ 
				alert("Las contraseñas no coinciden!"); document.getElementById("PASSWORD").value=""; document.getElementById("PASSWORD_CONFIRM").value=""; document.getElementById('PASSWORD').focus(); return false; 
			}
			var NOMBRE=document.getElementById("NOMBRE").value; 
			if(!NOMBRE) { alert("El campo nombre no puede estar vacío!"); document.getElementById('NOMBRE').focus(); return false; }
			var APELLIDOS=document.getElementById("APELLIDOS").value; 
			if(!APELLIDOS) { alert("El campo apellidos no puede estar vacío!"); document.getElementById('APELLIDOS').focus(); return false; }
			// Begin Raul - Mdesign - 13-Nov-2007 - Nuevos campos requeridos...
			var DOMICILIO=document.getElementById("DOMICILIO").value; 
			if(!DOMICILIO) { alert("Escribe tu domicilio!"); document.getElementById('DOMICILIO').focus(); return false; }
			var CIUDAD=document.getElementById("CIUDAD").value; 
			if(!CIUDAD) { alert("Escribe tu Ciudad!"); document.getElementById('CIUDAD').focus(); return false; }
			var ESTADO_ID=document.getElementById("ESTADO_ID").value; 
			if(!ESTADO_ID) { alert("Selecciona tu Entidad!"); document.getElementById('ESTADO_ID').focus(); return false; }
			// End Raul...
			var EMAIL=document.getElementById("EMAIL").value; 
			if(!EMAIL) { alert("Escribe un correo electrónico!"); document.getElementById('EMAIL').focus(); return false; }
			else if(!validarEmail(EMAIL)) { alert("El correo electrónico escrito es incorrecto!"); document.getElementById('EMAIL').focus(); return false; }
			// Begin Raul - Mdesign - 13-Nov-2007 - Nuevos campos requeridos...
			var TELEFONO=document.getElementById("TELEFONO").value; 
			if(!TELEFONO) { alert("Escribe tu telefono!"); document.getElementById('TELEFONO').focus(); return false; }
			var RFC=document.getElementById("RFC").value; 
			if(!RFC) { alert("Escribe tu R.F.C.!"); document.getElementById('RFC').focus(); return false; }
			var CP=document.getElementById("CP").value; 
			if(!CP) { alert("Escribe tu codigo postal!"); document.getElementById('CP').focus(); return false; }
			// End Raul...
			document.getElementById("row_msg_result").innerHTML="<img src='../images/main_loading.gif' width='16' height='16' border='0'><br>Enviando";
			load_options(type);
			return false;
		break;
		case "myaccount":
			var USUARIO=document.getElementById("USUARIO").value; 
			if(!USUARIO) { alert("Escribe un nombre de usuario!"); document.getElementById('USUARIO').focus(); return false; }
			var NOMBRE=document.getElementById("NOMBRE").value; 
			if(!NOMBRE) { alert("El campo nombre no puede estar vacío!"); document.getElementById('NOMBRE').focus(); return false; }
			var APELLIDOS=document.getElementById("APELLIDOS").value; 
			if(!APELLIDOS) { alert("El campo apellidos no puede estar vacío!"); document.getElementById('APELLIDOS').focus(); return false; }
			// Begin Raul - Mdesign - 13-Nov-2007 - Nuevos campos requeridos...
			var DOMICILIO=document.getElementById("DOMICILIO").value; 
			if(!DOMICILIO) { alert("Escribe tu domicilio!"); document.getElementById('DOMICILIO').focus(); return false; }
			var CIUDAD=document.getElementById("CIUDAD").value; 
			if(!CIUDAD) { alert("Escribe tu Ciudad!"); document.getElementById('CIUDAD').focus(); return false; }
			var ESTADO_ID=document.getElementById("ESTADO_ID").value; 
			if(!ESTADO_ID) { alert("Selecciona tu Entidad!"); document.getElementById('ESTADO_ID').focus(); return false; }
			// End Raul...
			var EMAIL=document.getElementById("EMAIL").value; 
			if(!EMAIL) { alert("Escribe un correo electrónico!"); document.getElementById('EMAIL').focus(); return false; }
			else if(!validarEmail(EMAIL)) { alert("El correo electrónico escrito es incorrecto!"); document.getElementById('EMAIL').focus(); return false; }
			// Begin Raul - Mdesign - 13-Nov-2007 - Nuevos campos requeridos...
			var TELEFONO=document.getElementById("TELEFONO").value; 
			if(!TELEFONO) { alert("Escribe tu telefono!"); document.getElementById('TELEFONO').focus(); return false; }
			var RFC=document.getElementById("RFC").value; 
			if(!RFC) { alert("Escribe tu R.F.C.!"); document.getElementById('RFC').focus(); return false; }
			var CP=document.getElementById("CP").value; 
			if(!CP) { alert("Escribe tu codigo postal!"); document.getElementById('CP').focus(); return false; }
			// End Raul...
			document.getElementById("row_msg_result").innerHTML="<img src='../images/main_loading.gif' width='16' height='16' border='0'><br>Enviando";
			load_options(type);
			return false;
		break;
		case "tosendpass":
			var EMAIL=document.getElementById("EMAIL").value; 
			if(!EMAIL) { alert("Escribe un correo electrónico!"); document.getElementById('EMAIL').focus(); return false; }
			else if(!validarEmail(EMAIL)) { alert("El correo electrónico escrito es incorrecto!"); document.getElementById('EMAIL').focus(); return false; }
			document.getElementById("BUTTON_TOSENDPASS").value="Espere...enviando";
			document.getElementById("BUTTON_TOSENDPASS").disabled=true;
			load_options('tosendpass_send');
			return false;
		break;
	}
}

function load_options(type)
{
	var archivo_ajax="ajax.php?type="+type;
	switch (type)
	{
		case "contact_send": 
			var valor='1'; 
			var NOMBRE	=document.getElementById("NOMBRE").value;
			var EMAIL	=document.getElementById("EMAIL").value;
			var MENSAJE	=document.getElementById("MENSAJE").value;
		break;
		case "register" :
			document.getElementById("row_msg_result").innerHTML="<img src='../images/main_loading.gif' width='16' height='16' border='0'><br>Enviando"; 
			var valor='1';
			var USU=document.getElementById("USUARIO").value; 
			var PA1=document.getElementById("PASSWORD").value;
			var PA2=document.getElementById("PASSWORD_CONFIRM").value; 
			var NOM=document.getElementById("NOMBRE").value; 
			var APE=document.getElementById("APELLIDOS").value;  
			var DOM=document.getElementById("DOMICILIO").value;  
			var CD =document.getElementById("CIUDAD").value;  
			var EID=document.getElementById("ESTADO_ID").value;  
			var EMA=document.getElementById("EMAIL").value;  
			var TEL=document.getElementById("TELEFONO").value;  
			var DID=document.getElementById("TIPO_DISTRIBUIDOR_ID").value;  
			var NID=document.getElementById("TIPO_NEGOCIO_ID").value;  
			var CEQ=document.getElementById("COMPRA_EQUIPO").value;  
			var CID=document.getElementById("TIPO_COMPRA_ID").value; 
			var EmpleadosId=document.getElementById("EMPLEADOS_ID").value; 
			var AntiguedadId=document.getElementById("ANTIGUEDAD_ID").value; 
			var CSO=document.getElementById("CLASE_DE_SOPORTE").value; 
			// Begin - Raul - Mdesign - 13-Nov-2007
			var RFC=document.getElementById("RFC").value;  
			var CP=document.getElementById("CP").value;  
			// End - Raul
		break;
		case "myaccount" :
			document.getElementById("row_msg_result").innerHTML="<img src='../images/main_loading.gif' width='16' height='16' border='0'><br>Enviando"; 
			var valor=document.getElementById("id").value;
			var USU=document.getElementById("USUARIO").value; 
			var PA1=document.getElementById("PASSWORD").value;
			var PA2=document.getElementById("PASSWORD_CHANGE").value; 
			var NOM=document.getElementById("NOMBRE").value; 
			var APE=document.getElementById("APELLIDOS").value;  
			var DOM=document.getElementById("DOMICILIO").value;  
			var CD =document.getElementById("CIUDAD").value;  
			var EID=document.getElementById("ESTADO_ID").value;  
			var EMA=document.getElementById("EMAIL").value;  
			var TEL=document.getElementById("TELEFONO").value;  
			var DID=document.getElementById("TIPO_DISTRIBUIDOR_ID").value;  
			var NID=document.getElementById("TIPO_NEGOCIO_ID").value;  
			var CEQ=document.getElementById("COMPRA_EQUIPO").value;  
			var CID=document.getElementById("TIPO_COMPRA_ID").value;
			var EmpleadosId=document.getElementById("EMPLEADOS_ID").value; 
			var AntiguedadId=document.getElementById("ANTIGUEDAD_ID").value; 
			var CSO=document.getElementById("CLASE_DE_SOPORTE").value; 
			// Begin - Raul - Mdesign - 13-Nov-2007
			var RFC=document.getElementById("RFC").value;  
			var CP=document.getElementById("CP").value;  
			// End - Raul
		break;
		case "tosendpass_send" : var valor='1';  var EMAIL=document.getElementById("EMAIL").value; break;
	}
	if(valor) 
	{
		var ajax=funcionnuevoAjax();
		ajax.open("POST", archivo_ajax, true);
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		switch (type)
		{
			case "contact_send": ajax.send("NOMBRE="+NOMBRE+"&EMAIL="+EMAIL+"&MENSAJE="+MENSAJE); break;
			case "register": ajax.send("USU="+USU+"&PA1="+PA1+"&PA2="+PA2+"&NOM="+NOM+"&APE="+APE+"&DOM="+DOM+"&CD="+CD+"&EID="+EID+"&EMA="+EMA+"&TEL="+TEL+"&DID="+DID+"&NID="+NID+"&CEQ="+CEQ+"&CID="+CID+"&CSO="+CSO+"&EmpleadosId="+EmpleadosId+"&AntiguedadId="+AntiguedadId+"&RFC="+RFC+"&CP="+CP); break;
			case "myaccount": ajax.send("id="+valor+"&USU="+USU+"&PA1="+PA1+"&PA2="+PA2+"&NOM="+NOM+"&APE="+APE+"&DOM="+DOM+"&CD="+CD+"&EID="+EID+"&EMA="+EMA+"&TEL="+TEL+"&DID="+DID+"&NID="+NID+"&CEQ="+CEQ+"&CID="+CID+"&CSO="+CSO+"&EmpleadosId="+EmpleadosId+"&AntiguedadId="+AntiguedadId+"&RFC="+RFC+"&CP="+CP); break;
			case "tosendpass_send" : 		ajax.send("EMAIL="+EMAIL);			break;
		}
		ajax.onreadystatechange=function()
		{
			if (ajax.readyState==1)
			{
				switch (type)
				{
					case "contact_send": document.getElementById("BUTTON_CONTACT").value="Espere...enviando"; document.getElementById("BUTTON_CONTACT").disabled=true; 				break;
					case "register": document.getElementById("row_msg_result").innerHTML="<img src='../images/main_loading.gif' width='16' height='16' border='0'><br>Enviando"; 	break;
					case "myaccount": document.getElementById("row_msg_result").innerHTML="<img src='../images/main_loading.gif' width='16' height='16' border='0'><br>Enviando"; 	break;
					case "tosendpass_send": document.getElementById("BUTTON_TOSENDPASS").value="Espere...enviando"; document.getElementById("BUTTON_TOSENDPASS").disabled=true; 	break;
				}
			}
			if (ajax.readyState==4)
			{
				//alert(ajax.responseText);
				if(!ajax.responseText) { }
				else 
				{
					switch (type)
					{
						case "contact_send": 		
							var respuesta=new Array(2); respuesta=ajax.responseText.split("*&*"); 
							document.getElementById("FILA_ERROR_EMAIL").innerHTML=respuesta[1]; 		
							document.getElementById("FILA_SEND").innerHTML=respuesta[2]; 		
						break; 
						case "register": 
							var respuesta=new Array(7); respuesta=ajax.responseText.split("*&*");
							document.getElementById("row_error_user").innerHTML=respuesta[1];
							document.getElementById("row_error_pass").innerHTML=respuesta[2];
							document.getElementById("row_error_confirm_pass").innerHTML=respuesta[3];
							document.getElementById("row_error_name").innerHTML=respuesta[4];
							document.getElementById("row_error_sname").innerHTML=respuesta[5];
							document.getElementById("row_error_email").innerHTML=respuesta[6];
							document.getElementById("row_msg_result").innerHTML=respuesta[7];
						break; 
						case "myaccount": 
							var respuesta=new Array(5); respuesta=ajax.responseText.split("*&*");
							document.getElementById("row_error_email").innerHTML=respuesta[1];
							document.getElementById("row_error_user").innerHTML=respuesta[2];
							document.getElementById("row_error_pass").innerHTML=respuesta[3];
							document.getElementById("row_error_name").innerHTML=respuesta[4];
							document.getElementById("row_msg_result").innerHTML=respuesta[5];
						break; 
						case "tosendpass_send": 
							var respuesta=new Array(2); respuesta=ajax.responseText.split("*&*"); 
							document.getElementById("FILA_ERROR_EMAIL").innerHTML=respuesta[1];
							document.getElementById("FILA_SEND").innerHTML=respuesta[2]; 
						break; 
					}
				}
			}
		}
	}
}

/***********************************************
* Cool DHTML tooltip script II- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/
var offsetfromcursorX=10 //Customize x offset of tooltip
var offsetfromcursorY=5 //Customize y offset of tooltip
var offsetdivfrompointerX=10 //Customize x offset of tooltip DIV relative to pointer image
var offsetdivfrompointerY=14 //Customize y offset of tooltip DIV relative to pointer image. Tip: Set it to (height_of_pointer_image-1).
document.write('<div id="dhtmltooltip"></div>') //write out tooltip DIV
document.write('<img id="dhtmlpointer" src="../images/arrow2.gif">') //write out pointer image
var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
if (ie||ns6)
var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""
var pointerobj=document.all? document.all["dhtmlpointer"] : document.getElementById? document.getElementById("dhtmlpointer") : ""
function ietruebody(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}
function ddrivetip(thetext, thewidth, thecolor){
	if (ns6||ie){
		if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
		if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
		tipobj.innerHTML=thetext
		enabletip=true
		return false
	}
}
function positiontip(e){
	if (enabletip){
		var nondefaultpos=false
		var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
		var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
		//Find out how close the mouse is to the corner of the window
		var winwidth=ie&&!window.opera? ietruebody().clientWidth : window.innerWidth-20
		var winheight=ie&&!window.opera? ietruebody().clientHeight : window.innerHeight-20
		var rightedge=ie&&!window.opera? winwidth-event.clientX-offsetfromcursorX : winwidth-e.clientX-offsetfromcursorX
		var bottomedge=ie&&!window.opera? winheight-event.clientY-offsetfromcursorY : winheight-e.clientY-offsetfromcursorY
		var leftedge=(offsetfromcursorX<0)? offsetfromcursorX*(-1) : -1000
		//if the horizontal distance isn't enough to accomodate the width of the context menu
		if (rightedge<tipobj.offsetWidth){
			//move the horizontal position of the menu to the left by it's width
			tipobj.style.left=curX-tipobj.offsetWidth+"px"
			nondefaultpos=true
		}
		else if (curX<leftedge)
			tipobj.style.left="5px"
		else{
			//position the horizontal position of the menu where the mouse is positioned
			tipobj.style.left=curX+offsetfromcursorX-offsetdivfrompointerX+"px"
			pointerobj.style.left=curX+offsetfromcursorX+"px"
		}
		//same concept with the vertical position
		if (bottomedge<tipobj.offsetHeight){
			tipobj.style.top=curY-tipobj.offsetHeight-offsetfromcursorY+"px"
			nondefaultpos=true
		}
		else{
			tipobj.style.top=curY+offsetfromcursorY+offsetdivfrompointerY+"px"
			pointerobj.style.top=curY+offsetfromcursorY+"px"
		}
		tipobj.style.visibility="visible"
		if (!nondefaultpos)
		pointerobj.style.visibility="visible"
		else
		pointerobj.style.visibility="hidden"
	}
}
function hideddrivetip(){
	if (ns6||ie){
		enabletip=false
		tipobj.style.visibility="hidden"
		pointerobj.style.visibility="hidden"
		tipobj.style.left="-1000px"
		tipobj.style.backgroundColor=''
		tipobj.style.width=''
	}
}
document.onmousemove=positiontip
