var xmlhttp
var xmlhttp2
var xmlhttp3
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
  try {
  xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
  xmlhttp2=new ActiveXObject("Msxml2.XMLHTTP");
  xmlhttp3=new ActiveXObject("Msxml2.XMLHTTP");
  tipo ='firefox';
 } catch (e) {
  try {
  	tipo = 'explorer';
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	 xmlhttp2=new ActiveXObject("Msxml2.XMLHTTP");
  xmlhttp3=new ActiveXObject("Msxml2.XMLHTTP");
  } catch (E) {
   xmlhttp=false;
    xmlhttp2=false;
  xmlhttp3=false;
  }
 }
@else
 xmlhttp=false
 xmlhttp2=false;
  xmlhttp3=false;
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
 try {
  xmlhttp = new XMLHttpRequest();
 } catch (e) {
  xmlhttp=false
 }
}
if (!xmlhttp2 && typeof XMLHttpRequest!='undefined') {
 try {
  xmlhttp2 = new XMLHttpRequest();
 } catch (e) {
  xmlhttp2=false
 }
}
if (!xmlhttp3 && typeof XMLHttpRequest!='undefined') {
 try {
  xmlhttp3 = new XMLHttpRequest();
 } catch (e) {
  xmlhttp3=false
 }
}

function Decimales(Numero, Decimales) {
pot = Math.pow(10,Decimales);
num = parseInt(Numero * pot) / pot;
nume = num.toString().split('.');
if(nume.length==1) {
  var deci='';
  for(i=0;i<Decimales;i++)
    deci+=String.fromCharCode(48);
  num=nume+'.'+deci;
}
return num;
}

function IsNumeric(sText)

{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }
function calcular(){
	var cantidad= document.getElementById('cantidad');
	var resultado= document.getElementById('resultado');
	var meses= document.getElementById('meses');
	if (cantidad.value=='')
	resultado.innerHTML='';
	else
	{
	if (meses.value!=0)
	{
	
	if (IsNumeric(meses.value) || (IsNumeric(cantidad.value)))
	{
		var cuota = meses.value*cantidad.value;
		cuota = cuota.toFixed(2);
		if (cuota>18)
		resultado.innerHTML='Cuota mensual:<br /><strong>'+cuota+' &euro;/mes</strong>'
		else
		resultado.innerHTML='Cuota mensual:<br /><strong style="color:red">Lo sentimos, la cuota mínima es de 18 &euro;/mes</strong>'
	}
	}
	else
	resultado.innerHTML='';
	}
}

function validarEmail(valor) {
  if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(valor)){
   return (true)
  } else {
      return (false);
  }
}
		var enviar ='no';
			function trim(stringToTrim) {
			return stringToTrim.replace(/^\s+|\s+$/g,"");
		}
function comprobarcontacto(){
var msgerror='';
var telefono = trim(document.f.telefono.value);

if (document.f.nombre.value=='') 
	msgerror = '* Nombre completo\n';
	
	if (document.f.metros.value=='') 
		msgerror += '* Nº de metros a instalar\n';
	
if (telefono=='') 
	{
	msgerror += msgerror +'* Teléfono\n';
	}
else
	{
	if (!IsNumeric(telefono)) 
		msgerror += msgerror +'* El teléfono ha de ser un número\n';
	}
	
if (document.f.email.value=='') 
	msgerror += '* Email\n';
else
	{
	if (validarEmail(document.f.email.value)==false)
		msgerror = msgerror +'* El Email parece incorrecto\n';
	}
	
if (!document.f.acepto.checked) 
	msgerror = msgerror +'* Aceptar política de privacidad\n';
	
if (msgerror==''){
 if ((telefono.length)<9)
 	msgerror = '* El teléfono ha de tener 9 cifras como mínimo\n';
	document.f.telefono.focus();
}
if (msgerror!=''){
	alert('Los siguientes campos son obligatorios:\n\n'+msgerror);
	return false;
	}
else{

	document.f.action='enviarpresupuesto.php';
	document.f.submit();
	return false;	

}
}
function financi(){
	if (document.getElementById('cantidad'))
		{
			if (parseFloat(document.getElementById('metrosx').value))
			{
			var precio=(document.getElementById('precio').value*document.getElementById('metrosx').value);
			document.getElementById('cantidad').value=Decimales(precio,2);
			}
		}
}

function comprobarcontacto2(){
var msgerror='';
var telefono = trim(document.f.telefono.value);

if (document.f.nombre.value=='') 
	msgerror = '* Nombre completo\n';
	
if (telefono=='') 
	{
	msgerror += msgerror +'* Teléfono\n';
	}
else
	{
	if (!IsNumeric(telefono)) 
		msgerror += msgerror +'* El teléfono ha de ser un número\n';
	}
	
if (document.f.email.value=='') 
	msgerror += '* Email\n';
else
	{
	if (validarEmail(document.f.email.value)==false)
		msgerror = msgerror +'* El Email parece incorrecto\n';
	}
	
if (!document.f.acepto.checked) 
	msgerror = msgerror +'* Aceptar política de privacidad\n';
	
if (msgerror==''){
 if ((telefono.length)<9)
 	msgerror = '* El teléfono ha de tener 9 cifras como mínimo\n';
	document.f.telefono.focus();
}
if (msgerror!=''){
	alert('Los siguientes campos son obligatorios:\n\n'+msgerror);
	return false;
	}
else{

	document.f.action='enviarcontacto2.php';
	document.f.submit();
	return false;	

}
}
function ccc(){
var msgerror='';
formulario =document.getElementById('buscar');

if (formulario.ciudad.value=='') 
	msgerror = msgerror +'* Por favor, indicanos la ciudad donde deseas buscar\n';

if (msgerror!=''){
	alert('Los siguientes campos son obligatorios:\n\n'+msgerror);
	return false;
	}
else{
	return true;	

}
}
var inicio=10;
var bgcolorxx="F6F6F6";
function cargarmas(idcarga,dominio,ciudad,operacion){
	var url = dominio+'mostrarlistado.php?bgcolor='+bgcolorxx+'&dominio='+dominio+'&inicio='+inicio+'&ciudad='+ciudad+'&operacion='+operacion;
	document.getElementById('enlacecarga'+idcarga).style.display='none';
//	window.open (url);
	xmlhttp.open("GET",url,true);
	
	xmlhttp.onreadystatechange=function() {
	if (xmlhttp.readyState==4) {
		data = xmlhttp.responseText;
		document.getElementById('cargarmas'+idcarga).innerHTML=data;
		inicio=inicio+5;
		if (bgcolorxx=="F6F6F6")
			bgcolorxx="FFFFFF";
	}
	}
	xmlhttp.setRequestHeader('Accept','message/x-jl-formresult');
	xmlhttp.send(null);

	return false;
}