/* ///////////////////////////////////////////////////////////////////////////////////////////
CODE MIXING BY MOLOKOLOCO for PROXITEK... [BETA TESTING FOR EVER] ............................

Functions :

	-> $() 												: GET BY ID... --> alert($('titre').value); || $('test').style.display = none;
	-> strRep(string,strSearch,strRep)					: STRING REPLACE
	-> Go(gototo)										: GOTO --> onClick="Go('actualite');" = index2.php?goto=actualite
	-> creatDiv(idDiv,parent_id,styleDiv,contentHtm) 	: CREER UNE DIV
	-> myPop(url,name,Wwide,Whigh) 						: POP UP URL
	-> PopImg(imageURL,imageTitle)						: POP UP IMAGE
	-> RollOver(imgId,imgSrc) 							: ROLLOVER IMAGE
	-> showHide()										: SHOW/ HIDE ELEMENT ID... (X ID arguments) --> showHide('divTitre','divMenu');
	-> printInfo(infos) 								: Utilise la div du header pour afficher des infos DYN (Ajax)
	-> MM_swapImgRestore(); MM_preloadImages(); MM_findObj(n, d); MM_swapImage()...
	-> linkShowHideWhom(linkId,whomId,imgId,imgStart,imgEnd) : Cf. Ex...
	
	+-> lightbox.js : POP UP IMG <a href="images/grand/toto.jpg" rel="lightbox" target="_blank" title="Zoom"><img src="images/mini/toto.jpg"></a>
	+-> ajax.js : window.onload = function(){ initAutoComplete($('F1'),$('motcle'),'ajax_get_blog.php'); };

/////////////////////////////////////////////////////////////////////////////////////////// */


/* ------------------------- VISITOR MATERIAL ---------------------------------- */
var DOM = (document.getElementById ? true : false); // IE / NS...
var IE = (document.all && !DOM ? true : false);
var NS = (document.layers && !DOM ? true : false);

/* ------------------------- GET BY I:D ---------------------------------- */
if (!Array.prototype.push) {
	Array.prototype.push = function() {
		var startLength = this.length;
		for (var i = 0; i < arguments.length; i++) this[startLength + i] = arguments[i];
		return this.length;
	}
}
function $() {
	var results = [], element;
	for (var i = 0; i < arguments.length; i++) {
		element = arguments[i];
		if (typeof element == 'string') {
			if (DOM) element = document.getElementById(element);
			else if (NS) element = document.layers[element];
			else if (IE) element = document.all[element];
		}
		results.push(element);
	}
	return results.length < 2 ? results[0] : results;
}
if (!document.getElementsByClassName) {
	document.getElementsByClassName = function(className) {
		var children = document.getElementsByTagName('*') || document.all;
		var elements = new Array();
		for (var i = 0; i < children.length; i++) {
			var child = children[i];
			var classNames = child.className.split(' ');
			for (var j = 0; j < classNames.length; j++) {
			  if (classNames[j] == className) {
				elements.push(child);
				break;
			  }
			}
		}
		return elements;
	}
}
if (!document.getElementsByTagName) {
	document.getElementsByTagName = function(TagName, parentElement) {
	  var children = ($(parentElement) || document.body).getElementsByTagName('*');
	  return $A(children).inject([], function(elements, child) {
		if (child.className.match(new RegExp("(^|\\s)" + className + "(\\s|$)")))
		  elements.push(Element.extend(child));
		return elements;
	  });
	}
}
/* ------------------------- STRING REPLACE ------------------------------ */
function strRep(string,strSearch,strRep) {
	var regEx = new RegExp(strSearch, 'gi'); // Active les liens...
	return string.replace(regEx,strRep);
}
/* ------------------------- GOTO ---------------------------------- */
function Go(gototo) { // ex : <td  onClick="Go('actualite');"> --> index2.php?goto=actualite
	var url = window.location.search;
	var pos = url.indexOf("=")+1;
	window.location.search = url.substring(0,pos)+gototo;
}
/* ------------------------- CREER UNE DIV ------------------------------ */
function creatDiv(idDiv,parent_id,styleDiv,contentHtm) {
	if (!$(idDiv)) {
		if (styleDiv == '') styleDiv = 'border:1px solid #999999;padding:0px;margin:0px;background-color:#FFFFFF;width:500;height:500;';
		// float:right;display:block;
		if (parent_id != '') var objBody = $(parent_id); // Parent ID...
		else var objBody = document.getElementsByTagName("body").item(0); // ... Ou BODY
		var ObjInfos_print = document.createElement("div");
		ObjInfos_print.setAttribute('id',idDiv);
		ObjInfos_print.setAttribute('style',styleDiv);
		//ObjInfos_print.onclick = function () {hideLightbox(); return false;}
		objBody.insertBefore(ObjInfos_print, objBody.firstChild);
	}
	if (contentHtm != '') $(idDiv).innerHTML = contentHtm;
		  
}
/* ------------------------- POP UP URL ---------------------------------- */
function myPop(url,name,Wwide,Whigh) {
	if (name=='') name = '_blank';
	var wide = window.screen.availWidth;
	var high = window.screen.availHeight; // Screen size
	var left = 0; var top = 0; // Position
	if (wide > Wwide) left = (wide-Wwide)/2; else Wwide = wide; if (high > Whigh) top = (high-Whigh)/2; else Whigh = high; // Max Size
	window.open(url,name,'height='+Whigh+',innerHeight='+Whigh+',width='+Wwide+',innerWidth='+Wwide+',left='+left+',screenX='+left+',top='+top+ ',screenY='+top+',toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable=0');
	name.window.focus();
	return false; // Don't open href link
}

