var pr = (window.print) ? 1:0;
var da = (document.all) ? 1:0;

function printThis() {
  if (pr) window.print();
  else if (da) vbPrintPage();
  else alert("Sorry, your browser doesn't support this feature. press ctrl + P to start printing.");
}


function handlePrintPage(url) {
	url = "print.php" + document.location.search;
	win = window.open(url,"printWin","statusbar=0,menubar=0,height=700,width=645");
}

function handleTDClick(urli) {
	document.location.href = urli;
}

function toggleContext(ev,objRef) {
        if(objRef && objRef.className) {
                objRef.className = (objRef.className == 'title')?'activeTitle':'title';
        }
}
function toggleClass(ev,objRef) {
        if(objRef && objRef.className) {
                if(objRef.className == 'navSub' || objRef.className == 'navSubHover') {
                        objRef.className = (objRef.className == 'navSub')?'navSubHover':'navSub';
                } else {
                        objRef.className= (objRef.className == 'navMain')?'navMainHover':'navMain';
                }
        }
}

function getToolboxDescription(ref) {

if(ref=="print") return "Imprimer ce document";
if(ref=="sitemap") return "Display a Sitemap of this Site ...";
if(ref=="links") return "Liens utiles";
if(ref=="contact") return "Nous &eacute;crire";
if(ref=="toolbox") return "Toolbox ...";
if(ref=="top") return "Goto top of this page ...";

}

function toggleToolboxImg(buttonObj,refString) {
//	alert(buttonObj.src);
}

var testT;

function handleToolboxMouseOut(ev,buttonObj,refString) {
//	buttonObj.src = "img/buttons/" + refString + ".gif";
	hideToolboxDesc(ev,buttonObj,refString);
}

function handleToolboxMouseOver(ev,buttonObj,refString) {
//	buttonObj.src = "img/buttons/" + refString + "_active.gif";
	//toogleToolboxImg(buttonObj,refString);
	showToolboxDesc(ev,buttonObj,refString);
}

function showToolboxDesc(ev,buttonObj,refString) {
	if(testT != null)clearTimeout(testT);
	hideAllToolboxDesc();
	buttonObj.src = "img/buttons/" + refString + "_active.gif";
	debug("showToolbox: " + refString);	
	helperObjRef = document.getElementById("toolbox_" + refString);
//	alert(helperObjRef);
//	alert(helperObjRef.id);
	
	boxWidth = parseInt(helperObjRef.style.width);
	boxHeight = parseInt(helperObjRef.style.height);
	
	scrollX = 0;
	scrollY = 0;
	
	buttonObjPos = getAnchorPosition(refString);
    hlpPosLeft = buttonObjPos.x;
	hlpPosTop = buttonObjPos.y;
	
//	alert(hlpPosLeft + " / " + boxWidth);
	
	helperObjRef.style.left = hlpPosLeft - boxWidth + 25;
	helperObjRef.style.top = hlpPosTop + 30;
	descStr = getToolboxDescription(refString);

	helperObjRef.style.visibility = "visible";
//	helperStr = toolBoxDescStr[refString].value;
//	alert(helperStr);
}

function hideAllToolboxDesc() {
/*
//	divCollection = document.getElementByTagName("DIV");
		if(document.body.all.tags)divCollection = document.body.all.tags("DIV");
//		if(document.body.getElementsByTagName("DIV"))divCollection = document.body.getElementsByTagName("DIV");

	for(i=0;i<divCollection.length;i++) {
	
		if(divCollection[i].ClassName == 'toolboxHelper') {
			divCollection[i].style.visibility="hidden";
		}
	}
	*/
	debug("hideAll");
	arStrings = Array("print","links","contact","home");
	for(i=0;i<arStrings.length;i++) {
//		alert(arStrings[i]);
		document.getElementById("toolbox_" + arStrings[i]).style.visibility = "hidden";
		document.getElementById("tb_img_" + arStrings[i]).src = "img/buttons/" + arStrings[i] + ".gif";
	}
	//document.getElementById("toolbox_links").style.visibility = "hidden";
	//document.getElementById("toolbox_contact").style.visibility = "hidden";
}

function hideToolboxDesc(ev, buttonObj, refString) {
	debug("hideToolbox: " + refString);
	helperObjRef = document.getElementById("toolbox_" + refString);
	nmTimeout = 500;
	
	codeString = "document.getElementById('tb_img_" + refString + "').src = 'img/buttons/" + refString + ".gif';"
	codeString += "helperObjRef.style.visibility='hidden';"
	testT = setTimeout(codeString, nmTimeout);
}

function handleHelperMouseover(divRef,ev,refString) {
//	alert(testT);
	if(testT)clearTimeout(testT);
}

function debug(str) {
	objRef = document.getElementById("debugDiv");
	objRef.innerHTML += str + "<br>";
}
