
 

function guia_getRequest() 
{
  var req;
  if (window.XMLHttpRequest) {
    try { req = new XMLHttpRequest(); }
    catch (e) {}
  } else if (window.ActiveXObject) {
    try { req = new ActiveXObject("Msxml2.XMLHTTP"); }
    catch (e) {
      try { req = new ActiveXObject("Microsoft.XMLHTTP"); }
      catch (e) {}
    }
  }
  return req;
}// guia_getRequest
 

var req;


var que_enlace;
function en_enviar(aa) 
{
 	aa = 1; 
	req = guia_getRequest();
	var resultados = function() 
	{
	    if (req.readyState == 4) 
		{
    	  if (req.status == 200) 
		  {
	       	//alert(req.responseText);
			ejecutaresultado();		
	      }
    	}
	  };
	
	req.onreadystatechange = resultados ; 
	if(aa==""){return;}

	aa = encodeURIComponent(aa) ;

	var en_n_1 = document.getElementById("en_nombre_1").value; 
	var en_e_1 = document.getElementById("en_email_1").value; 
	var en_n_2 = document.getElementById("en_nombre_2").value; 
	var en_e_2 = document.getElementById("en_email_2").value; 
	var en_t = document.getElementById("en_texto").value; 
	//alert(document.getElementById("en_nombre_1"));
	//alert(document.getElementById("en_nombre_1").value);

	var data = "aa=" +aa+"&en_nombre_1=" +en_n_1+"&en_email_1=" +en_e_1+"&en_nombre_2=" +en_n_2+"&en_email_2=" + en_e_2+"&en_texto=" + en_t
	
	//alert(data);
	
	
	document.getElementById("enviar_cerrar_m").innerHTML= "<div class='linea_enviar_m'>Enviando</div>";
	
	req.open("POST", "/en_enviar.php", true) ; 
	req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded") ; 
	req.setRequestHeader("Accept-Charset", "UTF-8");
	req.setRequestHeader("Content-Length" , data.length) ; 
	req.send(data) ;
	//alert(data);
}




function en_contacto(aa) 
{
 
 	aa = 1; 
	req = guia_getRequest();
	var resultados = function() 
	{
	    if (req.readyState == 4) 
		{
    	  if (req.status == 200) 
		  {
	       	//alert(req.responseText);
			ejecutaresultado_2();		
	      }
    	}
	  };
	
	req.onreadystatechange = resultados ; 
	if(aa==""){return;}

	aa = encodeURIComponent(aa) ;

	var en_n_1 = document.getElementById("co_nombre_1").value; 
	var en_e_1 = document.getElementById("co_email_1").value; 
	var en_t = document.getElementById("co_texto").value; 

	var data = "aa=" +aa+"&en_nombre_1=" + en_n_1+"&en_email_1=" + en_e_1+"&en_texto=" + en_t;
	
	
	
	document.getElementById("contacto_cerrar_m").innerHTML= "<div class='linea_enviar_m'>Enviando</div>";
	
	req.open("POST", "/en_consulta.php", true) ; 
	req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded") ; 
	req.setRequestHeader("Accept-Charset", "UTF-8");
	req.setRequestHeader("Content-Length" , data.length) ; 
	req.send(data) ;
	//alert(data);
}



//function ejecutaresultado()
function ejecutaresultado()
{
	var mensaje="";
	validaciones_ok = "1";
	// se leen los datos de vuelta
	 
	var respuesta = req.responseXML.getElementsByTagName("respuesta") ; 
	var error = req.responseXML.getElementsByTagName("er") ; 
	if ( respuesta.length>0)
	{
		validaciones_ok = "1";
		mensaje = respuesta[0].getAttribute("texto");
		f_contacto_close();
		document.getElementById("enviar_cerrar_m").innerHTML= "";
		//document.getElementById("contacto_cerrar_m").innerHTML= "<div class='linea_enviar_m'>Enviando</div>";
		
		alert(mensaje); 
	}
	else if ( error.length>0 )
	{
		mensaje="";
		for ( var i=0; i<error.length; i++ )
		{
			mensaje =mensaje+ "<p>"+error[i].getAttribute("texto")+"</p>";
			// se pone el texto
			document.getElementById("enviar_cerrar_m").innerHTML= "<div class='linea_enviar_m'>"+mensaje+"</div>";
		}
	}
	else
	{
		// se pone el texto
		document.getElementById("enviar_cerrar_m").innerHTML= "<div class='linea_enviar_m'>"+mensaje+"</div>";
	}
}


