//=======================================================================
// ROLLOVER EFFECT AND PRELOAD IMAGES
//=======================================================================



var lng = new String(window.location).toLowerCase().indexOf("/en/") >= 0 ? "en" : "fr";
var preloadFlag = false;

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}


function changeImages(id) {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			//document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
			document.getElementById(id).src = changeImages.arguments[i+1];
		}
	}
}


function preloadImages() {
	if (document.images) {

		// Images used for the roll over on the left menu
		img01 = newImage("/" + lng + "/images/top-02-over.gif");
		img02 = newImage("/" + lng + "/images/top-04-over.gif");
		img03 = newImage("/" + lng + "/images/top-06-over.gif");
		img04 = newImage("/" + lng + "/images/top-08-over.gif");
		img05 = newImage("/" + lng + "/images/top-10-over.gif");
		img06 = newImage("/" + lng + "/images/footer-email-over.gif");
		img07 = newImage("/" + lng + "/images/b-construction-over.jpg");
		img08 = newImage("/" + lng + "/images/b-construction-resi-over.jpg");
		img09 = newImage("/" + lng + "/images/b-construction-comm-over.jpg");
		img10 = newImage("/" + lng + "/images/b-electricite-over.jpg");
		img11 = newImage("/" + lng + "/images/b-automatisation-over.jpg");
		
		
		preloadFlag = true
	}
}


//=======================================================================
// SUBMENU EFFECT
//=======================================================================



var currentId = null;
var timer = null;



function styleCalque(idCalque) {
	if(document.all) calqueStyle = document.all[idCalque].style;
	else if(document.layers) calqueStyle = document.layers[idCalque];
	else calqueStyle = document.getElementById(idCalque).style;
	
	return calqueStyle;
}



function cacheMenu(idCalque) {
	styleCalque(idCalque).visibility = "hidden";
	currentId = null;
}



function affMenu(idCalque) {
	clearTimeout(timer);
	
	if(idCalque != currentId && currentId != null) {
		cacheMenu(currentId);
	}
	
	styleCalque(idCalque).visibility = "visible";
	currentId = idCalque;
}



function closemenu(idCalque) {
	timer = setTimeout("cacheMenu('" + idCalque + "');", 30);
}



//=======================================================================
// JQUERY FUNCTION
//=======================================================================


	// BOUTON CONSTRUCTION

$(document).ready(function(){

	if (open != 1){
	
	$('#b-construction-over').css({opacity:"0"});
	
		$('#b-construction-over').click(function(){

		if ( typeof( window[ 'lang' ] ) != "undefined" ) {
		   window.location = "/en/residentielle.asp";
		   } 
		else {
		   window.location = "/fr/residentielle.asp";
		   }

		});
	

		$('#b-construction-over').hover(function(){
			$('#b-construction-over').css({opacity: "1"});
			$('#b-construction').css({opacity: "0"});
		},
		function(){
			$('#b-construction-over').css({opacity: "0"});
			$('#b-construction').css({opacity: "1"});
	});

}

});



		// SCROLL

		$(function()
		{
			// this initialises the demo scollpanes on the page.
			$('#pane3').jScrollPane({scrollbarWidth:10, scrollbarMargin:10, wheelSpeed:30});
		});
		
		
		// SWITCH LANGUAGE
		
		$(document).ready(function(){
			str = document.URL;
			if (str.indexOf("/en/") != -1){
				$('#b-lang').parent("a").attr({href:"" + str.replace("/en/","/fr/") + ""});
			} else {
				$('#b-lang').parent("a").attr({href:"" + str.replace("/fr/","/en/") + ""});
			}
		});
		
		
		// RÉALISATIONS BACK BUTTON
		
		$(document).ready(function(){
						
			$('#b-retour-electricite').click(function(){
				document.location.href='../electricite.asp';
			});			
		});
