function $(t){return document.getElementById(t);}

function res(){

de=$("bf"); 
iO=de.offsetTop+de.offsetHeight+45;
b=$("body");
gg=$("bot");

if(iO<b.offsetHeight){
de.style['paddingBottom']=((b.offsetHeight-(iO))+20)+'px';
gg.style['top']=((b.offsetHeight-(iO))+20+45)+'px';
}

}


function hA(tx){with(tx){hD(tx,1);}}
function hB(tx){if(tx!=undefined){hD(tx,0.6);}}

function hD(tx,eV){
	with(tx){
	style['filter']="alpha(opacity="+(eV*100)+");";
	style['-moz-opacity']=eV;
	style['opacity']=eV;
	style['-khtml-opacity']=eV;
	}
}
function hC(tx){
	with(tx){
		var eX = 1;
		if(style['filter']!=undefined){
			eX = parseInt(style['filter'].substr(14,3))/100;
		}
		else if(style['-moz-opacity']!=undefined){
			eX = parseInt(style['-moz-opacity']);
		}
		else if(style['opacity']!=undefined){
			eX = parseInt(style['opacity']);
		}
		else if(style['-khtml-opacity']!=undefined){
			eX = parseInt(style['-khtml-opacity']);
		}
		return isNaN(eX)?1:eX;
	}
}

function iiC(tF,eI,eX,eV,eA){
 if(!eX(eA)){
	tF(eA);
	window.setTimeout(function(){iiC(tF,eI,eX,eV,eA);},eI);
 }
}



var eOpList = ['require','email'];

function vL(t,eA){
	var eOp = null;
	if(t==undefined){ return false; }
	
	for(eI in eA){
		switch(eA[eI]){
			case "require":
				if(t.value=="" || t.value=="undefined"){
					eOp=eA[eI];
				}
				break;
			case "email":
				if(!/^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+[.]{1}([a-zA-Z0-9-]{2,6})$/.test(t.value)){
					eOp=eA[eI];
				}
				break;
		}
	}
	
	if(eOp!=null){
		r = $(t.id+'_'+eOp);
		fOK($(t.id+'_ok'),0,r);
		fFalseb(t);
		return false;
	}
	else {
		for(eO in eOpList){
			r = $(t.id+'_'+eOpList[eO]);
			fFalse(r,0,t);
		}
		fOKb(t);
	}
	return true;
}

function fOK(nm,op,tx){
	if(op==1 && nm!=undefined){
		nm.style['display']="inline";
		hD(nm,0.1);
		iiC(function(rc){hD(rc[0],hC(rc[0])*2);},100,function(rc){if(hC(rc[0])==0){hD(rc[0],1);return true;}return hC(rc[0])<1?false:true;},undefined,[nm]);
	}
	else if(nm!=undefined) {
		iiC(function(rc){hD(rc[0],hC(rc[0])*0.2);},100,function(rc){if(hC(rc[0])>0.1){return false}else{rc[0].style['display']="none";fFalse(r,1);return true;}},undefined,[nm]);
	}
}


function fFalse(nm,op,t){
	if(op==1 && nm!=undefined){
		r.style['display']="inline";
		hD(r,0.1);
		iiC(function(rc){hD(rc[0],hC(rc[0])*2);},100,function(rc){return hC(rc[0])<1?false:true;},undefined,[nm]);
	}
	else if(nm!=undefined) {
		iiC(function(rc){hD(rc[0],hC(rc[0])*0.2);},100,function(rc){if(hC(rc[0])>0.1){return false}else{rc[0].style['display']="none";fOK($(t.id+'_ok'),1);return true;}},undefined,[nm]);

	}
}

function fFalseb(t){
	t.style['border']='1px solid #ff0000';
}
function fOKb(t){
	t.style['border']='1px solid #00cc00';
}


function sendForm(t){

 eT = [t.getElementsByTagName('input'),t.getElementsByTagName('select'),t.getElementsByTagName('textarea')];
 sArg={};
 for(eH in eT){
	for(eX in eT[eH]){
		if(eT[eH][eX].name!=undefined){
			if(eT[eH][eX].onchange!=undefined){
				if(!eT[eH][eX].onchange()){ return false; }
			}
			sArg+=escape(eT[eH][eX].name)+"="+escape(eT[eH][eX].value)+"&";
		}
	}
 }
 $('fLoad').style['display']= $('fLoade').style['display']='block';
 $('fLoad').style['top']=t.offsetTop+'px';
 $('fLoad').style['left']=t.offsetLeft+'px';
 $('fLoade').style['top']=t.offsetTop+(t.offsetHeight/2)+'px';
 $('fLoade').style['left']=t.offsetLeft+(t.offsetWidth/2)+'px';
 
		/*var myAjax = new Ajax.Request(
			'/fr/bulletin.php', 
			{
				method: 'post', 
				parameters: sArg, 
				onComplete: showResponse
			});*/
			
 return true;
}
function showResponse(s){
	$('fLoad').style['display']= $('fLoade').style['display']='none';

	eS = s.responseXML.getElementsByTagName('error')
	if(eS.item(0)!=undefined){
		if(eS.item(0).firstChild.data=="0: [0]"){
			$('errorLIST').innerHTML = ''; 
			for(i=1;eS.item(i)!=undefined;i++){
				$('errorLIST').innerHTML+='<h4>'+eS.item(i).firstChild.data+"</h4><br/>";
			}
		}
		else if(eS.item(0).firstChild.data=="0: [1]"){
			$('errorLIST').innerHTML = '<h4>Successful. We will reply as soon as possible.</h4>';
		}
	}

}