// JavaScript Document
function creaAjax(){
  var objetoAjax=false;
  try {
   /*Para navegadores distintos a internet explorer*/
   objetoAjax = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (e) {
   try {
     /*Para explorer*/
     objetoAjax = new ActiveXObject("Microsoft.XMLHTTP");
     } 
     catch (E) {
     objetoAjax = false;
   }
  }

  if (!objetoAjax && typeof XMLHttpRequest!='undefined') {
   objetoAjax = new XMLHttpRequest();
  }
  return objetoAjax;
}

function enviar(){
	o="notification";
	rutasencera="http://www.drauta.com/wp-content/themes/web09/contacte.php";

	var ajax=creaAjax();	
	var capaContenedora = document.getElementById(o);
	var nom=document.getElementById("nom").value;
	var empresa=document.getElementById("empresa").value;
	var pais=document.getElementById("pais").value;
	var ciutat=document.getElementById("ciutat").value;
	var telefon=document.getElementById("telefon").value;
	var email=document.getElementById("email").value;
	var consulta=document.getElementById("consulta").value;
	var lang=document.getElementById("lang").value;
	var url=document.getElementById("url").value;
	ajax.open ('POST',rutasencera, true);
	
    ajax.onreadystatechange = function() {
         if (ajax.readyState==4){
            if(ajax.status==200)
            {
                 document.getElementById(o).innerHTML=ajax.responseText; 
            }
		 }
	}
	
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajax.send("nom="+nom+"&empresa="+empresa+"&pais="+pais+"&ciutat="+ciutat+"&telefon="+telefon+"&email="+email+"&consulta="+consulta+"&url="+url+"&lang="+lang);
	return
}


function enviardom(){
	o="rdomini";
	rutasencera="http://test.ewf5.com/bef5/wp-content/themes/novaweb/rdominis.php";
	var ajax=creaAjax();	
	var capaContenedora = document.getElementById(o);
	var domini=document.getElementById("domini").value;
	var extensio=document.getElementById("extensio").value;

	ajax.open ('POST',rutasencera, true);
	
    ajax.onreadystatechange = function() {
         if (ajax.readyState==4){
            if(ajax.status==200)
            {
                 document.getElementById(o).innerHTML=ajax.responseText; 
            }
		 }
	}
	
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajax.send("domini="+domini+"&extensio="+extensio);
	return
}



function viewHide(id) {
	var targetId, srcElement, targetElement;
	var targetElement = document.getElementById(id);
	if (targetElement.style.display == "none") 
	{
		targetElement.style.display = "";
	} 
	else 
	{
		targetElement.style.display = "none";
	}
}
function view(id) {
	var targetId, srcElement, targetElement;
	var targetElement = document.getElementById(id);
	targetElement.style.display = "";
}
function hide(id){
	var targetId, srcElement, targetElement;
	var targetElement = document.getElementById(id);
	targetElement.style.display = "none";
}

function showUsername(valor, target){
	var tar = document.getElementById(target);
	tar.innerHTML=valor;
}

function compCheckBox(obj){
	if(obj.checked){
		duplicateContactData();
	}else{
			document.getElementById('c_firstname').readOnly = false;
			document.getElementById('c_lastname').readOnly = false;
			document.getElementById('c_email').readOnly = false;
			document.getElementById('c_email1').readOnly = false;
			document.getElementById('c_firstname').readOnly = false;
			document.getElementById('c_phone').readOnly = false;
			document.getElementById('c_phone1').readOnly = false;
			document.getElementById('c_phone2').readOnly = false;
			document.getElementById('c_fax').readOnly = false;
			document.getElementById('c_address').readOnly = false;
			document.getElementById('c_cp').readOnly = false;
			document.getElementById('c_city').readOnly = false;
			
			document.getElementById('c_firstname').style.backgroundColor='#FFFFFF';
			document.getElementById('c_lastname').style.backgroundColor='#FFFFFF';
			document.getElementById('c_email').style.backgroundColor='#FFFFFF';
			document.getElementById('c_email1').style.backgroundColor='#FFFFFF';
			document.getElementById('c_firstname').style.backgroundColor='#FFFFFF';
			document.getElementById('c_phone').style.backgroundColor='#FFFFFF';
			document.getElementById('c_phone1').style.backgroundColor='#FFFFFF';
			document.getElementById('c_phone2').style.backgroundColor='#FFFFFF';
			document.getElementById('c_fax').style.backgroundColor='#FFFFFF';
			document.getElementById('c_address').style.backgroundColor='#FFFFFF';
			document.getElementById('c_cp').style.backgroundColor='#FFFFFF';
			document.getElementById('c_city').style.backgroundColor='#FFFFFF';
			//document.getElementById('c_countryid').disabled = false;
			//document.getElementById('c_tratamientoId').readOnly = false;
			//document.getElementById('c_provinceid').disabled = false;
	}
}

function copySingle(camp, value){
	if(document.getElementById('c_copydata').checked){
		from = camp.substr(1,camp.length);
		document.getElementById('c'+from).value = value;
	}
}

function Validacion(formulario){
	if(document.getElementById('rdbparticular').checked == true){
		if (formulario.domicilio.value.length > 0 && formulario.city.value.length > 0 && formulario.provincia.value.length > 0 && formulario.country.value.length > 0 && formulario.cp.value.length > 0 && formulario.phone.value.length > 0 && formulario.payment_form.selectedIndex > 0 && formulario.codigo_entidad.value.length == 4 && formulario.codigo_oficina.value.length == 4 && formulario.digitos_control.value.length == 2 && formulario.numero_cuenta.value.length == 10 && formulario.firstname.value.length > 0 && formulario.lastname.value.length > 0 && formulario.nif.value.length > 0) {
			if(document.getElementById('rdbnif').checked == true){
				if(validar_nifcif(formulario.nif.value)==false){
					alert("El N.I.F. introducido es incorrecto");
					return (false);
				}
				else{
					return (true);
				}
			}
			if(document.getElementById('rdbnie').checked == true){
				if(validar_permiso(formulario.nie.value)==false){
					alert("El N.I.E. introducido es incorrecto");
					return (false);
				}
				else{
					return (true);
				}
			}			
			
		}
		else{
			alert("Debes rellenar todos los campos.");
			return (false);
		}		
	}
	if(document.getElementById('rdbempresa').checked == true){
		if (formulario.domicilio.value.length > 0 && formulario.city.value.length > 0 && formulario.provincia.value.length > 0 && formulario.country.value.length > 0 && formulario.cp.value.length > 0 && formulario.phone.value.length > 0 && formulario.payment_form.selectedIndex > 0 && formulario.codigo_entidad.value.length == 4 && formulario.codigo_oficina.value.length == 4 && formulario.digitos_control.value.length == 2 && formulario.numero_cuenta.value.length == 10 && formulario.companyname.value.length > 0 && formulario.contact_name.value.length > 0 && formulario.cif.value.length > 0){
				if(validar_nifcif(formulario.cif.value)==false){
					alert("El C.I.F. introducido es incorrecto");
					return (false);
				}
				else{
					return (true);
				}
		}
		else{
			alert("Debes rellenar todos los campos.");
			return (false);
		}
	}
	//----------------------------E-MAIL-------------------------------
	if ((formulario.email.value.indexOf ('@', 0) == -1)||(formulario.email.length < 5)) { 
			alert("Escriba una direccion de correo valida en el campo \"Email\"."); 
			return (false); 
	}//---------------------------------------------------
}
function validar_nifcif(cif) {
	par = 0;
	non = 0;
	n_documento = 0;
	letras = "ABCDEFGHKLMNPQS";
	let = cif.charAt(0);
	var retorno = true;

	if (!isNaN(let)) {
		n_documento = cif;
		if (!validar_nif(n_documento)) {
			retorno = false;
		}
	}
	else {
		if (cif.length != 9) {
			retorno = false;
		}
	
		if ( letras.indexOf( let.toUpperCase() ) == -1 ) {
			retorno = false;
		}
	
		for (zz = 2; zz < 8; zz += 2) {
			par = par + parseInt(cif.charAt(zz));
		}
	
		for (zz = 1; zz < 9; zz += 2) {
			nn = 2 * parseInt(cif.charAt(zz));
			if (nn > 9) {
				nn = 1 + (nn - 10);
			}
			non = non + nn;
		}
	
		parcial = par + non;
		
		control = ( 10 - ( parcial % 10) );
	
		if (control == 10) {
			control = 0;
		}
	
		if (control != cif.charAt(8)) {
			retorno = false;
		}
	}
	return retorno;
}

function validar_nif(texto) {
	dni = texto.substring(0, texto.length - 1);
	let = texto.charAt(texto.length - 1);
	var retorno = true;
	
	if (!isNaN(let)) {
		retorno = false;
	}
	else {
		cadena="TRWAGMYFPDXBNJZSQVHLCKET";
		posicion = dni % 23;
		letra = cadena.substring(posicion, posicion + 1);
		
		if (letra != let.toUpperCase()) {
			retorno = false;
		}
	}
	
	if (dni.length != 8) {
		retorno = false;
	}

	return retorno;
}

function validar_permiso(texto) {
	permiso = texto.substring(1, texto.length - 1);
	let = texto.charAt(texto.length - 1);
	var retorno = true;
	
	if (!isNaN(let)) {
		retorno = false;
	}
	else {
		cadena="TRWAGMYFPDXBNJZSQVHLCKET";
		posicion = permiso % 23;
		letra = cadena.substring(posicion, posicion + 1);
		
		if (letra != let.toUpperCase()) {
			retorno = false;
		}
	}
	
	if (permiso.length != 7) {
		retorno = false;
	}
	
	if (texto.charAt(0) != "0" && texto.charAt(0) != "X" && texto.charAt(0) != "x") {
		retorno = false;
	}
	return retorno;
}



//-------------------------DATOS DE USUARIO
//---->Editar
function edit_userData(intUserId) {
		
	xmlHttpUserData=GetXmlHttpObject()
	if (xmlHttpUserData==null){	alert ("Browser does not support HTTP Request");return;	} 

	if(intUserId!=""){
		var url="edit_datauser.php?userid="+intUserId
		var userdata_div = "";
		userdata_div = document.getElementById('userdata_div')
		
		xmlHttpUserData.open("GET",url,true)
		xmlHttpUserData.onreadystatechange=function(){
			if(xmlHttpUserData.readyState == 1 ) { 
				userdata_div.innerHTML = "<div align=center valign=middle style='width:415px;'><img src='images/ajax-loader.gif' border=0>&nbsp;<b>Cargando datos.</b></div>";	 
			}
			else if(xmlHttpUserData.readyState == 4 ) {
				//alert (xmlHttpClientData.responseText);
				userdata_div.innerHTML = xmlHttpUserData.responseText;   
			}
		} 	
		xmlHttpUserData.send(null); 
	}	
}
//---->Guardar
function save_userData(intUserId,username,password,fecha_alta){
	//alert("firstname: "+ firstname +" "+ lastname +" "+ nif);
	
	xmlHttpUserdataSave=GetXmlHttpObject()
	
	if (xmlHttpUserdataSave==null){	alert ("Browser does not support HTTP Request");return;	} 
	
	var url="edit_datauser.php";
	//alert(url);
	xmlHttpUserdataSave.open("POST",url,true)
	xmlHttpUserdataSave.onreadystatechange=function(){
		if(xmlHttpUserdataSave.readyState == 1 ) { 
			userdata_div.innerHTML = "<div align=center valign=middle><img src='images/ajax-loader.gif' border=0>&nbsp;<b>Guardando datos.</b></div>";	 
		}
		else if(xmlHttpUserdataSave.readyState == 4 ) {
			//alert (xmlHttpClientdataSave.responseText);
			location.href = "datos.php?userid="+intUserId;  
		}
	}	
	xmlHttpUserdataSave.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttpUserdataSave.send("userid="+intUserId+"&username="+username+"&password="+password+"&fecha_alta="+fecha_alta);
}
//-------------------------DATOS DE CLIENTE--------------------------
//---->Editar
function edit_clienteData(intUserId) {
		
	xmlHttpClientData=GetXmlHttpObject()
	if (xmlHttpClientData==null){	alert ("Browser does not support HTTP Request");return;	} 

	if(intUserId!=""){
		var url="edit_dataclient.php?userid="+intUserId
		var clientdata_div
		var clientdata_div = document.getElementById('clientdata_div')	
		
		xmlHttpClientData.open("GET",url,true)
		xmlHttpClientData.onreadystatechange=function(){
			if(xmlHttpClientData.readyState == 1 ) { 
				clientdata_div.innerHTML = "<div align=center valign=middle style='width:415px;'><img src='images/ajax-loader.gif' border=0 >&nbsp;<b>Cargando datos.</b></div>";	 
			}
			else if(xmlHttpClientData.readyState == 4 ) {
				//alert (xmlHttpClientData.responseText);
				clientdata_div.innerHTML = xmlHttpClientData.responseText;   
			}
		} 	
		xmlHttpClientData.send(null); 
	}	
}
//---->Guardar
function save_clienteData(intUserId,firstname,lastname,companyname,nif){
	//alert("firstname: "+ firstname +" "+ lastname +" "+ nif);
	
	xmlHttpClientdataSave=GetXmlHttpObject()
	
	if (xmlHttpClientdataSave==null){	alert ("Browser does not support HTTP Request");return;	} 
	
	var url="edit_dataclient.php";
	//alert(url);
	var clientdata_div;
	var clientdata_div = document.getElementById('clientdata_div')
		
	xmlHttpClientdataSave.open("POST",url,true)
	xmlHttpClientdataSave.onreadystatechange=function(){
		if(xmlHttpClientdataSave.readyState == 1 ) { 
			clientdata_div.innerHTML = "<div align=center valign=middle style='width:415px;'><img src='images/ajax-loader.gif' border=0>&nbsp;<b>Guardando datos.</b></div>";	 
		}
		else if(xmlHttpClientdataSave.readyState == 4 ) {
			//alert (xmlHttpClientdataSave.responseText);
			location.href = "datos.php?userid="+intUserId;  
		}
	}	
	xmlHttpClientdataSave.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttpClientdataSave.send("userid="+intUserId+"&firstname="+firstname+"&lastname="+lastname+"&companyname="+companyname+"&nif="+nif);
}
//-------------------------DATOS DE CONTACTO--------------------------
//---->Editar
function edit_clienteContact(intUserId){
	xmlHttpClientContact=GetXmlHttpObject()
	if (xmlHttpClientContact==null){	
		alert ("Browser does not support HTTP Request");return;	
	} 

	if(intUserId!=""){
		var url="edit_contactclient.php?userid="+intUserId
		var clientcontact_div = "";
		clientcontact_div = document.getElementById('clientcontact_div')		
		xmlHttpClientContact.open("GET",url,true)
		
		xmlHttpClientContact.onreadystatechange=function(){
			
			if(xmlHttpClientContact.readyState == 1 ) { 
				clientcontact_div.innerHTML = "<div align=center valign=middle><img src='images/ajax-loader.gif' border=0>&nbsp;<b>Cargando datos.</b></div>";	 
			}
			else if(xmlHttpClientContact.readyState == 4 ) {
				//alert (xmlHttpClientData.responseText);
				clientcontact_div.innerHTML = xmlHttpClientContact.responseText;   
			}
		} 	
		xmlHttpClientContact.send(null); 
	}
}
//---->Guardar
function save_clienteContact(intUserId,address,city,province,country,cp,contactname,phone,phone1,phone2,fax,email,email1,email2){
	xmlHttpClientcontactSave=GetXmlHttpObject()
	if (xmlHttpClientcontactSave==null){alert ("Browser does not support HTTP Request");return;	} 	
	var url="edit_contactclient.php";
	//alert(address);
//	alert("address: "+ address +"city"+ city +"province"+ province);
//	alert("country: "+ country +"province"+ province);	
//	alert("phone: "+ phone +"fax"+ fax +"email"+ email);

	var clientcontact_div = "";
	clientcontact_div = document.getElementById('clientcontact_div')
	
	xmlHttpClientcontactSave.open("POST",url,true)
	xmlHttpClientcontactSave.onreadystatechange=function(){
		if(xmlHttpClientcontactSave.readyState == 1 ) {
			clientcontact_div.innerHTML = "<div align=center valign=middle><img src='images/ajax-loader.gif' border=0>&nbsp;<b>Guardando datos.</b></div>";								
			
		}else if(xmlHttpClientcontactSave.readyState == 4 ) {
			//alert (xmlHttpClientcontactSave.responseText);
			location.href = "datos.php?userid="+intUserId;
		}
	}
	xmlHttpClientcontactSave.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttpClientcontactSave.send("userid="+intUserId+"&address="+address+"&city="+city+"&province="+province+"&country="+country+"&cp="+cp+"&contactname="+contactname+"&phone="+phone+"&phone1="+phone1+"&phone2="+phone2+"&fax="+fax+"&email="+email+"&email1="+email1+"&email2="+email2);
}
//-------------------------DATOS BANCARIOS--------------------------
//---->Editar
function edit_clienteBank(intUserId) {
		
	xmlHttpClientBank=GetXmlHttpObject()
	if (xmlHttpClientBank==null){	alert ("Browser does not support HTTP Request");return;	} 

	if(intUserId!=""){
	var url="edit_bankclient.php?userid="+intUserId
	
	var clientbank_div = "";
	clientbank_div = document.getElementById('clientbank_div')	
	
	xmlHttpClientBank.open("GET",url,true)
	xmlHttpClientBank.onreadystatechange=function(){
							if(xmlHttpClientBank.readyState == 1 ) { 
								clientbank_div.innerHTML = "<div align=center valign=middle><img src='images/ajax-loader.gif' border=0>&nbsp;<b>Cargando datos.</b></div>";	 
							}
							else if(xmlHttpClientBank.readyState == 4 ) {
								//alert (xmlHttpClientBank.responseText);
								clientbank_div.innerHTML = xmlHttpClientBank.responseText;  
							}
						} 	
	xmlHttpClientBank.send(null); 
	}
}
//---->Guardar
function save_clienteBank(intUserId,bankname,codigo_entidad,codigo_oficina,digitos_control,numero_cuenta){
	xmlHttpClientbankSave=GetXmlHttpObject()
	if (xmlHttpClientbankSave==null){alert ("Browser does not support HTTP Request");return;	} 	
	var url="edit_bankclient.php";
	//alert("codigo_entidad: "+codigo_entidad+" codigo_oficina:"+codigo_oficina+" digitos_control: "+ digitos_control+"numero_cuenta: "+numero_cuenta+" intUserId:"+ intUserId);	

	
	xmlHttpClientbankSave.open("POST",url,true)
	xmlHttpClientbankSave.onreadystatechange=function(){
		if(xmlHttpClientbankSave.readyState == 1 ) {
			clientbank_div.innerHTML = "<div align=center valign=middle><img src='images/ajax-loader.gif' border=0>&nbsp;<b>Guardando datos.</b></div>";								
			
		}else if(xmlHttpClientbankSave.readyState == 4 ) {
			//alert (xmlHttpClientbankSave.responseText);
			location.href = "datos.php?userid="+intUserId;
		}
	}
	xmlHttpClientbankSave.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttpClientbankSave.send("userid="+intUserId+"&bankname="+bankname+"&codigo_entidad="+codigo_entidad+"&codigo_oficina="+codigo_oficina+"&digitos_control="+digitos_control+"&numero_cuenta="+numero_cuenta);
}
//-------------------------OBSERVACIONES--------------------------
//---->Añadir
function add_observation(intUserId) {
		
	xmlHttpClientObservation=GetXmlHttpObject()
	if (xmlHttpClientObservation==null){	alert ("Browser does not support HTTP Request");return;	} 

	if(intUserId!=""){
		var url="add_observation.php?userid="+intUserId
		var clientobservation_div = "";
		clientobservation_div = document.getElementById('clientobservation_div')
		
		xmlHttpClientObservation.open("GET",url,true)
		xmlHttpClientObservation.onreadystatechange=function(){
			if(xmlHttpClientObservation.readyState == 1 ) { 
				clientobservation_div.innerHTML = "<div align=center valign=middle><img src='images/ajax-loader.gif' border=0>&nbsp;<b>Cargando...</b></div>";	 
			}
			else if(xmlHttpClientObservation.readyState == 4 ) {
				//alert (xmlHttpClientData.responseText);
				clientobservation_div.innerHTML = xmlHttpClientObservation.responseText;   
			}
		} 	
		xmlHttpClientObservation.send(null); 
	}	
}
//---->Guardar
function save_userObservation(intUserId,observacion){
	//alert("intUserId: "+ intUserId +" "+ "observacion" + observacion);
	
	xmlHttpClientObservationSave=GetXmlHttpObject()
	
	if (xmlHttpClientObservationSave==null){	alert ("Browser does not support HTTP Request");return;	} 
	
	var url="add_observation.php";
	var clientobservation_div = "";
	clientobservation_div = document.getElementById('clientobservation_div')	
	
	//alert(url);
	xmlHttpClientObservationSave.open("POST",url,true)
	xmlHttpClientObservationSave.onreadystatechange=function(){
		if(xmlHttpClientObservationSave.readyState == 1 ) { 
			clientobservation_div.innerHTML = "<div align=center valign=middle><img src='images/ajax-loader.gif' border=0>&nbsp;<b>Guardando datos.</b></div>";	 
		}
		else if(xmlHttpClientObservationSave.readyState == 4 ) {
			//alert (xmlHttpClientObservationSave.responseText);
			location.href = "datos.php?userid="+intUserId;  
		}
	}	
	xmlHttpClientObservationSave.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttpClientObservationSave.send("userid="+intUserId+"&observacion="+observacion);
}
//---->Editar observacion
function edit_observacion(userid,observationid,tr_color){
	xmlHttpEditObservation=GetXmlHttpObject()
	tr_color = tr_color.substring(1,7);
	
	var edit_observation=document.getElementById('edit_observation_'+observationid);
	
	if (xmlHttpEditObservation==null){	alert ("Browser does not support HTTP Request");return;	} 
	var url="edit_observation.php?userid="+userid+"&observationid="+observationid+"&tr_color="+tr_color	

//	alert(url);
	xmlHttpEditObservation.open("GET",url,true)
	xmlHttpEditObservation.onreadystatechange=function(){
		if(xmlHttpEditObservation.readyState == 1 ) { 
			edit_observation.innerHTML = "<div align=center valign=middle><img src='images/ajax-bank_loader_white.gif' border=0>&nbsp;<b>Cargando datos.</b></div>";	 
		}
		else if(xmlHttpEditObservation.readyState == 4 ) {			
			//alert (xmlHttpEditDomain.responseText);
			edit_observation.innerHTML = xmlHttpEditObservation.responseText;  
		}
	} 	
	xmlHttpEditObservation.send(null); 	
}
//---->Guardar edicion de la observacion
function save_editObservation(intUserId,observacion,observacionid){
	//alert("intUserId: "+ intUserId +" "+ "observacion" + observacion);
	xmlHttpEditObservationSave=GetXmlHttpObject()
	save_edit_observation=document.all['edit_observation_'+observacionid];
	
	if (xmlHttpEditObservationSave==null){	alert ("Browser does not support HTTP Request");return;	} 
	
	var url="edit_observation.php";
	//alert(url);
	xmlHttpEditObservationSave.open("POST",url,true)
	xmlHttpEditObservationSave.onreadystatechange=function(){
		if(xmlHttpEditObservationSave.readyState == 1 ) { 
			save_edit_observation.innerHTML = "<div align=center valign=middle><img src='images/ajax-bank_loader_white.gif' border=0>&nbsp;<b>Guardando datos...</b></div>";
		}
		else if(xmlHttpEditObservationSave.readyState == 4 ) {
			//alert (xmlHttpEditObservationSave.responseText);
			location.href = "datos.php?userid="+intUserId;  
		}
	}	
	xmlHttpEditObservationSave.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttpEditObservationSave.send("userid="+intUserId+"&observacion="+observacion+"&observacionid="+observacionid);
}

//------------PRODUCTOS-----------------------
//Añadir
function add_product(intUserId) {
	xmlHttpAddProduct=GetXmlHttpObject()
	if (xmlHttpAddProduct==null){	alert ("Browser does not support HTTP Request");return;	} 
	var url="product_selection.php?userid="+intUserId
	var products_div = "";
	products_div = document.getElementById('products_div');
	
//	alert(url)
	xmlHttpAddProduct.open("GET",url,true)
	xmlHttpAddProduct.onreadystatechange=function(){
		if(xmlHttpAddProduct.readyState == 1 ) { 
			products_div.innerHTML = "<div align=center valign=middle><img src='images/ajax-loader.gif' border=0>&nbsp;<b>Cargando datos.</b></div>";	 
		}
		else if(xmlHttpAddProduct.readyState == 4 ) {
			//alert (xmlHttpAddProduct.responseText);
			products_div.innerHTML = xmlHttpAddProduct.responseText;  
		}
	} 	
	xmlHttpAddProduct.send(null); 
}
//----Guardar
function save_product(intUserId,domainname,bill_type,domain_systemtype,product,payment_period){
	xmlHttpProductSave=GetXmlHttpObject()
	if (xmlHttpProductSave==null){alert ("Browser does not support HTTP Request");return;	} 	
	var url="add_products.php";
	//alert("domainname: "+domainname+" bill_type:"+bill_type+" domain_systemtype: "+ domain_systemtype+"product: "+product+" payment_period:"+ payment_period);	

	
	xmlHttpProductSave.open("POST",url,true)
	xmlHttpProductSave.onreadystatechange=function(){
		if(xmlHttpProductSave.readyState == 1 ) {
			products_div.innerHTML = "<div align=center valign=middle><img src='images/ajax-loader.gif' border=0>&nbsp;<b>Guardando datos.</b></div>";								
			
		}else if(xmlHttpProductSave.readyState == 4 ) {
			//alert (xmlHttpProductSave.responseText);
			location.href = "datos.php?userid="+intUserId;
		}
	}
	xmlHttpProductSave.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttpProductSave.send("userid="+intUserId+"&domainname="+domainname+"&bill_type="+bill_type+"&domain_systemtype="+domain_systemtype+"&product="+product+"&payment_period="+payment_period);
}
//----------------GUARDAR DOMINIO
function save_domain(intUserId,domainname,fecha_alta,fecha_expira,domain_type,tarifa){
	xmlHttpSaveDomain=GetXmlHttpObject()
	if (xmlHttpSaveDomain==null){alert ("Browser does not support HTTP Request");return;	} 	
	var url="add_domain.php";
	//alert("intUserId: "+intUserId+" domainname:"+domainname+" fecha_alta: "+ fecha_alta+"fecha_expira: "+fecha_expira+" domain_type: "+ domain_type);	

	
	xmlHttpSaveDomain.open("POST",url,true)
	xmlHttpSaveDomain.onreadystatechange=function(){
		if(xmlHttpSaveDomain.readyState == 1 ) {
			products_div.innerHTML = "<div align=center valign=middle><img src='images/ajax-loader.gif' border=0>&nbsp;<b>Guardando datos.</b></div>";								
			
		}else if(xmlHttpSaveDomain.readyState == 4 ) {
			//alert (xmlHttpSaveDomain.responseText);
			location.href = "datos.php?userid="+intUserId;
		}
	}
	xmlHttpSaveDomain.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttpSaveDomain.send("userid="+intUserId+"&domainname="+domainname+"&fecha_alta="+fecha_alta+"&fecha_expira="+fecha_expira+"&domain_type="+domain_type+"&cost="+tarifa);
}
//----------------ACTUALIZAR DOMINIO EDITADO
function save_domain_edit(intUserId,domainname,fecha_alta,fecha_expira,domain_type,intdomainnameid,intcost,option_obs,serverid_obs,user_obs,pass_obs,obs_text,renovate_options){
	xmlHttpSaveDomainEdit=GetXmlHttpObject()
	//edit_product=document.getElementById('edit_product_'+intdomainnameid);
	if (xmlHttpSaveDomainEdit==null){alert ("Browser does not support HTTP Request");return;	} 	
	var url="edit_domain.php";
	//alert("intUserId: "+intUserId+" domainname:"+domainname+" fecha_alta: "+fecha_alta+" fecha_expira: "+fecha_expira+" domain_type: "+ domain_type+" intdomainnameid: "+ intdomainnameid+" option_obs="+option_obs+" serverid_obs="+serverid_obs+" user_obs="+user_obs+" pass_obs="+pass_obs+" text_obs="+obs_text+" renovate_options"+renovate_options);	

	xmlHttpSaveDomainEdit.open("POST",url,true)
	xmlHttpSaveDomainEdit.onreadystatechange=function(){
		if(xmlHttpSaveDomainEdit.readyState == 1 ) {
			//edit_product.innerHTML = "<div align=center valign=middle><img src='images/ajax-bank_loader_white.gif' border=0>&nbsp;<b>Guardando datos.</b></div>";								
			
		}else if(xmlHttpSaveDomainEdit.readyState == 4 ) {
			//alert (xmlHttpSaveDomainEdit.responseText);
			location.href = "datos.php?userid="+intUserId;
		}
	}
	xmlHttpSaveDomainEdit.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttpSaveDomainEdit.send("userid="+intUserId+"&domainname="+domainname+"&fecha_alta="+fecha_alta+"&fecha_expira="+fecha_expira+"&domain_type="+domain_type+"&domainnameid="+intdomainnameid+"&cost="+intcost+"&option_obs="+option_obs+"&serverid_obs="+serverid_obs+"&user_obs="+user_obs+"&pass_obs="+pass_obs+"&text_obs="+obs_text+"&renovate_options="+renovate_options);
}
//----------------ACTUALIZAR HOSTING EDITADO
//payment_period,option_obs,serverid_obs,user_obs,pass_obs,obs_text
function save_hosting_edit(intUserId,domainname,fecha_alta,fecha_expira,domain_type,intdomainnameid,intcost,domainsystemtype,product,payment_period,option_obs,serverid_obs,user_obs,pass_obs,obs_text,renovate_options){
	xmlHttpSaveHostingEdit=GetXmlHttpObject()
	//edit_product=document.getElementById('edit_product_'+intdomainnameid);
	if (xmlHttpSaveHostingEdit==null){alert ("Browser does not support HTTP Request");return;	} 	
	var url="edit_hosting.php";
	//alert("intUserId: "+intUserId+" domainname:"+domainname+" fecha_alta: "+fecha_alta+" fecha_expira: "+fecha_expira+" domain_type: "+domain_type+" intdomainnameid: "+ intdomainnameid+" intcost: "+intcost+" domainsystemtype: "+domainsystemtype+" product: "+ product+" payment_period: "+payment_period+" OptionObs:"+option_obs+" ServerO_ID: "+serverid_obs+" userO: "+user_obs+" passO: "+pass_obs+" TextO: "+obs_text+" renovate_options"+renovate_options);	

	xmlHttpSaveHostingEdit.open("POST",url,true)
	xmlHttpSaveHostingEdit.onreadystatechange=function(){
		if(xmlHttpSaveHostingEdit.readyState == 1 ) {
			//edit_product.innerHTML = "<div align=center valign=middle><img src='images/ajax-bank_loader_white.gif' border=0>&nbsp;<b>Guardando datos.</b></div>";								
			
		}else if(xmlHttpSaveHostingEdit.readyState == 4 ) {
			//alert (xmlHttpSaveDomainEdit.responseText);
			location.href = "datos.php?userid="+intUserId;
		}
	}
	xmlHttpSaveHostingEdit.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttpSaveHostingEdit.send("userid="+intUserId+"&domainname="+domainname+"&fecha_alta="+fecha_alta+"&fecha_expira="+fecha_expira+"&domain_type="+domain_type+"&domainnameid="+intdomainnameid+"&cost="+intcost+"&domainsystemtype="+domainsystemtype+"&product="+product+"&payment_period="+payment_period+"&option_obs="+option_obs+"&serverid_obs="+serverid_obs+"&user_obs="+user_obs+"&pass_obs="+pass_obs+"&text_obs="+obs_text+"&renovate_options="+renovate_options);
}
//--------------EDITAR DOMINIO
function edit_domain(userid,domainnameid,tr_color){
	xmlHttpEditDomain=GetXmlHttpObject()
	tr_color = tr_color.substring(1,7);
	edit_product=document.getElementById('edit_product_'+domainnameid);
	if (xmlHttpEditDomain==null){	alert ("Browser does not support HTTP Request");return;	} 
	var url="edit_domain.php?userid="+userid+"&domainnameid="+domainnameid+"&tr_color="+tr_color	
	//alert(url);
	xmlHttpEditDomain.open("GET",url,true)
	xmlHttpEditDomain.onreadystatechange=function(){
		if(xmlHttpEditDomain.readyState == 1 ) { 
			edit_product.innerHTML = "<div align=center valign=middle><img src='images/ajax-bank_loader_white.gif' border=0>&nbsp;<b>Cargando datos.</b></div>";	 
		}
		else if(xmlHttpEditDomain.readyState == 4 ) {			
			//alert (xmlHttpEditDomain.responseText);
			edit_product.innerHTML = xmlHttpEditDomain.responseText;  
		}
	} 	
	xmlHttpEditDomain.send(null); 	
}
//--------------EDITAR HOSTING
function edit_hosting(userid,domainnameid,tr_color){
	xmlHttpEditHosting=GetXmlHttpObject()
	tr_color = tr_color.substring(1,7);
	edit_product=document.getElementById('edit_product_'+domainnameid);
	if (xmlHttpEditHosting==null){	alert ("Browser does not support HTTP Request");return;	} 
	var url="edit_hosting.php?userid="+userid+"&domainnameid="+domainnameid+"&tr_color="+tr_color	
	//alert(url);
	xmlHttpEditHosting.open("GET",url,true)
	xmlHttpEditHosting.onreadystatechange=function(){
		if(xmlHttpEditHosting.readyState == 1 ) { 
			edit_product.innerHTML = "<div align=center valign=middle><img src='images/ajax-bank_loader_white.gif' border=0>&nbsp;<b>Cargando datos.</b></div>";	 
		}
		else if(xmlHttpEditHosting.readyState == 4 ) {			
			//alert (xmlHttpEditHosting.responseText);
			edit_product.innerHTML = xmlHttpEditHosting.responseText;  
		}
	} 	
	xmlHttpEditHosting.send(null); 	
}
//--------------GUARDAR HOSTING
function save_hosting(intUserId,domainname,domain_systemtype,product,payment_period,fecha_alta,fecha_expira,tarifa,domaintype){
	xmlHttpSaveHosting=GetXmlHttpObject()
	if (xmlHttpSaveHosting==null){alert ("Browser does not support HTTP Request");return;	} 	
	var url="add_hosting.php";
	//alert("domainname: "+domainname+" domain_systemtype:"+domain_systemtype+" product: "+ product+" payment_period: "+payment_period+" fecha_alta"+fecha_alta+" fecha_expira"+fecha_expira+" tarifa:"+ tarifa+" Domaintype: "+domaintype);	

	xmlHttpSaveHosting.open("POST",url,true)
	xmlHttpSaveHosting.onreadystatechange=function(){
		if(xmlHttpSaveHosting.readyState == 1 ) {
			products_div.innerHTML = "<div align=center valign=middle><img src='images/ajax-loader.gif' border=0>&nbsp;<b>Guardando datos.</b></div>";								
			
		}else if(xmlHttpSaveHosting.readyState == 4 ) {
			//alert (xmlHttpSaveHosting.responseText);
			location.href = "datos.php?userid="+intUserId;
		}
	}
	xmlHttpSaveHosting.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttpSaveHosting.send("userid="+intUserId+"&domainname="+domainname+"&domain_systemtype="+domain_systemtype+"&product="+product+"&payment_period="+payment_period+"&fecha_alta="+fecha_alta+"&fecha_expira="+fecha_expira+"&cost="+tarifa+"&domaintype="+domaintype);
}
//--------------EDITAR OTROS
function edit_others(userid,domainnameid,tr_color){
	xmlHttpEditOthers=GetXmlHttpObject()
	tr_color = tr_color.substring(1,7);
	edit_product=document.getElementById('edit_product_'+domainnameid);
	if (xmlHttpEditOthers==null){	alert ("Browser does not support HTTP Request");return;	} 
	var url="edit_others.php?userid="+userid+"&domainnameid="+domainnameid+"&tr_color="+tr_color	
	//alert(url);
	xmlHttpEditOthers.open("GET",url,true)
	xmlHttpEditOthers.onreadystatechange=function(){
		if(xmlHttpEditOthers.readyState == 1 ) { 
			edit_product.innerHTML = "<div align=center valign=middle><img src='images/ajax-bank_loader_white.gif' border=0>&nbsp;<b>Cargando datos.</b></div>";	 
		}
		else if(xmlHttpEditOthers.readyState == 4 ) {			
			//alert (xmlHttpEditDomain.responseText);
			edit_product.innerHTML = xmlHttpEditOthers.responseText;  
		}
	} 	
	xmlHttpEditOthers.send(null); 	
}
//--------------GUARDAR EDICION OTROS
function save_others_edit(intUserId,domainname,payment_period,fecha_alta,fecha_expira,cost,intdomainnameid,option_obs,serverid_obs,user_obs,pass_obs,obs_text,renovate_options){
	xmlHttpSaveOthersEdit=GetXmlHttpObject()
	//edit_product=document.all['edit_product_'+intdomainnameid];
	if (xmlHttpSaveOthersEdit==null){alert ("Browser does not support HTTP Request");return;	} 	
	var url="edit_others.php";
	//alert("intUserId: "+intUserId+" domainname:"+domainname+" payment_period: "+payment_period+" fecha_alta: "+fecha_alta+" fecha_expira: "+ fecha_expira+" cost: "+ cost+" option_obs "+option_obs+" serverid_obs "+serverid_obs+" user_obs "+user_obs+" pass_obs "+pass_obs+" text_obs "+obs_text+" renovate_options"+renovate_options);	

	xmlHttpSaveOthersEdit.open("POST",url,true)
	xmlHttpSaveOthersEdit.onreadystatechange=function(){
		if(xmlHttpSaveOthersEdit.readyState == 1 ) {
			//edit_product.innerHTML = "<div align=center valign=middle><img src='images/ajax-bank_loader_white.gif' border=0>&nbsp;<b>Guardando datos.</b></div>";								
			
		}else if(xmlHttpSaveOthersEdit.readyState == 4 ) {
			//alert (xmlHttpSaveDomainEdit.responseText);
			location.href = "datos.php?userid="+intUserId;
		}
	}
	xmlHttpSaveOthersEdit.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttpSaveOthersEdit.send("userid="+intUserId+"&domainname="+domainname+"&payment_period="+payment_period+"&fecha_alta="+fecha_alta+"&fecha_expira="+fecha_expira+"&cost="+cost+"&domainnameid="+intdomainnameid+"&option_obs="+option_obs+"&serverid_obs="+serverid_obs+"&user_obs="+user_obs+"&pass_obs="+pass_obs+"&text_obs="+obs_text+"&renovate_options="+renovate_options);
}
//--------------GUARDAR OTROS
function save_others(intUserId,domainname,payment_period,fecha_alta,fecha_expira,cost){
	xmlHttpSaveOthers=GetXmlHttpObject()
	if (xmlHttpSaveOthers==null){alert ("Browser does not support HTTP Request");return;	} 	
	var url="add_others.php";
	//alert("domainname: "+domainname+" payment_period:"+payment_period+" fecha_alta: "+ fecha_alta+"fecha_expira: "+fecha_expira+" cost:"+ cost);	

	xmlHttpSaveOthers.open("POST",url,true)
	xmlHttpSaveOthers.onreadystatechange=function(){
		if(xmlHttpSaveOthers.readyState == 1 ) {
			products_div.innerHTML = "<div align=center valign=middle><img src='images/ajax-loader.gif' border=0>&nbsp;<b>Guardando datos.</b></div>";								
			
		}else if(xmlHttpSaveOthers.readyState == 4 ) {
			//alert (xmlHttpSaveOthers.responseText);
			location.href = "datos.php?userid="+intUserId;
		}
	}
	xmlHttpSaveOthers.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttpSaveOthers.send("userid="+intUserId+"&domainname="+domainname+"&payment_period="+payment_period+"&fecha_alta="+fecha_alta+"&fecha_expira="+fecha_expira+"&cost="+cost);
}
//--------------GUARDAR SERVIDOR DEDICADO
function save_serverdedicated(intUserId,domainname,payment_period,fecha_alta,fecha_expira,cost){
	xmlHttpSaveSerDed=GetXmlHttpObject()
	if (xmlHttpSaveSerDed==null){alert ("Browser does not support HTTP Request");return;	} 	
	var url="add_serverdedicated.php";
	//alert("domainname: "+domainname+" payment_period:"+payment_period+" fecha_alta: "+ fecha_alta+"fecha_expira: "+fecha_expira+" cost:"+ cost);	

	xmlHttpSaveSerDed.open("POST",url,true)
	xmlHttpSaveSerDed.onreadystatechange=function(){
		if(xmlHttpSaveSerDed.readyState == 1 ) {
			products_div.innerHTML = "<div align=center valign=middle><img src='images/ajax-loader.gif' border=0>&nbsp;<b>Guardando datos.</b></div>";								
			
		}else if(xmlHttpSaveSerDed.readyState == 4 ) {
			//alert (xmlHttpSaveOthers.responseText);
			location.href = "datos.php?userid="+intUserId;
		}
	}
	xmlHttpSaveSerDed.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttpSaveSerDed.send("userid="+intUserId+"&domainname="+domainname+"&payment_period="+payment_period+"&fecha_alta="+fecha_alta+"&fecha_expira="+fecha_expira+"&cost="+cost);
}
//--------------GUARDAR EDICION SERVIDOR DEDICADO
function save_serverdedicated_edit(intUserId,domainname,payment_period,fecha_alta,fecha_expira,cost,intdomainnameid,option_obs,serverid_obs,user_obs,pass_obs,obs_text,renovate_options){
	xmlHttpSaveOthersEdit=GetXmlHttpObject()
	//edit_product=document.all['edit_product_'+intdomainnameid];
	if (xmlHttpSaveOthersEdit==null){alert ("Browser does not support HTTP Request");return;	} 	
	var url="edit_server_dedicated.php";
	//alert("intUserId: "+intUserId+" domainname:"+domainname+" payment_period: "+payment_period+" fecha_alta: "+fecha_alta+" fecha_expira: "+ fecha_expira+" cost: "+ cost+" option_obs "+option_obs+" serverid_obs "+serverid_obs+" user_obs "+user_obs+" pass_obs "+pass_obs+" text_obs "+obs_text+" renovate_options: "+renovate_options);	

	xmlHttpSaveOthersEdit.open("POST",url,true)
	xmlHttpSaveOthersEdit.onreadystatechange=function(){
		if(xmlHttpSaveOthersEdit.readyState == 1 ) {
		//	edit_product.innerHTML = "<div align=center valign=middle><img src='images/ajax-bank_loader_white.gif' border=0>&nbsp;<b>Guardando datos.</b></div>";								
			
		}else if(xmlHttpSaveOthersEdit.readyState == 4 ) {
			//alert (xmlHttpSaveDomainEdit.responseText);
			location.href = "datos.php?userid="+intUserId;
		}
	}
	xmlHttpSaveOthersEdit.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttpSaveOthersEdit.send("userid="+intUserId+"&domainname="+domainname+"&payment_period="+payment_period+"&fecha_alta="+fecha_alta+"&fecha_expira="+fecha_expira+"&cost="+cost+"&domainnameid="+intdomainnameid+"&option_obs="+option_obs+"&serverid_obs="+serverid_obs+"&user_obs="+user_obs+"&pass_obs="+pass_obs+"&text_obs="+obs_text+"&renovate_options="+renovate_options);
}
//--------------SELECCION DEL PRODUCTO
function prodcut_selector(intSelection,intUserId){
	xmlHttpSelector=GetXmlHttpObject()
	if (xmlHttpSelector==null){	alert ("Browser does not support HTTP Request");return;	}
	var opcion = intSelection;
	var url = "";
	var products_div = "";
	products_div = document.getElementById('products_div')	
	switch(opcion){
		case "1":	
			var url="add_domain.php?userid="+intUserId;
			break;
		case "2": 
			var url="add_hosting.php?userid="+intUserId;
			break;
		case "3": 
			var url="add_serverdedicated.php?userid="+intUserId;
			break;
		case "4": 
			var url="add_virtualserver.php?userid="+intUserId;
			break;
		case "5": 
			var url="add_others.php?userid="+intUserId;
			break;			
	}
	//alert(url);
	xmlHttpSelector.open("GET",url,true)
	xmlHttpSelector.onreadystatechange=function(){
		if(xmlHttpSelector.readyState == 1 ) { 
			products_div.innerHTML = "<div align=center valign=middle><img src='images/ajax-loader.gif' border=0>&nbsp;<b>Cargando datos.</b></div>";	 
		}
		else if(xmlHttpSelector.readyState == 4 ) {
			//alert (xmlHttpSelector.responseText);
			products_div.innerHTML = xmlHttpSelector.responseText;  
		}
	} 	
	xmlHttpSelector.send(null); 	
}
//---------------MOSTRAR PRODUCTOS
function show_products(userid){
	xmlHttpShowProducts=GetXmlHttpObject()
	if (xmlHttpShowProducts==null){	alert ("Browser does not support HTTP Request");return;	} 

	var url="show_products.php?userid="+userid;
	//alert(url);
	var products_show = "";
	products_show = document.getElementById('products_show')
	
	xmlHttpShowProducts.open("GET",url,true)
	xmlHttpShowProducts.onreadystatechange=function(){
		if(xmlHttpShowProducts.readyState == 1 ) { 
			products_show.innerHTML = "<div align=center valign=middle><img src='images/ajax-bank_loader_white.gif' border=0>&nbsp;<b>Cargando datos.</b></div>";	 
		}
		else if(xmlHttpShowProducts.readyState == 4 ) {			
			//alert (xmlHttpShowProducts.responseText);
			products_show.innerHTML = xmlHttpShowProducts.responseText;  
		}
	} 	
	xmlHttpShowProducts.send(null); 	
}
//---------------NOMBRE DEL BANCO
function get_bankname(intBankcode) {
	xmlHttpgetName=GetXmlHttpObject()
	if (xmlHttpgetName==null){	alert ("Browser does not support HTTP Request");return;	} 
	var url="bank_names.php?id_bank="+intBankcode
	var bank_name = "";
	bank_name = document.getElementById('bank_name')	
	
	xmlHttpgetName.open("GET",url,true)
	xmlHttpgetName.onreadystatechange=function(){
		if(xmlHttpgetName.readyState == 1 ) { 
			bank_name.innerHTML = "<div align=center valign=middle><img src='images/ajax-bank_loader.gif' border=0>&nbsp;<b>Cargando datos.</b></div>";	 
		}
		else if(xmlHttpgetName.readyState == 4 ) {
			//alert (xmlHttpgetName.responseText);
			bank_name.innerHTML = xmlHttpgetName.responseText;  
		}
	} 	
	xmlHttpgetName.send(null); 
}
//-------------VERIFICACION DOMINIO EXISTENTE
function verify_domain(intUserid,strDomainname,intDomaintype){
	xmlHttpverifyDOmain=GetXmlHttpObject()
	if (xmlHttpverifyDOmain==null){	alert ("Browser does not support HTTP Request");return;	} 
	var url="verify_domain.php?userid="+intUserid+"&domainname="+encodeURIComponent(strDomainname)+"&domaintype="+intDomaintype
	//alert(url);
	var domain_name = "";
	domain_name = document.getElementById('domain_name')	
	
	xmlHttpverifyDOmain.open("GET",url,true)
	xmlHttpverifyDOmain.onreadystatechange=function(){
		if(xmlHttpverifyDOmain.readyState == 1 ) { 
			domain_name.innerHTML = "<div align=center valign=middle><img src='images/ajax-bank_loader.gif' border=0>&nbsp;<b>Cargando datos.</b></div>";	 
		}
		else if(xmlHttpverifyDOmain.readyState == 4 ) {
//			alert (xmlHttpverifyDOmain.responseText);			
			domain_name.innerHTML = xmlHttpverifyDOmain.responseText;  
		}
	} 	
	xmlHttpverifyDOmain.send(null); 	
}
//--------------VERIFICACION DOMINIO CON ALERT
function edit_verify_domain(intUserid,strDomainname,intDomaintype,fecha_alta,fecha_expira,intdomainnameid,intcost,domainsystemtype,product,payment_period,option_obs,serverid_obs,user_obs,pass_obs,obs_text,renovate_options){
	xmlHttpverifyEditDomain=GetXmlHttpObject()
	
	//alert("intUserId: "+intUserid+" domainname:"+strDomainname+" fecha_alta: "+fecha_alta+" fecha_expira: "+fecha_expira+" domain_type: "+ intDomaintype+" intdomainnameid: "+ intdomainnameid+" intcost: "+ intcost+" domainsystemtype: "+ domainsystemtype+" product: "+ product+" Pay Period: "+payment_period+" Opt Obs: "+option_obs+" Serv Opts: "+serverid_obs+" user opts: "+user_obs+" Pass opts: "+pass_obs+" Obvs Txt: "+obs_text+" renovate_options: "+renovate_options);	
	if (xmlHttpverifyEditDomain==null){	alert ("Browser does not support HTTP Request");return;	}	
	//VERIFICACION FECHA
	//->Fecha expirtacion
		var arrFechaExpira = fecha_expira.split("/");
		var dia_expira = arrFechaExpira[0];
		var mes_expira = arrFechaExpira[1];
		var any_expira = arrFechaExpira[2];
		var suma_expira = eval(any_expira+mes_expira+dia_expira);
	
	//->Fecha alta
		var arrFechaAlta = fecha_alta.split("/");
		var dia_alta = arrFechaAlta[0];
		var mes_alta = arrFechaAlta[1];
		var any_alta = arrFechaAlta[2];
		var suma_alta =  eval(any_alta+mes_alta+dia_alta);	
		
		//alert('suma_alta'+suma_alta+'suma_expira'+suma_expira);
		
	if(suma_alta>=suma_expira&&suma_alta!=29022008&&suma_expira!=1032009){
		alert("La Fecha de vencimiento ha de ser mayor a la de alta");
	}
	else{
		var url="edit_verify_domain.php?userid="+intUserid+"&domainname="+strDomainname+"&domaintype="+intDomaintype+"&domainnameid="+intdomainnameid
		//alert(url);
		intResult=0;
		xmlHttpverifyEditDomain.open("GET",url,true)
		xmlHttpverifyEditDomain.onreadystatechange=function(){
			if(xmlHttpverifyEditDomain.readyState == 1 ) { 
			}
			else if(xmlHttpverifyEditDomain.readyState == 4 ) {
				intResult = xmlHttpverifyEditDomain.responseText;
				//alert (xmlHttpverifyEditDomain.responseText);	
				if (intResult == 1){
					alert('El dominio que has introducido ya existe');
				}
				else{
					if(domainsystemtype==1&&product==1&&payment_period==1){
						save_domain_edit(intUserid,strDomainname,fecha_alta,fecha_expira,intDomaintype,intdomainnameid,intcost,option_obs,serverid_obs,user_obs,pass_obs,obs_text,renovate_options);
					}
					else{
						//serverid_obs,user_obs,pass_obs,obs_text
						save_hosting_edit(intUserid,strDomainname,fecha_alta,fecha_expira,intDomaintype,intdomainnameid,intcost,domainsystemtype,product,payment_period,option_obs,serverid_obs,user_obs,pass_obs,obs_text,renovate_options);
					}
				}
			}
		} 	
		xmlHttpverifyEditDomain.send(null);
	}
}

//--------------Paginacion 
//---->Enviar mediante post los datos de pagina y columna
function paginacion(col,order,registros,pagina){
	//alert("col: "+ col +" "+ "order: " + order+" registros: "+ registros +" pagina: "+ pagina);
	xmlHttpListado=null;
	xmlHttpListado=GetXmlHttpObject()

	if (xmlHttpListado==null){	alert ("Browser does not support HTTP Request");return;	} 
	
	var url="paginacion.php";
	var carga = "";
	carga = document.getElementById('carga')

	xmlHttpListado.open("POST",url,true)
	xmlHttpListado.onreadystatechange=function(){
		if(xmlHttpListado.readyState == 1 ) { 
			carga.innerHTML = "<div align=center valign=middle><img src='images/ajax-bank_loader_white.gif' border=0>&nbsp;<b>Guardando datos...</b></div>";
		}
		else if(xmlHttpListado.readyState == 4 ) {
			//alert(xmlHttpListado.responseText);
			carga.innerHTML = xmlHttpListado.responseText; 
		}
	}
	xmlHttpListado.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttpListado.send("col="+col+"&order="+order+"&num_pages="+registros+"&pagina="+pagina);
}
//------------- BUSQUEDA ------

function test_search(str_numPages){
	
	var nombre = document.getElementById('search_name').value;
	var empresa = document.getElementById('search_empresa').value;
	var domain = document.getElementById('search_domain').value;
	var email = document.getElementById('search_email').value;
	
	//alert("Numero paginas: "+ str_numPages+" Nombre: "+nombre+" Empresa: "+empresa+" Domain:"+domain+" Email: "+email);
	
	xmlHttpTest=null;
	xmlHttpTest=GetXmlHttpObject()

	if (xmlHttpTest==null){	alert ("Browser does not support HTTP Request");return;	} 
	
	var url="paginacion.php";

	var carga = "";
	carga = document.getElementById('carga')	

	xmlHttpTest.open("POST",url,true)
	xmlHttpTest.onreadystatechange=function(){
		if(xmlHttpTest.readyState == 1 ) { 
			carga.innerHTML = "<div align=center valign=middle><img src='images/ajax-bank_loader_white.gif' border=0>&nbsp;<b>Guardando datos...</b></div>";
		}
		else if(xmlHttpTest.readyState == 4 ) {
			//alert(xmlHttpTest.responseText);
			carga.innerHTML = xmlHttpTest.responseText; 
		}
	}
	xmlHttpTest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttpTest.send("search_name="+nombre+"&search_company="+empresa+"&search_domain="+domain+"&search_email="+email+"&num_pags="+str_numPages);
}
//--------------ENVIO DEL FORMULARIO AL DARLE AL ENTER------
function submitonEnter(evt){
	var charCode = (evt.which) ? evt.which : event.keyCode
	if(charCode == "13"){
		test_search(document.getElementById('num_pages').value);
	}
}	
//----------------------------------------------------------
//--------------RESETEAR CAMPOS DE BUSQUEDA------
function resetSearchField(intFieldNumber){
	switch(intFieldNumber){
		case 1:	
			document.getElementById('search_empresa').value ='Empresa';
			document.getElementById('search_domain').value='Dominio';
			document.getElementById('search_email').value='Email';
			break;
		case 2: 
			document.getElementById('search_name').value='Nombre';
			document.getElementById('search_domain').value='Dominio';
			document.getElementById('search_email').value='Email';
			break;
		case 3: 
			document.getElementById('search_name').value='Nombre';
			document.getElementById('search_empresa').value='Empresa';
			document.getElementById('search_email').value='Email';
			break;
		case 4: 
			document.getElementById('search_name').value='Nombre';
			document.getElementById('search_empresa').value='Empresa';
			document.getElementById('search_domain').value='Dominio';
			break;
	}
}

//--------------- INCIDENCIAS -------------
function incidence_list(col,order,registros,pagina){
	//alert("col: "+ col +" "+ "order: " + order+" registros: "+ registros +" pagina: "+ pagina);
	xmlHttpIncidenceLst=null;
	xmlHttpIncidenceLst=GetXmlHttpObject()

	if (xmlHttpIncidenceLst==null){	alert ("Browser does not support HTTP Request");return;	} 
	
	var url="incidence_list.php";
	var incidences = "";
	incidences = document.getElementById('incidences')	

	xmlHttpIncidenceLst.open("POST",url,true)
	xmlHttpIncidenceLst.onreadystatechange=function(){
		if(xmlHttpIncidenceLst.readyState == 1 ) { 
			incidences.innerHTML = "<div align=center valign=middle><img src='images/ajax-bank_loader_white.gif' border=0>&nbsp;<b>Guardando datos...</b></div>";
		}
		else if(xmlHttpIncidenceLst.readyState == 4 ) {
			//alert(xmlHttpListado.responseText);
			incidences.innerHTML = xmlHttpIncidenceLst.responseText; 
		}
	}
	xmlHttpIncidenceLst.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttpIncidenceLst.send("col="+col+"&order="+order+"&num_pags="+registros+"&pagina="+pagina);
}

//--------------GUARDAR OBSERVACION DEL PRODUCTO
function save_product_observation(domainnameid,serverid,user,password,observation,intUserId){
	xmlHttpSaveProdObs=GetXmlHttpObject()
	if (xmlHttpSaveProdObs==null){alert ("Browser does not support HTTP Request");return;	} 	
	var url="save_prod_observation.php";
	//alert("Save: -> domainnameid: "+domainnameid+" serverid:"+serverid+" user: "+ user+" password: "+password+" observation: "+observation+" intUserId: "+intUserId);	

	xmlHttpSaveProdObs.open("POST",url,true)
	xmlHttpSaveProdObs.onreadystatechange=function(){
		if(xmlHttpSaveProdObs.readyState == 1 ) {
			//products_div.innerHTML = "<div align=center valign=middle><img src='images/ajax-loader.gif' border=0>&nbsp;<b>Guardando datos.</b></div>";								
			
		}else if(xmlHttpSaveProdObs.readyState == 4 ) {
			//alert (xmlHttpSaveProdObs.responseText);
			location.href = "datos.php?userid="+intUserId;
		}
	}
	xmlHttpSaveProdObs.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttpSaveProdObs.send("domainnameid="+domainnameid+"&serverid="+serverid+"&user="+user+"&password="+password+"&observation="+observation);
}

//--------------ACTUALIZAR OBSERVACION DEL PRODUCTO
function update_product_observation(domainnameid,serverid,user,password,observation,intUserId){
	
	xmlHttpUpdateProdObs=GetXmlHttpObject()
	if (xmlHttpUpdateProdObs==null){	alert ("Browser does not support HTTP Request");return;	} 
	var url="save_prod_observation.php?domainnameid="+domainnameid+"&serverid="+serverid+"&user="+user+"&password="+password+"&observation="+observation
	//alert("Update: -> domainnameid: "+domainnameid+" serverid:"+serverid+" user: "+ user+" password: "+password+" observation: "+observation+" intUserId: "+intUserId);
	
	xmlHttpUpdateProdObs.open("GET",url,true)
	xmlHttpUpdateProdObs.onreadystatechange=function(){
		if(xmlHttpUpdateProdObs.readyState == 1 ) { 
			//products_div.innerHTML = "<div align=center valign=middle><img src='images/ajax-bank_loader.gif' border=0>&nbsp;<b>Cargando datos.</b></div>";	 
		}
		else if(xmlHttpUpdateProdObs.readyState == 4 ) {
			//alert (xmlHttpUpdateProdObs.responseText);			
			location.href = "datos.php?userid="+intUserId; 
		}
	} 	
	xmlHttpUpdateProdObs.send(null); 	
}

function check_list(opcion) {
	var price;
	switch(opcion){
		case 1:		
			if(document.getElementById('domain_systemtype').value == ''){
				document.getElementById('product').selectedIndex = 0
				alert('Selecciona un Sistema Operativo'); 
				return;		
			}
			break;
		case 2:
			if((document.getElementById('domain_systemtype').value == '')&&(document.getElementById('product').value == '')){
				document.getElementById('cmb_payment_period').selectedIndex = 0
				alert('Selecciona un Sistema operativo y un Plan'); 
				return;		
			}
			else{
				var domain_systemtypeid = document.getElementById('domain_systemtype').value
				var productid = document.getElementById('product').value
				var payment_periodid = document.getElementById('cmb_payment_period').value
				
				//alert('Sistema: '+domain_systemtypeid+' Producto: '+productid+' Periodo: '+payment_periodid);
				xmlHttpSelectPrice=GetXmlHttpObject()
				if (xmlHttpSelectPrice==null){	alert ("Browser does not support HTTP Request");return;	} 
				var url="get_price.php?domain_systemtypeid="+domain_systemtypeid+"&productid="+productid+"&payment_periodid="+payment_periodid
				//alert(url)
				//alert("Update: -> domainnameid: "+domainnameid+" serverid:"+serverid+" user: "+ user+" password: "+password+" observation: "+observation+" intUserId: "+intUserId);
				
				xmlHttpSelectPrice.open("GET",url,true)
				xmlHttpSelectPrice.onreadystatechange=function(){
					if(xmlHttpSelectPrice.readyState == 1 ) { 
					}
					else if(xmlHttpSelectPrice.readyState == 4 ) {
						//alert(xmlHttpSelectPrice.responseText);
						price = xmlHttpSelectPrice.responseText;
						document.getElementById('cost').value = price;
					}
				} 	
				xmlHttpSelectPrice.send(null);				
			}
		break;
	}
}

function charge_cmbPeriod(intValue,optionid,past_data){
	xmlHttpchargeCombo=GetXmlHttpObject()
	if (xmlHttpchargeCombo==null){	alert ("Browser does not support HTTP Request");return;	} 
	var url="charge_periodicidad.php?value="+intValue+"&option="+optionid+"&past_data="+past_data
	var periodicidad = "";
	periodicidad = document.getElementById('periodicidad_div')
	//alert(url);
	
	xmlHttpchargeCombo.open("GET",url,true)
	xmlHttpchargeCombo.onreadystatechange=function(){
		if(xmlHttpchargeCombo.readyState == 1 ) { 
			periodicidad.innerHTML = "<div align=center valign=middle><img src='images/ajax-bank_loader.gif' border=0>&nbsp;<b>Cargando.</b></div>";	 
		}
		else if(xmlHttpchargeCombo.readyState == 4 ) {
			//alert (xmlHttpchargeCombo.responseText);			
			periodicidad.innerHTML = xmlHttpchargeCombo.responseText; 
		}
	} 	
	xmlHttpchargeCombo.send(null); 	
}

function get_NewRenovationDate(date){
	xmlHttpGetDate=GetXmlHttpObject()
	if (xmlHttpGetDate==null){	alert ("Browser does not support HTTP Request");return;	} 
	
	var new_date = "";
	var payment_periodid = "";
	payment_periodid = document.getElementById('cmb_payment_period').value
	var url="get_renewal_day.php?fecha="+date+"&payment_periodid="+payment_periodid
	//alert(url);
	
	xmlHttpGetDate.open("GET",url,true)
	xmlHttpGetDate.onreadystatechange=function(){
		if(xmlHttpGetDate.readyState == 1 ) {}
		else if(xmlHttpGetDate.readyState == 4 ) {
			//alert (xmlHttpGetDate.responseText);			
			new_date = xmlHttpGetDate.responseText;
			document.getElementById('new_date').value = new_date;
		}
	} 	
	xmlHttpGetDate.send(null);
}

function save_product_renovation(domainnameid,intUserId,payment_periodid){
	xmlHttpSaveProductRenew=GetXmlHttpObject()
	if (xmlHttpSaveProductRenew==null){alert ("Browser does not support HTTP Request");return;	}
	var opcion = "";
	if(document.getElementById('rdbRenovar').checked == true){
		opcion = 1;
	}
	else{
		opcion = 2;
	}
	var url="product_options.php";
	//alert("Save: -> domainnameid: "+domainnameid+" serverid:"+serverid+" user: "+ user+" password: "+password+" observation: "+observation+" intUserId: "+intUserId);	

	xmlHttpSaveProductRenew.open("POST",url,true)
	xmlHttpSaveProductRenew.onreadystatechange=function(){
		if(xmlHttpSaveProductRenew.readyState == 1 ) {
			products_div.innerHTML = "<div align=center valign=middle><img src='images/ajax-loader.gif' border=0>&nbsp;<b>Guardando datos.</b></div>";								
			
		}else if(xmlHttpSaveProductRenew.readyState == 4 ) {
			//alert (xmlHttpSaveProductRenew.responseText);
			location.href = "datos.php?userid="+intUserId;
		}
	}
	xmlHttpSaveProductRenew.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttpSaveProductRenew.send("domainnameid="+domainnameid+"&payment_periodid="+payment_periodid+"&opcion="+opcion);
}

function product_action(userid,domainnameid,productid){
	xmlHttpProductAction=GetXmlHttpObject()
	if (xmlHttpProductAction==null){	alert ("Browser does not support HTTP Request");return;	} 

	var edit_product = "";
	edit_product = document.getElementById('edit_product_div')	
	var url="product_action.php?userid="+userid+"&domainnameid="+domainnameid
	//alert(url);
	
	xmlHttpProductAction.open("GET",url,true)
	xmlHttpProductAction.onreadystatechange=function(){
		if(xmlHttpProductAction.readyState == 1 ) {
			edit_product.innerHTML = "<div align=center valign=middle><img src='images/ajax-bank_loader_white.gif' border=0>&nbsp;<b>Cargando...</b></div>";
		}
		else if(xmlHttpProductAction.readyState == 4 ) {
			//alert (xmlHttpProductAction.responseText);			
			edit_product.innerHTML = xmlHttpProductAction.responseText; 		
		}
	} 	
	xmlHttpProductAction.send(null);
}

function product_selection(intSelection,intUserId,domainnameid,productid){
	xmlHttpProduct_Selection=GetXmlHttpObject()
	if (xmlHttpProduct_Selection==null){	alert ("Browser does not support HTTP Request");return;	}
	var opcion = intSelection;
	var url = "";
	//alert(domainnameid)
	var products_div = "";
	products_div = document.getElementById('edit_product_div')	
	switch(opcion){
		case "1":	
			var url="edit_product.php?userid="+intUserId+"&domainnameid="+domainnameid;
			break;
		case "2": 
			var url="product_observation.php?userid="+intUserId+"&domainnameid="+domainnameid+"&product_id="+productid;
			break;
		case "3": 
			var url="product_options.php?userid="+intUserId+"&domainnameid="+domainnameid;
			break;			
	}
	//alert(url);
	xmlHttpProduct_Selection.open("GET",url,true)
	xmlHttpProduct_Selection.onreadystatechange=function(){
		if(xmlHttpProduct_Selection.readyState == 1 ) { 
			products_div.innerHTML = "<div align=center valign=middle><img src='images/ajax-loader.gif' border=0>&nbsp;<b>Cargando datos.</b></div>";	 
		}
		else if(xmlHttpProduct_Selection.readyState == 4 ) {
			//alert (xmlHttpProduct_Selection.responseText);
			products_div.innerHTML = xmlHttpProduct_Selection.responseText;  
		}
	} 	
	xmlHttpProduct_Selection.send(null); 	
}

function edit_product(userid,domainnameid){
	xmlHttpEditProduct=GetXmlHttpObject()
	if (xmlHttpEditProduct==null){	alert ("Browser does not support HTTP Request");return;	} 

	var edit_product = "";
	edit_product = document.getElementById('edit_product_div')	
	var url="product_edit.php?userid="+userid+"&domainnameid="+domainnameid
	//alert(url);
	
	xmlHttpEditProduct.open("GET",url,true)
	xmlHttpEditProduct.onreadystatechange=function(){
		if(xmlHttpEditProduct.readyState == 1 ) {
			edit_product.innerHTML = "<div align=center valign=middle><img src='images/ajax-bank_loader_white.gif' border=0>&nbsp;<b>Cargando...</b></div>";
		}
		else if(xmlHttpEditProduct.readyState == 4 ) {
			//alert (xmlHttpEditProduct.responseText);			
			edit_product.innerHTML = xmlHttpEditProduct.responseText; 		
		}
	} 	
	xmlHttpEditProduct.send(null);
}

function product_renovate(intSelection,intUserId,domainnameid,payment_periodid){
	xmlHttpProductRenovate=GetXmlHttpObject()
	if (xmlHttpProductRenovate==null){	alert ("Browser does not support HTTP Request");return;	}
	
	var div_renovation_date = "";
	
	div_renovation_date = document.getElementById('div_renovation_date')
		var new_renew_date = "";		
		var url="renovation_date.php?userid="+intUserId+"&domainnameid="+domainnameid+"&payment_periodid="+payment_periodid+"&intRenew="+intSelection;
		//alert(url);
		
		xmlHttpProductRenovate.open("GET",url,true)
		xmlHttpProductRenovate.onreadystatechange=function(){
			if(xmlHttpProductRenovate.readyState == 1 ) {
				//div_renovation_date.innerHTML = "<div align=center valign=middle><img src='images/ajax-bank_loader_white.gif' border=0>&nbsp;<b>Cargando...</b></div>";
			}
			else if(xmlHttpProductRenovate.readyState == 4 ) {
				//alert (xmlHttpProductRenovate.responseText);			
				new_renew_date = xmlHttpProductRenovate.responseText;
				if(intSelection==1){
					document.getElementById('div_state').innerHTML = "Activo"; 	
					document.getElementById('fecha_renovacion').value = new_renew_date;	
					document.getElementById('product_stateid').value = 1;		
				}
				else{
					document.getElementById('fecha_renovacion').value = new_renew_date;	
					document.getElementById('div_state').innerHTML = "No renovado"; 		
					document.getElementById('product_stateid').value = 4;		
				}
			}
		} 	
	

	xmlHttpProductRenovate.send(null);
}

//--------------FUNCIONES AJAX----------
function stateChanged(){ 	 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
	} 
} 
function GetXmlHttpObject(){ 
var satelite=false; 
/* Compatibilidad con FireFox, Opera y cualquier otro BUEN navegador */
  if(typeof(XMLHttpRequest) != 'undefined'){
    try{
      var satelite = new XMLHttpRequest();
    }
    catch(e){ }
  }
  else{
    /* Compatibilidad para el navegador más ASQUEROSO del planeta [ IE ] */
    try{
      var satelite = new ActiveXObject('Microsoft.XMLHTTP');
    }
    catch(e){
      var satelite = new ActiveXObject('Msxml2.XMLHTTP');
    }
  }
  return satelite;
}





