

function enviarFormulario(url, formid,resultado){

        var Formulario = document.getElementById(formid);
        var longitudFormulario = Formulario.elements.length;
        var cadenaFormulario = "";
        var sepCampos;
        sepCampos = "";
        for (var i=0; i <= Formulario.elements.length-1;i++) {
            cadenaFormulario += sepCampos+Formulario.elements[i].name+'='+encodeURI(Formulario.elements[i].value);
            sepCampos="&";
    }
	    peticion=createObject();
	    peticion.open("POST", url, true);
	    peticion.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=ISO-8859-1');
	    peticion.send(cadenaFormulario);
	    peticion.onreadystatechange = function() {
          if (peticion.readyState == 4 && (peticion.status == 200 || window.location.href.indexOf ("http") == - 1)){
            
                document.getElementById(resultado).innerHTML = peticion.responseText;
		//alert(peticion.responseText);
          }
    }
}

function enviarFormularioIcono(url, formid,resultado,icono){
	sepCampos = "";
		if (formid!=""){
        var Formulario = document.getElementById(formid);
        var longitudFormulario = Formulario.elements.length;
        var cadenaFormulario = "";
        var sepCampos;
        
        for (var i=0; i <= Formulario.elements.length-1;i++) {
            cadenaFormulario += sepCampos+Formulario.elements[i].name+'='+encodeURI(Formulario.elements[i].value);
            sepCampos="&";
    		}
		}
		document.getElementById(resultado).innerHTML=icono;
	    peticion=createObject();
	    peticion.open("POST", url, true);
	    peticion.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=ISO-8859-1');
	    peticion.send(cadenaFormulario);
		 
		
	    peticion.onreadystatechange = function() {
          if (peticion.readyState == 4 && (peticion.status == 200 || window.location.href.indexOf ("http") == - 1)){
            
                document.getElementById(resultado).innerHTML = peticion.responseText;
		//alert(peticion.responseText);
          }
    }
}

function enviarFormularioIconoLoginWidget(url, formid,resultado,icono){
	sepCampos = "";
		if (formid!=""){
        var Formulario = document.getElementById(formid);
        var longitudFormulario = Formulario.elements.length;
        var cadenaFormulario = "";
        var sepCampos;
        
        for (var i=0; i <= Formulario.elements.length-1;i++) {
            cadenaFormulario += sepCampos+Formulario.elements[i].name+'='+encodeURI(Formulario.elements[i].value);
            sepCampos="&";
    		}
		}
		document.getElementById(resultado).innerHTML=icono;
	    peticion=createObject();
	    peticion.open("POST", url, true);
	    peticion.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=ISO-8859-1');
	    peticion.send(cadenaFormulario);
		 
		
	    peticion.onreadystatechange = function() {
          if (peticion.readyState == 4 && (peticion.status == 200 || window.location.href.indexOf ("http") == - 1)){
            
                document.getElementById(resultado).innerHTML = peticion.responseText;
				errorTexto1="Necesita Activar su cuenta";
				errorTexto2="No existe el usuario";
				
	
	
	if ($('errorLogin')){
		if (errorTexto1.indexOf($('errorLogin').innerHTML)==-1 || errorTexto2.indexOf($('errorLogin').innerHTML)==-1)
		$valid=false;	
	}else{
			$valid=true;	
	}
	
	if ($valid)
		{
		if (document.quieresPreguntar)
		document.quieresPreguntar.action= "/respuestas/preguntar.php";
		
		if ($('detalleRespuesta'))
		$('detalleRespuesta').className="";	
		
		
		if ($('necesitaRegistro'))
		$('necesitaRegistro').className="hidden";	
		
		}
		
	
				
				
		//alert(peticion.responseText);
          }
    }
}



