/*
JavaScript Functions


XHTML Strict and W3C DOM compliancy using getElementById()
*/

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

// Image Preloads
var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		front1_off = newImage('cimages/front1.jpg');
		front1_on = newImage('cimages/front1_on.jpg');
		front2_off = newImage('cimages/front2.jpg');
		front2_on = newImage('cimages/front2_on.jpg');
		front3_off = newImage('cimages/front3.jpg');
		front3_on = newImage('cimages/front3_on.jpg');
		front4_off = newImage('cimages/front4.jpg');
		front4_on = newImage('cimages/front4_on.jpg');
		services_off = newImage('cimages/services.jpg');
		services_on = newImage('cimages/services_on.jpg');
		joindre_off = newImage('cimages/joindre.jpg');
		joindre_on = newImage('cimages/joindre_on.jpg');
		projets_off = newImage('cimages/projets.jpg');
		projets_on = newImage('cimages/projets_on.jpg');
		title1_off = newImage('cimages/title1.jpg');
		title1_on = newImage('cimages/title1_on.jpg');
		title2_off = newImage('cimages/title2.jpg');
		title2_on = newImage('cimages/title2_on.jpg');
		title3_off = newImage('cimages/title3.jpg');
		title3_on = newImage('cimages/title3_on.jpg');
		title4_off = newImage('cimages/title4.jpg');
		title4_on = newImage('cimages/title4_on.jpg');
		
		
		preloadFlag = true;
	}
}

// Fancy fade transistion on mouseover
var transitionToggle = 0;
function changeImages() {
	if (document.getElementById && (preloadFlag == true)) {
		for (var i = 0; i < changeImages.arguments.length; i += 2) {
			id = changeImages.arguments[i];
			name = changeImages.arguments[i + 1];
			document.getElementById(id).filters[0].Apply();
			// After setting Apply(), changes to the object are not displayed until Play() is called.
			if (transitionToggle) {
				transitionToggle = 0;
				document.getElementById(id).src = eval(name + ".src");
			}
			else {
				transitionToggle = 1;
				document.getElementById(id).src = eval(name + ".src");
			}
			document.getElementById(id).filters[0].Play();
		}
	}
}

// Mouseover highlight for button form elements
// Must see if "className" exists first, so older browsers don't choke.
function hov(loc,cls) {
	if(loc.className) loc.className=cls;
}