function duplicateContactData(){
	var a=confirm('¿Desea utilizar los mismos datos de Facturaci\u00F3n para Contacto?');
	if (a){
			
			if (document.getElementById('i_countryid').selectedIndex==52){
				showProvinceCombo('c_provinceid','c_layer_province',document.getElementById('i_provinceid').selectedIndex);	
			}
			else{
				showProvinceText('c_provinceid','c_layer_province',document.getElementById('i_provinceid').value);
			}	
			document.getElementById('c_firstname').value=document.getElementById('i_firstname').value;
			document.getElementById('c_lastname').value=document.getElementById('i_lastname').value;
			document.getElementById('c_email').value=document.getElementById('i_email').value;
			document.getElementById('c_email1').value=document.getElementById('i_email1').value;
			document.getElementById('c_phone').value=document.getElementById('i_phone').value;
			document.getElementById('c_phone1').value=document.getElementById('i_phone1').value;
			document.getElementById('c_phone2').value=document.getElementById('i_phone2').value;
			document.getElementById('c_fax').value=document.getElementById('i_fax').value;
			document.getElementById('c_address').value=document.getElementById('i_address').value;
			document.getElementById('c_cp').value=document.getElementById('i_cp').value;
			document.getElementById('c_city').value=document.getElementById('i_city').value;
			document.getElementById('c_countryid').selectedIndex=document.getElementById('i_countryid').selectedIndex;
			
			document.getElementById('c_tratamientoId').value=document.getElementById('i_tratamientoId').value;
			
			//Disabled de los Campos
			document.getElementById('c_firstname').readOnly = true;
			document.getElementById('c_lastname').readOnly = true;
			document.getElementById('c_email').readOnly = true;
			document.getElementById('c_email1').readOnly = true;
			document.getElementById('c_firstname').readOnly = true;
			document.getElementById('c_phone').readOnly = true;
			document.getElementById('c_phone1').readOnly = true;
			document.getElementById('c_phone2').readOnly = true;
			document.getElementById('c_fax').readOnly = true;
			document.getElementById('c_address').readOnly = true;
			document.getElementById('c_cp').readOnly = true;
			document.getElementById('c_city').readOnly = true;
			
			document.getElementById('c_firstname').style.backgroundColor='#F3F3F3';
			document.getElementById('c_lastname').style.backgroundColor='#F3F3F3';
			document.getElementById('c_email').style.backgroundColor='#F3F3F3';
			document.getElementById('c_email1').style.backgroundColor='#F3F3F3';
			document.getElementById('c_firstname').style.backgroundColor='#F3F3F3';
			document.getElementById('c_phone').style.backgroundColor='#F3F3F3';
			document.getElementById('c_phone1').style.backgroundColor='#F3F3F3';
			document.getElementById('c_phone2').style.backgroundColor='#F3F3F3';
			document.getElementById('c_fax').style.backgroundColor='#F3F3F3';
			document.getElementById('c_address').style.backgroundColor='#F3F3F3';
			document.getElementById('c_cp').style.backgroundColor='#F3F3F3';
			document.getElementById('c_city').style.backgroundColor='#F3F3F3';
			
			//document.getElementById('c_provinceid').disabled = true;
			//document.getElementById('c_countryid').disabled = true;
			//document.getElementById('c_tratamientoId').readOnly = true;
	}
}