function enviarFormularioIconoPreguntar(url, formid,resultado,icono){

        var Formulario = document.getElementById(formid);
        var longitudFormulario = Formulario.elements.length;
        var cadenaFormulario = "";
        var sepCampos;
        sepCampos = "";
        for (var i=0; i <= Formulario.elements.length-1;i++) {
            cadenaFormulario += sepCampos+Formulario.elements[i].name+'='+encodeURI(Formulario.elements[i].value);
            sepCampos="&";
    }
		$(resultado).className='hidden';
		document.getElementById('icono').innerHTML=icono
	    peticion=createObject();
	    peticion.open("POST", url, true);
	    peticion.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=ISO-8859-1');
	    peticion.send(cadenaFormulario);
		 
		
	    peticion.onreadystatechange = function() {
          if (peticion.readyState == 4 && (peticion.status == 200 || window.location.href.indexOf ("http") == - 1)){
			//dealert(peticion.responseText);
			
            	if (peticion.responseText==""){
					 
					
					 
					 
					 document.getElementById('icono').innerHTML = "<table align='center'  style='margin:0px 0px 30px 10px'><tr><td>Gracias por publicar tu respuesta en Captalis.<br><br><a href='/respuestas/'>volver</a></td></tr></table>";	
					
					 
					 
				}else{
					 document.getElementById('icono').innerHTML='';
					$(resultado).className='';
					$('errorPregunta').value="Error al insertar la pregunta compruebe el formulario por favor.";
				}
			
			
		//alert(peticion.responseText);
          }
    }
}

function votoAjax(idRespuesta,IdPregunta,accion){
	 	peticion=createObject();
	 	peticion.open("POST", "/respuestas/ajax/votacion.php", true);
	    peticion.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=ISO-8859-1');
	    peticion.send('idRespuesta='+idRespuesta+'&IdPregunta='+IdPregunta+'&accion='+accion);
		 
		
	    peticion.onreadystatechange = function() {
          if (peticion.readyState == 4 && (peticion.status == 200 || window.location.href.indexOf ("http") == - 1)){
         
			//alert(peticion.responseText);
               if (peticion.responseText == "OK"){
				   if (accion=="suma")
				   $(accion+idRespuesta).innerHTML=parseInt($(accion+idRespuesta).innerHTML)+1;
				   else
				   $(accion+idRespuesta).innerHTML=parseInt($(accion+idRespuesta).innerHTML)+1;
			   }
	
          }
    }
}


function enviarObjetoIcono(url, objeto,resultado,icono){

     	cadenaFormulario=objeto+'='+$(objeto).value;
       
		document.getElementById(resultado).innerHTML=icono;
		
	    peticion=createObject();
	    peticion.open("POST", url, true);
	    peticion.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=ISO-8859-1');
	    peticion.send(cadenaFormulario);
		 
		
	    peticion.onreadystatechange = function() {
          if (peticion.readyState == 4 && (peticion.status == 200 || window.location.href.indexOf ("http") == - 1)){
            
                document.getElementById(resultado).innerHTML = peticion.responseText;
	
          }
    }
}


function enviarFormularioDos(url, formid,resultado){

        var Formulario = document.getElementById(formid);
        var longitudFormulario = Formulario.elements.length;
        var cadenaFormulario = "";
        var sepCampos;
        sepCampos = "";
        for (var i=0; i <= Formulario.elements.length-1;i++) {
            cadenaFormulario += sepCampos+Formulario.elements[i].name+'='+encodeURI(Formulario.elements[i].value);
            sepCampos="&";
    }
	    peticion=createObject();
	    peticion.open("POST", url, true);
	    peticion.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=ISO-8859-1');
	    peticion.send(cadenaFormulario);
	    peticion.onreadystatechange = function() {
          if (peticion.readyState == 4 && (peticion.status == 200 || window.location.href.indexOf ("http") == - 1)){
             
            //	
           
           var sliderizq = new Fx.Slide('sliderizq',
					{
					mode:'vertical',
					duration: 1000,
					wait: false					
					});
            	
            	
            	
                document.getElementById(resultado).innerHTML = peticion.responseText;
           	    sliderizq.hide();
                
				
				
				
				 
				// 
				
				 
				     sliderizq.slideIn();
				     	
				 (function(){	
				  
				   	$('sliderizq').setStyle('visibility','visible');
				   			$('iconoAjax').setStyle('visibility','hidden');
				 	  
				 	 
				 	   }).delay(800);
				 				
		
				
				 	
          }
    }
}

