var tim1,tim2;


function setLeftBarH(height)
{
	var el=document.getElementById("download_home");
	el.style.height=height;
};

function ValidateContact(req,defNome,defInd,defTel,defMail,defInfo,defAz,defTipAz,cliType,lang){

	var emailID=document.frmContacts.txtUmail;
	var nomeID=document.frmContacts.txtNome;
	var telID=document.frmContacts.txtTel;
	var indID=document.frmContacts.txtInd;
	var areaID=document.frmContacts.txtInfo;
	var privacyID=document.frmContacts.chkPrivacyCn;
	var azID=document.frmContacts.txtAz;
	var tipAzID=document.frmContacts.txtAzTip;
	var radioIDpri=document.frmContacts.pri;
	var radioIDprj=document.frmContacts.prj;
	var radioIDazi=document.frmContacts.azi;

	var first=document.getElementById('cnResult');

	var el=document.getElementById("newsletter");

	if(privacyID.checked==false)
	{
		invalidEmail(lang,"privacy","cnResult");
		//invalidEmail(lang,"privacy");
		return false;

	}	
	if ((emailID.value==null)||(emailID.value=="")){
		invalidEmail(lang,"email","cnResult");
		return false;
	}

	
	if(azID && radioIDazi.checked){
		if ((azID.value==null)||(azID.value.value=="")){
			invalidEmail(lang,"email","cnResult");
			defAz="asd";
			defTipAz="asd";
		}
	}

	if (mailCheck(emailID.value)==false){
		invalidEmail(lang,"email","cnResult");
		return false;
	}

	if(emailID.value==defMail || nomeID.value==defNome || indID.value==defInd || telID.value==defTel || areaID.value==defInfo)
	{
		invalidEmail(lang,"insert","cnResult");
		return false;
	}

	if(azID && radioIDazi.checked){
		if(azID.value==defAz || tipAzID.value==defTipAz)
		{
			invalidEmail(lang,"insert","cnResult");
			return false;
		}
	}
	
	//alert("All ok");

	var myRequest = new XMLHttpRequest();

	if(azID && radioIDazi.checked)	
		myRequest.open("get","sendmail.php?req=" + req +"&" +"mail=" + emailID.value +"&" + "nome=" + nomeID.value+"&" + "ind=" + indID.value+"&" + "tel=" + telID.value + "&" + "text=" + areaID.value +"&" + "azi=" + azID.value +"&" + "tipazi=" + tipAzID.value + "&" + "lang=" + lang,false);

	else
		myRequest.open("get","sendmail.php?req=" + req +"&" +"mail=" + emailID.value +"&" + "nome=" + nomeID.value+"&" + "ind=" + indID.value+"&" + "tel=" + telID.value + "&" + "text=" + areaID.value +"&" + "lang=" + lang,false);

	myRequest.send(null);
	first.innerHTML=myRequest.responseText;
	return true;
 };

function ValidateCat(req,defNome,defInd,defTel,defMail,lang){

	var emailID=document.frmContacts.txtUmail;
	var nomeID=document.frmContacts.txtNome;
	var telID=document.frmContacts.txtTel;
	var indID=document.frmContacts.txtInd;
	var privacyID=document.frmContacts.chkPrivacyCn;

	var el=document.getElementById("newsletter");

	var first=document.getElementById('cnResult');

	if(privacyID.checked==false)
	{
		invalidEmail(lang,"privacy","cnResult");
		//invalidEmail(lang,"privacy");
		return false;

	}	
	if ((emailID.value==null)||(emailID.value=="")){
		invalidEmail(lang,"email","cnResult");
		return false;
	}

	
	if (mailCheck(emailID.value)==false){
		invalidEmail(lang,"email","cnResult");
		return false;
	}

	if(emailID.value==defMail || nomeID.value==defNome || indID.value==defInd || telID.value==defTel)
	{
		invalidEmail(lang,"insert","cnResult");
		return false;
	}

	//alert("All ok");

	var myRequest = new XMLHttpRequest();


	myRequest.open("get","sendmail.php?req=" + req +"&" +"mail=" + emailID.value +"&" + "nome=" + nomeID.value+"&" + "ind=" + indID.value+"&" + "tel=" + telID.value + "&" + "lang=" + lang,false);


	myRequest.send(null);
	first.innerHTML=myRequest.responseText;
	return true;
 };

function cancelText(id,def){

	var el=document.getElementsByName(id);
	if(el[0].value==def)
		el[0].value="";

};

function restoreText(id,def){

	var el=document.getElementsByName(id);
	if(el[0].value=="")
		el[0].value=def;

};