function validateClientsEditForm(intEdit){

		if(intEdit==0){
			if(document.getElementById('pass1').value==''){
				alert("Tiene que introducir un password");
				document.getElementById('pass1').focus();
				return false;
			}
			else if(document.getElementById('pass1').value != document.getElementById('pass2').value){
				alert("El password y su confirmación deben ser iguales");
				document.getElementById('pass2').focus();
				return false;
			}
		}
		else{
				if(document.getElementById('pass1').value!='' && (document.getElementById('pass1').value != document.getElementById('pass2').value)){
					alert("El password y su confirmación deben ser iguales");
					document.getElementById('pass2').focus();
					return false;
				}
		}
		
		
		
		if(document.getElementById('c_tratamientoId').value==0){
			alert("Tiene que introducir un Titulo");
			document.getElementById('c_tratamientoId').focus();
			return false;
		}
		else if(document.getElementById('c_firstname').value==''){
			alert("Tiene que introducir un nombre");
			document.getElementById('c_firstname').focus();
			return false;
		}
		else if(document.getElementById('c_lastname').value==''){
			alert("Tiene que introducir el apellido");
			document.getElementById('c_lastname').focus();
			return false;
		}
		else if(document.getElementById('c_email').value==''){
			alert("Tiene que introducir un correo electronico");
			document.getElementById('c_email').focus();
			return false;
		}
		else if(!validarEmail(document.getElementById('c_email').value)){
			alert("El formato del correo electrónico es incorrecto");
			document.getElementById('c_email').focus();
			return false;
		}
		else if(document.getElementById('c_email1').value!='' && !validarEmail(document.getElementById('c_email1').value)){
			alert("El formato del correo electrónico es incorrecto");
			document.getElementById('c_email1').focus();
			return false;
		}
		else if(document.getElementById('c_phone').value==''){
			alert("Tiene que introducir un telefono de contacto");
			document.getElementById('c_phone').focus();
			return false;
		}
		//Edit Juanan: Validar Telefono
		else if(validarTel(document.getElementById('c_phone').value)==false){
			alert("Tiene que introducir un numero de telefono valido");
			document.getElementById('c_phone').focus();
			return false;
		}
		//End Edit Juanan: Validar Telefono
		else if(document.getElementById('c_address').value==''){
			alert("Tiene que introducir un domicilio de contacto");
			document.getElementById('c_address').focus();
			return false;
		}
		else if(document.getElementById('c_cp').value==''){
			alert("Tiene que introducir el C\u00F3digo postal");
			document.getElementById('c_cp').focus();
			return false;
		}
		//Edit Juanan: Validar CP
		else if(validarCP(document.getElementById('c_cp').value)==false){
			alert("Tiene que introducir un C\u00F3digo postal valido");
			document.getElementById('c_cp').focus();
			return false;
		}
		//End Edit Juanan: Validar CP
		else if(document.getElementById('c_city').value==''){
			alert("Tiene que introducir la localidad");
			document.getElementById('c_city').focus();
			return false;
		}
		else if(document.getElementById('c_countryid').value==0){
			alert("Tiene que seleccionar el pa\u00EDs");
			document.getElementById('c_countryid').focus();
			return false;
		}
		else if(document.getElementById('c_countryid').value==52){
				if(document.getElementById('c_provinceid').value==0){
				alert("Tiene que seleccionar la provincia");
				document.getElementById('c_provinceid').focus();
				return false;
			}
		}
		else if(document.getElementById('c_countryid').value!=52){
				if(document.getElementById('c_provinceid').value==''){
				alert("Tiene que seleccionar la provincia");
				document.getElementById('c_provinceid').focus();
				return false;
			}
		}
		

		if(document.getElementById('is_company').value==1){
				if(document.getElementById('i_companyname').value==''){
					alert("Tiene que introducir el nombre de la empresa");
					document.getElementById('i_companyname').focus();
					return false;
				}
				else if(document.getElementById('i_nif').value==''){
					alert("Tiene que introducir el CIF");
					document.getElementById('i_nif').focus();
					return false;
				}
				else if(!validateIdentityDoc(document.getElementById('i_document_typeid').value,document.getElementById('i_nif').value)){
					document.getElementById('i_nif').focus();
					return false;
				}
				else if(document.getElementById('i_address').value==''){
					alert("Tiene que introducir un domicilio de contacto");
					document.getElementById('i_address').focus();
					return false;
				}
				else if(document.getElementById('i_cp').value==''){
					alert("Tiene que introducir el C\u00F3digo postal");
					document.getElementById('i_cp').focus();
					return false;
				}
				//Edit Juanan: Validar CP
				else if(validarCP(document.getElementById('i_cp').value)==false){
					alert("Tiene que introducir un C\u00F3digo postal valido");
					document.getElementById('i_cp').focus();
					return false;
				}
				//End Edit Juanan: Validar CP
				else if(document.getElementById('i_email').value==''){
					alert("Tiene que introducir un correo electronico");
					document.getElementById('i_email').focus();
					return false;
				}
				else if(!validarEmail(document.getElementById('i_email').value)){
					alert("El formato del correo electrónico es incorrecto");
					document.getElementById('i_email').focus();
					return false;
				}
				else if(document.getElementById('i_city').value==''){
					alert("Tiene que introducir la localidad");
					document.getElementById('i_city').focus();
					return false;
				}
				else if(document.getElementById('i_countryid').value==0){
					alert("Tiene que seleccionar el pa\u00EDs");
					document.getElementById('i_countryid').focus();
					return false;
				}
				else if(document.getElementById('i_countryid').value==52 && document.getElementById('i_provinceid').value==0){
					alert("Tiene que seleccionar la provincia");
					document.getElementById('i_provinceid').focus();
					return false;
				}
				else if(document.getElementById('i_countryid').value!=52 && document.getElementById('i_provinceid').value==''){
					alert("Tiene que seleccionar la provincia");
					document.getElementById('i_provinceid').focus();
					return false;
				}
				else if(document.getElementById('paymentformid').value==0){
					alert("Tiene que seleccionar una Forma de Pago");
					document.getElementById('paymentformid').focus();
					return false;
				}
				else if(document.getElementById('ivaTypeId').value==0){
					alert("Tiene que seleccionar una Tipo de IVA");
					document.getElementById('ivaTypeId').focus();
					return false;
				}
				else if(document.getElementById('paymentformid').value==1 && (document.getElementById('i_codigo_entidad').value=='' || document.getElementById('i_codigo_entidad').value==0)){
					alert("Tiene que introducir el c\u00F3digo de la entidad bancaria");
					document.getElementById('i_codigo_entidad').focus();
					return false;
				}
				else if(document.getElementById('paymentformid').value==1 && document.getElementById('i_codigo_oficina').value==''){
					alert("Tiene que introducir el c\u00F3digo de la oficina");
					document.getElementById('i_codigo_oficina').focus();
					return false;
				}
				//Edit Juanan: Validar Cod. Oficina
				else if(document.getElementById('paymentformid').value==1 && validarCod_Oficina(document.getElementById('i_codigo_oficina').value)==false){
					alert("Tiene que introducir un C\u00F3digo de oficina valido");
					document.getElementById('i_codigo_oficina').focus();
					return false;
				}
				//End Edit Juanan: Validar Cod. Oficina
				else if(document.getElementById('paymentformid').value==1 && document.getElementById('i_digitos_control').value==''){
					alert("Tiene que introducir los d\u00EDgitos de control");
					document.getElementById('i_digitos_control').focus();
					return false;
				}
				//Edit Juanan: Validar Dig. Control
				else if(document.getElementById('paymentformid').value==1 && validarDigit_Control(document.getElementById('i_digitos_control').value)==false){
					alert("Tiene que introducir unos digitos de control validos");
					document.getElementById('i_digitos_control').focus();
					return false;
				}
				//End Edit Juanan: Validar Dig. Control
				else if(document.getElementById('paymentformid').value==1 && document.getElementById('i_numero_cuenta').value==''){
					alert("Tiene que introducir el n\u00FAmero de cuenta");
					document.getElementById('i_numero_cuenta').focus();
					return false;
				}
				//Edit Juanan: Validar Num. Cuenta
				else if(document.getElementById('paymentformid').value==1 && validarNum_Cuenta(document.getElementById('i_numero_cuenta').value)==false){
					alert("Tiene que introducir un numero de cuenta valido");
					document.getElementById('i_numero_cuenta').focus();
					return false;
				}
				//End Edit Juanan: Validar Num. Cuenta
		}
		else
				{
				if(document.getElementById('i_tratamientoId').value==0){
					alert("Tiene que introducir un Titulo");
					document.getElementById('i_tratamientoId').focus();
					return false;
				}
				else if(document.getElementById('i_firstname').value==''){
					alert("Tiene que introducir un nombre");
					document.getElementById('i_firstname').focus();
					return false;
				}
				else if(document.getElementById('i_lastname').value==''){
					alert("Tiene que introducir el apellido");
					document.getElementById('i_lastname').focus();
					return false;
				}
				else if(document.getElementById('i_nif').value==''){
					alert("Tiene que introducir el DNI / NIE / Pasaporte");
					document.getElementById('i_nif').focus();
					return false;
				}
				else if(!validateIdentityDoc(document.getElementById('i_document_typeid').value,document.getElementById('i_nif').value)){
					document.getElementById('i_nif').focus();
					return false;
				}
				else if(document.getElementById('i_email').value==''){
					alert("Tiene que introducir un correo electronico");
					document.getElementById('i_email').focus();
					return false;
				}
				else if(!validarEmail(document.getElementById('i_email').value)){
					alert("El formato del correo electrónico es incorrecto");
					document.getElementById('i_email').focus();
					return false;
				}
				else if(document.getElementById('i_email1').value!='' && !validarEmail(document.getElementById('i_email1').value)){
					alert("El formato del correo electrónico es incorrecto");
					document.getElementById('i_email1').focus();
					return false;
				}
				else if(document.getElementById('i_phone').value==''){
					alert("Tiene que introducir un telefono de contacto");
					document.getElementById('i_phone').focus();
					return false;
				}
				//Edit Juanan: Validar Telefono
				else if(validarTel(document.getElementById('i_phone').value)==false){
					alert("Tiene que introducir un numero de telefono valido");
					document.getElementById('i_phone').focus();
					return false;
				}
				//End Edit Juanan: Validar Telefono
				else if(document.getElementById('i_address').value==''){
					alert("Tiene que introducir un domicilio de contacto");
					document.getElementById('i_address').focus();
					return false;
				}
				else if(document.getElementById('i_cp').value==''){
					alert("Tiene que introducir el C\u00F3digo postal");
					document.getElementById('i_cp').focus();
					return false;
				}
				//Edit Juanan: Validar Telefono
				else if(validarCP(document.getElementById('i_cp').value)==false){
					alert("Tiene que introducir un Codigo Postal valido");
					document.getElementById('i_cp').focus();
					return false;
				}
				//End Edit Juanan: Validar Telefono
				else if(document.getElementById('i_city').value==''){
					alert("Tiene que introducir la localidad");
					document.getElementById('i_city').focus();
					return false;
				}
				else if(document.getElementById('i_countryid').value==52 && document.getElementById('i_provinceid').value==0){
						alert("Tiene que seleccionar la provincia");
						document.getElementById('i_provinceid').focus();
						return false;
				}
				else if(document.getElementById('i_countryid').value!=52 && document.getElementById('i_provinceid').value==''){
					alert("Tiene que seleccionar la provincia");
					document.getElementById('i_provinceid').focus();
					return false;
				}
				else if(document.getElementById('i_countryid').value==0){
					alert("Tiene que seleccionar el pa\u00EDs");
					document.getElementById('i_countryid').focus();
					return false;
				}
				else if(document.getElementById('paymentformid').value==0){
					alert("Tiene que seleccionar una Forma de Pago");
					document.getElementById('paymentformid').focus();
					return false;
				}
				else if(document.getElementById('paymentformid').value==1 && (document.getElementById('i_codigo_entidad').value=='' || document.getElementById('i_codigo_entidad').value==0)){
					alert("Tiene que introducir el c\u00F3digo de la entidad bancaria");
					document.getElementById('i_codigo_entidad').focus();
					return false;
				}
				else if(document.getElementById('paymentformid').value==1 && document.getElementById('i_codigo_oficina').value==''){
					alert("Tiene que introducir el c\u00F3digo de la oficina");
					document.getElementById('i_codigo_oficina').focus();
					return false;
				}
				//Edit Juanan: Validar Cod. Oficina
				else if(document.getElementById('paymentformid').value==1 && validarCod_Oficina(document.getElementById('i_codigo_oficina').value)==false){
					alert("Tiene que introducir un C\u00F3digo de oficina valido");
					document.getElementById('i_codigo_oficina').focus();
					return false;
				}
				//End Edit Juanan: Validar Cod. Oficina
				else if(document.getElementById('paymentformid').value==1 && document.getElementById('i_digitos_control').value==''){
					alert("Tiene que introducir los d\u00EDgitos de control");
					document.getElementById('i_digitos_control').focus();
					return false;
				}
				//Edit Juanan: Validar Dig. Control
				else if(document.getElementById('paymentformid').value==1 && validarDigit_Control(document.getElementById('i_digitos_control').value)==false){
					alert("Tiene que introducir unos digitos de control validos");
					document.getElementById('i_digitos_control').focus();
					return false;
				}
				//End Edit Juanan: Validar Dig. Control
				else if(document.getElementById('paymentformid').value==1 && document.getElementById('i_numero_cuenta').value==''){
					alert("Tiene que introducir el n\u00FAmero de cuenta");
					document.getElementById('i_numero_cuenta').focus();
					return false;
				}
				//Edit Juanan: Validar Num. Cuenta
				else if(document.getElementById('paymentformid').value==1 && validarNum_Cuenta(document.getElementById('i_numero_cuenta').value)==false){
					alert("Tiene que introducir un numero de cuenta valido");
					document.getElementById('i_numero_cuenta').focus();
					return false;
				}
				//End Edit Juanan: Validar Num. Cuenta
				/*
				else if(document.getElementById('paymentformid').value==1 && document.getElementById('i_codigo_oficina').value==''){
					alert("Tiene que introducir el c\u00F3digo de la oficina");
					document.getElementById('i_codigo_oficina').focus();
					return false;
				}
				else if(document.getElementById('paymentformid').value==1 && document.getElementById('i_digitos_control').value==''){
					alert("Tiene que introducir los d\u00EDgitos de control");
					document.getElementById('i_digitos_control').focus();
					return false;
				}
				else if(document.getElementById('paymentformid').value==1 && document.getElementById('i_numero_cuenta').value==''){
					alert("Tiene que introducir el n\u00FAmero de cuenta");
					document.getElementById('i_numero_cuenta').focus();
					return false;
				}
				*/
				else if(document.getElementById('ivaTypeId').value==0){
					alert("Tiene que seleccionar una Tipo de IVA");
					document.getElementById('ivaTypeId').focus();
					return false;
				}
		}

			document.forms[0].submit();
}

