/************************************************************************************************************
CENTERED ULTIMATE TOOLTIP
************************************************************************************************************/
function fadeIn(paragraphId,couleur){ 
	if(couleur<255) { //If color is not white yet
		couleur+=11; // increase color darkness
		document.getElementById(paragraphId).style.color="rgb("+couleur+","+couleur+","+couleur+")";
		setTimeout("fadeIn(\'"+paragraphId+"\', "+couleur+")",10); 
	}
	else {
	couleur=0; //reset couleurTitre value
	}
}
function fadeOut(paragraphId,couleur){ 
	if(couleur>0) { //If color is not black yet
		couleur-=11; // increase color darkness
		document.getElementById(paragraphId).style.color="rgb("+couleur+","+couleur+","+couleur+")";
		setTimeout("fadeOut(\'"+paragraphId+"\', "+couleur+")",10); 
	}
	else {
	couleur=255; //reset couleurTitre value
	document.getElementById(paragraphId).style.top=-500+"px";
	}
}
function showAbsoluteTooltipText (DivID){
	DivIDWidth = document.getElementById(DivID).style.width.substr(0, (document.getElementById(DivID).style.width.length-2));
	DivIDHeight = document.getElementById(DivID).style.height.substr(0, (document.getElementById(DivID).style.height.length-2));
	document.getElementById(DivID).style.left=(getWindowWidth()/2)-(DivIDWidth/2)+"px";
	document.getElementById(DivID).style.top=(getWindowHeight()/2)-(DivIDHeight/2)+"px";
	fadeIn(DivID,0);
	setTimeout("fadeOut(\'"+DivID+"\', 255)",4500); 
}
/************************************************************************************************************
GET WINDOW HEIGHT & WIDTH
************************************************************************************************************/
function getWindowWidth() {
	var windowWidth=0;
	if (typeof(window.innerWidth)=="number") {
		windowWidth=window.innerWidth;
	}
	else {
		if (document.documentElement&&
		document.documentElement.clientWidth) {
			windowWidth = document.documentElement.clientWidth;
		}
		else {
			if (document.body&&document.body.clientWidth) {
				windowWidth=document.body.clientWidth;
			}
		}
	}
	return windowWidth;
}
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;
}
/************************************************************************************************************
START BLAJAX (c) 2007 Baudouin LAMOURERE - BLWORKS.NET
************************************************************************************************************/
//close function//
function hideMe(who){
	document.getElementById(who).style.display = "none";
}
var blajax_xmlhttp;
var div2fill;
var myCallBack;
function blajax(aj_method,url,datas,div2update,callbackFunction) {
	div2fill = div2update;
	myCallBack=callbackFunction;
	if (div2fill == "fullscreen"){
          dragObject = document.createElement("DIV");
          document.body.appendChild(dragObject);
          dragObject.setAttribute('id','fullscreen');
		document.getElementById(div2fill).style.height = getWindowHeight()+"px";
		//-20px to avoid horizontal scrollbar !
		document.getElementById(div2fill).style.width = (getWindowWidth()-20)+"px";
		document.getElementById(div2fill).style.color = "#000000";
		document.getElementById(div2fill).style.zIndex = "100000";
		document.getElementById(div2fill).style.display = "block";
		document.getElementById(div2fill).style.top = "0px";
		document.getElementById(div2fill).style.left = "0px";
                document.getElementById(div2fill).style.position = "absolute";
		document.getElementById(div2fill).innerHTML = "<table style=\"height:100%;width:100%;\"><tr><td style=\"vertical-align:middle;text-align:center;\"><div style=\"text-align:center;background:#ffffff;border:1px solid #000000;width:550px;margin:auto;padding:5px;\"><img src=\".\/includes/loading.gif\" alt=\"loading\" title=\"loading\" style=\"vertical-align:middle;\" \/> loading...<\/div><\/td><\/tr><\/table>";
	} else {
		document.getElementById(div2fill).innerHTML = "<img src=\".\/includes/loading.gif\" alt=\"loading\" title=\"loading\" style=\"vertical-align:middle;\" \/> loading...";
	}
	if(window.XMLHttpRequest) blajax_xmlhttp = new XMLHttpRequest();
	if(window.ActiveXObject) blajax_xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	if(blajax_xmlhttp && blajax_xmlhttp.readyState < 4) blajax_xmlhttp.abort();
	blajax_xmlhttp.onreadystatechange = processjax;
	if (aj_method=="GET"){
		urlToGo = url +"?"+ datas + "&linkjax="+(Math.random()*99999);// random for IE to stop caching...stupid ie
		blajax_xmlhttp.open(aj_method, urlToGo, true);
		blajax_xmlhttp.send(null);
	} else {
		urlToGo = url + "?linkjax="+(Math.random()*99999);// random for IE to stop caching...stupid ie
		blajax_xmlhttp.open("POST", urlToGo, true);
		blajax_xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		blajax_xmlhttp.send(datas);
	}
	return false; // AJAX called, tell browser to stop the follow through on the link
}

