/* ///////////////////////////////////////////////////////////////////////////////////////////
CODE MIXING BY MOLOKOLOCO.... [BETA TESTING FOR EVER] .....................................

Functions :

	-> $() 												: GET BY ID... --> alert($('titre').value); || $('test').style.display = none;
	-> Go(gototo)										: GOTO --> onClick="Go('actualite');" = index2.php?goto=actualite
	-> PSR_imprimer()									: IMPRIMER en POP UP
	-> 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()...
	
	+-> lightbox.js : POP UP IMG <a href="images/toto.jp" rel="lightbox" target="_blank" title="Zoom">
	+-> 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, 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;
	  });
	}
}
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;
	  });
	}
}
/* ------------------------- 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');
}

/* ------------------------- 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) {
	document.images[imgId].src = imgSrc;
}
/* ------------------------- ROLLOVER Class ---------------------------------- */
function RollClass(id,nom) {
	document.getElementById(id).className = nom;
}
/* ------------------------- 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;

/* ------------------------- Utilise la div du header pour afficher des infos DYN ------------------------------ */
function printInfo(infos) {
	if (infos == '') return;
	
	if (!$('infos_print')) creatDiv('infos_print','','','');
	$('infos_print').innerHTML = infos;

	var offset = 0;
	if (document.body.scrollTop) offset = document.body.scrollTop; // No value at top...
	else if (window.pageYOffset) offset = window.pageYOffset; // No value at top...
	
	if (!$('infos')) creatDiv('infos','infos_print','','');
	
	if ($('infos').style.posTop) {
		$('infos').style.posTop = offset + 20;
		$('infos_print').style.posTop = offset + 30;
	}
	else {
		$('infos').style.top = offset + 20;
		$('infos_print').style.top = offset + 30;
	}

	$('infos').style.display = 'inline';
	$('infos_print').style.display = 'inline';
	setTimeout("$('infos').style.display='none'; $('infos_print').style.display='none';", 5000);
}

function BandeauHome(langue){
var bandeau = new Array();
bandeau[0] = new Array("bleu");
bandeau[1] = new Array("fushia");
bandeau[2] = new Array("jaune");
bandeau[3] = new Array("orange");
bandeau[4] = new Array("vert");

var nb = bandeau.length-1;
var num = Math.round(Math.random()*nb);
//alert(num);
document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="891" height="215">');
document.write('<param name="movie" value="swf/common/bandeau_'+bandeau[num][0]+'.swf?langue='+langue+'">');
document.write('<param name="quality" value="high">');
document.write('<embed src="swf/common/bandeau_'+bandeau[num][0]+'.swf?langue='+langue+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="891" height="215"></embed>');
document.write('</object>');
}

function Bandeau(){
var bandeau = new Array();
bandeau[0] = new Array("1.jpg");
bandeau[1] = new Array("2.jpg");
bandeau[2] = new Array("3.jpg");
bandeau[3] = new Array("4.jpg");
bandeau[4] = new Array("5.jpg");

var nb = bandeau.length-1;
var num = Math.round(Math.random()*nb);
//alert(num);

document.write(' <img src=\"images/common/bandeau/'+bandeau[num][0]+'\">');
}

function newsletter() {
	whom = document.frmnewsletter;
	var error = "";
	if (whom.mail_newsletter.value.indexOf('@') == -1 || whom.mail_newsletter.value.indexOf('.') == -1  || whom.mail_newsletter.length < 7) error += "\n- Vérifiez le champ E-mail";
	if (error != "") alert(error);
	else whom.submit();
}

function affiche_ami(){
var etat = 	document.getElementById("ami").style.display;
	if(etat == 'none'){
	document.getElementById("ami").style.display = "block";
	}else{
	document.getElementById("ami").style.display = "none";
	}
}
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}


function Pro(etat){
	if(etat == 1){
	document.getElementById("Pro").style.display = "block";
	}else{
	document.getElementById("Pro").style.display = "none";
	}
}