function showFormParticularEdit(userid){

	document.getElementById('is_company').value=0;
	document.getElementById('c_copydata').disabled = false;
	
		var url="clients_fact_particular_ajax.php?userid="+userid;

	xmlHttpShowFormParticular=GetXmlHttpObject();
	xmlHttpShowFormParticular.open("GET",url,true);
	xmlHttpShowFormParticular.onreadystatechange=function(){

		if(xmlHttpShowFormParticular.readyState == 1 ) { 
			layer_fact.innerHTML = "<div align=center valign=middle><img src='images/ajax-bank_loader.gif' border=0>&nbsp;<b>Cargando.</b></div>";	 
		}
		else if(xmlHttpShowFormParticular.readyState == 4 ) {
				document.getElementById('layer_fact').innerHTML = xmlHttpShowFormParticular.responseText; 
		}
	} 	
	xmlHttpShowFormParticular.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttpShowFormParticular.send(null); 	
}

function showFormEmpresaEdit(userid){

	document.getElementById('is_company').value=1;
	//BEGIN EDIT: Juan Antonio
	document.getElementById('c_copydata').checked = false;
	document.getElementById('c_copydata').disabled = true;

	document.getElementById('c_firstname').readOnly = false;
	document.getElementById('c_lastname').readOnly = false;
	document.getElementById('c_email').readOnly = false;
	document.getElementById('c_email1').readOnly = false;
	document.getElementById('c_firstname').readOnly = false;
	document.getElementById('c_phone').readOnly = false;
	document.getElementById('c_phone1').readOnly = false;
	document.getElementById('c_phone2').readOnly = false;
	document.getElementById('c_fax').readOnly = false;
	document.getElementById('c_address').readOnly = false;
	document.getElementById('c_cp').readOnly = false;
	document.getElementById('c_city').readOnly = false;
	
	document.getElementById('c_firstname').style.backgroundColor='#FFFFFF';
	document.getElementById('c_lastname').style.backgroundColor='#FFFFFF';
	document.getElementById('c_email').style.backgroundColor='#FFFFFF';
	document.getElementById('c_email1').style.backgroundColor='#FFFFFF';
	document.getElementById('c_firstname').style.backgroundColor='#FFFFFF';
	document.getElementById('c_phone').style.backgroundColor='#FFFFFF';
	document.getElementById('c_phone1').style.backgroundColor='#FFFFFF';
	document.getElementById('c_phone2').style.backgroundColor='#FFFFFF';
	document.getElementById('c_fax').style.backgroundColor='#FFFFFF';
	document.getElementById('c_address').style.backgroundColor='#FFFFFF';
	document.getElementById('c_cp').style.backgroundColor='#FFFFFF';
	document.getElementById('c_city').style.backgroundColor='#FFFFFF';
	//FIN EDIT: Juan Antonio

		var url="clients_fact_empresa_ajax.php?userid="+userid;


	xmlHttpShowFormEmpresas=GetXmlHttpObject();
	xmlHttpShowFormEmpresas.open("GET",url,true);
	xmlHttpShowFormEmpresas.onreadystatechange=function(){

		if(xmlHttpShowFormEmpresas.readyState == 1 ) { 
			layer_fact.innerHTML = "<div align=center valign=middle><img src='images/ajax-bank_loader.gif' border=0>&nbsp;<b>Cargando.</b></div>";	 
		}
		else if(xmlHttpShowFormEmpresas.readyState == 4 ) {
				document.getElementById('layer_fact').innerHTML = xmlHttpShowFormEmpresas.responseText; 
		}
	} 	
	xmlHttpShowFormEmpresas.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttpShowFormEmpresas.send(null); 	
}