function createObject()
{
	var xmlHttp;
	try
	  {
	  // Firefox
	  xmlHttp=new XMLHttpRequest();
	  }
	catch (e)
	  {
	  // Internet Explorer
	  try
	    {
	    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	    }
	  catch (e)
	    {
	    try
	      {
	      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	      }
	    catch (e)
	      {
	      alert("Your browser does not support AJAX!");
	      return false;
	      }
	    }
	  }
	  return xmlHttp;
}


	
function orderby(path,order)
{ 
	var xmlHttp;
	
	xmlHttp = createObject();

	   xmlHttp.onreadystatechange=function()
	   {
			/*if (xmlHttp.readyState==1)
			{
				document.getElementById("ajax_loader").style.display="";
			}*/
			if(xmlHttp.readyState==4)
			  {
			  	document.getElementById("vertical_slide").innerHTML=xmlHttp.responseText;
			  	//document.getElementById("ajax_loader").style.display="none";
			  	
			  }
		}
		var status = {
		'true': 'open',
		'false': 'close'
		};
		
		var myVerticalSlide = new Fx.Slide('vertical_slide');
		if (status[myVerticalSlide.open] == "open")
			myVerticalSlide.hide();
			
		xmlHttp.open("GET",path+order+"/",true);
		xmlHttp.send(null);
		setTimeout("var myVerticalSlide = new Fx.Slide('vertical_slide'); myVerticalSlide.slideIn()",500);
		
		
		
		
		
		
	/*	var blind_hidden;
		blind_hidden = new Spry.Effect.Blind("vertical_slide", {duration: 4000, from: '0%', to: '100%', toggle: true});
		blind_hidden.start();*/

  }
  
function changeProvincia()
{ 
	
	idProvincia=$('cbo_provincia').value;
	var xmlHttp;
	
	xmlHttp = createObject();

	   xmlHttp.onreadystatechange=function()
	   {
			if(xmlHttp.readyState==4)
			  {
			 
			  $('cmp_cbo_municipio').innerHTML=xmlHttp.responseText;
		  	
			  }
		}
		
		xmlHttp.open("GET","/provinciasajaxnuevo.php?id_prov="+idProvincia,true);
		xmlHttp.send(null);
		

  }
  
    function changeProvinciaLandingCambiaDoble()
{ 
	
	idProvincia=$('txt_provinciahipoteca').value;
	var xmlHttp;
	
	xmlHttp = createObject();

	   xmlHttp.onreadystatechange=function()
	   {
			if(xmlHttp.readyState==4)
			  {
			 
			  $('cmp_txt_localidadhipoteca').innerHTML=xmlHttp.responseText;
		  	
			  }
		}
		
		xmlHttp.open("GET","./provinciasajaxnuevo.php?id=localidadHipoteca&id_prov="+idProvincia,true);
		xmlHttp.send(null);
		

  }
  
  
  function changeProvinciaLandingCambia()
{ 
	
	idProvincia=$('cbo_provincia').value;
	var xmlHttp;
	
	xmlHttp = createObject();

	   xmlHttp.onreadystatechange=function()
	   {
			if(xmlHttp.readyState==4)
			  {
			 
			  $('cmp_cbo_municipio').innerHTML=xmlHttp.responseText;
		  	
			  }
		}
		
		xmlHttp.open("GET","/provinciasajaxnuevo.php?id_prov="+idProvincia,true);
		xmlHttp.send(null);
		

  }
  
 function registroAjax()
{ 
	
	
	var xmlHttp;
	
	xmlHttp = createObject();

	   xmlHttp.onreadystatechange=function()
	   {
			if(xmlHttp.readyState==4)
			  {
			 
			  $('registro').innerHTML=xmlHttp.responseText;
		  	
			  }
		}
		
		xmlHttp.open("POST","registroAccion.php",true);
		xmlHttp.send(null);
	
		

  }
  	
