/*****************************************************/
/*  ouverture popup  */
/*****************************************************/

function mentions(){
	largr = 500 ;
	hautr = 500;
	url = "/credits.php";
	var posX = (screen.width / 2) - (largr / 2);
	var posY = (screen.height / 2) - (hautr / 2);
	window.open(url,"test","menubar=no, status=no, scrollbars=yes, menubar=no, width="+largr+", height="+hautr+", left=250, top=250");		
}


function openPop(url){
	largr = 500 ;
	hautr = 500;
	var posX = ((screen.width / 2) - (largr/2));
	var posY = ((screen.height / 2) - (hautr / 2));
	window.open(url,"test","menubar=no, status=no, scrollbars=yes, menubar=no, width="+largr+", height="+hautr+", left="+posX+", top="+posY+"");		
}


/*****************************************************/
/*  correction des Png sous ie                       */
/*****************************************************/

function correctPNG()
{
for(var i=0; i<document.images.length; i++)
{
var img = document.images[i]
var imgName = img.src.toUpperCase()
if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
{
var imgID = (img.id) ? "id='" + img.id + "' " : ""
var imgClass = (img.className) ? "class='" + img.className + "' " : ""
var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
var imgStyle = "display:inline-block;" + img.style.cssText
if (img.align == "left") imgStyle = "float:left;" + imgStyle
if (img.align == "right") imgStyle = "float:right;" + imgStyle
if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
var strNewHTML = "<span " + imgID + imgClass + imgTitle
+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
+ "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
img.outerHTML = strNewHTML
i = i-1
}
}
}
var userAgent=navigator.userAgent;
//alert(userAgent);
    if ((userAgent.indexOf('MSIE') != -1)&&(userAgent.indexOf("MSIE 7.0") == -1)) {
         window.attachEvent("onload", correctPNG);
	}
	
/*****************************************************/
/*  ouverture Tween des divs                         */
/*****************************************************/

function openCloseDiv(myDiv){	
	var obj = document.getElementById(myDiv);	
	var h = obj.scrollHeight;	
	var h2 = obj.style.height;
	
	if (h2=='0px'){
		// ouverture de la div ...
		sizeTween = new Tween(obj.style,'height',Tween.regularEaseInOut,2,h,0.5,'px');
		sizeTween.start();	
			
	}else{
		// fermeture de la div ...
		sizeTween = new Tween(obj.style,'height',Tween.regularEaseInOut,h,0,0.7,'px');
		sizeTween.start();
	}	
	
}


/******************************************/

var holdMenu = "";
var holdMenu2 = "";
var oldH;
var tailleDefil = 110;
var mult = 0;

function openCloseParag(item){
	var id = 'div'+item;
	var id_btn = 'btn'+item;
	var srcBtn = document.getElementById(id_btn).src;
	var start = srcBtn.lastIndexOf('/'); start++;
    srcBtn = srcBtn.substring(start,srcBtn.length);

	if(srcBtn=="bt-info.gif"){
	// si le paragraphe est fermé ...	
		var obj = document.getElementById(id);
		var h = obj.scrollHeight;
		sizeTween = new Tween(obj.style,'height',Tween.regularEaseInOut,0,h,0.7,'px');
		sizeTween.start();		
		document.getElementById('btn'+item).src="/media/bt-close.gif";	
	}
	
	if(srcBtn=="bt-close.gif"){	
		var id = 'div'+item;
		var obj2 = document.getElementById(id);
		var h2 = obj2.scrollHeight;
		sizeTween = new Tween(obj2.style,'height',Tween.regularEaseInOut,h2,1,0.3,'px');
		sizeTween.start();
		document.getElementById('btn'+item).src="/media/bt-info.gif";	
	}
}


/*****************************************************/

/*****************************************************/


function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

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];}
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}

MM_reloadPage(true);

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_jumpMenuGo(selName,targ,restore){ //v3.0
  var selObj = MM_findObj(selName); if (selObj) MM_jumpMenu(targ,selObj,restore);
}

function affichepuce(item) {
	if ((MM_findObj('puce'+item).style.display)=='') {
		MM_findObj('puce'+item).style.display = 'none';
	} else {
		MM_findObj('puce'+item).style.display = '';
	}
}

function emailok(email) {
	var re = /([a-z0-9]+([-_]?[a-z0-9]+)*.)*[a-z0-9]+([-_]?[a-z0-9]+)*@([a-z0-9]+([-_]?[a-z0-9]+)*.)+[a-z]{2,4}/g;
	var M = email.value.toLowerCase();
	return (M.match(re) == M);

	//au lieu de faire une vérif regex, on va plutot questioner le serveur via ajax pour tester le nom de domaine (DNS..)
	
}

function limiteur(elm, elem1, elem2, max) {
	maximum = max;
    champ = elm.elements[elem1];
    indic = elm.elements[elem2];

    if (champ.value.length > maximum) {
		champ.value = champ.value.substring(0, maximum);
	} else {
		indic.value = maximum - champ.value.length;
	}
}


function changevaleur(nomchamp) {
	MM_findObj('photo' + nomchamp).src = MM_findObj(nomchamp).value;
	if (MM_findObj(nomchamp).value!="") {
		MM_findObj('a' + nomchamp).style.display = '';
	} else {
		MM_findObj('a' + nomchamp).style.display = 'none';
	}
}







//* GESTION MENUS *//

function affichemenu(item) {
	if ((MM_findObj('menu'+item).style.display)=='') {
		MM_findObj('menu'+item).style.display = 'none';
	} else {
		MM_findObj('menu'+item).style.display = '';
		MM_findObj('etape').value = item;
	}
}


function affichedetail(item) {
	if ((MM_findObj('detail'+item).style.display)=='') {
		MM_findObj('detail'+item).style.display = 'none';
	} else {
		MM_findObj('detail'+item).style.display = '';
	}
}




function ConfirmDelete(message, url) {
	if (confirm(message)) {
		window.location = url;
	}
}