function showFormParticularAdd(){
	document.getElementById('is_company').value=0;
	document.getElementById('c_copydata').disabled = false;
	var url="clients_fact_particular_add_ajax.php";

	xmlHttpShowFormParticularAdd=GetXmlHttpObject();
	xmlHttpShowFormParticularAdd.open("GET",url,true);
	xmlHttpShowFormParticularAdd.onreadystatechange=function(){

		if(xmlHttpShowFormParticularAdd.readyState == 1 ) { 
			layer_fact.innerHTML = "<div align=center valign=middle><img src='images/ajax-bank_loader.gif' border=0>&nbsp;<b>Cargando.</b></div>";	 
		}
		else if(xmlHttpShowFormParticularAdd.readyState == 4 ) {
				document.getElementById('layer_fact').innerHTML = xmlHttpShowFormParticularAdd.responseText; 
		}
	} 	
	xmlHttpShowFormParticularAdd.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttpShowFormParticularAdd.send(null); 	
}


function showFormEmpresaAdd(){

	document.getElementById('is_company').value=1;
	//BEGIN EDIT: Juan Antonio
	document.getElementById('c_copydata').checked = false;
	document.getElementById('c_copydata').disabled = true;
	
	document.getElementById('c_firstname').readOnly = false;
	document.getElementById('c_lastname').readOnly = false;
	document.getElementById('c_email').readOnly = false;
	document.getElementById('c_email1').readOnly = false;
	document.getElementById('c_firstname').readOnly = false;
	document.getElementById('c_phone').readOnly = false;
	document.getElementById('c_phone1').readOnly = false;
	document.getElementById('c_phone2').readOnly = false;
	document.getElementById('c_fax').readOnly = false;
	document.getElementById('c_address').readOnly = false;
	document.getElementById('c_cp').readOnly = false;
	document.getElementById('c_city').readOnly = false;
	
	document.getElementById('c_firstname').style.backgroundColor='#FFFFFF';
	document.getElementById('c_lastname').style.backgroundColor='#FFFFFF';
	document.getElementById('c_email').style.backgroundColor='#FFFFFF';
	document.getElementById('c_email1').style.backgroundColor='#FFFFFF';
	document.getElementById('c_firstname').style.backgroundColor='#FFFFFF';
	document.getElementById('c_phone').style.backgroundColor='#FFFFFF';
	document.getElementById('c_phone1').style.backgroundColor='#FFFFFF';
	document.getElementById('c_phone2').style.backgroundColor='#FFFFFF';
	document.getElementById('c_fax').style.backgroundColor='#FFFFFF';
	document.getElementById('c_address').style.backgroundColor='#FFFFFF';
	document.getElementById('c_cp').style.backgroundColor='#FFFFFF';
	document.getElementById('c_city').style.backgroundColor='#FFFFFF';
	//FIN EDIT: Juan Antonio
	var url="clients_fact_empresa_add_ajax.php";

	xmlHttpShowFormEmpresasAdd=GetXmlHttpObject();
	xmlHttpShowFormEmpresasAdd.open("GET",url,true);
	xmlHttpShowFormEmpresasAdd.onreadystatechange=function(){

		if(xmlHttpShowFormEmpresasAdd.readyState == 1 ) { 
			layer_fact.innerHTML = "<div align=center valign=middle><img src='images/ajax-bank_loader.gif' border=0>&nbsp;<b>Cargando.</b></div>";	 
		}
		else if(xmlHttpShowFormEmpresasAdd.readyState == 4 ) {
				document.getElementById('layer_fact').innerHTML = xmlHttpShowFormEmpresasAdd.responseText; 
		}
	} 
	xmlHttpShowFormEmpresasAdd.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttpShowFormEmpresasAdd.send(null); 	
}