function orderbyPorEntidad(path)
{ 
	var xmlHttp;
	
	xmlHttp = createObject();

	   xmlHttp.onreadystatechange=function()
	   {
			/*if (xmlHttp.readyState==1)
			{
				document.getElementById("ajax_loader").style.display="";
			}*/
			if(xmlHttp.readyState==4)
			  {
			  	document.getElementById("vertical_slide").innerHTML=xmlHttp.responseText;
			  	//document.getElementById("ajax_loader").style.display="none";
			  	
			  }
		}
		var status = {
		'true': 'open',
		'false': 'close'
		};
		
		var myVerticalSlide = new Fx.Slide('vertical_slide');
		if (status[myVerticalSlide.open] == "open")
			myVerticalSlide.hide();
			
		xmlHttp.open("GET",path,true);
		xmlHttp.send(null);
		setTimeout("var myVerticalSlide = new Fx.Slide('vertical_slide'); myVerticalSlide.slideIn()",500);
		
		
		
		
		
		
	/*	var blind_hidden;
		blind_hidden = new Spry.Effect.Blind("vertical_slide", {duration: 4000, from: '0%', to: '100%', toggle: true});
		blind_hidden.start();*/

  }
  
 function pagina(path,order,page)
{ 
	var xmlHttp;
	
	xmlHttp = createObject();

	   xmlHttp.onreadystatechange=function()
	   {

			if(xmlHttp.readyState==4)
			  {
			  	document.getElementById("vertical_slide").innerHTML=xmlHttp.responseText;
			  	
			  }
		}
		/*var status = {
		'true': 'open',
		'false': 'close'
		};
		
		var myVerticalSlide = new Fx.Slide('vertical_slide');
		if (status[myVerticalSlide.open] == "open")
			myVerticalSlide.hide();*/
		xmlHttp.open("GET",path+order+"/"+page+"/",true);
		xmlHttp.send(null);
	//s	setTimeout("var myVerticalSlide = new Fx.Slide('vertical_slide'); myVerticalSlide.slideIn()",500);
		setTimeout("activaOpciones();",400);
		
		
	/*	var blind_hidden;
		blind_hidden = new Spry.Effect.Blind("vertical_slide", {duration: 4000, from: '0%', to: '100%', toggle: true});
		blind_hidden.start();*/

  }
   
  
 function show(path,id)
{ 
	var xmlHttp;
	xmlHttp = createObject();
	  	xmlHttp.onreadystatechange=function()
		{
			/*if (xmlHttp.readyState==1)
			{
				document.getElementById("ajax_loader").style.display="";
			}*/
			if(xmlHttp.readyState==4)
			  {
			  	document.getElementById(id).innerHTML=xmlHttp.responseText;
			  //	document.getElementById("ajax_loader").style.display="none";
			  	
			  }
		}
		xmlHttp.open("GET",path+"/",true);
		xmlHttp.send(null);
		return true;
  }
