sfHover = function() {
	if(document.getElementById("menu_nav")) {
		var sfEls = document.getElementById("menu_nav").getElementsByTagName("LI");
		for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onmouseover=function() {
				this.className+=" sfhover";
			}
			sfEls[i].onmouseout=function() {
				this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
			}
		}
	}
}


// GETELEMENTSBYCLASSNAME
function getElementsByClassName(oElm, strTagName, strClassName){
    var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
    var arrReturnElements = new Array();
    strClassName = strClassName.replace(/\-/g, "\\-");
    var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
    var oElement;
    for(var i=0; i<arrElements.length; i++){
        oElement = arrElements[i];      
        if(oRegExp.test(oElement.className)){
            arrReturnElements.push(oElement);
        }   
    }
    return (arrReturnElements)
}
// FIN GETELEMENTSBYCLASSNAME
	
// SHORTCUT GETELEMENTSBYCLASSNAME
function gEbC(strClassName){
	return getElementsByClassName(document, "div", strClassName)[0];
}
// FIN SHORTCUT GETELEMENTSBYCLASSNAME

// ********************************************************** GESTION DU FOOTER
function isIe6(){
	var strChUserAgent = navigator.userAgent;
	var intSplitStart = strChUserAgent.indexOf("(",0);
	var intSplitEnd = strChUserAgent.indexOf(")",0);
	var strChStart = strChUserAgent.substring(0,intSplitStart);
	var strChMid = strChUserAgent.substring(intSplitStart, intSplitEnd);
	return (strChMid.indexOf("MSIE 6") != -1)
}
function getWindowHeight() {
	var windowHeight=0;
	if (typeof(window.innerHeight)=='number') {
		windowHeight=window.innerHeight;
	} else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight=
			document.documentElement.clientHeight;
		} else {
			if (document.body&&document.body.clientHeight) {
				windowHeight=document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}
function fixColumns() {
	if (document.getElementById) {
		var windowHeight=getWindowHeight();
		if (windowHeight>0) {
			var heightCenter = 0;
			if(document.getElementById("contenu_centre_home")){
				heightCenter = document.getElementById("contenu_centre_home").offsetHeight;
			}
			var heightHeader = 0;
			if(document.getElementById("header2")){
				heightHeader = document.getElementById("header2").offsetHeight;
			}
			var footerHeight = document.getElementById('footer').offsetHeight;
			if (windowHeight-(heightCenter + heightHeader + footerHeight)>=0) {
				var contentHeight = windowHeight - (heightHeader + footerHeight);
				if (isIe6()){
					contentHeight = contentHeight - 27;
				} else {
					contentHeight = contentHeight - 10;
				}
				document.getElementById("contenu_centre_home").style.height = contentHeight + "px" ;
			
			}
		}
	}
}
// ******************************************************** TABLE ROLLOVER INIT
function isIE(){
	return typeof(window.innerHeight) != 'number';
}

function cocher(idparent){
	document.getElementById(idparent).checked=true;		
}

function decocher(idparent) {
	if (document.getElementById(idparent).checked == false){
    	var liste = document.getElementById('ul_'+idparent);
    	var checkboxes = liste.getElementsByTagName("input");
    	for(i=0; i<checkboxes.length; i++){
    		if (checkboxes[i].checked == true){
    			checkboxes[i].checked=false;
    		}
    	}
    }        
}

function initTableWithHover(){
	if (isIE()){
		var tables = document.getElementsByTagName("table");
		for ( var i = 0 ; i < tables.length ; i++){
			if (tables[i].className == "tableWithHover"){
				var table = tables[i];
				var trs = table.getElementsByTagName("tr");
				for (var j = 0 ; j < trs.length ; j++){
					trs[j].onmouseover = function(){
						this.className = "over";
					}
					trs[j].onmouseout = function(){
						this.className = "";
					}
				}
			}
		}
	}
}
// ********************************************************** SEARCH BLOCK INIT
function initSearchBlock(id, txt){
	var searchInput = document.getElementById(id);
	if (searchInput){
		searchInput.onblur = function(){
			if (this.value == "")
				this.value = txt;
		}
		searchInput.onfocus = function(){
			if (this.value == txt)
				this.value = "";
		}
	}
}
// ************************************************************** DOCUMENT INIT
window.onload = function(){
	if (window.attachEvent)
		sfHover();
	fixColumns();
	initTableWithHover();
	initSearchBlock("searchInput", "Search");
	initSearchBlock("searchWord", "Word, Expression");
	initSearchBlock("searchReference", "Reference");
	griser('register_now');
	griser('ask_a_question')
	
	/* Market */
	if( navigator.appName!="Microsoft Internet Explorer" ) {
		var x = 1;
		while( document.getElementById('row1_'+x) != null ) {
			var largeur = document.getElementById('row1_'+x).offsetWidth;
			document.getElementById('top_th_'+x).width = ( largeur - 3 );
			x++;
		}
	}
}
window.onresize = fixColumns;