function updateSearchField(intDatasource,intFilterId){
	var strURL="";
	var strCombo="searchComboField_ajax.php?intDatasource="+intDatasource+"&intFilterId="+intFilterId;
	if (strURL==""){
		strURL="searchTextField_ajax.php";
	}
	xmlHttpUpdateSearchField=GetXmlHttpObject()

	xmlHttpUpdateSearchField.open("GET",strURL,true)
	xmlHttpUpdateSearchField.onreadystatechange=function(){
		if(xmlHttpUpdateSearchField.readyState == 1 ) { 
			//layer_field.innerHTML = "<div align=center valign=middle><img src='images/ajax-bank_loader.gif' border=0>&nbsp;<b>Cargando.</b></div>";	 
		}
		else if(xmlHttpUpdateSearchField.readyState == 4 ) {
			//alert (xmlHttpchargeCombo.responseText);			
			document.getElementById('layer_field').innerHTML = xmlHttpUpdateSearchField.responseText; 
		}
	} 	
	xmlHttpUpdateSearchField.send(null); 	
}

function validarEmail(txt){   
       

        var b=/^[^@\s]+@[^@\.\s]+(\.[^@\.\s]+)+$/   
        
        return b.test(txt)   
}   

//BEGIN Funciones de Validacion
function validarTel(txt){
	var b=/^[0-9]{2,3}-? ?[\s0-9\s]{6,15}$/
	return b.test(txt)
}
function validarCP(txt){
	var b=/^([1-9]{2}|[0-9][1-9]|[1-9][0-9])[0-9]{3}$/
	return b.test(txt)
}
function validarCod_Oficina(txt){
	var b=/^[0-9]{4}$/
	return b.test(txt)
}
function validarDigit_Control(txt){
	var b=/^[0-9]{2}$/
	return b.test(txt)
}
function validarNum_Cuenta(txt){
	var b=/^[0-9]{10}$/
	return b.test(txt)
}
//END Funciones de Validacion

//Muestra formulario de nº de cuenta
function showBankForm(){
	document.getElementById('layer_bankNameTitle').style.display='block';
	document.getElementById('layer_bankName').style.display='block';
	document.getElementById('layer_cuenta').style.display='block';
	document.getElementById('bank_layer').style.display='block';
}

//Oculta formulario de nº de cuenta
function hideBankForm(){
	document.getElementById('layer_bankNameTitle').style.display='none';
	document.getElementById('layer_bankName').style.display='none';
	document.getElementById('layer_cuenta').style.display='none';
	document.getElementById('bank_layer').style.display='none';
}

//MUESTRA BANCO
function showBank(bankid){
	xmlHttpBankShow=GetXmlHttpObject()
	if (xmlHttpBankShow==null){	alert ("Browser does not support HTTP Request");return;	} 
 
		var url="bank_ajax.php?bankid="+bankid 
		
		
		xmlHttpBankShow.open("GET",url,true)
		xmlHttpBankShow.onreadystatechange=function(){
			if(xmlHttpBankShow.readyState == 1 ) { 
				bank_layer.innerHTML = "<div align=center valign=middle ><img src='images/ajax-loader.gif' border=0 >&nbsp;<b>Cargando datos.</b></div>";	 
			}
			else if(xmlHttpBankShow.readyState == 4 ) { 
				document.getElementById('bank_layer').innerHTML = xmlHttpBankShow.responseText;   
			}
		} 	
		xmlHttpBankShow.send(null);  
}


