/*********************************************************************
/GLOBAL VARIABLES/
*********************************************************************/
theDoc = document


/*********************************************************************
NAV ALWAYS ON THE TOP
*********************************************************************/
var targetDelay = 0;
var thumbDelay = 0

function iniLeftNav() {
	objNavWindow = new divMaker('divNavWindow');
	objNavWindow.startPos = objNavWindow.y;
	objNavContent = new divMaker('divNavContent','divNavWindow');
	checkNavPosition();
	objNavWindow.show();
}

function checkNavPosition() {
	obj = objNavWindow;

	if(is.ie)      target = theDoc.body.scrollTop;
	else if(is.ns) target = window.pageYOffset;
	if(target<obj.startPos) target = obj.startPos;

	if(obj.y != target){
		obj.target = target
		moveToTarget(obj.target,obj.objName);
	}
	setTimeout('checkNavPosition();',1000);

}

function moveToTarget(target,objName) {
	obj = eval(objName);
	oldY = obj.y;
	distance = (obj.target - oldY)*0.08;
	newY = oldY +distance;
	obj.moveTo(null,newY);
	targetDelay = setTimeout("moveToTarget("+obj.target+","+obj.objName+")", 15);
	if (distance<0.05 && distance>-0.05) {
		obj.moveTo(null,target);
		clearTimeout(targetDelay);
	}
}

function handleThumb() {
		obj = objNavThumb;
		obj.target = (!obj.flagThumb) ? obj.thumbPosTop : obj.thumbPosBot;
		moveToTarget(obj.target,obj.objName);
		obj.flagThumb = !obj.flagThumb;
}

/*********************************************************************
BROWSER SNIFFER
*********************************************************************/
function browser() {
	nav = navigator;
	bwName = nav.appName;
	bwAgent = nav.userAgent;
	bwVer = parseInt(nav.appVersion);
	this.pc=(bwAgent.indexOf("Windows") != -1)  ? true:false;
	this.mac=(bwAgent.indexOf("Mac") != -1)  ? true:false;

	this.dom=theDoc.getElementById?true:false;

	this.op =(bwAgent.indexOf("Opera") != -1) ? true:false;
	this.ie =(bwAgent.indexOf("MSIE")!= -1  && !this.op) ? true:false;
	this.ns =(bwName=="Netscape") ? true:false;

	this.ie4 = (bwAgent.indexOf('MSIE 4')!= -1) ? true:false;
	this.ie6 = (bwAgent.indexOf("MSIE 6.")!= -1) ? true:false;
	this.ie5up = (this.ie && bwVer>=4) ? true:false;

	this.ns4 =(this.ns && bwVer==4) ? true:false;
	this.ns6=(this.ns && bwVer==5 &&(bwAgent.indexOf("Gecko") != -1)) ? true:false;;

	this.op5 = (bwAgent.indexOf("Opera 5.") != -1) ? true:false;;
	this.op6 =( (bwAgent.indexOf("Opera 6")!=-1) || (bwAgent.indexOf("Opera/6")!=-1) ) ? true:false;
}
is = new browser()

/*********************************************************************
DHTML OBJ CONSTRUCTOR
*********************************************************************/
function divMaker(id,ParentLay) {
	//customize to use ParentLayer
    Reflay = (ParentLay) ? 'document.'+ParentLay+'.' : ''
    this.elm = is.dom?theDoc.getElementById(id):is.ie4?theDoc.all[id]:is.ns4?eval(Reflay+'document.'+id):0;
    this.css = is.dom?this.elm.style:is.ie4?this.elm.style:is.ns4?this.elm:0;
    this.doc = (is.dom || is.ie4)?theDoc:is.ns4?this.css.document:0;
    this.x = (is.dom || is.ie4)?this.elm.offsetLeft:is.ns4?this.css.left:0;
    this.y = (is.dom || is.ie4)?this.elm.offsetTop:is.ns4?this.css.top:0;
    this.w = (is.dom || is.ie4)?this.elm.offsetWidth:is.ns4?this.css.clip.width:0;
    this.h = (is.dom || is.ie4)?this.elm.offsetHeight:is.ns4?this.css.clip.height:0;
	this.divName = id;
	this.objName = 'obj'+id.substr(3);

this.moveTo = moveTo;
this.show = show;
}
function moveTo(x,y) {
	if (x!=null) {
		this.x = x
		if (is.ie4) this.css.pixelLeft = this.x
		else this.css.left = this.x
	}
	if (y!=null) {
		this.y = y
		if (is.ie4) this.css.pixelTop = this.y
		else this.css.top = this.y
	}
}
function show() {
	this.css.visibility = (is.ns4)? "show" : "visible"
}

function isValidEmail(strEmail) {
	if (!/^[\.\w-]+@[\.\w-]+\.\w{2,4}$/g.test(strEmail))
		return true;
	else
		return false;
}
function checkFocus(obj) {
	if (obj.value=='                  Votre Email') obj.value='';
}

function checkForm()
	{
	if (is.ns4)
		{
		if (isValidEmail(document.divNavWindow.document.divNavContent.document.monform.email.value))
			alert("Veuillez entrer un email valide");
		else
		launchEmail();
		}
	else
		{

		if (isValidEmail(document.monform.email.value))
			alert("Veuillez entrer un email valide");
		else
		launchEmail();
		}
	}

function launchEmail() 
	{
		var formValue
		if (is.ns4)
			{
			formValue = document.divNavWindow.document.divNavContent.document.monform.email.value;
			}
		else
			{
			formValue = document.monform.email.value;
			}
			
		var MyWindow = window.open("demande_infos.asp?action=envoyer&Email="+formValue, "Contact", 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=yes,width=300,height=120,top=200,left=10');
		MyWindow.focus();
	}

function doPopUp(strFileName, intWidth, intHeight, strScroll, intTop, intLeft)
	{
	var parametres = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars='+ strScroll +',resizable=no,copyhistory=yes,left='+ intLeft +',top='+ intTop +',width='+ intWidth +',height='+ intHeight;
	var myContacts = window.open(strFileName, "Contacts", parametres); 
	myContacts.focus();
	}
