/* Formulario de contacto: */
function abrirPop(obj) {
	get(obj).style.display='block';
}
function cerrarPop(obj) {
	get(obj).style.display='none';
}
function checkContacto() {
	if (get('Nombre').value=='') {
		alert('Ingrese su nombre.');
		get('Nombre').focus();
	}
	else if (get('email').value!='' && !checkMail(get('email').value)) {
		alert('Igrese un e-mail válido.');	
		get('email').focus();
	}
	else if (get('email').value=='' && get('Telefono').value=='') {
		alert('Ingrese su e-mail o número de teléfono para que podamos contactarnos con usted.');	
		get('email').focus();
	}
	else if (get('Mensaje').value=='') {
		alert('Escriba un mensaje.');	
		get('Mensaje').focus();
	}
	else {
		//Enviar mensaje:
		get('Contacto').style.display='none';
		get('Wait').style.display='block';
		var ajax=nuevoAjax();
		ajax.onreadystatechange=function() {
			if (ajax.readyState==4)	{
				if (ajax.responseText=='ok') {
					get('envioMsj').innerHTML='<p>El mensaje fue enviado correctamente.</p>';
					
					get('Nombre').value='';
					get('Medio').value='';
					get('email').value='';
					get('Telefono').value='';
					get('Mensaje').value='';
				}
				else
					get('envioMsj').innerHTML='<p>Hubo un error al enviar su mensaje. Vuelva a realizar esta operación más tarde.</p>';
				
				get('Wait').style.display='none';
				get('Enviado').style.display='block';
			}
		}
		ajax.open("POST", "contacto.php", true);
		ajax.setRequestHeader('content-type', 'application/x-www-form-urlencoded');	
		ajax.send('Nombre='+escape(get('Nombre').value)+'&Medio='+escape(get('Medio').value)+'&email='+escape(get('email').value)+'&Telefono='+escape(get('Telefono').value)+'&Mensaje='+escape(get('Mensaje').value));
	}
}
function checkSuscripcion() {
	if (get('susNombre').value=='') {
		alert('Ingrese su nombre.');
		get('susNombre').focus();
	}
	else if (!checkMail(get('susEmail').value)) {
		alert('Igrese un e-mail válido.');	
		get('susEmail').focus();
	}
	else {
		//Enviar mensaje:
		get('Suscripcion').style.display='none';
		get('Wait').style.display='block';
		var ajax=nuevoAjax();
		ajax.onreadystatechange=function() {
			if (ajax.readyState==4)	{
				if (ajax.responseText=='ok') {
					get('envioMsj').innerHTML='<p>Gracias por suscribirse a nuestros Newsletters.<br />Muy pronto recibirá nuestras noticias en su casilla de correo.</p>';
				}
				else if (ajax.responseText=='ok2')
					get('envioMsj').innerHTML='<p>Usted ya se ha suscripto a nuestros newsletters anteriormente.<br />Muy pronto recibirá nuestras noticias en su casilla de correo.</p>';
				else if (ajax.responseText=='ok3')
					get('envioMsj').innerHTML='<p>Hemos reestablecido su suscripción a nuestros newsletters.<br />Muy pronto recibirá nuestras noticias en su casilla de correo.<br /></p>';
				else
					get('envioMsj').innerHTML='<p>Hubo un error al realizar la suscripción. Vuelva a realizar esta operación más tarde.</p>';

				if (ajax.responseText=='ok' || ajax.responseText=='ok2' || ajax.responseText=='ok3') {
					get('susNombre').value='';
					get('susMedio').value='';
					get('susEmail').value='';
				}
				get('Wait').style.display='none';
				get('Enviado').style.display='block';
			}
		}
		ajax.open("POST", "suscripcion.php", true);
		ajax.setRequestHeader('content-type', 'application/x-www-form-urlencoded');	
		ajax.send('Nombre='+escape(get('susNombre').value)+'&Medio='+escape(get('susMedio').value)+'&email='+escape(get('susEmail').value));
	}
}
function checkMail(txt) {
	var er=/^[A-Za-z][A-Za-z0-9_\.\-]*@[A-Za-z0-9_\-]+\.[A-Za-z0-9_.]+[A-za-z]$/;
	return er.test(txt);
}