function validateClientProductEditForm(intEdit){
var prodType=document.getElementById('product_typeid').value;
	if(prodType==1){
			if(document.getElementById('domainname').value==''){
				alert("Tiene que introducir un nombre para el dominio");
				document.getElementById('domainname').focus();
				return false;
			}
			else if(document.getElementById('domain_typeid').value==0){
				alert("Tiene que introducir un tipo para el dominio");
				document.getElementById('domain_typeid').focus();
				return false;
			}
			else if(document.getElementById('fecha_alta').value==''){
				alert("Tiene que introducir una fecha de alta");
				document.getElementById('fecha_alta').focus();
				return false;
			}
			
			else if(document.getElementById('cost').value==''){
				alert("Tiene que introducir una tarifa");
				document.getElementById('cost').focus();
				return false;
			}
			else if(document.getElementById('serverid').value==0){
				alert("Tiene que introducir una servidor");
				document.getElementById('serverid').focus();
				return false;
			}
			
			if (intEdit==0){
				if(document.getElementById('durationId').value==0){
				alert("Tiene que introducir una duración");
				document.getElementById('durationId').focus();
				return false;
				}
			}

	}
	else if(prodType==2){
			if(document.getElementById('domainname').value==''){
				alert("Tiene que introducir un nombre para el dominio");
				document.getElementById('domainname').focus();
				return false;
			}
			else if(document.getElementById('domain_typeid').value==0){
				alert("Tiene que introducir un tipo para el dominio");
				document.getElementById('domain_typeid').focus();
				return false;
			}
			else if(document.getElementById('domain_systemtypeid').value==0){
				alert("Tiene que escoger un Sistema Operativo");
				document.getElementById('domain_systemtypeid').focus();
				return false;
			}
			else if(document.getElementById('productid').value==0){
				alert("Tiene que escoger un Plan");
				document.getElementById('productid').focus();
				return false;
			}
			else if(document.getElementById('payment_periodid').value==0){
				alert("Tiene que escoger una periodicidad");
				document.getElementById('payment_periodid').focus();
				return false;
			}
			else if(document.getElementById('fecha_alta').value==''){
				alert("Tiene que introducir una fecha de alta");
				document.getElementById('fecha_alta').focus();
				return false;
			}

			else if(document.getElementById('cost').value==''){
				alert("Tiene que introducir una tarifa");
				document.getElementById('cost').focus();
				return false;
			}
			else if(document.getElementById('serverid').value==0){
				alert("Tiene que introducir una servidor");
				document.getElementById('serverid').focus();
				return false;
			}
		if (intEdit==0){
				if(document.getElementById('durationId').value==0){
				alert("Tiene que introducir una duración");
				document.getElementById('durationId').focus();
				return false;
				}
			}
	}
	else if(prodType==3 || prodType==4 || prodType==5){
			if(document.getElementById('domainname').value==''){
				alert("Tiene que introducir un nombre para el dominio");
				document.getElementById('domainname').focus();
				return false;
			}


			else if(document.getElementById('payment_periodid').value==0){
				alert("Tiene que escoger una periodicidad");
				document.getElementById('payment_periodid').focus();
				return false;
			}
			else if(document.getElementById('fecha_alta').value==''){
				alert("Tiene que introducir una fecha de alta");
				document.getElementById('fecha_alta').focus();
				return false;
			}

			else if(document.getElementById('cost').value==''){
				alert("Tiene que introducir una tarifa");
				document.getElementById('cost').focus();
				return false;
			}
			else if(document.getElementById('serverid').value==0){
				alert("Tiene que introducir una servidor");
				document.getElementById('serverid').focus();
				return false;
			}
			if (intEdit==0){
				if(document.getElementById('durationId').value==0){
				alert("Tiene que introducir una duración");
				document.getElementById('durationId').focus();
				return false;
				}
			}
	}
		
	document.forms[0].submit();
}

function showProvinceText(fieldname,strLayer,strValue){
	while(strValue.indexOf(" ") != -1)
		{
			strValue=strValue.replace(" " ,"%20");
		}	
	var url="province_textfield_ajax.php?fieldname="+fieldname+"&strValue="+strValue;

	xmlHttpShowProvinceText=GetXmlHttpObject();
	xmlHttpShowProvinceText.open("GET",url,true);
	xmlHttpShowProvinceText.onreadystatechange=function(){

		if(xmlHttpShowProvinceText.readyState == 1 ) { 
			
		}
		else if(xmlHttpShowProvinceText.readyState == 4 ) {
				document.getElementById(strLayer).innerHTML = xmlHttpShowProvinceText.responseText; 
		}
	} 	
	xmlHttpShowProvinceText.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttpShowProvinceText.send(null); 	
}

function showProvinceCombo(fieldname,strLayer,strValue){
	var url="province_combo_ajax.php?fieldname="+fieldname+"&strValue="+strValue;

	xmlHttpShowProvinceCombo=GetXmlHttpObject();
	xmlHttpShowProvinceCombo.open("GET",url,true);
	xmlHttpShowProvinceCombo.onreadystatechange=function(){

		if(xmlHttpShowProvinceCombo.readyState == 1 ) { 
			
		}
		else if(xmlHttpShowProvinceCombo.readyState == 4 ) {
				document.getElementById(strLayer).innerHTML = xmlHttpShowProvinceCombo.responseText;
		}
	} 	
	xmlHttpShowProvinceCombo.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttpShowProvinceCombo.send(null); 	
}

function validar_nifcif(cif) {
	par = 0;
	non = 0;
	letras = 'ABCDEFGHKLMNPQS';
	let = cif.charAt(0);
	var retorno = true;

	if (!isNaN(let)) {
		nif = cif;
		if (!validar_nif(nif)) {
			retorno = false;
		}
	}
	else {

		if (cif.length != 9) {
			retorno = false;
		}
	
		if ( letras.indexOf( let.toUpperCase() ) == -1 ) {
			retorno = false;
		}
	
		for (zz = 2; zz < 8; zz += 2) {
			par = par + parseInt(cif.charAt(zz));
		}
	
		for (zz = 1; zz < 9; zz += 2) {
			nn = 2 * parseInt(cif.charAt(zz));
			if (nn > 9) {
				nn = 1 + (nn - 10);
			}
			non = non + nn;
		}
	
		parcial = par + non;
		
		control = ( 10 - ( parcial % 10) );
	
		if (control == 10) {
			control = 0;
		}
	
		if (control != cif.charAt(8)) {
			retorno = false;
		}
	}

	return retorno;
}

function validar_nif(texto) {
	dni = texto.substring(0, texto.length - 1);
	let = texto.charAt(texto.length - 1);
	var retorno = true;
	
	if (!isNaN(let)) {
		retorno = false;
	}
	else {
		cadena='TRWAGMYFPDXBNJZSQVHLCKET';
		posicion = dni % 23;
		letra = cadena.substring(posicion, posicion + 1);
		
		if (letra != let.toUpperCase()) {
			retorno = false;
		}
	}
	
	if (dni.length != 8) {
		retorno = false;
	}

	return retorno;
}

function validar_permiso(texto) {
	permiso = texto.substring(1, texto.length - 1);
	let = texto.charAt(texto.length - 1);
	var retorno = true;
	
	if (!isNaN(let)) {
		retorno = false;
	}
	else {
		cadena='TRWAGMYFPDXBNJZSQVHLCKET';
		posicion = permiso % 23;
		letra = cadena.substring(posicion, posicion + 1);
		
		if (letra != let.toUpperCase()) {
			retorno = false;
		}
	}
	
	if (permiso.length != 7) {
		retorno = false;
	}
	
	if (texto.charAt(0) != '0' && texto.charAt(0) != 'X' && texto.charAt(0) != 'x') {
		retorno = false;
	}

	return retorno;
}

function change_tiponif(msg,intType,strLabelName,strHiddenFieldName) {
	document.getElementById(strLabelName).value = msg;
	document.getElementById(strHiddenFieldName).value = intType;
}

function validar_nie(texto) {
	permiso = texto.substring(1, texto.length - 1);
	let = texto.charAt(texto.length - 1);
	var retorno = true;
	
	if (!isNaN(let)) {
		retorno = false;
	}
	else {
		cadena="TRWAGMYFPDXBNJZSQVHLCKET";
		posicion = permiso % 23;
		letra = cadena.substring(posicion, posicion + 1);
		
		if (letra != let.toUpperCase()) {
			retorno = false;
		}
	}
	
	if (permiso.length != 7) {
		retorno = false;
	}
	
	if (texto.charAt(0) != "0" && texto.charAt(0) != "X" && texto.charAt(0) != "x") {
		retorno = false;
	}

	return retorno;
}

function validateIdentityDoc(intTypeDoc,strDoc){
	var bool=true;
	if(intTypeDoc==1)
		bool=validar_nifcif(strDoc);
	else if (intTypeDoc==2)
		bool=validar_nie(strDoc);
	else if (intTypeDoc==3)
		bool=validar_nifcif(strDoc);				
		
	if (!bool){
		if(intTypeDoc==1)
			alert("El formato del NIF es incorrecto, Introducir sin espacios ni simbolos.");
		else if (intTypeDoc==2)
			alert("El formato del NIE es incorrecto, Introducir sin espacios ni simbolos.");
		else if (intTypeDoc==3)
			alert("El formato del CIF es incorrecto, Introducir sin espacios ni simbolos");
	}
		
	return bool;
}

function addProduct(userId,intType){
	location.href="client_products_add.php?userid="+userId+"&product_typeId="+intType;
}


function getRadioButtonSelectedValue(ctrl)
{
	alert(document.getElementById('product_typeid').cheked);
for (i==0;i<document.getElementById('product_typeid').length;i++)
	alert('cc');
}


function getRenovationDate(varDate,periodType){
	xmlHttpGetDate=GetXmlHttpObject()
	if (xmlHttpGetDate==null){	alert ("Browser does not support HTTP Request");return;	} 

	var new_date = "";
		
	var url="get_renewal_date.php?fecha="+varDate+"&payment_periodid="+periodType;

	xmlHttpGetDate.open("GET",url,true)
	xmlHttpGetDate.onreadystatechange=function(){
		if(xmlHttpGetDate.readyState == 1 ) {}
		else if(xmlHttpGetDate.readyState == 4 ) {
			//alert (xmlHttpGetDate.responseText);			
			new_date = xmlHttpGetDate.responseText;
			document.getElementById('fecha_renovacion').value = new_date;
		}
	} 	
	xmlHttpGetDate.send(null);
}


function getNewRenovationDate(varDate,periodType,intIncrement,boolShow){
	xmlHttpGetNewRenovationDate=GetXmlHttpObject()
	if (xmlHttpGetNewRenovationDate==null){	alert ("Browser does not support HTTP Request");return;	} 

	var new_date = "";
	var url="get_renewal_date_new.php?fecha="+varDate+"&payment_periodid="+periodType+"&increment="+intIncrement;

	xmlHttpGetNewRenovationDate.open("GET",url,true)
	xmlHttpGetNewRenovationDate.onreadystatechange=function(){
		if(xmlHttpGetNewRenovationDate.readyState == 1 ) {}
		else if(xmlHttpGetNewRenovationDate.readyState == 4 ) {
			//alert (xmlHttpGetDate.responseText);			

			new_date = xmlHttpGetNewRenovationDate.responseText;

			document.getElementById("tempRenewDate").value = new_date; 
						alert(document.getElementById("tempRenewDate").value);
			if (boolShow)
				document.getElementById("layer_renew_date").innerHTML = "<b>"+new_date+"</b>"; 
		}
	} 	
	xmlHttpGetNewRenovationDate.send(null);
}

function renewProduct(userId,domainnameId){
	location.href="client_product_renew.php?userid="+userId+"&domainnameid="+domainnameId;
}

function renewDenegateProduct(userId,domainnameId){
	var a=confirm("Esta seguro que no desea renovar el producto");
	if (!a){
		return false;
	}
	location.href="client_product_detail.php?edit=4&userid="+userId+"&domainnameid="+domainnameId;
}


function bajaProducto(userId,domainnameId){
	var a=confirm("Esta seguro que desea dar de baja el producto");
	if (!a){
		return false;
	}
	location.href="client_product_detail.php?edit=5&userid="+userId+"&domainnameid="+domainnameId;
}

function viewProductDetail(userId,domainnameId){
	location.href="client_product_detail.php?userid="+userId+"&domainnameid="+domainnameId;
}

function showPeriodesCombo(fieldname,strLayer,intPeriodeType,renew_date){
	var url="periode_combo_ajax.php?fieldname="+fieldname+"&intPeriodeType="+intPeriodeType+"&renew_date="+renew_date;

	xmlHttpShowPeriodesCombo=GetXmlHttpObject();
	xmlHttpShowPeriodesCombo.open("GET",url,true);
	xmlHttpShowPeriodesCombo.onreadystatechange=function(){

		if(xmlHttpShowPeriodesCombo.readyState == 1 ) { 
			
		}
		else if(xmlHttpShowPeriodesCombo.readyState == 4 ) {
				document.getElementById(strLayer).innerHTML = xmlHttpShowPeriodesCombo.responseText; 
		}
	} 	
	xmlHttpShowPeriodesCombo.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttpShowPeriodesCombo.send(null); 	
}

function validateClientProductRenew(userId,domainnameid){
			if(document.getElementById('payment_periodid').value==0){
				alert("Tiene que introducir una peridodicidad de pago");
				document.getElementById('payment_periodid').focus();
				return false;
			}
			else if(document.getElementById('durationId').value==0){
				alert("Tiene que introducir una duración para la renovación");
				document.getElementById('durationId').focus();
				return false;
			}
		
	document.forms[0].submit();
}

function showConfirmRenovation(userId,domainnameId){
	location.href="client_product_renew_confirm.php?userid="+userId+"&domainnameid="+domainnameId+"&confirm=1";
}

function showCancelRenovation(userId,domainnameId){
	location.href="client_product_renew_confirm.php?userid="+userId+"&domainnameid="+domainnameId+"&confirm=0";
}

function confirmRenovation(){
	if(document.getElementById('confirm').value==0 && document.getElementById('observations').value==''){
		alert("Introduzca el motivo por el cual no se puede renovar el producto");
		document.getElementById('observations').focus();
		return false;
	}
	document.forms[0].submit();
}

function validateProductSelect(){
	var bool=0;
	var userId=0;
	var venciment="";
	for(i=0;i<document.getElementById("numProducts").value;i++){
		if(document.getElementById("chkProductId"+i).checked==true){
			if(!bool){
				userId=document.getElementById("productClientId"+i).value;
				venciment=document.getElementById("venciment"+i).value;
				bool=1;
			}
			else if(userId!=document.getElementById("productClientId"+i).value){
				bool=2;		
				i=document.getElementById("numProducts").value;
			}
			else if(userId==document.getElementById("productClientId"+i).value && venciment != document.getElementById("venciment"+i).value){
				bool=3;		
				i=document.getElementById("numProducts").value;
			}
		}
	}
	if(bool==0){
		alert('Tiene que seleccionar algun producto para generar la factura.');
		return false;
	} 
	else if(bool==2){
		alert('Ha seleccionado productos de dos clientes distintos. Compruebe su selección');
		return false;
	} 
	else if(bool==3){
		alert('Ha seleccionado productos con vencimientos distintos. Compruebe su selección');
		return false;
	} 
	else{
		document.forms[0].submit();
	}
}

function invoiceProdSel(){
		document.forms[0].action='pendientes_facturar.php';
		document.forms[0].submit();
}

function generateInvoice(){
	var a= confirm ("Esta seguro/a que desea generar la factura?");
	if (!a){
		return false;
		}
	else{
		document.forms[0].submit();
	}
}

function sendInvoiceRemesa(invoiceId,remesaId){
	location.href="invoice_send_remesa.php?invoiceId="+invoiceId+"&remesaId="+remesaId;
}

function viewRemesaDetail(remesaId){
	location.href="remesa_detalle.php?remesaId="+remesaId;
}

function sendInvoiceRemesaConfirm(remesaId,invoiceId){
	location.href="remesa_detalle.php?remesaId="+remesaId+"&invoiceId="+invoiceId+"&edit=1";
}




function returnInvoiceRemesa(invoiceId,remesaId){
	location.href="invoice_return_remesa.php?invoiceId="+invoiceId+"&remesaId="+remesaId;
}

function returnInvoiceRemesaConfirm(invoiceId,remesaId,newRemesaId){
	boolFraRecargo=0;
	if(document.getElementById("chkRecargo").checked==true){
		boolFraRecargo=1;
	}
	location.href="remesa_detalle.php?remesaId="+remesaId+"&invoiceId="+invoiceId+"&newRemesaId="+newRemesaId+"&boolFraRecargo="+boolFraRecargo+"&edit=2";
}

function sendRemesa(opc){
	document.forms[0].action="remesa_detalle_opc.php?opc="+opc;
	document.forms[0].submit();
}

