<!--
function win(fileName) {
     myFloater = window.open('','myWindow','scrollbars=yes,status=no,width=300,height=300')
     myFloater.location.href = fileName;
}
function winimage(fileName,width,height) {
     myFloater = window.open(fileName,'myWindow','resizable=1,scrollbars=1,status=0,width=' + width + ',height=' + height)
    // myFloater.location.href = fileName;
}
function swapImages() {
  var i,p,v,obj,args=swapImages.arguments;
  for (i=0; i< (args.length-2); i+=3)
	if ((obj=document.getElementById(args[i]))!=null) {
		v=args[i+2];
    		if (obj.style) {
			obj=obj.style;
			v=(v=='show')?'visible':(v='hide')?'hidden':v;
		}
    		obj.visibility=v;
	}
}
function taLimiter(nom_controletexte, nbcar, nom_controledecompte){
    var textarea = document.getElementById(nom_controletexte);
    var countctrl = document.getElementById(nom_controledecompte);
    if (textarea && countctrl){
		textarea.onclick = function(){TextAreaEstRempli(textarea, nbcar, countctrl)};
		textarea.onblur = function(){TextAreaEstRempli(textarea, nbcar, countctrl)};
		textarea.onkeyup = function(){TextAreaEstRempli(textarea, nbcar, countctrl)};
		textarea.onkeypress = function(){TextAreaEstRempli(textarea, nbcar, countctrl)};
		if(countctrl.type) {
			countctrl.value = NbCarRestant(textarea, nbcar);
		} else {
	     	countctrl.innerHTML = NbCarRestant(textarea, nbcar);
	    }
	}
}
function TextAreaEstRempli(textarea, nbcar, countctrl){
	if (textarea){
		if (textarea.value.length <= nbcar){
			if(countctrl.type) {
				countctrl.value = NbCarRestant(textarea, nbcar);
			} else {
				countctrl.innerHTML = NbCarRestant(textarea, nbcar);
			}
			return true;
		} else {
			textarea.value = textarea.value.substr(0, nbcar);
			if(countctrl.type) {
				countctrl.value = NbCarRestant(textarea, nbcar);
			} else {
				countctrl.innerHTML = NbCarRestant(textarea, nbcar);
			}
			return false;
		}
	}
}
function NbCarRestant(textarea, nbcar){
	if (textarea.value.length) {
		return new Number(nbcar - textarea.value.length);
	} else {
		return new Number(nbcar);
	}
}
function rollMnIn(el){
	document.getElementById(el).style.background= '#F7F7F7';
	document.getElementById(el).style.cursor='pointer';
	return false;
}
function rollMnOut(el){
	document.getElementById(el).style.background= '#FFF';
	return false;
}

var overlayImage = new Image(); 
overlayImage.src = 'images/misc/overlay.png';
var loadingImage = 'images/misc/loading.gif';		
function getPageScroll(){
	var yScroll;
	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}
	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}
function getPageSize(){
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}
	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}
function makeOverlay(objLink){
	var objOverlay = document.getElementById('overlay');
	var objLoadingImage = document.getElementById('loadingImage');
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	// center loadingImage if it exists
	if (objLoadingImage) {
		objLoadingImage.style.top = (arrayPageScroll[1] + ((arrayPageSize[3] - 35 - objLoadingImage.height) / 2) + 'px');
		objLoadingImage.style.left = (((arrayPageSize[0] - 20 - objLoadingImage.width) / 2) + 'px');
		objLoadingImage.style.display = 'block';
	}
	// set height of Overlay to take up whole page and show
	objOverlay.style.height = (arrayPageSize[1] + 'px');
	objOverlay.style.display = 'block';
}
function initLightbox(){
	if (!document.getElementsByTagName){ return; }
	// the rest of this code inserts html at the top of the page that looks like this:
	// <div id="overlay">
	//		<img id="loadingImage" />
	//	</div>
	var objBody = document.getElementsByTagName("body").item(0);
	// create overlay div and hardcode some functional styles (aesthetic styles are in CSS file)
	var objOverlay = document.createElement("div");
	objOverlay.setAttribute('id','overlay');
	objOverlay.style.display = 'none';
	objOverlay.style.position = 'absolute';
	objOverlay.style.top = '0';
	objOverlay.style.left = '0';
	objOverlay.style.zIndex = '90';
 	objOverlay.style.width = '100%';
	objBody.insertBefore(objOverlay, objBody.firstChild);
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	// preload and create loader image
	var imgPreloader = new Image();
	// if loader image found, create link to hide lightbox and create loadingimage
	imgPreloader.onload=function(){
		var objLoadingImage = document.createElement("img");
		objLoadingImage.src = loadingImage;
		objLoadingImage.setAttribute('id','loadingImage');
		objLoadingImage.style.position = 'absolute';
		objLoadingImage.style.zIndex = '150';
		objOverlay.appendChild(objLoadingImage);
		imgPreloader.onload=function(){};	//	clear onLoad, as IE will flip out w/animated gifs
		return false;
	}
	imgPreloader.src = loadingImage;
}

