// *****************************************   Preload des images

var myimages=new Array()

	function preloadimages(){
		for (i=0;i<preloadimages.arguments.length;i++){
			myimages[i]=new Image()
			myimages[i].src=preloadimages.arguments[i]
		}
	}

//preloadimages("");

//<body onload="preloadimages()">

// OnFocus - clear text

function defaultText(obj, text) {
	if (obj.value == text) obj.value = "";
	else if (obj.value == "") obj.value = text;
	}

// showHideElement()

function showHideElement(obj){
    var my_element = document.getElementById(obj);

    if (my_element.style.display == "none"){
        my_element.style.display = "block";
    } else {
        my_element.style.display = "none";
    }
}

// showElement()

function showElement(obj){
    var my_element = document.getElementById(obj);
    my_element.style.display = "block";
}

// hideElement()

function hideElement(obj){
    var my_element = document.getElementById(obj);
    my_element.style.display = "none";
}

// get total dimensions of a broswer window
// taken from : http://codylindley.com/Webdev/295/javascript-get-page-height-with-scroll
function getPageSizeWithScroll() {
	if (window.innerHeight != undefined && window.scrollMaxY  != undefined) { // Firefox
		yWithScroll = window.innerHeight + window.scrollMaxY;
		xWithScroll = window.innerWidth + window.scrollMaxX;
	} else if (window.innerHeight && document.body.scrollHeight > document.body.offsetHeight) {
		yWithScroll = (window.innerHeight > document.body.scrollHeight) ? window.innerHeight : document.body.scrollHeight;
		xWithScroll = (window.innerWidth > document.body.scrollWidth) ? window.innerWidth : document.body.scrollWidth;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		yWithScroll = document.body.scrollHeight;
		xWithScroll = document.body.scrollWidth;
	} else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
		yWithScroll = document.body.offsetHeight + document.body.offsetTop;
		xWithScroll = document.body.offsetWidth + document.body.offsetLeft;
  	}
	
	arrayPageSizeWithScroll = new Array(xWithScroll, yWithScroll);
	//alert( 'The height is ' + yWithScroll + ' and the width is ' + xWithScroll );
	return arrayPageSizeWithScroll;
}

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;
	}
	//alert('yScroll = ' + yScroll);
	
	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.scrollHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}
	//alert('windowHeight = ' + windowHeight);
	
	// 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) 
	//alert('pageWidth = ' + pageWidth + ', pageHeight = ' + pageHeight + ', windowWidth = ' + windowWidth + ', windowHeight = ' + windowHeight);
	return arrayPageSize;
}

// once body is loaded, need to compare window height with actual height...
// if actual height is greater, means scrollbar is activated, and we must change the params of class 'bg_container' so that height is not limited to 100% ... switch to 'bg_container_xl'
function checkBody(divId, newClass, oldClass) {
	wh = window.innerHeight;	//FF
	if ( !wh ) {
		wh = document.body.clientHeight;	//IE
	}
	
	// get page dims
	check = getPageSize();
	//alert($('the_bg_container').innerHeight);
	
	// compare window height with actual height
	if (wh < check[1]) {
		// change the class of the div
		document.getElementById(divId).className = newClass;
	} else {
		if (document.getElementById(divId).className == newClass && oldClass != "") {
			document.getElementById(divId).className = oldClass;
		}
	}
}

// taken from : http://www.howtocreate.co.uk/tutorials/javascript/browserwindow
function alertSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  window.alert( 'Width = ' + myWidth );
  window.alert( 'Height = ' + myHeight );
}

// taken from : http://www.howtocreate.co.uk/tutorials/javascript/browserwindow
function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}
