//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 changeHeader(type){
     var flashMovie=getFlashMovieObject("slideShow");
     flashMovie.switchHeader(type);
}
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);
	}
}
function showEvents(id,move){
	var int = 120;
	var dummy = document.getElementById(id);
	var top = parseFloat(dummy.style.top);
	var H = ElmHeight(id);
	var minY = -(H-235);
	if(H > 235){
		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,3,'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 ElmWidth(elmID) {
	var W = null
	if(document.getElementById(elmID).clientWidth) {
		W = document.getElementById(elmID).clientWidth;
	}else if(document.getElementById(elmID).offsetWidth){
		W = document.getElementById(elmID).offsetWidth;
	}
	return W;
}
function ElmX(elmID) {
	X = document.getElementById(elmID).offsetLeft;
	return X;
}
function ElmY(elmID) {
	Y = document.getElementById(elmID).offsetTop;
	return Y;
}
function setAxis(elmID, x, y){
	var WW = document.body.offsetWidth;
	if(WW > 1000){
		var OX = ((WW-1000)/2)+parseFloat(x);
	}else{
		var OX = parseFloat(x);
	}
	var OY = parseFloat(y);
	if(document.getElementById(elmID).setAttribute){
		document.getElementById(elmID).setAttribute("style","left:"+OX+"px");
		document.getElementById(elmID).setAttribute("style","top:"+OY+"px");
	}
	if(document.getElementById(elmID).style.top){
		document.getElementById(elmID).style.left = OX+"px";
		document.getElementById(elmID).style.top = OY+"px";
	}	
}
function showNav(){
	var H1 = ElmHeight('comingEvents');
	var H2 = ElmHeight('passedEvents');
	if(H1 > 235){
		make_Visible('comingnav', true);
	}
	if(H2 > 235){
		make_Visible('passednav', true);
	}
}
function setNav(){
	myTimeout = setTimeout("showNav()",200);
}