/* Fin formulario de contacto */

function buscarFocus() {
	if (document.getElementById('Buscar').value=='Buscar...') {
		document.getElementById('Buscar').value='';
	}
}
function buscarBlur() {
	if (document.getElementById('Buscar').value=='') {
		document.getElementById('Buscar').value='Buscar...';
	}
}
/* View de fotos: */
function menos() {
	if (actIms>0)
		actIms--;
	else
		actIms=(cantIms-1);
		
	viewFoto();
}
function mas() {
	if (actIms<(cantIms-1))
		actIms++;
	else
		actIms=0;
	
	viewFoto();
}
var imagen;
function viewFoto() {
try {
	get('Sobre').style.display='none';
	reflotar('Sobre', 100, 'viewFotoOk()');
}
catch (err) { alert(err); }
}
function viewFotoOk() {
	counter++;
	get('pfDivFoto').innerHTML='<img id="pfImg'+counter+'" src="" width="320" height="240" border="0" alt="" />';
	get('pfImg'+counter).src='imagenes/imagen.php?i=noticias/'+ims[actIms]+'&w=320&h=240&f=2';
	get('pfEpigrafe').innerHTML=ime[actIms];
	cargando();
	setTimeout('wait(true)', 60);
}
function viewFotoFin() {
	wait(false);
	desvanecer('Sobre', 100, null);
	cantFotos();
	
	var prox=(actIms>=(cantIms-1) ? 0 : actIms+1);
	var ant=(actIms==0 ? cantIms-1 : actIms-1);
		
	var impre=new Image();
	impre.src='imagenes/imagen.php?i=noticias/'+ims[ant]+'&w=348&h=261&f=2';
	var impos=new Image();
	impos.src='imagenes/imagen.php?i=noticias/'+ims[prox]+'&w=348&h=261&f=2';
}
var cargado=false;
function cargando() {
	if (get('pfImg'+counter).complete) {
		cargado=true;
		viewFotoFin();
	}
	else {
		cargado=false;
		setTimeout("cargando()", 50);
	}
}
function wait(s) {
	if (s && !cargado) {
		get('Sobre').innerHTML='<img src="imagenes/wait.gif" width="32" height="32" border="0" alt="" />';
	}
	else
		get('Sobre').innerHTML='&nbsp;';
}
function cantFotos() {
	if (cantIms>1)
		get('pfBotones').innerHTML='Imagen '+(actIms+1)+' / '+cantIms+'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript: menos();"><img src="imagenes/btnIzq.gif" width="24" height="20" border="0" alt="" align="absmiddle" /></a>&nbsp;<a href="javascript: mas();"><img src="imagenes/btnDer.gif" width="24" height="20" border="0" alt="" align="absmiddle" /></a>';
}
/* Fin View de fotos */

/* View Videos */
function menosV() {
	if (actVid>0)
		actVid--;
	else
		actVid=(cantVid-1);
		
	viewVideo();
}
function masV() {
	if (actVid<(cantVid-1))
		actVid++;
	else
		actVid=0;
	
	viewVideo();
}
function viewVideo() {
	gvVideo('pvDivVideo', vidp[actVid], vidc[actVid], 320, 240);
	get('pvEpigrafe').innerHTML=vide[actVid];
	cantVideos();
}
function gvVideo(objID, proveedorID, codigo, width, height) {
	if (proveedorID==1) {
		var so=new SWFObject('http://www.youtube.com/v/'+codigo+'&amp;hl=es&amp;fs=1', 'id', width, height, '9', '#000000');
		so.addParam('allowscriptaccess', 'always');
		so.addParam('allowfullscreen', 'true');
		so.write(objID);
	}
	else if (proveedorID==2) {
		var so=new SWFObject('http://vimeo.com/moogaloop.swf?clip_id='+codigo+'&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=1&amp;show_portrait=0&amp;color=000000&amp;fullscreen=1&amp;autoplay=0', 'id', width, height, '9', '#000000');
		so.addParam('allowscriptaccess', 'always');
		so.addParam('allowfullscreen', 'true');
		so.write(objID);
	}
}
function cantVideos() {
	if (cantVid>1)
		get('pvBotones').innerHTML='Video '+(actVid+1)+' / '+cantVid+'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript: menosV();"><img src="imagenes/btnIzq.gif" width="24" height="20" border="0" alt="" align="absmiddle" /></a>&nbsp;<a href="javascript: masV();"><img src="imagenes/btnDer.gif" width="24" height="20" border="0" alt="" align="absmiddle" /></a>';
}
/* Fin View Videos */

