// JavaScript Document
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function togglePlus(obj) {
	obj.innerHTML = (obj.innerHTML.indexOf("+") == -1) ? "( + )" : "( - )&nbsp;";
	
}

function toggleSlideMenu() {
	if (document.menuOpen == null) document.menuOpen = true;
	if (document.tweening == null) document.tweening = false;
	if (document.tweening) return;
	document.tweening = true;
	if (!document.menuOpen) {
		var contObj = MM_findObj("menuLinks");
		if (contObj != null) contObj.className = "";
		var boundObj = MM_findObj("slideMenu");
		if (boundObj != null) boundObj.style.width = "450px";
		Tween(1);
	} else {
		Tween(-1);
	}
}

function Tween(direction,obj) {
	var ease = 0.2;
	var speed = 2;
	var slideObj = MM_findObj("slideMenuContent");
	if (slideObj == null) return;
	var startX = (direction > 0) ? parseInt(slideObj.offsetLeft) : 385+parseInt(slideObj.offsetLeft);
	var distance = Math.round(direction*speed*Math.abs(ease*startX));
	slideObj.style.left = (parseInt(slideObj.offsetLeft)+distance)+"px";
	if (distance == 0) {
		slideObj.style.left = (direction > 0) ? "0px" : "-385px";
		if (direction > 0) {
			document.menuOpen = true;
			var slideBtnObj = MM_findObj("slideBtn");
			if (slideBtnObj != null) slideBtnObj.innerHTML = "&lt;&lt; Menu";
		} else {
			document.menuOpen = false;
			var boundObj = MM_findObj("slideMenu");
			if (boundObj != null) boundObj.style.width = "65px";
			var contObj = MM_findObj("menuLinks");
			if (contObj != null) contObj.className = "hide";
			var slideBtnObj = MM_findObj("slideBtn");
			if (slideBtnObj != null) slideBtnObj.innerHTML = "Menu &gt;&gt;";
		}
		document.tweening = false;
		return;
	}
	setTimeout("Tween("+direction+")",50);
}

function menuWait() {
	if (document.menuWait == null) {
		document.menuWait = true;
	} else {
		toggleSlideMenu();
		return;
	}
	setTimeout("menuWait()",1000);
}

function showTab(id) {
	if (document.currentTab == null) document.currentTab = 1;
	var oldTab = MM_findObj("catTab"+document.currentTab);
	if (oldTab != null) oldTab.className = "catTabContent";
	var oldTabBtn = MM_findObj("tabBtn"+document.currentTab);
	if (oldTabBtn != null) oldTabBtn.className = "";
	var tabCont = MM_findObj("catTab"+id);
	if (tabCont != null) tabCont.className = "catTabContentShow";
	var tabBtn = MM_findObj("tabBtn"+id);
	if (tabBtn != null) tabBtn.className = "tabActive";
	var tabBar = MM_findObj("catTabtop");
	if (tabBar != null) tabBar.style.backgroundPosition = "01 "+((1-id)*25)+"px";
	document.currentTab = id;
}

function showGlosTab(str) {
	var partern = "ABCDEFGHIJKLMNOPQRSTUVWXYZNUM";
	var pos = partern.indexOf(str);
	if (document.currentGlosTab == null) document.currentGlosTab = "A";
	var oldTabBtn = MM_findObj("glosTabBtn"+document.currentGlosTab);
	if (oldTabBtn != null) oldTabBtn.className = "";
	var tabBtn = MM_findObj("glosTabBtn"+str);
	if (tabBtn != null) tabBtn.className = "glosTabBtnOn";
	var tabBar = MM_findObj("glosTabList");
	if (tabBar != null) tabBar.style.backgroundPosition = (pos*23)+"px "+((pos==0)?"0":((pos==26)?"-50px":"-25px"));
	var oldTab = MM_findObj("glosContent"+document.currentGlosTab);
	if (oldTab != null) oldTab.className = "glosContent";
	var tabCont = MM_findObj("glosContent"+str);
	if (tabCont != null) tabCont.className = "glosContentActive";
	document.currentGlosTab = str;
}

function showTip(str) {
	var tipObj = MM_findObj("actionTitle");
	if (tipObj != null) tipObj.innerHTML = str;
}

function isPhone(s) {
	if (s.search(/^[0-9\_\.]+$/) != -1) return true;
	return false;
}

function isFrPhone(s) {
	num1=s.substring(0,1);
	num2=s.substring(1,2);
//	alert(num1);
//	alert (num2);
	if (num1==0) {
		if (num2<=6 && num2>=1) {
			return true;
		}
	} 
	return false;
}

function isPhoneComplete(s)
{
	if (s.length < 10) return false;
	return true;
}

function frmagentalert(){
	var f=document.frmalert;
	var fs=document.consulter;
	if(f.email.value==""){
		alert ("Format d'email non valide !");
		f.email.focus();
		return false;
	}
	if(!isEmail(f.email.value)){
		alert ("Format d'email non valide !");
		f.email.focus();
		f.email.select();
		return false;
	}
}
	
function inputControl(number) {
	var pattern = "0123456789";
	
	if (len != 0)
	{
		var index = 0;
		var len = number.value.length;
		
		while ((index < len) && (len != 0))
			if (pattern.indexOf(number.value.charAt(index)) == -1)
			{
				if (index == len-1)
					number.value = number.value.substring(0, len-1);
				else if (index == 0)
					 	number.value = number.value.substring(1, len);
					 else number.value = number.value.substring(0, index)+number.value.substring(index+1, len);
				index = 0;
				len = number.value.length;
			}
			else index++;
	}
}



function slide(divID) {
	divObj = $(divID);
	if (divObj != document.toggleElement) {
		new Effect.toggle(document.toggleElement,'blind');
	
	}
	new Effect.toggle(divObj,'blind');
}

function ShowCegosPopup(url,title,width,height,resizable)
{
    window.open(
        url,
        title,
        'width=' + width + ',height=' + height + (resizable ? '' : ',resizable=no') + ',menubar=no,scrollbars=yes,directories=no,location=no,status=no,toolbar=no');
}

function getTotalTTC(id){
    clientId = "";
    iIndex = 0;
    while((clientId == "")&&(iIndex < document.elements.length)){
        if(document.elements[iIndex].id.indexOf(id,0) > 0){
            clientId = document.elements[iIndex].id;
        }
        iIndex++;
    }
    return clientId;
}