/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
   GET OBJECTS
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
function gebi(str){
	return(document.getElementById(str));
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
function gebtn(tag){
	var p=document;
	var argv=gebtn.arguments;
	if(typeof(argv[1])!='undefined') p=argv[1];
	return(p.getElementsByTagName(tag));
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
function getSelectValue(obj){
	return(obj[obj.selectedIndex].value);
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
   UTILS
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
function ajax_decode(code){
	code=code.replace(/\[nl\]/g,'\n');
	return(code);
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
function flash(movie,width,height,bgColor,title,transparent){
	var code='';
	code+='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="'+width+'" height="'+height+'" align="middle" title="'+title+'">\n';
	code+='	<param name="allowScriptAccess" value="always" />\n';
	code+='	<param name="movie" value="'+movie+'" />\n';
	code+='	<param name="quality" value="high" />\n';
	if(transparent) code+='	<param name="wmode" value="transparent" />\n';
	if(bgColor) code+='	<param name="bgcolor" value="'+bgColor+'" />\n';
	code+='	<param name="menu" value="false" />\n';
	code+='	<embed src="'+movie+'" menu="false" quality="high"';
	if(transparent) code+=' wmode="transparent" ';
	if(bgColor) code+='bgcolor="'+bgColor+'"';
	code+=' width="'+width+'" height="'+height+'" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />\n';
	code+='</object>';
	document.write(code);
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
function goToLocation(loc){
	location.href=loc;
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
function isValidEmail(email){
	return(email.match(/^([a-z0-9])+([\.]?[_a-z0-9-]+)*@([a-z0-9]{1})([\.]?[a-z0-9-]+)+[\.]{1}[a-z]{2,6}$/i));
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
function newsletterFormCheck(f){
	if(f){
		var err='';
		var sof='\n- ';
		f.email.value=f.email.value.toLowerCase();
		if(!isValidEmail(f.email.value)) err+=sof+lg_nlsInvalidEmail;
		if(err=='') f.submit();
		else alert(lg_pleaseCheck+err);
	}
	return(false);
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
function showHide(obj){
	var rv=null;
	if (typeof(obj)=='string') obj=gebi(obj);
	if(obj){
		var argv=showHide.arguments;
		var show='switch';
		if(typeof(argv[1])!='undefined') show=argv[1];
		var disp='';
		if(!(show==true||(show=='switch'&&obj.style.display=='none'))) disp='none';
		obj.style.display=disp;
		rv=(disp=='')?true:false;
	}
	return(rv);
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
   LINKS
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
function customLinks(){
	var links=gebtn('a');
	for(i=0;i<links.length;i++){
		if(links[i].className.match(/([ ]*)ext([ ]*)/gi)) {
			links[i].onclick=function(){window.open(this.href);return(false);};
			links[i].title+=(links[i].title!='')?' ':'';
			links[i].title+='(Lien externe)';
		}
	}
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
   CONTACT FORM CHECK
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
var ContactFormCheck=function(){
	this.oVar='cfc';
	this.interval=null;
	this.charsCount=0;
	this.charsMax=0;
	this.idCharsCount='';
	this.idCharsMax='';
	this.idForm='';
	this.objCharsCount=null;
	this.objCharsMax=null;
	this.objForm=null;
	/* - - - - - - - - - - - - - - - - - - - - - - - - */
	this.init=function(oVar,formId,suffix,charsMax){
		this.oVar=oVar;
		this.charsMax=charsMax;
		this.idCharsCount=suffix+'CharsCount';
		this.idCharsMax=suffix+'CharsMax';
		this.idForm=formId;
		this.objCharsCount=gebi(this.idCharsCount);
		this.objCharsMax=gebi(this.idCharsMax);
		if(this.objCharsMax) this.objCharsMax.innerHTML=this.charsMax;
		this.objForm=gebi(this.idForm);
		this.interval=setInterval(this.oVar+'.count()',50);
		this.update();
	}
	/* - - - - - - - - - - - - - - - - - - - - - - - - */
	this.check=function(){
		var err='';
		var sof='\n- ';
		this.count();
		if(this.objForm.identity){
			if(this.objForm.identity.value.length<3) err+=sof+lg_cfcInvalidIdentity;
		}
		if(this.objForm.email){
			if(!isValidEmail(this.objForm.email.value)) err+=sof+lg_cfcInvalidEmail;
		}
		if(this.objForm.service){
			if(this.objForm.service.type=='select-one'){
				if(getSelectValue(this.objForm.service)=='0') err+=sof+lg_cfcInvalidService;
			}
		}
		if(this.objForm.company){
			if(this.objForm.company.value.length<3) err+=sof+lg_cfcInvalidCompany;
		}
		if(this.objForm.phone){
			if(this.objForm.phone.value.length<10) err+=sof+lg_cfcInvalidPhone;
		}
		if(this.objForm.shop){
			if(this.objForm.shop.value.length<3) err+=sof+lg_cfcInvalidShop;
		}
		if(this.objForm.message){
			if(this.objForm.message.value.length<20) err+=sof+lg_cfcInvalidMessage;
		}
		if(err==''){
			if(confirm(lg_cfcSendConfirm)){
				this.objForm.action='contactMail.php';
				this.objForm.submit();
			}
		}else{
			alert(lg_pleaseCheck+err);
		}
		return(false);
	}
	/* - - - - - - - - - - - - - - - - - - - - - - - - */
	this.count=function(){
		var kill=true;
		if(this.objForm){
			if(this.objForm.message){
				kill=false;
				this.charsCount=this.objForm.message.value.length;
				if(this.charsCount>this.charsMax){
					this.charsCount=this.charsMax;
					this.objForm.message.value=this.objForm.message.value.substr(0,this.charsMax);
				}
				this.update();
			}
		}
		if(kill&&this.interval){
			clearInterval(this.interval);
			this.interval=null;
		}
	}
	/* - - - - - - - - - - - - - - - - - - - - - - - - */
	this.update=function(){
		if(this.objCharsCount){
			this.objCharsCount.innerHTML=this.charsCount;
		}
	}
	/* - - - - - - - - - - - - - - - - - - - - - - - - */
}

/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
   MISC
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
function rider_defaultThumb(){
	var o=gebi('teamRiders');
	if(o){
		var imgs=gebtn('img',o);
		var i;
		for(i=0;i<imgs.length;i++){
			imgs[i].onerror=function(){this.src='img/riders/default.jpg';};
		}
	}
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
window.defaultStatus='TECARE';
