var raiz;
raiz=return_url()+"/components/com_ongastronomy/";
var http = getXmlHttpObject();
var capa;
function sendQuerystring(nombre_objeto,idn_objeto,tip_objeto,uni_objeto,p_capa){
	url2=raiz+"contenedor_front.php";
	capa=p_capa;
    http.open("GET", url2 + "?nom_objeto="+nombre_objeto+"&idn_objeto="+idn_objeto+"&tip_objeto="+tip_objeto+"&uni_objeto="+uni_objeto, true);
	http.setRequestHeader('Content-Type','text/html; charset=iso-8859-1');
    http.onreadystatechange = handleHttpResponse;
    http.send(null);
}
function sendQuerystringBuscador(campo,p_capa){
	url2=raiz+"contenedor_front.php";
	capa=p_capa;
    http.open("GET", url2 + "?campo="+campo+"&tipo=buscador", true);
	http.setRequestHeader('Content-Type','text/html; charset=iso-8859-1');
    http.onreadystatechange = handleHttpResponse;
    http.send(null);
}

function sendQuerystringCompartir(params,p_capa){
	url2=raiz+"contenedor_front.php";
	capa=p_capa;
    http.open("GET", url2 + "?params="+params+"&tipo=compartir", true);
	http.setRequestHeader('Content-Type','text/html; charset=iso-8859-1');
    http.onreadystatechange = handleHttpResponse;
    http.send(null);
}

function sendQuerystringContactar(params,p_capa){
	url2=raiz+"contenedor_front.php";
	capa=p_capa;
    http.open("GET", url2 + "?params="+params+"&tipo=contactar", true);
	window.alert(params);
	http.setRequestHeader('Content-Type','text/html; charset=iso-8859-1');
    http.onreadystatechange = handleHttpResponse;
    http.send(null);
}

function handleHttpResponse(){
    if (http.readyState == 1){ //muy importante tenemos que poner el resultado en la capa corresponDIENTE
     	document.getElementById(capa).innerHTML = "...";
    }
    if (http.readyState == 4){
       	results=unescape(http.responseText);
            txt2=results.replace(/\+/gi," ");
        document.getElementById(capa).innerHTML = txt2;
    }
}
function getXmlHttpObject(){
	var objXMLHttp=null
	if (window.XMLHttpRequest)
	{
		objXMLHttp=new XMLHttpRequest()
		}
	else if (window.ActiveXObject)
	{
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
	}
	return objXMLHttp
}


function passwordLevel (p){
	l = 0;
	v1 = 'aeiou1234567890';
	v2 = 'AEIOUbcdfghjklmnpqrst';
	v3 = 'vxyzBCDFGHJKLMNPQRST';
	v4 = 'VXYZ$@#';
	var cadena;
	for (i = 0; i < p.length; i++){
	if (v1.indexOf(p[i]) != -1) l += 1;
	else if (v2.indexOf(p[i]) != -1) l += 2;
	else if (v3.indexOf(p[i]) != -1) l += 3;
	else if (v4.indexOf(p[i]) != -1) l += 4;
	else l += 5;
	}
	l *= 3;
	if(l > 100)l = 100;
	/*if (l<34)
	{
		document.mosForm.c_s_password.style.color="red";
	}else if ((l>33)&&(l<66))
	{
		document.mosForm.c_s_password.style.color="orange";
	}else{
		document.mosForm.c_s_password.style.color="green";
	}*/
	return l;
}

function aleatorio(inferior,superior){
    numPosibilidades = superior - inferior
    aleat = Math.random() * numPosibilidades
    aleat = Math.round(aleat)
    return parseInt(inferior) + aleat
} 

function actualizacion_seguridad(level)
{	
	document.getElementById('relleno_s').style.width=parseInt(level)+"px";
	document.getElementById('vacio_s').style.width=(100-parseInt(level))+"px";
	if (level<34)
	{
		document.getElementById('relleno_s').style.background="red";
	}else if ((level>33)&&(level<66))
	{
		document.getElementById('relleno_s').style.background="orange";
	}else{
		document.getElementById('relleno_s').style.background="green";
	}
}

function desplegar_formulario_compartir(posx,posy)
{
	document.getElementById('CapaEmail').style.height='300px';
	document.getElementById('CapaEmail').style.visibility='visible';
	document.getElementById('CapaEmail').style.top=posy-110+'px';
	document.getElementById('CapaEmail').style.left=390+'px';
	document.getElementById('despleCompartir').value=1;
}
function plegar_formulario_compartir()
{
	document.getElementById('CapaEmail').style.height='0px';
	document.getElementById('CapaEmail').style.visibility='hidden';
	document.getElementById('CapaEmail').style.top='-2000px';
	document.getElementById('CapaEmail').style.left='0px';
	document.getElementById('despleCompartir').value=0;
}

var posx;
var posy;
function desplegar_plegar()
{
	var t=document.getElementById('despleCompartir').value;
	if (t==0)
	{
		desplegar_formulario_compartir(posx,posy);
		
	}else{
		plegar_formulario_compartir();
		
	}
}
var isIE = document.all?true:false;
if (!isIE) document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = getMousePosition;
function getMousePosition(e) {
  var _x;
  var _y;
  if (!isIE) {
    _x = e.pageX;
    _y = e.pageY;
  }
  if (isIE) {
    _x = event.clientX;
    _y = event.clientY;
  }
  posx=_x;
  posy=_y;
  return true;
}


function desplegar_formulario_contacta(posx,posy)
{
	document.getElementById('CapaEmailContactar').style.height='300px';
	document.getElementById('CapaEmailContactar').style.visibility='visible';
	document.getElementById('CapaEmailContactar').style.top=posy-110+'px';
	document.getElementById('CapaEmailContactar').style.left=390+'px';
	document.getElementById('despleContactar').value=1;
}
function plegar_formulario_contacta()
{
	document.getElementById('CapaEmailContactar').style.height='0px';
	document.getElementById('CapaEmailContactar').style.visibility='hidden';
	document.getElementById('CapaEmailContactar').style.top='-2000px';
	document.getElementById('CapaEmailContactar').style.left='0px';
	document.getElementById('despleContactar').value=0;
}

function desplegar_plegar_contactar()
{
	var t=document.getElementById('despleContactar').value;
	if (t==0)
	{
		desplegar_formulario_contacta(posx,posy);
		
	}else{
		plegar_formulario_contacta();
		
	}
}

function printContent(id) {
	var ventana = window.open("", "", "");
	str=document.getElementById(id).innerHTML
	var contenido = "<html><body onload='window.print();window.close();'>" + str + "</body></html>";
	ventana.document.open();
	ventana.document.write(contenido);
	ventana.document.close();
}