function sendRemesaForm(){
	var numChk=document.getElementById("numChk").value;
	var opc=document.getElementById("opc").value;
	var chkSelected=0;
	if(numChk==0){
		if(opc==1){
			alert('No hay facturas para enviar');
			return false;
		}
		else if(opc==2){
			alert('No hay facturas para generar devoulción');
			return false;
		}
		else if(opc==3){
			alert('No hay facturas para confirmar el cobro');
			return false;
		}
	}
	else{
		for (i=0;i<numChk-1;i++){
			if(document.getElementById("chk"+i).checked == true){
				chkSelected=true;
			}
		}
	}

	if(chkSelected==0){
		alert('Tiene que seleccionar alguna factura');
		return false;
	}
	
	if(opc==1){
		document.forms[0].action="remesa_detalle.php";
	}
	else if(opc==2){
		document.forms[0].action="confirmaDenegar.php";
		
	}
	else if(opc==3){
		document.forms[0].action="remesa_detalle.php";
	}

		
	if(chkSelected==1)	
		document.forms[0].submit();
}

function sendInvoiceRemesaConfirm(remesaId,invoiceId){
	location.href="remesa_detalle.php?remesaId="+remesaId+"&invoiceId="+invoiceId+"&edit=1";
}

function activarLogin(valor) {
	document.getElementById('campoUsuario').disabled = false;
	document.getElementById('campoPassword').disabled = false;
	document.getElementById('campoUsuario').style.backgroundColor='#FFFFFF';
	document.getElementById('campoPassword').style.backgroundColor='#FFFFFF';
	document.getElementById('valorOpcion').value = valor; 
}

function descativarLogin(valor) {
	document.getElementById('campoUsuario').disabled = true;
	document.getElementById('campoPassword').disabled = true;
	document.getElementById('campoUsuario').style.backgroundColor='#DCDCDC';
	document.getElementById('campoPassword').style.backgroundColor='#DCDCDC';
	document.getElementById('valorOpcion').value = valor; 

}

function showPaymentPeriods(plan) {
	xmlHttpShowPM=GetXmlHttpObject()
	if (xmlHttpShowPM==null){	alert ("Browser does not support HTTP Request");return;	} 

		var url="showRadioPrices.php?plan_pay="+plan;
		xmlHttpShowPM.open("GET",url,true)
		xmlHttpShowPM.onreadystatechange=function(){
			if(xmlHttpShowPM.readyState == 1 ) { 
				
			}
			else if(xmlHttpShowPM.readyState == 4 ) {
				//alert (xmlHttpClientData.responseText);
				div_prices.innerHTML = xmlHttpShowPM.responseText;   
			}
		} 	
		xmlHttpShowPM.send(null); 

}

function contratar_redirect(op){
	if (op == 1)				document.forms[0].action="contratar_paso_4.php";
	else if (op == 2)	document.forms[0].action="contratar_paso_3.php";
	document.forms[0].submit();
	
}

function validarPaso2(){
if(document.getElementById('wantdomain').value==1){
	document.forms[0].action="contratar_paso_2a.php";
}
else{
	document.forms[0].action="contratar_paso_3.php";
}
	document.forms[0].submit();
	
}

function validarPaso2a(){
	document.forms[0].submit();
	
}

function userLogin(){
	document.forms[0].action="contratar_paso_5.php";
	document.forms[0].submit();
}

function validarPaso3(){
	if(document.getElementById('plan').value!=10){
		if(document.getElementById('mainDomain').value==""){
			alert('Tiene que introducir el dominio principal al que irá asociado el alojamiento');
			document.getElementById('mainDomain').focus();
			return false;
		}
		if(document.getElementById('mainExtension').value==0){
			alert('Tiene que seleccionar una extensión para el dominio');
			document.getElementById('mainExtension').focus();
			return false;
		}
	}
	
	
	
	document.forms[0].action="contratar_paso_4.php";
	document.forms[0].submit();
	
}


function validarPaso6(){
	if(confirm('Confirma que desea Contratar los servicios seleccionados?')){
		document.forms[0].action="contratar_paso_7.php";
		document.forms[0].submit();
	}
}

function userRegister(){
	document.forms[0].action="contratar_paso_4b.php";
	document.forms[0].submit();
}




function showDomainResults() {
	
	xmlHttpShowDomainResults=GetXmlHttpObject()
	if (xmlHttpShowDomainResults==null){	alert ("Browser does not support HTTP Request");return;	} 
	var boolFirst=true;
	var postVariables="";
	postVariables="domainname="+document.getElementById("domainname").value;
	for (i=0; i<document.forms[0].elements.length; i++) {
	  objeto = document.forms[0].elements[i] ;
		nombreCampo=objeto.id; 
		if (objeto.type=="checkbox" && nombreCampo.substr(0,5)=="top2_") {
				if(objeto.checked){
						postVariables=postVariables+"&"+nombreCampo+"=1";
				}
		}
		else if(objeto.type=="hidden" && nombreCampo.substr(0,17)=="domainTypeResult_"){
			if(objeto.value==1){
				postVariables=postVariables+"&"+nombreCampo+"=1";
			}
		}
	}

		var url="check_domain_result_ajax.php";
		xmlHttpShowDomainResults.open("POST",url,true)
		xmlHttpShowDomainResults.onreadystatechange=function(){
			if(xmlHttpShowDomainResults.readyState == 1 ) { 
				
			}
			else if(xmlHttpShowDomainResults.readyState == 4 ) {
				domlist.innerHTML = xmlHttpShowDomainResults.responseText;   
			}
		} 	
		xmlHttpShowDomainResults.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

		xmlHttpShowDomainResults.send(postVariables); 

}

function showPlanSpecs(plan) {
	xmlHttpShowPS=GetXmlHttpObject()
	if (xmlHttpShowPS==null){	alert ("Browser does not support HTTP Request");return;	} 

		var url="showPlanSpecs.php?plan_pay="+plan;
		xmlHttpShowPS.open("GET",url,true)
		xmlHttpShowPS.onreadystatechange=function(){
			if(xmlHttpShowPS.readyState == 1 ) { 
				
			}
			else if(xmlHttpShowPS.readyState == 4 ) {
				//alert (xmlHttpClientData.responseText);
				div_planSpec.innerHTML = xmlHttpShowPS.responseText;   
			}
		} 	
		xmlHttpShowPS.send(null); 
}

function showMainDomain(plan,nombreDominio,tipoDominio){
	xmlHttpShowMD=GetXmlHttpObject()
	if (xmlHttpShowPS==null){	alert ("Browser does not support HTTP Request");return;	} 
		var url="showMainDomain.php?plan_pay="+plan+"&nombreDominio="+nombreDominio+"&tipoDominio="+tipoDominio;
		xmlHttpShowMD.open("GET",url,true)
		xmlHttpShowMD.onreadystatechange=function(){
			if(xmlHttpShowMD.readyState == 1 ) { 
				
			}
			else if(xmlHttpShowMD.readyState == 4 ) {
				//alert (xmlHttpClientData.responseText);
				div_mainDomain.innerHTML = xmlHttpShowMD.responseText;   
			}
		} 	
		xmlHttpShowMD.send(null); 
}


function renewPass(){
	document.forms[0].action="renew_pass.php?renew=1";
	document.forms[0].submit();
}

function desactivar_radio(tipo){
	/*1 - lin: desactivar win
		2 - win: desactivar lin
		3 - win: activar radios win
		4 - lin: activar radios lin
	*/
	switch(tipo){
		case 1:
			document.getElementById("plesk_win").disabled  = true;
			document.getElementById("plesk_win").checked   = false;
			document.getElementById("plesk_win1").disabled = true;
			document.getElementById("plesk_win2").disabled = true;
			document.getElementById("plesk_win3").disabled = true;
			document.getElementById("plesk_win1").checked = false;
			document.getElementById("plesk_win2").checked = false;
			document.getElementById("plesk_win3").checked = false;
			document.getElementById("plesk_lin").disabled  = false;
			break;
	
	case 2:
			document.getElementById("plesk_win").disabled  = false;
			document.getElementById("plesk_lin").disabled  = true;
			document.getElementById("plesk_lin").checked   = false;
			document.getElementById("plesk_linux").disabled   = true;
			document.getElementById("plesk_linux").checked   = false;
		break;
		
	case 3:
		if (document.getElementById("plesk_win").checked == true){
			document.getElementById("plesk_win1").disabled = false;
			document.getElementById("plesk_win2").disabled = false;
			document.getElementById("plesk_win3").disabled = false;
			document.getElementById("plesk_win1").checked = true;
			
			if (document.getElementById("so2").checked == true){
				document.getElementById("plesk_lin").disabled = false;
				document.getElementById("plesk_lin").checked = false;
				document.getElementById("plesk_linux").disabled = true;
			}
		}
		else{
			document.getElementById("plesk_win1").disabled = true;
			document.getElementById("plesk_win2").disabled = true;
			document.getElementById("plesk_win3").disabled = true;
			document.getElementById("plesk_win1").checked = false;
			document.getElementById("plesk_win2").checked = false;
			document.getElementById("plesk_win3").checked = false;
			
			if (document.getElementById("so2").checked == true){
				document.getElementById("plesk_lin").disabled = false;
				document.getElementById("plesk_lin").checked = false;
				document.getElementById("plesk_linux").disabled = true;
			}
		}
		break;
		
	case 4:
		if (document.getElementById("plesk_lin").checked == true){
			document.getElementById("plesk_linux").disabled = false;
			document.getElementById("plesk_linux").checked = true;
			
			document.getElementById("plesk_win1").disabled = true;
			document.getElementById("plesk_win2").disabled = true;
			document.getElementById("plesk_win3").disabled = true;
			document.getElementById("plesk_win1").checked = false;
			document.getElementById("plesk_win2").checked = false;
			document.getElementById("plesk_win3").checked = false;
			
			if (document.getElementById("so2").checked == true){
				document.getElementById("plesk_win").disabled = false;
				document.getElementById("plesk_win").checked = false;
			}

		}
		else{
			document.getElementById("plesk_linux").disabled = true;
			document.getElementById("plesk_linux").checked = false;
			
			if (document.getElementById("so2").checked == true){
				document.getElementById("plesk_win").disabled = false;
				document.getElementById("plesk_win").checked = false;
			}
		}
		break;
	
	default:
		document.getElementById("plesk_lin").disabled = false;
		document.getElementById("plesk_lin").checked = false;
		
		document.getElementById("plesk_win").disabled = false;
		document.getElementById("plesk_win").checked = false;
		break;
	}
}

function actualizar(tipo_precio){
	var precio;
	
	/*
		tipo_precio:
		
		1 - estandar
		2 - avanzado
	*/
	switch(tipo_precio){
		case 1:
				precio = 249;
				break;
		case 2:
				precio = 329;
				break;
	}
	
	// RAM
	if (document.getElementById("ram1").checked == true){
		document.getElementById("div_ram").innerHTML = "<b>RAM:</b> Sin mem&oacute;ria";
	}
	else if (document.getElementById("ram2").checked == true){
		document.getElementById("div_ram").innerHTML = "<b>RAM:</b> +1 Gb DDR2 ECC 667 GHz";
		precio += 30;
	}
	else if (document.getElementById("ram3").checked == true){
		document.getElementById("div_ram").innerHTML = "<b>RAM:</b> +2 Gb DDR2 ECC 667 GHz";
		precio += 50;
	}
	
	// SISTEMA OPERATIVO
	if (document.getElementById("so1").checked == true){
		document.getElementById("div_so").innerHTML = "<b>SO:</b> Linux CentOS (incluido)";
	}
	else if (document.getElementById("so2").checked == true){
		document.getElementById("div_so").innerHTML = "<b>SO:</b> Otro Sistema Operativo";
		precio += 35;
	}
	else if (document.getElementById("so3").checked == true){
		document.getElementById("div_so").innerHTML = "<b>SO:</b> Windows Server 2003 Standard";
		precio += 40;
	}
	
	// PANEL DE CONTROL (WINDOWS)
	if (document.getElementById("plesk_win").checked == true){
		if (document.getElementById("plesk_win1").checked == true){
			document.getElementById("div_plesk").innerHTML = "<b>Plesk:</b> 30 dominios";
			precio += 10;
		}
		else if (document.getElementById("plesk_win2").checked == true){
			document.getElementById("div_plesk").innerHTML = "<b>Plesk:</b>:100 dominios";
			precio += 20;
		}
		else if (document.getElementById("plesk_win3").checked == true){
			document.getElementById("div_plesk").innerHTML = "<b>Plesk:</b> Ilimitados dominios";
			precio += 30;
		}
	}
	// PANEL DE CONTROL (LINUX)
	else if (document.getElementById("plesk_lin").checked == true){
		if (document.getElementById("plesk_linux").checked == true){
			document.getElementById("div_plesk").innerHTML = "<b>Plesk:</b> WHM / Cpanel ilimitados";
			precio += 40;
		}
	}
	// SIN PANEL
	else{
		document.getElementById("div_plesk").innerHTML = "<b>Plesk:</b> Sin panel de control";
	}
	
	// BASES DE DATOS
	if (document.getElementById("bd1").checked == true){
		document.getElementById("div_bd").innerHTML = "<b>BD:</b> Sin SQL Server";
	}
	else if (document.getElementById("bd2").checked == true){
		document.getElementById("div_bd").innerHTML = "<b>BD:</b> SQL SERVER Express";
	}
	else if (document.getElementById("bd3").checked == true){
		document.getElementById("div_bd").innerHTML = "<b>BD:</b> SQL SERVER Estándard";
		precio += 40;
	}
	
	// MONITORIZACION PUERTOS
	if (document.getElementById("puertos1").checked == true){
		document.getElementById("div_puertos").innerHTML = "<b>Puertos:</b> Sin monitorizaci&oacute;n";
	}
	else if (document.getElementById("puertos2").checked == true){
		document.getElementById("div_puertos").innerHTML = "<b>Puertos:</b> 1 puerto monitorizado";
		precio += 9;
	}
	
	// CONECTIVIDAD
	if (document.getElementById("con1").checked == true){
		document.getElementById("div_con").innerHTML = "<b>Conectividad:</b> Por defecto";
	}
	else if (document.getElementById("con2").checked == true){
		if (document.getElementById("tipo_con1").checked == true){
			document.getElementById("div_con").innerHTML = "<b>Conectividad:</b> +1 Mbps";
		}else{
			document.getElementById("div_con").innerHTML = "<b>Conectividad:</b> +250 Gb";
		}
		precio += 55;
	}
	else if (document.getElementById("con3").checked == true){
		if (document.getElementById("tipo_con1").checked == true){
			document.getElementById("div_con").innerHTML = "<b>Conectividad:</b> +2 Mbps";
		}else{
			document.getElementById("div_con").innerHTML = "<b>Conectividad:</b> +500 Gb";
		}
		precio += 105;
	}

	document.getElementById("total").innerHTML = precio;

}

//-- COMPROBAR FORMULARIO SOLICITUD INFO ---------------------------------------

function validarTelf(valor){
		if(/^[0-9]{2,3}-? ?[\s0-9\s]{6,15}$/.test(valor)){
			return true;
		}else{
			return false;
		}
}
	
function validarEmail(valor) {
		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(valor)){
			return true;
		}else{
			return false;
		}
}
	
function validaDedicado(){
		if(document.getElementById("nombre").value.length <= 0){
			alert("Por favor, escriba un nombre de contacto.");
			document.getElementById("nombre").focus();
			return false;
		}
		if(document.getElementById("tel").value.length <= 0){
			alert("Por favor, introduzca un telefono de contacto valido.");
			document.getElementById("tel").focus();
			return false;
		}else if(validarTelf(document.getElementById("tel").value) == false){
			alert("Por favor, introduzca un telefono de contacto valido.");
			document.getElementById("tel").focus();
			return false;
		}
		if(document.getElementById("email").value.length <= 0){
			alert("Por favor, introduzca una direccion de correo electronico valida.");
			document.getElementById("email").focus();
			return false;
		}else if(validarEmail(document.getElementById("email").value) == false){
			alert("Por favor, introduzca una direccion de correo electronico valida.");
			document.getElementById("email").focus();
			return false;
		}
		alert("Formulario enviado correctamente. \nNos pondremos en contacto con usted lo antes posible.");
		document.forms[0].action='contratar_dedicado.php';
		document.forms[0].submit();
}

function iraform(tipo){
	switch(tipo){
		case 1:
			document.forms[0].action='contratar-dedicado-estanar.php';
			document.forms[0].submit();
			break;
		case 2:
			document.forms[0].action='contratar-dedicado-avanzado.php';
			document.forms[0].submit();
			break;
	}
}
