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

function calcTotalprice(){
//	alert($("#espaciodisco").val());
	
	var valorespaciodisco = $('#espaciodisco').val() || 0; 
	var intespacioendisco = $('#espaciodisco').val() || 0; 
	var intmemoriaram = $('#memoriaram').val() || 0; 
	var inttransferencia = $('#transferencia').val() || 0; 
	var inttotalprice = $('#preciototal').val() || 0; 

	var priceespacio = 0;
	var pricememoria = 0;
	var pricetransfe = 0;
	var pricecentos = 15;
	var pricetotal = 0;	

	if (intespacioendisco == 30 ){
		priceespacio = 32;
	}else{
		priceespacio = 50;
	}
	
	if(intmemoriaram == 1){
		preciomemoria = 25;
	}else{
		preciomemoria = 40;
	}
	
	if(inttransferencia == 100){
		pricetransfe = 24;
	}else{
		pricetransfe = 48;
	}
	
	//alert(priceespacio+' - '+preciomemoria+' - '+pricetransfe+' - '+pricecentos);
	
	$("#preciototal").val((priceespacio)+parseInt(preciomemoria)+parseInt(pricetransfe)+parseInt(pricecentos));
	
}

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 compCheckBox(obj){
	if(obj.checked){
		duplicateContactData();
	}else{
		
		if (document.getElementById('i_countryid').selectedIndex==52){
			enableContactData(1);
		}
		else{
			enableContactData(0);
		}
			//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 copySingleCombo(camp, value){
	if(document.getElementById('c_copydata').checked){
		from = camp.substr(1,camp.length);
		document.getElementById('c'+from).selectedIndex = 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 = "ABCDEFGHJKLMNPQS";
	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 duplicateProvince(){
	
}

function duplicateContactData(){
	var a=confirm('¿Desea utilizar los mismos datos de Facturaci\u00F3n para Contacto?');
	if (a){
			
			if (document.getElementById('i_countryid').selectedIndex==52){
				showProvinceComboDuplicate('c_provinceid','c_layer_province',document.getElementById('i_provinceid').selectedIndex);	
			}
			else{
				showProvinceTextDuplicate('c_provinceid','c_layer_province',document.getElementById('i_provinceid').value);
			}	
			

	}
	else{
		document.getElementById('c_copydata').checked=false;
	}
}

function enableContactData(boolProvinceCombo){
	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_tratamientoId').disabled = false;
	
	document.getElementById('c_countryid').disabled = false;
	
	if(boolProvinceCombo==1){
		document.getElementById('c_provinceid').disabled = false;
	}
	else{
		document.getElementById('c_provinceid').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_tratamientoId').style.backgroundColor='#FFFFFF';
	document.getElementById('c_countryid').style.backgroundColor='#FFFFFF';
	document.getElementById('c_provinceid').style.backgroundColor='#FFFFFF';

}

function copyDisableFields(boolProvinceCombo){
	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').selectedIndex=document.getElementById('i_tratamientoId').selectedIndex;
	if(boolProvinceCombo==1){
		document.getElementById('c_provinceid').selectedIndex = document.getElementById('i_provinceid').selectedIndex;
	}
	else{
		document.getElementById('c_provinceid').value=document.getElementById('i_provinceid').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_tratamientoId').disabled = true;
	
	document.getElementById('c_countryid').disabled = true;
	if(boolProvinceCombo==1){
		document.getElementById('c_provinceid').disabled = true;
	}
	else{
		document.getElementById('c_provinceid').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_tratamientoId').style.backgroundColor='#F3F3F3';
	document.getElementById('c_countryid').style.backgroundColor='#F3F3F3';
	document.getElementById('c_provinceid').style.backgroundColor='#F3F3F3';
}

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('last_c_email').value!=document.getElementById('c_email').value){
					var res=confirm('Se ha modificado el email de contacto. Este cambio modificará el nombre de usuario de inicio de sesión al panel de control. Confirma desea realizar los cambios?');
					if(!res)
						return false;
				}
				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('duplicatedClient').value==1){
			alert("El email de contacto añadido esta duplicado en la base de datos. Este campo es el nombre que se utilizará para acceder al panel de control. Por favor introduzca otro email de contacto.");
			document.getElementById('c_email').focus();
			return false;
		}
		else 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;
				}
		}
		enableCombos();
			
				document.forms[0].submit();
}

function enableCombos(){
		document.getElementById('c_tratamientoId').disabled = false;
		document.getElementById('c_countryid').disabled = false;
		if (document.getElementById('i_countryid').selectedIndex==52){
			document.getElementById('c_provinceid').disabled = false;
		}
		else{
			document.getElementById('c_provinceid').readOnly = false;
		}
	document.getElementById('c_tratamientoId').style.backgroundColor='#FFFFFF';
	document.getElementById('c_provinceid').style.backgroundColor='#FFFFFF';
	document.getElementById('c_countryid').style.backgroundColor='#FFFFFF';
				
}

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_tratamientoId').disabled = false;
	document.getElementById('c_provinceid').disabled = false;
	document.getElementById('c_countryid').disabled = 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; 
				enableCombos();
		}
	} 	
	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_tratamientoId').disabled = false;
	document.getElementById('c_provinceid').disabled = false;
	document.getElementById('c_countryid').disabled = 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_tratamientoId').style.backgroundColor='#FFFFFF';
	document.getElementById('c_provinceid').style.backgroundColor='#FFFFFF';
	document.getElementById('c_countryid').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; 
				enableCombos();
		}
	} 
	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 showProvinceComboContact(fieldname,strLayer,strValue){
	var url="province_combo_ajax.php?fieldname="+fieldname+"&strValue="+strValue;

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

		if(xmlHttpShowProvinceCombContacto.readyState == 1 ) { 
			
		}
		else if(xmlHttpShowProvinceCombContacto.readyState == 4 ) {
				document.getElementById(strLayer).innerHTML = xmlHttpShowProvinceCombContacto.responseText;
				document.getElementById('c_provinceid').disabled = true;
				document.getElementById('c_provinceid').style.backgroundColor='#F3F3F3';
		}
	} 	
	xmlHttpShowProvinceCombContacto.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttpShowProvinceCombContacto.send(null); 	
}


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

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

		if(xmlHttpShowProvinceTextContact.readyState == 1 ) { 
			
		}
		else if(xmlHttpShowProvinceTextContact.readyState == 4 ) {
				document.getElementById(strLayer).innerHTML = xmlHttpShowProvinceTextContact.responseText; 
				document.getElementById('c_provinceid').readOnly = true;
				document.getElementById('c_provinceid').style.backgroundColor='#F3F3F3';
		}
	} 	
	xmlHttpShowProvinceTextContact.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttpShowProvinceTextContact.send(null); 	
}