function initRollovers()	{
	var upSuffix = '_u';
	var overSuffix = '_o';
	var W3CDOM = (document.createElement && document.getElementsByTagName);
	if (!W3CDOM) return;
	var mouseOvers = new Array();
	var mouseOuts = new Array();
	var imgs = document.getElementsByTagName('img');
	for (var i=0; i < imgs.length; i++){
		var suffix = imgs[i].src.substring(imgs[i].src.lastIndexOf('.'));
		var sel = imgs[i].src.substring(imgs[i].src.lastIndexOf('_'));
		if (sel == upSuffix+suffix) {
			mouseOuts[i] = new Image();
			mouseOuts[i].src = imgs[i].src;
			mouseOvers[i] = new Image();
			mouseOvers[i].src = imgs[i].src.substring(0,imgs[i].src.lastIndexOf('_')) + overSuffix + suffix;
			imgs[i].onmouseover = mouseGoesOver;
			imgs[i].onmouseout = mouseGoesOut;	
			imgs[i].onclick = mouseGoesOut;	
			imgs[i].number = i;
		}
	}
	function mouseGoesOver(){;
		this.src = mouseOvers[this.number].src;
	}
	function mouseGoesOut(){
		this.src = mouseOuts[this.number].src;
	}
	var mouseOvers2 = new Array();
	var mouseOuts2 = new Array();
	var inputs = document.getElementsByTagName('input');
	for (var i=0; i < inputs.length; i++){
		var suffix = inputs[i].src.substring(inputs[i].src.lastIndexOf('.'));
		var sel = inputs[i].src.substring(inputs[i].src.lastIndexOf('_'));
		if (sel == upSuffix+suffix) {
			mouseOuts2[i] = new Image();
			mouseOuts2[i].src = inputs[i].src;
			mouseOvers2[i] = new Image();
			mouseOvers2[i].src = inputs[i].src.substring(0,inputs[i].src.lastIndexOf('_')) + overSuffix + suffix;
			inputs[i].onmouseover = mouseGoesOver2;
			inputs[i].onmouseout = mouseGoesOut2;		
			inputs[i].number = i;
		}
	}
	function mouseGoesOver2(){;
		this.src = mouseOvers2[this.number].src;
	}
	function mouseGoesOut2(){
		this.src = mouseOuts2[this.number].src;
	}	
}

function getInputChange(txtCtrl, priceCtrl, selCtrl){
	
    var textinput = document.getElementById(txtCtrl);
    var countctrl = document.getElementById(priceCtrl);
    var selectList = document.getElementById(selCtrl);
    var priceArray = new Array();

 	selectList.onchange = function(){
 		if (selectList.selectedIndex != 0) {
			textinput.value = "";
			updateCtrl(textinput, countctrl);
		}
	};
	
    if (textinput && countctrl){
		textinput.onclick = function(){
			updateCtrl(textinput, countctrl);
		};
		textinput.onblur = function(){
			updateCtrl(textinput, countctrl);
		};
		textinput.onkeyup = function(){
			updateCtrl(textinput, countctrl);
		};
		textinput.onkeypress = function(){
			updateCtrl(textinput, countctrl);
			if (selectList.selectedIndex != 0) {
				selectList.selectedIndex = 0; 
			}
		};
		
		priceArray = getPrice(textinput);
		if(countctrl.type) {
			countctrl.value = priceArray["totalPrice"];
		} else {
	     	countctrl.innerHTML = priceArray["totalPrice"];
	    }
	}
}