function fade(id){

	
	alert("ciao");

}


function rollin(id){

	var div=document.getElementById(id);
	var elAz=document.getElementsByName('txtAz');
	var elAzTip=document.getElementsByName('txtAzTip');	

	var inc=1;

	var tim1;
	var tim2;

	var opAz=parseInt(elAz[0].style.height)+1;
	var opAzTip= parseInt(elAzTip[0].style.height)+1;

	if(opAz>=25)
		inc=2;

	var op=parseInt(div.style.paddingBottom)+inc;

	var irv=1900;

	if(opAz!=25){
		elAz[0].style.height = opAz+"px";
		elAzTip[0].style.height = opAzTip+"px";
	}

	if(op>=35)
	{
		//elAz[0].style.height = '25px';
		//elAzTip[0].style.height = '25px'

		tim1=setInterval("fadein('txtAz')", irv);
		tim2=setInterval("fadein('txtAzTip')", irv);

		clearInterval();

		if(parseFloat(elAz[0].style.MozOpacity)>=0.99){
			clearInterval(tim1);
			clearInterval(tim2);
		}

	}else{div.style.paddingBottom=op+"px";}

}

function rollout(id){

	var div=document.getElementById(id);
	var elAz=document.getElementsByName('txtAz');
	var elAzTip=document.getElementsByName('txtAzTip');	

	var op=parseInt(div.style.paddingBottom);
	var opAz=parseInt(elAz[0].style.height)-1;
	var opAzTip= parseInt(elAzTip[0].style.height)-1;

	var irv=900;

	if(opAz!=0){
		elAz[0].style.height = opAz+"px";
		elAzTip[0].style.height = opAzTip+"px";
	}

	if(op==35)
	{
		//elAz[0].style.height = '25px';
		//elAzTip[0].style.height = '25px'

		setInterval("fadeout('txtAz')", irv);
		setInterval("fadeout('txtAzTip')", irv);

	}else{div.style.paddingBottom=op+"px";}

}

function fadein(id){

	var el=document.getElementsByName(id);
	var op=el[0].style.opacity;

	if(BrowserDetect.browser=="Firefox")
		el[0].style.MozOpacity = Math.min(parseFloat(el[0].style.MozOpacity)+0.1, 0.99);
	else
		el[0].style.opacity = Math.min(parseFloat(el[0].style.opacity)+0.1, 0.99);

	//clearInterval(tim);

}

function fadeout(id){

	var el=document.getElementsByName(id);
	var op=el[0].style.opacity;

	if(BrowserDetect.browser=="Firefox"){
		el[0].style.MozOpacity = Math.max(Math.min(parseFloat(el[0].style.MozOpacity)-0.1, 0.99),0.0);
		//el[0].style.MozOpacity=0.0;

		if(el[0].style.MozOpacity==0.0)
			el[0].style.height = '0px';

	}

	else{

		el[0].style.opacity = Math.max(Math.min(parseFloat(el[0].style.opacity)-0.1, 0.99),0.0);
		//el[0].style.MozOpacity=0.0;

		if(el[0].style.opacity==0.0)
			el[0].style.height = '0px';
	}

	//clearInterval(tim);

}

function hide(id){

	var elAz=document.getElementsByName('txtAz');
	var elAzTip=document.getElementsByName('txtAzTip');
	var radioDiv=document.getElementById('radioDiv');

	var irv=50;

	if(id=='pri' || id=='prj')
	{

		//elAz[0].style.visibility = 'hidden';
		//elAzTip[0].style.visibility = 'hidden';
		//elAz[0].style.height = 0;
		//elAzTip[0].style.height = 0;
		//radioDiv.style.padding = 0;
		//radioDiv.style.padding = 0;
		clearInterval(tim1);
		clearInterval(tim2);
		//setInterval("fadeout('txtAz')", irv);
		//setInterval("fadeout('txtAzTip')", irv);
		tim1=setInterval("fadeout('txtAz')", irv);
		tim2=setInterval("fadeout('txtAzTip')", irv);

	}
	else
	{

		//elAz[0].style.visibility = 'visible';
		//elAzTip[0].style.visibility = 'visible';
		elAz[0].style.height = '25px';
		elAzTip[0].style.height = '25px';
		radioDiv.style.paddingBottom = '35px';
		radioDiv.style.paddingBottom = '35px';
		//elAz[0].style.opacity=0.0;
		//clearTimer(tim);
		clearInterval(tim1);
		clearInterval(tim2);
		tim1=setInterval("fadein('txtAz')", irv);
		tim2=setInterval("fadein('txtAzTip')", irv);

	}

};