//function ejecutaresultado()
function ejecutaresultado_2()
{
	var mensaje="";
	validaciones_ok = "1";
	// se leen los datos de vuelta
	 
	var respuesta = req.responseXML.getElementsByTagName("respuesta") ; 
	var error = req.responseXML.getElementsByTagName("er") ; 
	if ( respuesta.length>0)
	{
		validaciones_ok = "1";
		mensaje = respuesta[0].getAttribute("texto");
		f_contacto_close();
		//document.getElementById("enviar_cerrar_m").innerHTML= "<div class='linea_enviar_m'>Enviando</div>";
		document.getElementById("contacto_cerrar_m").innerHTML= "";
		
		alert(mensaje); 
	}
	else if ( error.length>0 )
	{
		mensaje="";
		for ( var i=0; i<error.length; i++ )
		{
			mensaje =mensaje+ "<p>"+error[i].getAttribute("texto")+"</p>";
			// se pone el texto
			document.getElementById("contacto_cerrar_m").innerHTML= "<div class='linea_enviar_m'>"+mensaje+"</div>";
		}
	}
	else
	{
		// se pone el texto
		document.getElementById("contacto_cerrar_m").innerHTML= "<div class='linea_enviar_m'>"+mensaje+"</div>";
	}
}







addEvent(window, "load", f_contacto_ini );
	
var html_enviar_popup='';var html_enviar_popup_ok='';
var html_contacto_popup='';var html_contacto_popup_ok='';
var html_compartir_popup='';var html_compartir_popup_ok='';


function f_contacto_ini()
{ 

	if (document.getElementById ("he_consulta") )
	{
		document.getElementById("he_consulta").onclick = function () { f_contacto(this); }  	
		document.getElementById("he_consulta").href = 'javascript:void("null")';
	}
	
	if (document.getElementById ("he_enviar") )
	{
		document.getElementById("he_enviar").onclick = function () { f_enviar(this); }  	
		document.getElementById("he_enviar").href = 'javascript:void("null")';
	}
	if (document.getElementById ("he_compartir") )
	{
		document.getElementById("he_compartir").onclick = function () { f_compartir(this); }  	
		document.getElementById("he_compartir").href = 'javascript:void("null")';
	}
	
	
	
	if (document.getElementById ("contacto_cerrar")) { document.getElementById ("contacto_cerrar").onclick = function () 	{  f_contacto_close(); } }
	if (document.getElementById ("enviar_cerrar")) { document.getElementById ("enviar_cerrar").onclick = function () 		{  f_contacto_close(); } }
	if (document.getElementById ("compartir_cerrar")) { document.getElementById ("compartir_cerrar").onclick = function () 	{  f_contacto_close(); } }
	
	if( document.getElementById("contacto_popup") ){}else{return true; }
	
	
	html_contacto_popup+='<div id="contacto_popup2"><div id="contacto_popup3">		';
	html_contacto_popup+='<p><a id="contacto_cerrar" href="javascript:f_contacto_close()"><span>Cerrar</span></a></p>	';
	html_contacto_popup+='<form action="#" name="formPesContacto" id="formPesContacto" method="post">	';
	html_contacto_popup+='<ul>	';
	html_contacto_popup+='	<li>	';
	html_contacto_popup+='		<label for="co_nombre_1">	';
	html_contacto_popup+='			<span>'+texto_1+'*</span>	';
	html_contacto_popup+='			<input type="text" name="co_nombre_1"  id="co_nombre_1" />	';
	html_contacto_popup+='		</label>	';
	html_contacto_popup+='	</li>	';
	html_contacto_popup+='	<li>	';
	html_contacto_popup+='		<label for="co_email_1">	';
	html_contacto_popup+='			<span>E-mail*</span>	';
	html_contacto_popup+='			<input type="text" name="co_email_1"  id="co_email_1" />	';
	html_contacto_popup+='		</label>	';
	html_contacto_popup+='	</li>	';
	html_contacto_popup+='	<li>	';
	html_contacto_popup+='		<label for="co_texto">	';
	html_contacto_popup+='			<span>'+texto_3+'*</span>	';
	html_contacto_popup+='			<textarea  name="co_texto"  id="co_texto" ></textarea>	';
	html_contacto_popup+='		</label>	';
	html_contacto_popup+='	</li>	';
	html_contacto_popup+='	<li style="padding:0;">	';
	html_contacto_popup+='		<button type="button" onclick="en_contacto(1)"><span>'+texto_8+'</span></button>	';
	html_contacto_popup+='	</li>	';
	html_contacto_popup+='	</ul>	';
	html_contacto_popup+='	</form>	';
	html_contacto_popup+='<div id="contacto_cerrar_m" ></div>';
	html_contacto_popup+='	</div></div>	';
	document.getElementById("contacto_popup").innerHTML = html_contacto_popup ;
	

	html_enviar_popup+='<div id="enviar_popup2"><div id="enviar_popup3">	';
	html_enviar_popup+='<p><a id="enviar_cerrar" href="javascript:f_contacto_close()"><span>Cerrar</span></a></p>	';
	html_enviar_popup+='<form action="#" name="formPesContacto" id="formPesContacto" method="post">	';
	html_enviar_popup+='<ul>	';
	html_enviar_popup+='	<li>	';
	html_enviar_popup+='		<label for="en_nombre_1">	';
	html_enviar_popup+='			<span>'+texto_4+'*</span>	';
	html_enviar_popup+='			<input type="text" name="en_nombre_1"  id="en_nombre_1" />	';
	html_enviar_popup+='		</label>	';
	html_enviar_popup+='	</li>	';
	html_enviar_popup+='	<li>	';
	html_enviar_popup+='		<label for="en_email_1">	';
	html_enviar_popup+='			<span>'+texto_5+'*</span>	';
	html_enviar_popup+='			<input type="text" name="en_email_1"  id="en_email_1" />	';
	html_enviar_popup+='		</label>	';
	html_enviar_popup+='	</li>	';
	html_enviar_popup+='	<li>	';
	html_enviar_popup+='		<label for="en_nombre_2">	';
	html_enviar_popup+='			<span>'+texto_6+'*</span>	';
	html_enviar_popup+='			<input type="text" name="en_nombre_2"  id="en_nombre_2" />	';
	html_enviar_popup+='		</label>	';
	html_enviar_popup+='	</li>	';
	html_enviar_popup+='	<li>	';
	html_enviar_popup+='		<label for="en_email_2">	';
	html_enviar_popup+='			<span>'+texto_7+'*</span>	';
	html_enviar_popup+='			<input type="text" name="en_email_2"  id="en_email_2" />	';
	html_enviar_popup+='		</label>	';
	html_enviar_popup+='	</li>	';
	html_enviar_popup+='	<li>	';
	html_enviar_popup+='		<label for="en_en_texto">	';
	html_enviar_popup+='			<span>'+texto_3+'</span>	';
	html_enviar_popup+='			<textarea  name="en_texto"  id="en_texto" ></textarea>	';
	html_enviar_popup+='		</label>	';
	html_enviar_popup+='	</li>	';
	html_enviar_popup+='	<li style="padding:0;">	';
	html_enviar_popup+='		<button type="button" onclick="en_enviar(1)"><span>'+texto_8+'</span></button>	';
	html_enviar_popup+='	</li>	';
	html_enviar_popup+='	</ul>	';
	html_enviar_popup+='	</form>	';
	html_enviar_popup+='<div id="enviar_cerrar_m" ></div>';
	html_enviar_popup+='	</div>	</div>	';
	document.getElementById("enviar_popup").innerHTML = html_enviar_popup ;
	
/*
	html_compartir_popup+='<div id="compartir_popup2">	';
	html_compartir_popup+='<p><a id="enviar_cerrar" href="javascript:f_contacto_close()"><span>Cerrar</span></a></p>	';
	html_compartir_popup+='	<ul>	';
	html_compartir_popup+='			<li><script type="text/javascript" src="http://platform.linkedin.com/in.js"></script><script type="in/share"></script></li>		';
	html_compartir_popup+='			<li class="herra_twitter"><a target="_blank" href="http://twitter.com/home?status=Currently reading <? print urlencode($direcion_faceb) ; ?>" title="Compártelo en Twitter">Twitter</a></li>  ';
	html_compartir_popup+='		</ul>  ';
	html_compartir_popup+='	</div>	';
*/
	//document.getElementById("compartir_popup").innerHTML = html_compartir_popup ;

	
	
}