/* View Audio */
function menosA() {
	if (actAud>0)
		actAud--;
	else
		actAud=(cantAud-1);
		
	viewAudio();
}
function masA() {
	if (actAud<(cantAud-1))
		actAud++;
	else
		actAud=0;
	
	viewAudio();
}
function viewAudio() {
	gvAudio('paDivAudio', 'audios/'+auda[actAud]);
	get('paEpigrafe').innerHTML=aude[actAud];
	cantAudio();
}
function gvAudio(objID, file) {
	var so=new SWFObject("repro.swf", 'id', 320, 30, '10', '#CCCCCC');
	so.addVariable('Audio', file);
	so.write(objID);
}
function cantAudio() {
	if (cantVid>1)
		get('paBotones').innerHTML='Audio '+(actAud+1)+' / '+cantAud+'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript: menosA();"><img src="imagenes/btnIzq.gif" width="24" height="20" border="0" alt="" align="absmiddle" /></a>&nbsp;<a href="javascript: masA();"><img src="imagenes/btnDer.gif" width="24" height="20" border="0" alt="" align="absmiddle" /></a>';
}
/* Fin View Audio */

/* Transparentador: */
function desvanecer(obj, trIni, funcion) {
	chTransparent(obj, trIni, 0, trIni, funcion);
}
function reflotar(obj, trMax, funcion) {
	chTransparent(obj, 0, trMax, 0, funcion);
}
function chTransparent(obj, trIni, trFin, trAct, funcion) {
	var ch=false;
	if (trIni>trFin && trAct>trFin) {
		trAct-=10;
		ch=true;
	}
	else if (trIni<trFin && trAct<trFin) {
		trAct+=10;
		ch=true;
	}
	if (ch) {
		var trAct2=parseFloat(trAct/100);
		get(obj).style.filter='alpha(opacity='+trAct+')'
		get(obj).style.mozOpacity=trAct2;
		get(obj).style.opacity=trAct2;
		
		if (get(obj).style.display=='none')
			get(obj).style.display='block';
		
		setTimeout("chTransparent('"+obj+"', "+trIni+", "+trFin+", "+trAct+", '"+funcion+"');", 30);
	}
	else if (funcion)
		eval(funcion);
	
	if (trAct==0)
		get(obj).style.display='none';
}
/* Fin Transparentador: */

/* Visor de fotos: */


/* Fin visor de fotos: */
function video(cod, ap) {
	//var so=new SWFObject('http://vimeo.com/moogaloop.swf?clip_id='+cod+'&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=1&amp;show_portrait=0&amp;color=000000&amp;fullscreen=1&amp;autoplay='+ap, 'id', '332', '249', '9', '#000000');
	var so=new SWFObject('http://vimeo.com/moogaloop.swf?clip_id='+cod+'&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=1&amp;show_portrait=0&amp;color=000000&amp;fullscreen=1&amp;autoplay='+ap, 'id', '276', '207', '9', '#000000');
	so.addParam('allowscriptaccess', 'always');
	so.addParam('allowfullscreen', 'true');
	so.write("VideoView");
}

function get(obj) {	var r=null;	if (document.getElementById) { if (document.getElementById(obj)) r=document.getElementById(obj); } else if (document.all) {	if (document.all[obj]) r=document.all[obj]; } return r; }
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;}