function wizardADSLValidacion() {
mantenimiento=document.wizardAd.mantenimiento.options[document.wizardAd.mantenimiento.selectedIndex].value;
  if($('cuotaMensual').value!=' Cuota Mensual' && mantenimiento!="z"){
  $('cuotaMensual').set('style','background-color:#EFF1F2;border-color:#5794BF #3C7FB1 #C7E2F1 #C7E2F1;border-style:solid;border-width:1px ;color:#676760 ;font-size:11px;width:100px');
  $('mantenimiento').set('style','background-color:#EFF1F2;border-color:#5794BF #3C7FB1 #C7E2F1 #C7E2F1;border-style:solid;border-width:1px ;color:#676760 ;font-size:11px;width:120px');
  wizardADSL();
  }else{ if($('cuotaMensual').value==' Cuota Mensual'){ 
  $('cuotaMensual').set('style','background-color:#ffd4d4;border-color:#5794BF #3C7FB1 #C7E2F1 #C7E2F1;border-style:solid;border-width:1px ;color:#676760 ;font-size:11px;width:100px');
  }
   if(mantenimiento=='z'){ 
  $('mantenimiento').set('style','background-color:#ffd4d4;border-color:#5794BF #3C7FB1 #C7E2F1 #C7E2F1;border-style:solid;border-width:1px ;color:#676760 ;font-size:11px;width:120px');
  }
  }
 
 
 }
 function textoadslfinal(testo){
  $('textoWizard').innerHTML="<div style='padding:4px 7px 4px 7px;color:#000000; border:1px solid #d7d7d7; background-color:#fffec3'>Puedes ahorrar hasta <font style='font-size:12px;font-weight:bold;color:#7f8900'>"+testo+" al a&ntilde;o</font>. Mira las ofertas abajo</div>";
 }
 
  function wizardADSL() {
    var myVerticalSlide = new Fx.Slide('vertical_slide');
	myVerticalSlide.hide(); 
document.getElementById("iconoAjax").innerHTML="<br><br><table align='center'><tr><td><img src='/images/canal_3/ajaxloader.gif'></td></tr></TABLE>";
  
cuota=$('cuotaMensual').value;
mantenimiento=document.wizardAd.mantenimiento.options[document.wizardAd.mantenimiento.selectedIndex].value;
//mantenimiento=$('mantenimiento').options[$('mantenimiento').selectedIndex].value;
cuota=parseFloat(mantenimiento)+parseFloat(cuota);

velocidad=document.wizardAd.velocidad.options[document.wizardAd.velocidad.selectedIndex].value;
total=Decimales(cuota*12,2);
$('resultadoWizardADSL').innerHTML="<table style='padding-top:8px' cellpadding='0' cellspacing='0'><tr><td width='40' ><img src='/images/canal/flechaWizard.jpg'></td><td align='center' ><b>Coste Anual</b><br><div style='color:#0c6df8;font-size: 15pt;padding-top:3px'>"+total+" &euro; </div></td></tr></table><div  style='cursor:pointer;padding-top:0px;color:#3C890D; width:200px;text-align:right;float:right;font-size: 8pt;' ><img src='/images/canal/refresh.jpg' tittle='Volver a Calcular' onClick='if($(\"cuotaMensual\").value!=\" Cuota Mensual\"){$(\"cuotaMensual\").set(\"style\",\"background-color:#EFF1F2;border-color:#5794BF #3C7FB1 #C7E2F1 #C7E2F1;border-style:solid;border-width:1px ;color:#676760 ;font-size:11px;width:100px\");wizardADSL();}else{$(\"cuotaMensual\").set(\"style\",\"background-color:#ffd4d4;border-color:#5794BF #3C7FB1 #C7E2F1 #C7E2F1;border-style:solid;border-width:1px ;color:#676760 ;font-size:11px;width:100px\");}'  style='cursor:pointer'  alt='Volver a Calcular '></div> ";

  
  var xmlHttp;
	
	xmlHttp = createObject();

	   xmlHttp.onreadystatechange=function()
	   {
			/*if (xmlHttp.readyState==1)
			{
				document.getElementById("ajax_loader").style.display="";
			}*/
			if(xmlHttp.readyState==4)
			  {
			  	document.getElementById("vertical_slide").innerHTML=xmlHttp.responseText;
			  	myVerticalSlide.slideIn();
			  	document.getElementById("iconoAjax").innerHTML="";
			  	if ($('ahorroAnualFinal')){
			  	(function(){ textoadslfinal($('valorAhorro').innerHTML)}).delay(400);
			  	}
			  	//document.getElementById("ajax_loader").style.display="none";
			  	
			  }
		}
		var status = {
		'true': 'open',
		'false': 'close'
		};
		
		
				
		xmlHttp.open("GET","/adsl/ajaxWizardAdsl.php?wizardADSL=1&total="+total+"&velocidad="+velocidad,true);
		xmlHttp.send(null);
		 
		

		
		
		
		
		
  }