function f_contacto(este)
{
	f_contacto_close(); 
	if( document.getElementById ("contacto_popup") ){}else{return true; }
	var subobj = document.getElementById ("contacto_popup") ; 
	subobj.style.display=(subobj.style.display!="block")? "block" : "none"	
	var xpos=getposOffset(este, "left")+((typeof opt_position!="undefined" && opt_position.indexOf("right")!=-1)? -(subobj.offsetWidth-este.offsetWidth) : 0) 
	var ypos=getposOffset(este, "top")+((typeof opt_position!="undefined" && opt_position.indexOf("bottom")!=-1)? este.offsetHeight : 0)
//	if( brw=="NN")
	ypos = ypos-350;
	xpos = xpos-270; 
	subobj.style.left=xpos+"px"
	subobj.style.top=ypos+"px"
	return false
}
function f_enviar(este)
{	
	f_contacto_close(); 
	if( document.getElementById ("enviar_popup") ){}else{return true; }
	document.getElementById("enviar_popup").innerHTML = html_enviar_popup ;
	var subobj = document.getElementById ("enviar_popup") ; 
	subobj.style.display=(subobj.style.display!="block")? "block" : "none"	
	var xpos=getposOffset(este, "left")+((typeof opt_position!="undefined" && opt_position.indexOf("right")!=-1)? -(subobj.offsetWidth-este.offsetWidth) : 0) 
	var ypos=getposOffset(este, "top")+((typeof opt_position!="undefined" && opt_position.indexOf("bottom")!=-1)? este.offsetHeight : 0)
//	if( brw=="NN")
	ypos = ypos-450;
	xpos = xpos-67; 
	subobj.style.left=xpos+"px"
	subobj.style.top=ypos+"px"
	return false
}
function f_compartir(este)
{	
	
	f_contacto_close(); 
	if( document.getElementById ("compartir_popup") ){}else{return true; }
	//document.getElementById("compartir_popup").innerHTML = html_compartir_popup ;
	var subobj = document.getElementById ("compartir_popup") ; 
	subobj.style.display=(subobj.style.display!="block")? "block" : "none"	
	var xpos=getposOffset(este, "left")+((typeof opt_position!="undefined" && opt_position.indexOf("right")!=-1)? -(subobj.offsetWidth-este.offsetWidth) : 0) 
	var ypos=getposOffset(este, "top")+((typeof opt_position!="undefined" && opt_position.indexOf("bottom")!=-1)? este.offsetHeight : 0)
//	if( brw=="NN")
	ypos = ypos-154;
	xpos = xpos-40; 
	subobj.style.left=xpos+"px"
	subobj.style.top=ypos+"px"
	return false

	
}
 
 
 