function showProvinceComboDuplicate(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;
				copyDisableFields(1);
		}
	} 	
	xmlHttpShowProvinceCombo.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttpShowProvinceCombo.send(null); 	
}


function showProvinceTextDuplicate(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; 
				copyDisableFields(0);
		}
	} 	
	xmlHttpShowProvinceText.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttpShowProvinceText.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 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 validarPaso2c(){
	result=false;
		
	var numDomains=document.getElementById("numDomains").value;

	for(i=0;i<numDomains;i++){
		
		if(document.getElementById("domSelected_"+i).checked){
				result=true;
				i=numDomains;
		}
	}

	if(result){
		document.forms[0].action="contratar_paso_3.php?checkDom=2";
		document.forms[0].submit();
	}
	else{
		alert('Debe seleccionar algún dominio.');
		return false;
	}
	
}

function validarPaso3c(){
	if(document.getElementById('plan').value!=10){
		if(document.getElementById('otherDomainName').value==""){
			alert('Tiene que introducir un nombre de dominio asignado al alojamiento web.');
			document.getElementById('otherDomainName').focus();
			return false;
		}
		if(!comprueba_dominio(document.getElementById('otherDomainName').value,true)){
				document.getElementById('otherDomainName').focus();
				return false;
			}

	}
	document.forms[0].action="contratar_paso_4.php";
		document.forms[0].submit();
}