/* ------------------------- POP UP IMAGE ---------------------------------- */
var PositionX = 100; var PositionY = 100; // Set the horizontal and vertical position for the popu
var defaultWidth  = 500; var defaultHeight = 500; // Set these value approximately 20 pixels greater than the size of the largest image to be used (needed for Netscape)
var AutoClose = true; // Set autoclose true to have the window close automatically - Set autoclose false to allow multiple popup windows
if (parseInt(navigator.appVersion.charAt(0))>=4){
	var isNN=(navigator.appName=="Netscape")?1:0;
	var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;
}
var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
var optIE='scrollbars=no,width=150,height=100,left='+PositionX+',top='+PositionY;

function PopImg(imageURL,imageTitle) {
	if (isNN){ var imgWin=window.open('about:blank','',optNN);}
	if (isIE){ var imgWin=window.open('about:blank','',optIE);}
	with (imgWin.document){
		writeln('<html><head><title>Loading...</title><style type="text/css">body{margin:0px;overflow:hidden;}</style>');writeln('<sc'+'ript type="text/javascript">');
		writeln('var isNN,isIE;');writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
		writeln('isNN=(navigator.appName=="Netscape")?1:0;');writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
		writeln('function reSizeToImage(){');writeln('if (isIE){');writeln('window.resizeTo(100,100);');
		writeln('width=100-(document.body.clientWidth-document.images[0].width);');
		writeln('height=100-(document.body.clientHeight-document.images[0].height);');
		writeln('window.resizeTo(width,height);}');writeln('if (isNN){');       
		writeln('window.innerWidth=document.images["George"].width;');writeln('window.innerHeight=document.images["George"].height;}}');
		writeln('function doTitle(){document.title="'+imageTitle+'";}');writeln('</sc'+'ript>');
		if (!AutoClose) writeln('</head><body bgcolor="#000000" scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
		else writeln('</head><body bgcolor="#000000" scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close();" onClick="self.close();">');
		writeln('<img name="George" src='+imageURL+' style="display:block"></body></html>');
		close();		
	}
}

/* ------------------------- ROLLOVER ---------------------------------- */
function RollOver(imgId,imgSrc) {
	if (!imgId || !imgSrc) return;
	document.images[imgId].src = imgSrc;
}

/* ------------------------- SHOW/ HIDE ELEMENT ID ---------------------------------- */
function showHide() {
	for (var i = 0; i < arguments.length; i++) {
		var element = $(arguments[i]);
		element.style.display = (element.style.display == 'none' ? '' : 'none');
	}
}

/* ------------------------- STOP ERROR ---------------------------------- */
function stopError() {
	return true;
}
//window.onerror = stopError;

/* ------------------------- DREAM ! ---------------------------------- */
function MM_swapImgRestore() { //v3.0
	var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
	var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
	var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

/* ------------------------- POP UP SUR LA HOME ------------------------------ */
function printPop(titre,texte,img,delay) { //

	texte = strRep(texte,'&quot;','"'); // Active les liens...

	var innerPOP = '<table id="tableInfo" width="603" border="0" cellpadding="0" cellspacing="0">';
	innerPOP += '<tr>';
	innerPOP += '<td height="1" colspan="3"><img src="images/pop_int/pop_int_r1_c1.png" name="pop_int_r1_c1" width="603" height="62" border="0" usemap="#pop_int_r1_c1Map" id="pop_int_r1_c1" /><map name="pop_int_r1_c1Map"><area shape="rect" coords="559,19,584,44" href="javascript:void(0);" onClick="$(\'pop\').style.display=\'none\'; $(\'pop_print\').style.display=\'none\';" title="close"></map></td>';
	innerPOP += '</tr>';
	innerPOP += '<tr>';
	innerPOP += '<td width="13" background="images/pop_int/pop_int_r2_c1.png"><img src="images/common/pix.gif" width="13" height="1"></td>';
	innerPOP += '<td height="220" valign="top" style="background: #61B909 url(images/pop_int/pop_int_r2_c2.png) no-repeat top;"><table width="100%" border="0" cellspacing="0" cellpadding="5">';
	innerPOP += '<tr>';
	innerPOP += '<td><table width="100%" border="0" cellspacing="0" cellpadding="5">';
	if (titre != '') {
		innerPOP += '<tr>';
		innerPOP += '<td class="texmenu">'+titre+'</td>';
		innerPOP += '</tr>';
	}
	if (img != '') {
		innerPOP += '<tr>';
		innerPOP += '<td align="center"><img src="'+img+'" style="border:1px solid #FFFFFF;" ></td>';
		innerPOP += '</tr>';
	}
	if (texte != '') {
		innerPOP += '<tr>';
		innerPOP += '<td class="textoprincipal_02">'+texte+'</td>';
		innerPOP += '</tr>';
	}
	innerPOP += '</table></td>';
	innerPOP += '</tr>';
	innerPOP += '</table><p>&nbsp;</p></td>';
	innerPOP += '<td width="12" background="images/pop_int/pop_int_r2_c3.png"><img src="images/common/pix.gif" width="12" height="1"></td>';
	innerPOP += '</tr>';
	innerPOP += '<tr>';
	innerPOP += '<td height="1"><img name="pop_int_r3_c1" src="images/pop_int/pop_int_r3_c1.png" width="13" height="9" border="0" id="pop_int_r3_c1" /></td>';
	innerPOP += '<td><img name="pop_int_r3_c2" src="images/pop_int/pop_int_r3_c2.png" width="578" height="9" border="0" id="pop_int_r3_c2" /></td>';
	innerPOP += '<td><img name="pop_int_r3_c3" src="images/pop_int/pop_int_r3_c3.png" width="12" height="9" border="0" id="pop_int_r3_c3" /></td>';
	innerPOP += '</tr>';
	innerPOP += '</table>';

	//<div id="pop_print" class="divPopInfo">
	
	if (!$('pop_print')) creatDiv('pop_print','','','');
	$('pop_print').innerHTML = innerPOP;
	
	if (!$('pop')) creatDiv('pop','','','');
	
	// ------ Cf. lightbox.js ------------------------------------------------------------------- //
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	
	Theight = $('tableInfo').height ? $('tableInfo').height : 450;
	Twidth = $('tableInfo').width ? $('tableInfo').width : 603;

	$('pop_print').style.top = ( arrayPageScroll[1] + ((arrayPageSize[3] - 200 - Theight)/2) )+'px';
	$('pop_print').style.left = ((764 - Twidth) / 2)+'px'; //arrayPageSize[0]
	$('pop_print').style.display = 'block';

	$('pop').style.height = (arrayPageSize[1]) + 'px';
	$('pop').style.display = 'block';


	if (delay > 0) setTimeout("$('pop').style.display='none'; $('pop_print').style.display='none';", delay);
}

/* ------------------------- linkShowHideWhom ------------------------------ */
/*
<a id="linkOption" href="javascript:void(0);" onClick="linkShowHideWhom('linkOption','otpions','showOpt1','images/nav/flech_down.png','images/nav/flech_up.png');"  onMouseOver="lshwOnMouseOver('otpions','showOpt1','images/nav/flech_down_over.png','images/nav/flech_up_over.png');"
onMouseOut="lshwOnMouseOut('otpions','showOpt1','images/nav/flech_down.png','images/nav/flech_up.png');" title="Afficher/Masquer les options"><img src="images/nav/flech_down.png" id="showOpt1" border="0"></a><div id="otpions" style="display:none;">TEST</div>
*/
var pos = new Array();
function linkShowHideWhom(linkId,whomId,imgId,imgStart,imgEnd) {
	if (!pos[whomId]) pos[whomId] = 'open'; // Store init pos..
	ElinkId = $(linkId);
	EwhomId = $(whomId);
	EimgId = $(imgId);
	if (pos[whomId] == 'open') { 
		EwhomId.style.display = 'block';
		if (document.images[imgId]) document.images[imgId].src = imgEnd;
		else EimgId.src = imgEnd;
		pos[whomId] = 'close';
	}
	else {
		EwhomId.style.display = 'none';
		if (document.images[imgId]) document.images[imgId].src = imgStart;
		else EimgId.src = imgStart;
		pos[whomId] = 'open';
	}
}
function lshwOnMouseOver(whomId,imgId,imgStart_over,imgEnd_over) {
	if (!pos[whomId]) pos[whomId] = 'open'; // Store init pos..
	if (pos[whomId] == 'open') RollOver(imgId,imgStart_over);
	else RollOver(imgId,imgEnd_over);
}
function lshwOnMouseOut(whomId,imgId,imgStart,imgEnd) {
	if (pos[whomId] == 'open') RollOver(imgId,imgStart);
	else RollOver(imgId,imgEnd);
}