function f_contacto_close()
{
	if (document.getElementById){}else{ return true } ; 
	if (document.getElementById ("contacto_popup") )
	{
		document.getElementById ("contacto_popup").style.display = "none" ; 	
	}
	if (document.getElementById ("enviar_popup") )
	{
		document.getElementById ("enviar_popup").style.display = "none" ; 	
	}
	if (document.getElementById ("compartir_popup") )
	{
		document.getElementById ("compartir_popup").style.display = "none" ; 	
	}
	
	
	
}

















addEvent(window, "load", f_contactoweb_ini );


function f_contactoweb_ini()
{
	if (document.getElementById){}else{ return true };
	if (document.getElementById("contactar_3")){document.getElementById("contactar_3").onclick = function () { f_contactar(3); } }
	if (document.getElementById("contactar_2")){document.getElementById("contactar_2").onclick = function () { f_contactar(2); } }
	if (document.getElementById("contactar_1")){document.getElementById("contactar_1").onclick = function () { f_contactar(1); } }
	if (document.getElementById("contactar_enviar")){document.getElementById("contactar_enviar").onclick = function () { f_contactar_enviar(); } }
	 
}

function f_contactar_enviar()
{ 
	document.getElementById("formu_contactar").submit();
}


function f_contactar(cual)
{
	if (cual=="1"){document.getElementById("contactar").value="1"; document.getElementById("aquien_1").checked = true; }
	if (cual=="2"){document.getElementById("contactar").value="2"; document.getElementById("aquien_2").checked = true; }
	if (cual=="3"){document.getElementById("contactar").value="3"; document.getElementById("aquien_3").checked = true; }
	document.getElementById("formu_contacto").style.display="block";
	document.location = "#3_ref";
}

function addEvent(elm, evType, fn, useCapture)
{
  if (elm.addEventListener){
    elm.addEventListener(evType, fn, useCapture);
    return true;
  } else if (elm.attachEvent){
    var r = elm.attachEvent("on"+evType, fn);
    return r;
  } else {
    alert("No se puede acceder al evento");
  }
} 





function f_getParent(el, pTagName) 
{
	if (el == null){return null;}
	else if (el.nodeType == 1 && el.tagName.toLowerCase() == pTagName.toLowerCase()){return el;}else{return f_getParent(el.parentNode, pTagName);}
}

function tc_getParent2(el, pTagName) 
{
	el = el.parentNode
	if (el == null){return null;}
	else if (el.nodeType == 1 && el.tagName.toLowerCase() == pTagName.toLowerCase()){return el;}else{return tc_getParent(el.parentNode, pTagName);}
}

function f_getElementsByClassName(ele, eltag, strClassName)
{
	var arrElements = (eltag == "*" && ele.all)? ele.all : ele.getElementsByTagName(eltag);
	var arrReturnElements = new Array();
	strClassName = strClassName.replace(/-/g, "\-");
	var oRegExp = new RegExp("(^|\s)" + strClassName + "(\s|$)");
	var oElement;
	for ( var i=0; i<arrElements.length; i++ ) { oElement = arrElements[i];if(oRegExp.test(oElement.className)){arrReturnElements.push(oElement);}}
	return (arrReturnElements)
}

function getposOffset(overlay, offsettype)
{
	var totaloffset=(offsettype=="left")? overlay.offsetLeft : overlay.offsetTop;
	var parentEl=overlay.offsetParent;
	while (parentEl!=null)
	{
		totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
		parentEl=parentEl.offsetParent;
	}
	return totaloffset;
}






