function setLangue(lg)
{
	page = self.location.href.replace("&", "|");
	//alert(page);
	window.location.href='langue.php?lg='+lg+'&url='+page;;
}

function checkBrowser(){
	this.ver=navigator.appVersion;
	this.name=navigator.appName;
	this.mac=(navigator.platform.toLowerCase().indexOf('mac')>-1)?true:false;
	this.opera=(navigator.userAgent.toLowerCase().indexOf('opera')>-1)?true:false;
	this.dom=document.getElementById?true:false;
	this.ns=(this.name=='Netscape');
	this.ie4=(document.all && !this.dom)?true:false;
	this.ie=(this.name =='Microsoft Internet Explorer'&&!this.opera)?true:false;
	this.ie5=(this.ie && (navigator.userAgent.indexOf("MSIE 5")!=-1))?true:false;
	this.macie50=(this.mac&&this.ie5&&(navigator.userAgent.indexOf("MSIE 5.0")!=-1))?true:false
	this.macie51=(this.mac&&this.ie5&&(navigator.userAgent.indexOf("MSIE 5.1")!=-1))?true:false
	this.macie523=(this.mac&&this.ie5&&(navigator.userAgent.indexOf("MSIE 5.23")!=-1))?true:false
	this.ns4=(this.ns && parseInt(this.ver) == 4)?true:false;
	this.ns6=((this.name=="Netscape")&&(parseInt(this.ver)==5))?true:false
	this.standards=document.getElementById?true:false;
	this.dhtml=this.standards||this.ie4||this.ns4;
	this.macsafari=(this.mac&&this.ns&&(navigator.userAgent.indexOf("Safari")!=-1))?true:false
	//alert(this.ver+' -\- '+this.name+' -\- '+this.macsafari);
}

function popwin(url,name,w,h,optionlist,align)
{
	if(align == "center")
	{
		t = ((screen.height-h)/2);
		l = ((screen.width-w)/2);
		optionlist += (optionlist != "" ? "," : "")+"top="+t+",left="+l;
	}
	optionlist = optionlist != "" ? ","+optionlist : "";
	eval(name+" = window.open('"+url+"','"+name+"','width="+w+",height="+h+optionlist+"');");
	eval(name+".focus();");
}

function afficheresult(type,id)
{
	popwin('pages/spopup.php?type='+type+'&id='+id,'result',550,550,'scrollbars=no,resizable=no','center')
}

function modelesswin(url,name,w,h,optionlist,align)
{
	if (document.all&&window.print) //if ie5
	{
		eval(name+' = window.showModelessDialog(url,"'+name+'","scroll:1;status:0;center:1;help:1;resizable:1;dialogWidth:'+w+'px;dialogHeight:'+h+'px")');
	}
	else
	{
		popwin(url,name,w,h,'resizable=yes,scrollbars=yes,menubar=yes,status=no','center');
	}
}

function courrier(id,subid)
{
	if(id && subid)
	{
		popwin('pages/forum/popmail.php?id='+id+'&subid='+subid,'popmail',400,293,'resizable=no,scrollbars=no,menubar=no,status=no','center');
	}
}

function winprint()
{
	popwin('printpage.html','printpage',775,500,'resizable=yes,scrollbars=yes,menubar=yes,status=no','center');
}

function winsend()
{
	popwin('pages/popups/sendpage.php','sendpage',390,300,'resizable=no,scrollbars=no,menubar=no,status=no','center');
}

function windoc()
{
		popwin('upload/doc.doc','window',600,500,'resizable=yes,scrollbars=yes,menubar=yes,status=no','center');
}

function deplie(id)
{
	eval('etat = document.getElementById("smenu'+id+'").style.display == "block" ? "none" : "block" ;');
	eval('document.getElementById("smenu'+id+'").style.display = "'+etat+'";');
}

function checkMail(email)
{
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(email)) return true;
	else return false;
}

// trim()
String.prototype.trim = function()
{
 return this.replace(/(^\s*)|(\s*$)/g, '');
}

// trimEnd()
String.prototype.trimEnd = function()
{
 return this.replace(/\s*$/g, '');
}

// trimStart()
String.prototype.trimStart = function()
{
 return this.replace(/^\s*/g, '');
}

function valid(formtype)
{
	switch(formtype)
	{
		case "forum_c":
			formatEmail = new RegExp("^\\w[\\w+\.\-]*@[\\w\-]+\.\\w[\\w+\.\-]{2,}\\w$","gi");
			if(document.addmessage.nom.value.length < 1)
			{
				alert('Vous devez entrer votre nom ou pseudo.');
				return false;
			}
			if(document.addmessage.email.value.length < 1)
			{
				alert('Vous devez entrer votre adresse email.');
				return false;
			}
			if(!document.addmessage.email.value.match(formatEmail))
			{
				alert('Le format de votre email n\'est pas valide.');
				return false;
			}
			if(document.addmessage.message.value.length < 1)
			{
				alert('Vous devez entrer un message.');
				return false;
			}
			return true;
			break;
		case "popmail":
			formatEmail = new RegExp("^\\w[\\w+\.\-]*@[\\w\-]+\.\\w[\\w+\.\-]{2,}\\w$","gi");
			if(document.popmail.nom.value.length < 1)
			{
				alert('Vous devez entrer votre nom ou pseudo.');
				return false;
			}
			if(document.popmail.email.value.length < 1)
			{
				alert('Vous devez entrer votre adresse email.');
				return false;
			}
			if(!document.popmail.email.value.match(formatEmail))
			{
				alert('Le format de votre email n\'est pas valide.');
				return false;
			}
			if(document.popmail.message.value.length < 1)
			{
				alert('Vous devez entrer un message.');
				return false;
			}
			return true;
			break;
		default:
			return false;
			break;
	}
}