function processjax() {
	if(blajax_xmlhttp.readyState == 4 && blajax_xmlhttp.status == 200) {
          if (myCallBack=="reload") window.location.reload();
		if (div2fill == "fullscreen"){
			document.getElementById(div2fill).innerHTML = "<table style=\"height:100%;width:100%;\"><tr><td style=\"vertical-align:middle;text-align:center;\"><div id=\"floatingForm\" style=\"position:relative;text-align:left;background:#ffffff;border:1px solid #000000;width:550px;margin:auto;padding:5px;overflow-x:hidden;height:"+(400)+"px;overflow-y:scroll;\"><div style=\"position:absolute;right:5px;\"><a href=\"javascript:hideMe(\'"+div2fill+"\');\">close<\/a><\/div>" + blajax_xmlhttp.responseText + "<\/div><\/td><\/tr><\/table>";
		} else {
			document.getElementById(div2fill).innerHTML = blajax_xmlhttp.responseText;
		}
	}
	if(blajax_xmlhttp.readyState == 4 && blajax_xmlhttp.status != 200) {
		document.getElementById(div2fill).innerHTML = "<table style=\"height:100%;width:100%;\"><tr><td style=\"vertical-align:middle;text-align:center;\"><div id=\"floatingForm\" style=\"position:relative;text-align:left;background:#ffffff;border:1px solid #000000;width:550px;margin:auto;padding:5px;overflow-x:hidden;height:"+(getWindowHeight()-50)+"px;overflow-y:scroll;\"><div style=\"position:absolute;right:5px;\"><a href=\"javascript:hideMe(\'"+div2fill+"\');\">close<\/a><\/div>error<\/div><\/td><\/tr><\/table>";
	}
}

function only_number(input) {
         var num = input.value.replace(/\./g,'');
         input.value = input.value.replace(/[^\d]*/g,'');
}
function isValidEmail(str)
{
	var x = str;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(x)) {
	  //alert('YES! Correct email address');
          return true;
        } else {
                 alert('Incorrect email address');
        return false;
        }
}
/************************************************************************************************************
CSS CLASS TABS SWITCHER
************************************************************************************************************/
	function tabCSSswitch(prefix,id,total,newclassname){
		for(i=1;i<(total+1);i++)
		{
			document.getElementById(prefix+i).className="";
		}
		document.getElementById(prefix+id).className=newclassname;
         }
function print_date(){
	Stamp = new Date();
	theDay = Stamp.getDate();
	theMonth = Stamp.getMonth()+ 1;
        if (theDay <10){
	     theDay ="0" + theDay;
        }
        if (theMonth <10){
	     theMonth ="0" + theMonth;
        }

	//document.write();
	var Hours;
	var Mins;
	Hours = Stamp.getHours();
	Mins = Stamp.getMinutes();
	if (Hours < 10) {
		Hours = "0" + Hours;
	}
	if (Mins < 10) {
		Mins = "0" + Mins;
	}
	
	document.write(theDay +"/"+ theMonth + "/"+ Stamp.getFullYear() + ' - ' + Hours + ":" + Mins + '');
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////
//TOOLTIP !!!!
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
function ToolTip(e,text,TTwidth){
	if(document.all)e = event;
	if (!TTwidth) TTwidth=147;
	var obj = document.getElementById('bubble_tooltip');
	var obj2 = document.getElementById('bubble_tooltip_content');
	obj2.innerHTML = text;
	obj.style.width = TTwidth + "px";
        obj.style.width = 'auto';
        //newWidth = obj.offsetWidth;
        obj.style.display = 'block';
	
	var leftPos = e.clientX +20;//TTwidth ;
	if(leftPos<0)leftPos = 0;
	obj.style.left = leftPos + 'px';
	

	//var st = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
	var st = document.documentElement.scrollTop;
	if(navigator.userAgent.toLowerCase().indexOf('safari')>=0) st=document.body.scrollTop; 

	topPos = e.clientY + st;
	//alert(getWindowHeight()+"/"+obj.offsetHeight+"/"+e.clientY+"/"+document.body.scrollTop+"/"+document.documentElement.scrollTop);
	if(topPos+obj.offsetHeight>getWindowHeight()+ st) topPos -= obj.offsetHeight;
	obj.style.top =  topPos + 'px';
	//obj.style.top = (e.clientY+3)+'px';
	//obj.style.left = (e.clientX+3)+'px';

}

function hideToolTip(){
	document.getElementById('bubble_tooltip').style.display = 'none';
}

/************************************************************************************************************
DIV VISIBLE/HIDE
************************************************************************************************************/
function toggle(id) {
			if (document.getElementById(id).style.display == '' || document.getElementById(id).style.display == 'block'){
				document.getElementById(id).style.display = 'none';
			} else {
				document.getElementById(id).style.display = '';
			}
}
function toggleTD(id) {
			if (document.getElementById(id).style.display == ''){
				document.getElementById(id).style.display = 'none';
			} else {
				document.getElementById(id).style.display = '';
			}
}