function validarPaso1(){
	if(document.all['nomdominio'].value==""){
		alert('Tiene que introducir un nombre de dominio.');
		document.all['nomdominio'].focus();
		return false;
	}

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

function userLogin(origen){
	if (origen == 2){
		document.forms[0].action="contratar_serv_3.php";
	}
	else{
		document.forms[0].action="contratar_paso_5.php";
	}
	document.forms[0].submit();
}

function userLoginSSL(origen){
	document.forms[0].action="contratar_ssl_2a.php";
	document.forms[0].submit();
}

function userLoginServidores(origen){
	document.forms[0].action="contratar_servidores_dedicados_2.php";
	document.forms[0].submit();
}

function validarPaso3(){

	if(document.getElementById('plan').value!=10){
		if(document.getElementById('mainExtension').value==0){
			if(document.getElementById('otherDomainName').value==""){
				alert('Tiene que introducir el dominio principal al que irá asociado el alojamiento');
				document.getElementById('otherDomainName').focus();
				return false;
			}
			if(!comprueba_dominio(document.getElementById('otherDomainName').value,true)){
				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 validarPasoSSL3(){
	if(confirm('Confirma que desea Contratar los servicios seleccionados?')){
		document.forms[0].action="contratar_ssl_4.php";
		document.forms[0].submit();
	}
}

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

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

function userRegister(origen){
	if (origen == 2){
		document.forms[0].action="contratar_serv_2b.php";
	}
	else{
		document.forms[0].action="contratar_paso_4b.php";
	}
	document.forms[0].submit();
}

function userRegisterSSL(origen){
	if (origen == 2){
		document.forms[0].action="contratar_ssl_2b.php";
	}
	else{
		document.forms[0].action="contratar_ssl_2b.php";
	}
	document.forms[0].submit();
}

function userRegisterServidor(origen){
	if (origen == 2){
		document.forms[0].action="contratar_servidor_dedicado2b.php";
	}
	else{
		document.forms[0].action="contratar_servidor_dedicado2b.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,isDomainMasive){

	xmlHttpShowMD=GetXmlHttpObject()
	if (xmlHttpShowPS==null){alert ("Browser does not support HTTP Request");return;} 
		var url="showMainDomain.php?plan_pay="+plan+"&nombreDominio="+nombreDominio+"&tipoDominio="+tipoDominio+"&isDomainMasive="+isDomainMasive;
		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 showDomainName(plan){

	xmlHttpShowMD=GetXmlHttpObject()
	if (xmlHttpShowPS==null){alert ("Browser does not support HTTP Request");return;} 
		var url="showDomainName.php?plan_pay="+plan;
		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 validaConsulta(){
		if(document.getElementById("nombre").value.length <= 0 || document.getElementById("nombre").value == 'Nombre y apellidos'){
			alert("Por favor, escriba un nombre de contacto.");
			document.getElementById("nombre").focus();
			return false;
		}
		if(document.getElementById("tel").value.length <= 0 || document.getElementById("tel").value == 'Teléfono'){
			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 || document.getElementById("email").value == 'E-Mail'){
			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='consulta_general.php';
		document.forms[0].submit();
}



function iraform(tipo){
	document.forms[0].action='contratar_serv_1.php';
	document.forms[0].submit();
}


		function validarMailConsulta(){
			if(document.getElementById('nombre').value.length <= 0){
				alert('Por favor, escriba un nombre de contacto.');
				document.getElementById('nombre').setfocus();
				return false;
			}
			else if(document.getElementById('tel').value.length <= 0){
				alert('Por favor, introduzca un telefono de contacto valido.');
				document.getElementById('tel').setfocus();
				return false;
			}
			else if(validarTelf(document.getElementById('tel').value) == false){
				alert('Por favor, introduzca un telefono de contacto valido.');
				document.getElementById('tel').setfocus();
				return false;
			}
			if(document.getElementById('email').value.length <= 0){
				alert('Por favor, introduzca una direccion de correo electronico valida.');
				document.getElementById('email').setfocus();
				return false;
			}
			else if(validarEmail(document.getElementById('email').value) == false){
				alert('Por favor, introduzca una direccion de correo electronico valida.');
				document.getElementById('email').setfocus();
				return false;
			}
			else if(document.getElementById('text').value.length <= 0){
				alert('Por favor, introduzca la consulta que desea realizar.');
				document.getElementById('text').setfocus();
				return false;
			alert('Formulario enviado correctamente. \nNos pondremos en contacto con usted lo antes posible.');
			return true;
		}
		document.forms[0].submit();
	}

function anularIntro(e){
	result=true;
	tecla=(document.all) ? e.keyCode : e.which;
  if(tecla==13)
  	result=false;

return result;
}

function loginKeyPress(e,form,origen){

	result=true;
	tecla=(form) ? e.keyCode : e.which;
		
  if(tecla==13){
  	result=false;
  	userLogin(origen);
	}

return result;
}

function loginSSLKeyPress(e,form,origen){

	result=true;
	tecla=(form) ? e.keyCode : e.which;
		
  if(tecla==13){
  	result=false;
  	userLoginSSL(origen);
	}

return result;
}

function loginServidoresKeyPress(e,form,origen){

	result=true;
	tecla=(form) ? e.keyCode : e.which;
		
  if(tecla==13){
  	result=false;
  	userLoginServidores(origen);
	}

return result;
}

function showContratoPopup(){
	window.open('contrato_serv_popup.php', 'popcontrato', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,left=350,top=250,width=350,height=200');
}

function contrato_dl_Popup(){
	location.href="documentos/api4.pdf";
	window.close();
}

function actualizarServ(div_name,optionId,optionTypeId){
	//alert(div_name);
	
	var xmlHttpActualizar = "xmlHttpActualizar"+optionTypeId;
	
	xmlHttpActualizar = GetXmlHttpObject()
	if (xmlHttpActualizar == null){alert ("Browser does not support HTTP Request");return;} 
		var url="show_change_ajax.php?opt="+optionId+"&optionTypeId="+optionTypeId;
		xmlHttpActualizar.open("GET",url,true)
		xmlHttpActualizar.onreadystatechange=function(){
			if(xmlHttpActualizar.readyState == 1 ) { 
			}
			else if(xmlHttpActualizar.readyState == 4 ) {
				//alert (xmlHttpClientData.responseText);
				document.getElementById(div_name).innerHTML = xmlHttpActualizar.responseText;
				
				
		actualizarPrecio();
			}
		} 	
		xmlHttpActualizar.send(null);
		
}

function showConectivityType(div_name,optionId,asd,optionTypeId){
	
	//alert(div_name);
	tipo=document.getElementById("tipo").value;
	alert("tipo: "+tipo);
	xmlHttpConectt = GetXmlHttpObject()
	if (xmlHttpConectt == null){alert ("Browser does not support HTTP Request");return;} 
		var url="show_conectivity_type_ajax.php?opt="+optionId+"&tipo="+tipo;
		xmlHttpConectt.open("GET",url,true)
		xmlHttpConectt.onreadystatechange=function(){
			if(xmlHttpConectt.readyState == 1 ) { 
			}
			else if(xmlHttpConectt.readyState == 4 ) {
				//alert (xmlHttpClientData.responseText);
				document.getElementById(div_name).innerHTML = xmlHttpConectt.responseText;

			}
		} 	
		xmlHttpConectt.send(null);
		
}


function updateConectType(conType,tipo){
	xmlHttpConectType = GetXmlHttpObject()
	if (xmlHttpConectType == null){alert ("Browser does not support HTTP Request");return;} 
		var url="show_conect_type_ajax.php?conType="+conType+"&tipo="+tipo;
		xmlHttpConectType.open("GET",url,true)
		xmlHttpConectType.onreadystatechange=function(){
			if(xmlHttpConectType.readyState == 1 ) { 
			}
			else if(xmlHttpConectType.readyState == 4 ) {
				//alert (xmlHttpClientData.responseText);
				document.getElementById("div_serverConect").innerHTML = xmlHttpConectType.responseText;

			}
		} 	
		xmlHttpConectType.send(null);
		
}

function updateConectExtType(conType,optionId){
	xmlHttpConectExtType = GetXmlHttpObject()
	if (xmlHttpConectExtType == null){alert ("Browser does not support HTTP Request");return;} 
		var url="show_conect_type_ext_ajax.php?conType="+conType+"&optionId="+optionId;
		xmlHttpConectExtType.open("GET",url,true)
		xmlHttpConectExtType.onreadystatechange=function(){
			if(xmlHttpConectExtType.readyState == 1 ) { 
			}
			else if(xmlHttpConectExtType.readyState == 4 ) {
				//alert (xmlHttpClientData.responseText);
				if(optionId != 11){
					document.getElementById("div_con").innerHTML = xmlHttpConectExtType.responseText;
				}
			}
		} 	
		xmlHttpConectExtType.send(null);
		
}


function updateConectExt(conType,optionId){
	xmlHttpConectExtType = GetXmlHttpObject()
	if (xmlHttpConectExtType == null){alert ("Browser does not support HTTP Request");return;} 
		var url="show_conect_type_ext_ajax.php?conType="+conType+"&optionId="+optionId;
		xmlHttpConectExtType.open("GET",url,true)
		xmlHttpConectExtType.onreadystatechange=function(){
			if(xmlHttpConectExtType.readyState == 1 ) { 
			}
			else if(xmlHttpConectExtType.readyState == 4 ) {
				document.getElementById("div_con").innerHTML = xmlHttpConectExtType.responseText;
				actualizarPrecio();
			}
		} 	
		xmlHttpConectExtType.send(null);
		
}

function actualizarPrecio(){

	precio =  parseFloat(document.getElementById("precio").value);
	precio += parseFloat(document.getElementById("price_ram").value);
	precio += parseFloat(document.getElementById("price_so").value);
	precio += parseFloat(document.getElementById("price_panel").value);
	precio += parseFloat(document.getElementById("price_bbdd").value);
	precio += parseFloat(document.getElementById("price_monit").value);
	precio += parseFloat(document.getElementById("price_conect").value);
	
	xmlHttpPriceUpdate = GetXmlHttpObject()
	if (xmlHttpPriceUpdate == null){alert ("Browser does not support HTTP Request");return;} 
		var url="show_total_ajax.php?precio="+precio;
		xmlHttpPriceUpdate.open("GET",url,true)
		xmlHttpPriceUpdate.onreadystatechange=function(){
			if(xmlHttpPriceUpdate.readyState == 1 ) { 
			}
			else if(xmlHttpPriceUpdate.readyState == 4 ) {
				document.getElementById("total_price").innerHTML = "<font style='FONT-SIZE: 15px;'><b>"+xmlHttpPriceUpdate.responseText+"</font>";
			}
		} 	
		xmlHttpPriceUpdate.send(null);
}

function actualizarPlesk(elementId){
	switch(elementId){
		case 14:
				document.getElementById("plesk_win").disabled = true;
				document.getElementById("plesk_lin").disabled = false;
				break;
		case 15:
				document.getElementById("plesk_win").disabled = false;
				document.getElementById("plesk_lin").disabled = true;
				break;
		default:
				document.getElementById("plesk_win").disabled = false;
				document.getElementById("plesk_lin").disabled = false;
	}
	
	document.getElementById("plesk_win").checked = false;
	document.getElementById("plesk_lin").checked = false;
	actualizarPleskWin(document.getElementById("plesk_win"));
	actualizarPleskLin(document.getElementById("plesk_lin"));
	
}

function actualizarPleskLin(doc){
	
	optId = 20;
	check = 0;
	
	if (doc.checked == true){
		check = 1;
		if (document.getElementById("plesk_win").checked == true){
			actualizarPleskWin("plesk_win");
			check = 1;
			optId = 20;
			document.getElementById("plesk_win").checked = false;
		}
	}
	else{
		optId = 32;
	}
	
	
	xmlHttpActualizarPleskLin=GetXmlHttpObject()
	if (xmlHttpActualizarPleskLin==null){alert ("Browser does not support HTTP Request");return;} 
		var url="update_plesk_lin.php?check="+check+"&optId="+optId;
		xmlHttpActualizarPleskLin.open("GET",url,true)
		xmlHttpActualizarPleskLin.onreadystatechange=function(){
			if(xmlHttpActualizarPleskLin.readyState == 1 ) { 
				
			}
			else if(xmlHttpActualizarPleskLin.readyState == 4 ) {
				//alert (xmlHttpClientData.responseText);
				resp2 = xmlHttpActualizarPleskLin.responseText;
				
				document.getElementById("linuxOpt_div").innerHTML = resp2;
			}
		} 	
		xmlHttpActualizarPleskLin.send(null);
	
	actualizarServ('div_plesk',optId,2,6);
}

function actualizarPleskWin(doc){
	
	optId = 17;
	check = 0;
	
	if (doc.checked == true){
		check = 1;
		if (document.getElementById("plesk_lin").checked == true){
			actualizarPleskLin("plesk_lin");
			check = 1;
			optId = 17;
			document.getElementById("plesk_lin").checked = false;
		}
	}
	else{
		optId = 32;
	}
	
	
	xmlHttpActualizarPleskWin=GetXmlHttpObject()
	if (xmlHttpActualizarPleskWin==null){alert ("Browser does not support HTTP Request");return;} 
		var url="update_plesk_win.php?check="+check+"&optId="+optId;
		xmlHttpActualizarPleskWin.open("GET",url,true)
		xmlHttpActualizarPleskWin.onreadystatechange=function(){
			if(xmlHttpActualizarPleskWin.readyState == 1 ) { 
				
			}
			else if(xmlHttpActualizarPleskWin.readyState == 4 ) {
				//alert (xmlHttpClientData.responseText);
				resp2 = xmlHttpActualizarPleskWin.responseText;
				
				document.getElementById("windowsOpt_div").innerHTML = resp2;
			}
		} 	
		xmlHttpActualizarPleskWin.send(null);
	
	actualizarServ('div_plesk',optId,1,6);
}


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

function changeWinEnabled(strEnabled){
	document.getElementById("cp_ext17").disabled = !strEnabled;
	document.getElementById("cp_ext18").disabled = !strEnabled;
	document.getElementById("cp_ext19").disabled = !strEnabled;
	if(strEnabled==false){
		document.getElementById("cp_ext17").checked = strEnabled;
		document.getElementById("cp_ext18").checked = strEnabled;
		document.getElementById("cp_ext19").checked = strEnabled;
	}
	actualizarServ('div_plesk',32,6);
}

function changeLinuxEnabled(strEnabled){
	document.getElementById("cp_ext20").disabled = !strEnabled;
	if(strEnabled==false)
		document.getElementById("cp_ext20").checked = strEnabled;
	actualizarServ('div_plesk',32,6);
}

function updateCheckPleskStatus(is_win,is_win_new){
	if(is_win_new==0){
		document.getElementById("plesk_win0").disabled = false;
		document.getElementById("plesk_win1").checked= false;
		document.getElementById("plesk_win1").disabled= true;
		disableWinCPRadio();
		if (is_win!=is_win_new){
			actualizarServ('div_plesk',32,6);
		}
	}
	else if(is_win_new==1){
		document.getElementById("plesk_win0").disabled = true;
		document.getElementById("plesk_win0").checked= false;
		document.getElementById("plesk_win1").disabled= false;
		disableLinuxCPRadio();
		if (is_win!=is_win_new){
			actualizarServ('div_plesk',32,6);
		}
	}
	else{
		document.getElementById("plesk_win0").disabled = true;
		document.getElementById("plesk_win1").disabled= true;
		document.getElementById("plesk_win0").checked= false;
		document.getElementById("plesk_win1").checked= false;
		disableWinCPRadio();
		disableLinuxCPRadio();
		
		actualizarServ('div_plesk',32,6);
	}
}

function disableWinCPRadio(){
	document.getElementById("cp_ext17").disabled = true;
	document.getElementById("cp_ext17").checked = false;
	document.getElementById("cp_ext18").disabled = true;
	document.getElementById("cp_ext18").checked = false;
	document.getElementById("cp_ext19").disabled = true;
	document.getElementById("cp_ext19").checked = false;
}

function disableLinuxCPRadio(){
	document.getElementById("cp_ext20").disabled = true;
	document.getElementById("cp_ext20").checked = false;
}


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

function minusculas(strText){
	return strText.toLowerCase();
}


function comprueba_dominio(nombre_dominio,boolNeedExtension)
{
var arr = new Array(
'.com','.net','.org','.biz','.coop','.info','.museum','.name',
'.pro','.edu','.gov','.int','.mil','.ac','.ad','.ae','.af','.ag',
'.ai','.al','.am','.an','.ao','.aq','.ar','.as','.at','.au','.aw',
'.az','.ba','.bb','.bd','.be','.bf','.bg','.bh','.bi','.bj','.bm',
'.bn','.bo','.br','.bs','.bt','.bv','.bw','.by','.bz','.ca','.cc',
'.cd','.cf','.cg','.ch','.ci','.ck','.cl','.cm','.cn','.co','.cr',
'.cu','.cv','.cx','.cy','.cz','.de','.dj','.dk','.dm','.do','.dz',
'.ec','.ee','.eg','.eh','.er','.es','.et','.eu','.fi','.fj','.fk','.fm',
'.fo','.fr','.ga','.gd','.ge','.gf','.gg','.gh','.gi','.gl','.gm',
'.gn','.gp','.gq','.gr','.gs','.gt','.gu','.gv','.gy','.hk','.hm',
'.hn','.hr','.ht','.hu','.id','.ie','.il','.im','.in','.io','.iq',
'.ir','.is','.it','.je','.jm','.jo','.jp','.ke','.kg','.kh','.ki',
'.km','.kn','.kp','.kr','.kw','.ky','.kz','.la','.lb','.lc','.li',
'.lk','.lr','.ls','.lt','.lu','.lv','.ly','.ma','.mc','.md','.me','.mg',
'.mh','.mk','.ml','.mm','.mn','.mo','.mp','.mq','.mr','.ms','.mt',
'.mu','.mv','.mw','.mx','.my','.mz','.na','.nc','.ne','.nf','.ng',
'.ni','.nl','.no','.np','.nr','.nu','.nz','.om','.pa','.pe','.pf',
'.pg','.ph','.pk','.pl','.pm','.pn','.pr','.ps','.pt','.pw','.py',
'.qa','.re','.ro','.rw','.ru','.sa','.sb','.sc','.sd','.se','.sg',
'.sh','.si','.sj','.sk','.sl','.sm','.sn','.so','.sr','.st','.sv',
'.sy','.sz','.tc','.td','.tf','.tg','.th','.tj','.tk','.tm','.tn',
'.to','.tp','.tr','.tt','.tv','.tw','.tz','.ua','.ug','.uk','.um',
'.us','.uy','.uz','.va','.vc','.ve','.vg','.vi','.vn','.vu','.ws',
'.wf','.ye','.yt','.yu','.za','.zm','.zw','.cat','.com.es','.org.es'
,'.nom.es','.edu.es');
var comprobacion = nombre_dominio;
var val = true;
var punto = comprobacion.indexOf(".");
var nombre_dominio = comprobacion.substring(0,punto);
var extension = comprobacion.substring(punto,comprobacion.length);

if(punto== -1 && !boolNeedExtension && comprobacion.toString().length>2){
    return true;
}
if(punto>2 && punto<57)
{
for(var i=0; i<arr.length; i++)
{
if(extension == arr[i])
{
val = true;
break;
}	
else
{
val = false;
}
}


if(val == false)
{
alert("la extensión del dominio "+extension+" no es correcta");
return false;
}
else
{
for(var j=0; j<nombre_dominio.length; j++)
{
var dh = nombre_dominio.charAt(j);
var hh = dh.charCodeAt(0);
if((hh > 47 && hh<59) || (hh > 64 && hh<91) || (hh > 96 && hh<123) || hh==45 || hh==46)
{
if((j==0 || j==nombre_dominio.length-1) && hh == 45)	
{
alert("El nombre del dominio no puede contener el símbolo guion '-' al principio ni al final");
return false;
}
}
else	{
alert("El dominio no puede contener carácteres especiales");
return false;
}
}
}
}
else
{
alert("El número de caracteres insertado no es correcto para el nombre de dominio. Posiblemente falte añadir el punto y la extesión.");
return false;
}	
return true;
}

function showBannerPopup(){
	window.open('http://www.prakton-news.com/news/praktonhost/01-04-09/');
}

function showUserName(newName){
	document.getElementById('username').value=newName;
		document.getElementById('layer_username').innerHTML = newName; 
	
}

function validateUsername(strUserName,intUserId) {

			var url="validate_username.php?strUserName="+strUserName+"&userId="+intUserId;
			
			xmlHttpValidateUserName=GetXmlHttpObject();
			xmlHttpValidateUserName.open("GET",url,true);
			xmlHttpValidateUserName.onreadystatechange=function(){
				
									if(xmlHttpValidateUserName.readyState == 1 ) { 
										//document.getElementById("layer_client_data").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(xmlHttpValidateUserName.readyState == 4 ) { 

										var resultado = xmlHttpValidateUserName.responseText;

										if(resultado==1){
											document.getElementById('alertas').style.display='block';
											document.getElementById("duplicatedClient").value=1;
										}
										else{
											document.getElementById('alertas').style.display='none';
											document.getElementById("duplicatedClient").value=0;
										}
									}
								} 
			xmlHttpValidateUserName.send(null); 
}	 

function invoiceMailChanges(obj,strUserName,intUserId){
	if(document.getElementById('c_copydata').checked==true){
			document.getElementById('alertas').style.display='none';
			document.getElementById("duplicatedClient").value=0;
			copySingle(obj.name,obj.value)
			showUserName(document.getElementById('i_email').value);
			validateUsername(strUserName,intUserId);
	}
}

function contactMailChanges(obj,strUserName,intUserId){
	document.getElementById('alertas').style.display='none';
	document.getElementById("duplicatedClient").value=0;
			showUserName(document.getElementById('c_email').value);
			validateUsername(strUserName,intUserId);

}

function calcPrices(certificate,years){

	if ( years == 1 ) {
	
		if ( certificate == 1 ) {
			document.all['precio'].value = 95;
		}else{
			if ( certificate == 2 ) {
				document.all['precio'].value = 150;
			}else{
				document.all['precio'].value = 350;
			}
		}
		
	}else{
		
		if ( certificate == 1 ) {
			document.all['precio'].value = 185;
		}else{
			if ( certificate == 2 ) {
				document.all['precio'].value = 285;
			}else{
				document.all['precio'].value = 665;
			}
		}	
	}
}

/* CONTRATACION ALOJAMIENTOS SUGARCRM */

function sugarSetprice(num){
	precio = document.getElementById('precio');
	switch(num){
	case "1":
		precio.value = 180;
		break;
	case "2":
		precio.value = 299;
		break;
	case "3":
		precio.value = 480;
		break;
	case "4":
		precio.value = 549;
		break;
	}
	
	showSugarDescription(num);
}

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

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

function userLoginCRM(origen){
	document.forms[0].action="contratar_sugarcrm_2a.php";
	document.forms[0].submit();
}

function userRegisterCRM(origen){
	if (origen == 2){
		document.forms[0].action="contratar_sugarcrm_2b.php";
	}
	else{
		document.forms[0].action="contratar_sugarcrm_2b.php";
	}
	document.forms[0].submit();
}

function showSugarDescription(num){
	var url="showsugar_description.php?idplan="+num;
	
	xmlHttpshowSugarDescription=GetXmlHttpObject();
	xmlHttpshowSugarDescription.open("GET",url,true);
	xmlHttpshowSugarDescription.onreadystatechange=function(){
		
		if(xmlHttpshowSugarDescription.readyState == 1 ) { 
		}else if(xmlHttpshowSugarDescription.readyState == 4 ) { 
			var resultado = xmlHttpshowSugarDescription.responseText;
			document.getElementById('crm_description').innerHTML=resultado;
		}
	} 
	xmlHttpshowSugarDescription.send(null);
}

function validateHomeDomain(nombre_dominio){
    var res=false;
    nombre_dominio=document.getElementById('domainname').value;
    res=comprueba_dominio(nombre_dominio,false);
    if(res){
        var comprobacion = nombre_dominio;
        var punto = comprobacion.indexOf(".");
       if(punto != -1){
            var nombre_dominio = comprobacion.substring(0,punto);
            var extension = comprobacion.substring(punto,comprobacion.length);
       }
       else{
           nombre_dominio=comprobacion;
           extension="";
       }
        
        prepareHomeDomainSearchValues(nombre_dominio,extension);
        document.forms[0].submit();
    }
    else{
        document.getElementById('domainname').focus();
    }
        
}

function prepareHomeDomainSearchValues(nombre_dominio,extension){
    switch(extension){
        case ".es":
            document.getElementById("top_es").value=1;
            break;
        case ".com":
            document.getElementById("top_com").value=1;
            break;
        case ".net":
            document.getElementById("top_net").value=1;
            break;
        case ".org":
            document.getElementById("top_org").value=1;
            break;
        case ".info":
            document.getElementById("top_info").value=1;
            break;
        case ".eu":
            document.getElementById("top_eu").value=1;
            break;
        case ".biz":
            document.getElementById("top_biz").value=1;
            break;
        case ".me":
            document.getElementById("top_me").value=1;
            break;
        case ".com.es":
            document.getElementById("top_com.es").value=1;
            break;
        case ".org.es":
            document.getElementById("top_org.es").value=1;
            break;
        case ".nom.es":
            document.getElementById("top_nom.es").value=1;
            break;
        case ".edu.es":
            document.getElementById("top_edu.es").value=1;
            break;
        case ".cat":
            document.getElementById("top_cat").value=1;
            break;
        case ".tv":
            document.getElementById("top_tv").value=1;
            break;
        default:
            document.getElementById("top_es").value=1;
            break;
    }
    document.getElementById('domainname').value=nombre_dominio;
}

function indexDomainNameKeyPress(e){
	result=true;
		tecla=(document.all) ? e.keyCode : e.which;
	  if(tecla==13){
	  	validateHomeDomain(document.getElementById("domainname").value);
	  	result=false;
	  }
	  	
	return result;
}