function getInputChangeWithCom(txtCtrl, priceCtrl, comCtrl){
	
    var textinput = document.getElementById(txtCtrl);
    var countctrl = document.getElementById(priceCtrl);
    var commctrl = document.getElementById(comCtrl);
    var priceArray = new Array();
    	
    if (textinput && countctrl){
		textinput.onclick = function(){
			updateCtrl2(textinput, countctrl, commctrl);
		};
		textinput.onblur = function(){
			updateCtrl2(textinput, countctrl, commctrl);
		};
		textinput.onkeyup = function(){
			updateCtrl2(textinput, countctrl, commctrl);
		};
		textinput.onkeypress = function(){
			updateCtrl2(textinput, countctrl, commctrl);
			if (selectList.selectedIndex != 0) {
				selectList.selectedIndex = 0; 
			}
		};
		
		priceArray = getPrice(textinput);
		if(countctrl.type) {
			countctrl.value = priceArray["totalPrice"];
			commctrl.value = priceArray["commission"];
		} else {
	     	countctrl.innerHTML = priceArray["totalPrice"];
	     	commctrl.innerHTML = priceArray["commission"];
	    }
	}
}

function updateCtrl(textinput, countctrl){
	var priceArray = new Array();
	
	if (textinput){
		priceArray = getPrice(textinput);
		if(countctrl.type) {
			countctrl.value = priceArray["totalPrice"];
		} else {
	     	countctrl.innerHTML = priceArray["totalPrice"];
	    }	
	}
}
function updateCtrl2(textinput, countctrl, commctrl){
	var priceArray = new Array();

	if (textinput){
		priceArray = getPrice(textinput);
		if(countctrl.type) {
			countctrl.value = priceArray["totalPrice"];
			commctrl.value = priceArray["commission"];
		} else {
	     	countctrl.innerHTML = priceArray["totalPrice"];
	     	commctrl.innerHTML = priceArray["commission"];
	    }	
	}
}
function getPrice(textinput){
	
	var origPrice = textinput.value;
	var totalPrice = new Number();
	var commission = new Number();
	var priceArray = new Array();
	//Pour recherche d'une chaine de type "x(n)", "x(n),nn" ou "x(n).nn"
	var suitExp = new RegExp("^[0-9]+((,|[.])[0-9]{0,2})?$", "g");
	
	if (suitExp.test(origPrice)) {
		
		origPrice = str_replace(',', '.', origPrice);
		origPrice = Number(origPrice);
		
		if (0 <= origPrice && origPrice <= 800) {
			totalPrice = origPrice + 80;
		} else if (800 < origPrice && origPrice <= 30000) {
			totalPrice = (origPrice * 10 / 100) + origPrice;
		} else if (30000 < origPrice && origPrice <= 60000) {
			totalPrice =  (origPrice - 30000) * (9/100) + 3000 + origPrice;
		} else if (60000 < origPrice && origPrice <= 90000) {
			totalPrice =  (origPrice - 60000) * (8/100) + 5700 + origPrice;
		} else if (90000 < origPrice && origPrice <= 120000) {
			totalPrice =  (origPrice - 90000) * (7/100) + 8100 + origPrice;
		} else if (120000 < origPrice && origPrice <= 150000) {
			totalPrice =  (origPrice - 120000) * (6/100) + 10200 + origPrice;
		} else if (150000 < origPrice && origPrice <= 180000) {
			totalPrice =  (origPrice - 150000) * (5/100) + 12000 + origPrice;
		} else if (180000 < origPrice) {
			totalPrice =  (origPrice - 180000) * (4/100) + 13500 + origPrice;
		}
		
		totalPrice = Math.round(totalPrice*100)/100;
		commission = totalPrice - origPrice;
		commission = Math.round(commission*100)/100;
		
		totalPrice = totalPrice + " &euro";
		commission = commission + " &euro";
		
		
	} else {
		totalPrice = "-";
		commission = "-";
	}
	
	priceArray["totalPrice"] = totalPrice;
	priceArray["commission"] = commission;
	return priceArray
}

function str_replace(a, b, str) {
    return str_replace2(str, a, b);
}
function str_replace2(SRs, SRt, SRu) {
  SRRi = SRs.indexOf(SRt);
  SRRr = '';
  if (SRRi == -1) return SRs;
  SRRr += SRs.substring(0,SRRi) + SRu;
  if ( SRRi + SRt.length < SRs.length)
    SRRr += str_replace2(SRs.substring(SRRi + SRt.length, SRs.length), SRt, SRu);
  return SRRr;
}
function confirmGoto(){
	//if(confirm(txt)) {
	//	document.location.href=link;
	//}
}

window.onload = initRollovers;

function addLoadEvent(func){	
	var oldonload = window.onload;
	if (typeof window.onload != 'function'){
    	window.onload = func;
	} else {
		window.onload = function(){
		oldonload();
		func();
		}
	}
}
addLoadEvent(initLightbox);

//-->
