//POPUP WINDOW
//<a href="yourpage.html" onClick="winPopup(this.href,'name','584','211','no');return false">
//------------------------------------------------------------------
var win = null;
function winPopup(mypage,myname,w,h,scroll,size){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings =
"height="+h+",width="+w+",top="+TopPosition+",left="+LeftPosition+",scrollbars="+scroll+",resizable="+size;
win = window.open(mypage,myname,settings);
}
function formDelay(f){
	myTimeout = setTimeout("formSubmit('"+f+"')",50);
}
function formSubmit(f){
	var x = document.getElementsByTagName('textarea').length;
	for(i=0;i<x;i++){
		d = document.getElementsByTagName('textarea')[i].id;
		WYSIWYG.updateTextArea(d);
	}
	doc = document.getElementById(f);
	doc.submit();
}
function formDelay2(f){
	myTimeout = setTimeout("formSubmit2('"+f+"')",50);
}
function formSubmit2(f){
	doc = document.getElementById(f);
	doc.submit();
}
function alertSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  myWidth = (myWidth - 960)/2;
  return myWidth;
}
mySub = new Array('submenu4','submenu5','submenu8');
function submenu(x, show){
	myShow = 'submenu'+show;
	document.getElementById('submenu').style.display="inline-block";
	document.getElementById('submenu').setAttribute('style','display:block;');
	document.getElementById(myShow).style.display="inline-block";
	document.getElementById(myShow).setAttribute('style','display:block;');
	coor = parseFloat(alertSize())+parseFloat(x);
	menu = document.getElementById('submenu');
	menu.style.left=coor;
	menu.setAttribute('style','left:'+coor+'px;');
	for(i=0;i<mySub.length;i++){
		if(mySub[i]!=myShow){
			document.getElementById(mySub[i]).style.display="none";	
		}
	}
}
function delaysubmenu(){
	myTimeout = setTimeout("hidesubmenus()",500);
}
function resetsubmenu(){
	if(typeof(myTimeout)!='undefined'){
	 	clearInterval(myTimeout);
	}
}
function hidesubmenus(){
	SendDataToFlashMovie();
	document.getElementById('submenu').style.display="none";
}
function flashhidesubmenus(){
	document.getElementById('submenu').style.display="none";
}
function getFlashMovieObject(movieName){
	return document.getElementById(movieName);
}
function initGaleries(av,ap){
     var flashMovie=getFlashMovieObject("flash_galerie");
     flashMovie.init(av,ap);
}
function initAvant(){
     var flashMovie=getFlashMovieObject("flash_galerie");
     flashMovie.showAvant();
		 document.getElementById('avant_link').className = "select";
		 document.getElementById('apres_link').className = "";
}
function initApres(){
     var flashMovie=getFlashMovieObject("flash_galerie");
     flashMovie.showApres();
		 document.getElementById('avant_link').className = "";
		 document.getElementById('apres_link').className = "select";
}
function imageGalery(galeryname, directoryname, start, browser){
	if(galeryname!="" && directoryname!=""){
		var xmlHttp;
		try{// Firefox, Opera 8.0+, Safari
			xmlHttp=new XMLHttpRequest();
		}
		catch (e){
			try{// Internet Explorer
				xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (e){
					try{
						xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
					}
					catch (e){
						alert("Your browser does not support AJAX!");
						return false;
					}
			}
		}
		xmlHttp.onreadystatechange=function(){
			if(xmlHttp.readyState==4){
				if(document.getElementById('largeHolder').setAttribute){
					document.getElementById('largeHolder').setAttribute("style","display:inline-block");
				}
				if(document.getElementById('largeHolder').style.display){
					document.getElementById('largeHolder').style.display = "inline-block";
				}
				document.getElementById('largeHolder').innerHTML = xmlHttp.responseText;
			}
		}
		xmlHttp.open("GET","galerie_photos.php?Titre="+escape(galeryname)+"&Directory="+directoryname+"&Current="+start+"&Browser="+browser,true);
		xmlHttp.send(null);
	} else {
		document.getElementById('largeHolder').style.display = "none";
	}
}

function paginationOver(el){
	el.className = "current";
}
function paginationOut(el){
	el.className = "normal";
}
function getURL(url){
	window.location.href = url;
}
function make_Visible(obj, bol){
	if(bol){val="inline-block";}else{val="none";}
	if(document.getElementById(obj).setAttribute){
		document.getElementById(obj).setAttribute("style","display:"+val+"");
	}
	if(document.getElementById(obj).style.display){
		document.getElementById(obj).style.display = val;
	}	
}
function switch_Visible(obj){
	if(check_Visible(obj)){
		swtch = false;
	}else if(!check_Visible(obj)){
		swtch = true;
	}
	var loadingTimer = setTimeout("make_Visible('"+obj+"', "+swtch+")",50);
}
function check_Visible(obj){
		var val = document.getElementById(obj).style.display;
		if(val=="none"){
			return false;
		}else if(val=="inline-block"){
			return true;
		}
}
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 addEvent(obj, ev, fu){
	var obj = document.getElementById(obj);
	if (obj.attachEvent){
		obj.attachEvent("on"+ev, eval(fu));
	}else{
		obj.addEventListener(ev, eval(fu), false);
	}
}
function removeEvent(obj, ev, fu){
	var obj = document.getElementById(obj);
	if (obj.detachEvent){	
		obj.detachEvent("on"+ev, eval(fu));
	}else{
		obj.removeEventListener(ev, eval(fu), false);
	}
}
var t1 = null;
function showEvents(id,move){
	if(t1 != null){
		t1.stop();
	}
	var int = 215;
	var dummy = document.getElementById(id);
	var top = parseFloat(dummy.style.top);
	var H = ElmHeight(id);
	var minY = -(H-215);
	if(H > 215){
		if(move == "up"){
			if(top-int < minY){
				to = minY;
			}else if(top-int >= minY){
				to = top-int
			}
		}else if(move == "down"){
			if(top+int > 0){
				to = 0;
			}else if(top+int <= 0){
				to = top+int
			}
		}
	}else{
		to = 0;
	}
	t1 = new Tween(dummy.style,'top',Tween.regularEaseOut,top,to,1,'px');
	t1.start();
}
function showBoutique(id,move){
	if(t1 != null){
		t1.stop();
	}
	var int = 414;
	var dummy = document.getElementById(id);
	var top = parseFloat(dummy.style.top);
	var H = ElmHeight(id);
	var minY = -(H-414);
	if(H > 414){
		if(move == "up"){
			if(top-int < minY){
				to = minY;
			}else if(top-int >= minY){
				to = top-int
			}
		}else if(move == "down"){
			if(top+int > 0){
				to = 0;
			}else if(top+int <= 0){
				to = top+int
			}
		}
	}else{
		to = 0;
	}
	t1 = new Tween(dummy.style,'top',Tween.regularEaseOut,top,to,1,'px');
	t1.start();
}
function ElmHeight(elmID) {
	var H = null
	if(document.getElementById(elmID).clientHeight) {
		H = document.getElementById(elmID).clientHeight;
	}else if(document.getElementById(elmID).offsetHeight){
		H = document.getElementById(elmID).offsetHeight;
	}
	return H;
}
function showNav(page){
	var H1 = ElmHeight('galeries');
	if(H1 > 215){
		make_Visible('galeriesnav', true);
	}
	var av = getImgAvant();
	var ap = getImgApres();
	initGaleries(av,ap);
	if(page == "cle"){
		make_Visible('nav', true);
		document.getElementById('avant_link').className = "select";
		document.getElementById('apres_link').className = "";
	}
}
function setNav(page){
	myTimeout = setTimeout("showNav('"+page+"')",200);
}
function overThumb(el){
	el.className = "over";
}
function outThumb(el){
	var ct = getCurrentThumb();
	var tn = getThumbNb(el.id);
	if(ct != tn){
		el.className = "normal";
	}
}
function clickThumb(el,av,ap){
	var ct = getCurrentThumb();
	if(ct != ""){
		document.getElementById('thumb_'+ct).className = "normal";
	}
	var tn = getThumbNb(el.id);
	el.className = "select";
	setCurrentThumb(tn);
	initGaleries(av,ap);
	setImgAvant(av);
	setImgApres(ap);
	if(av != ""){
		make_Visible('nav', true);
		document.getElementById('avant_link').className = "select";
		document.getElementById('apres_link').className = "";
	}else{
		make_Visible('nav', false);
	}
}
function getCurrentThumb(){
	var ct = document.getElementById('thumb').value;
	return ct;
}
function setCurrentThumb(nb){
	document.getElementById('thumb').value = nb;
}
function getThumbNb(str){
	var nb = null;
	if(str.indexOf("_") != -1){
		nb = str.split('_');
		nb = nb[1];
	}else{
		nb = str;
	}
	return nb;
}
function getImgAvant(){
	return document.getElementById('imgavant').value;
}
function setImgAvant(av){
	document.getElementById('imgavant').value = av;
}
function getImgApres(){
	return document.getElementById('imgapres').value;
}
function setImgApres(ap){
	document.getElementById('imgapres').value = ap;
}
