function trim(cadena) {for(i_=0; i_<cadena.length; ++i_) {if(cadena.charAt(i_)==" ") cadena=cadena.substring(i_+1, cadena.length);else break;}for(i_=cadena.length-1; i_>=0; i_=cadena.length-1) {if(cadena.charAt(i_)==" ") cadena=cadena.substring(0,i_);else break;}return cadena;}
function nuevoAjax(){
	var xmlhttp=false;
 	try {
 		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 	} catch (e) {
 		try {
 			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
 		} catch (E) {
 			xmlhttp = false;
 		}
  	}

	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
 		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}

function comentar(id){
	t1 = document.getElementById('fname').value;
	t2 = document.getElementById('ftitle').value;
	t3 = document.getElementById('ftext').value;
	t5 = document.getElementById('femail').value;
	if (t1==''){
		alert("Tu nombre es un campo obligatorio");		
	}else{
		var contenedor;
		contenedor = document.getElementById('aporta');
		contenedor.innerHTML = '<h3><em>Aporta</em> tu comentario</h3><br/><br/><img src="./img/loading.gif"></p>';
		contenedor.style.display = 'none';
		contenedor.style.display = 'block';
		ajax=nuevoAjax();
		ajax.open("POST", "aj_comentario.php",true);
		ajax.onreadystatechange=function() {
			if (ajax.readyState==4) {
			contenedor.innerHTML = ajax.responseText;
			fadeIn();
			//document.getElementById('contribution').style.visibility = 'hidden';
		 	}
		}
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		ajax.send("t1="+escape(t1)+"&t2="+escape(t2)+"&t3="+escape(t3)+"&t4="+escape(id)+"&t5="+escape(t5));
	}
}

function preenviarvideo(id){
	document.getElementById('videoid').value=id;
	document.getElementById('formsend').style.display = 'block';
	document.getElementById('pemail').focus();
	fadeIn2();	
	//document.getElementById('formsend').style.top=480+'px';	
}


function enviarvideo(){
	t1 = document.getElementById('pemail').value;
	t2 = document.getElementById('demail').value;
	t3 = document.getElementById('text').value;
	t4 = document.getElementById('videoid').value;
	t5 = document.getElementById('dnom').value;
	if (t1==''){
		alert("Tu email es un campo obligatorio");		
	}else{
		var contenedor;
		contenedor = document.getElementById('formsend');
		contenedor.innerHTML = '<p><img src="./img/loading.gif"></p>';
		ajax=nuevoAjax();
		ajax.open("POST", "aj_envio.php",true);
		ajax.onreadystatechange=function() {
			if (ajax.readyState==4) {
			//contenedor.innerHTML = ajax.responseText;
			fadeOut2();
		 	}
		}
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		ajax.send("t1="+escape(t1)+"&t2="+escape(t2)+"&t3="+escape(t3)+"&t4="+escape(t4)+"&t5="+escape(t5));
	}
}





//fades layer in
ie5 = (document.all && document.getElementById);
ns6 = (!document.all && document.getElementById);
opac = 0;

function fadeIn() {
if(opac != 100){
opac2 = 100;
opac+=1;
if(ie5) document.getElementById('aporta').filters.alpha.opacity = opac;
if(ns6) document.getElementById('aporta').style.MozOpacity = opac/100;
setTimeout('fadeIn()', 0);
}
}
function fadeIn2() {
if(opac != 100){
opac2 = 100;
opac+=10;
if(ie5) document.getElementById('formsend').filters.alpha.opacity = opac;
if(ns6) document.getElementById('formsend').style.MozOpacity = opac/100;
setTimeout('fadeIn2()', 0);
}
}


//fades layer out
ie5 = (document.all && document.getElementById);
ns6 = (!document.all && document.getElementById);
opac2 = 100;

function fadeOut() {
//document.write(opac2);
if(opac2 > 0){
opac = 0;
opac2-=1;
if(ie5) document.getElementById('aporta').filters.alpha.opacity = opac2;
if(ns6) document.getElementById('aporta').style.MozOpacity = opac2/100;
setTimeout('fadeOut()', 0);
}
}

function fadeOut2() {
//document.write(opac2);
if(opac2 > 0){
opac = 0;
opac2-=10;
if(ie5) document.getElementById('formsend').filters.alpha.opacity = opac2;
if(ns6) document.getElementById('formsend').style.MozOpacity = opac2/100;
setTimeout('fadeOut2()', 0);
}
if(opac2 < 1){
document.getElementById('formsend').style.display = 'none';
}
}

function fadeIn3() {
document.getElementById('newsletterd').style.display = 'block';
if(opac != 100){
opac2 = 100;
opac+=10;
if(ie5) document.getElementById('newsletterd').filters.alpha.opacity = opac;
if(ns6) document.getElementById('newsletterd').style.MozOpacity = opac/100;
setTimeout('fadeIn3()', 0);
}
}


function ComeIn() {
ie5 = (document.all && document.getElementById);
ns6 = (!document.all && document.getElementById);
document.getElementById('compartirin').style.left = 'auto';
if(ie5){document.getElementById('compartirin').filters.alpha.opacity = '85';}
if(ns6){document.getElementById('compartirin').style.MozOpacity = '.85';}
}

function ComeOut() {
ie5 = (document.all && document.getElementById);
ns6 = (!document.all && document.getElementById);
document.getElementById('compartirin').style.left = '-999em';
if(ie5){document.getElementById('compartirin').filters.alpha.opacity = 0;}
if(ns6){document.getElementById('compartirin').style.MozOpacity = 0;}
}

function valida(){
	contenedor1=document.getElementById('emailaddress');
	contenedor2=document.getElementById('newsletterd');
	suscripcion(contenedor1,contenedor2,1);
	fadeIn3();	
}

 
function suscripcion(contenedor1,contenedor2,alta){
	t1 = contenedor1.value;
	t2 = alta;
	var contenedor;
	contenedor2.innerHTML = '';
	ajax=nuevoAjax();
	ajax.open("POST", "/ajax/aj_susc.php",true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
		contenedor2.innerHTML = ajax.responseText;
		//fadeOut2();
	 	}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajax.send("t1="+escape(t1)+"&t2="+escape(t2));
}