var x1 = 110;
var x2 = 0;
var acel = 32;
var i=0;
var opa=100;
var flag=0;
var out=0;

function desplazaIzq(){		
	if (x1 >= 5){
		obj = document.getElementById('ediv');
		//obj.style.filter = 'alpha(opacity=' +f1+ ')';
		//f1 = f1 + 0.3;

		obj.style.left = x1 + "%";
		
		x1 = x1 - x2;
		x2 = (x1 - x2)/acel;
		setTimeout('desplazaIzq()',acel);
		return;			
	}
}
function esperar(funcion, id){
	funcion= funcion + "('" + id + "')";
	setTimeout(funcion, 1000);

}
function high(which2)
{
theobject=which2;
highlighting=setInterval("highlightit(theobject)",20);
	
}
function low(which2)
{
clearInterval(highlighting);
which2.filters.alpha.opacity=80;
}
function highlightit(cur2)
{
if(cur2.filters.alpha.opacity<100)
cur2.filters.alpha.opacity+=2
else if(window.highlighting)
clearInterval(highlighting)
}

function checkhtml(control){
	//comprueba la existencia de codigo html inyectado en los controles
	for(b=0;b<=control.length;b++)
			if (control.charAt(b)=='<' || control.charAt(b)=='>')
				flag=1;			
}
function filterupdetail(id){
	if (i<100){
		div=document.getElementById(id);
		midiv=id;
		//alert(id);
		div.style.filter = 'alpha(opacity=100)'; //IE
		div.style.opacity = (100/100); 	// Mozilla Firefox new version
		div.style.MozOpacity = (100/100); // Mozilla Firefox older version
		div.style.display = "inline";
	}else
		i=0;	
}
function filterup(id){
	if (i<100){
		div=document.getElementById(id);
		midiv=id;
		//alert(id);
		div.style.filter = 'alpha(opacity=' + i + ')'; //IE
		div.style.opacity = (i/100); 	// Mozilla Firefox new version
		div.style.MozOpacity = (i/100); // Mozilla Firefox older version
		//div.style.display = "inline";
		i+=5;
		
		setTimeout('filterup(midiv)',10);

		/*if (out==0){
			setTimeout('filterup(midiv)',10);
			return;
	
		}else{			
			div.style.filter = 'alpha(opacity=0)';
			div.style.opacity = 0; 
			div.style.MozOpacity = 0; 
			out=0;
			i=0;
		}		*/
	}else
		i=0;	
}
function filterdownup(id){
	if (opa>0){
		obj=document.getElementById(id);
		midiv=id;
		//alert(id);
		obj.style.filter = 'alpha(opacity=' + opa + ')'; //IE
		obj.style.opacity = (opa/100); 	// Mozilla Firefox new version
		obj.style.MozOpacity = (opa/100); // Mozilla Firefox older version
		//div.style.display = "inline";
		opa-=20;
		setTimeout('filterdownup(midiv)',10);
	}else{
		opa=100;
		obj.style.filter = 'alpha(opacity=' + opa + ')'; //IE
		obj.style.opacity = (opa/100); 	// Mozilla Firefox new version
		obj.style.MozOpacity = (opa/100); // Mozilla Firefox older version
	}		
}
function filterdown(id){

		div=document.getElementById(id);		
		div.style.filter = 'alpha(opacity=0)';
		div.style.opacity = 0; 
		div.style.MozOpacity = 0; 
		/*if(i<100 && i>0)		
			out=1;
		else
			i=0;
		*/
}

function validar(){
	var mail;
for(a=0;a<=0;a++){
	if(document.getElementById('name').value.length==0){
		filterup('namevalidator');
		document.getElementById('name').focus();	
		break;
	}
	else{
		filterdown('namevalidator');
		field=document.getElementById('name').value;
		checkhtml(field);		

	}
	if(document.getElementById('apellido').value.length==0){
		filterup('apevalidator');
		document.getElementById('apellido').focus();
		break;
	}else{
		filterdown('apevalidator');
		field=document.getElementById('apellido').value;
		checkhtml(field);	
	}
	if(document.getElementById('email').value.length!=0){	
		mail=document.getElementById('email').value;

		if(mail.indexOf('@') < 1 || mail.indexOf('.')<1){
			//el metodo indexof me dice que posicion se encuentra el caracter
			filterup('emailvalidator');
			document.getElementById('email').focus();
			break;
		}else{
			filterdown('emailvalidator');
			field=document.getElementById('email').value;
			checkhtml(field);
		}
	}else{
		filterdown('emailvalidator');
		field=document.getElementById('email').value;
		checkhtml(field);
	}

	
	if(document.getElementById('coment').value.length==0){
		filterup('comentvalidator');
		document.getElementById('coment').focus();
		break;
	}else{
		filterdown('comentvalidator');
		field=document.getElementById('coment').value;
		checkhtml(field);
	}			

	
	if(!flag){
		miform.submit();	
	}

}	
}
function iluminar(micontrol){
	micontrol.style.color='#FFFFFF';
	micontrol.style.textDecoration='underline';

}
function apagar(micontrol){
	micontrol.style.color='#000000';
	micontrol.style.textDecoration='none';
}
function muestrapubli(id){
	publi=document.getElementById(id).style;
	w = screen.width;	
	h = screen.height;
	t = (h - 400)/2;
	l = (w - 350)/2;
	publi.top = t + "px";	
	publi.left = l + "px";
	publi.visibility = "visible";
	publi.display = "inline";
	filterup(id);
}
	
	
	
