// ================ frame killer ================
//if (top.frames.length!=0) top.location=self.document.location;


// ================ préchargement des images ================
//préchargement des images rollover
/*
if (document.images) {	
	imgA = new Image();
	imgA.src = "../img/bouton_liste_over.gif";

	imgB = new Image();
	imgB.src = "../img/bouton_media_over.gif";
	
	imgC = new Image();
	imgC.src = "../img/bouton_more_over.gif";
	
	imgD = new Image();
	imgD.src = "../img/close.gif";
	
	imgE = new Image();
	imgE.src = "../img/open.gif";
}
*/
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];}
}
MM_preloadImages('img/common/fleche_haut_off.gif','img/common/fleche_bas_off.gif')
// ============== filtre anti-spam ==============
function noSpam(user,domain) {
	locationstring = "mailto:" + user + "@" + domain;
	window.location = locationstring;
}


// ============== menu de navigation =============
function gotoURL(code) {
/*
Méthode d'appel :
-----------------
javascript:gotoURL('01');

Liste des codes :
-----------------
"techno" -> from QT

*/
	if (code == 'techno') window.location="base.php?dl=technology";
	else if (code == 'early') window.location="base.php?dl=Early_Childhood";
	else if (code == 'howapply') window.location="base.php?dl=How_to_Apply";
	else if (code == 'applyform') window.location="base.php?dl=admissions";
	else if (code == '05') window.location="organisation.php";
	else if (code == '06') window.location="contact_liens.php";
	else if (code == '07') window.location="accueil.php"; //appel automatique à la fin de l'animation Flash
	else window.location="index.php";
}


// ============== ouverture popup ==============
function openPopup(type,url) {
	if (type == 1) { // 1 = popup
		var hauteur = 450;
		var largeur = 500;
		//popup centrée
		var top=(screen.height-hauteur)/2;
		var left=(screen.width-largeur)/2;
		window.open(url,'popup','toolbar=0,location=0,directories=0,status=1,scrollbars=1,resizable=1,copyhistory=0,menuBar=0,width='+largeur+',height='+hauteur+',left='+left+',top='+top+'');
	}
	else if (type == 2) { // 2 = liste des participants aux ateliers
		var hauteur = 450;
		var largeur = 500;
		//popup centrée
		var top=(screen.height-hauteur)/2;
		var left=(screen.width-largeur)/2;
		window.open(url,'popup','toolbar=0,location=0,directories=0,status=1,scrollbars=1,resizable=1,copyhistory=0,menuBar=0,width='+largeur+',height='+hauteur+',left='+left+',top='+top+'');
	}
	else if (type == 3) { // 3 = download form
		var hauteur = 450;
		var largeur = 525;
		var top=(screen.height-hauteur)/2;
		var left=(screen.width-largeur)/2;
		window.open(url,'downloadForm','toolbar=0,location=0,directories=0,status=1,scrollbars=auto,resizable=1,copyhistory=0,menuBar=0,width='+largeur+',height='+hauteur+',left='+left+',top='+top+'');
	}
	else if (type == 4) { // 4 = copyright, privacy policy
		var hauteur = 490;
		var largeur = 515;
		var top=(screen.height-hauteur)/2;
		var left=(screen.width-largeur)/2;
		window.open(url,'copycredits','toolbar=0,location=0,directories=0,status=1,scrollbars=1,resizable=1,copyhistory=0,menuBar=0,width='+largeur+',height='+hauteur+',left='+left+',top='+top+'');
	}
	else if (type == 5) { // 5 = portraits
		var hauteur = 680;
		var largeur = 640;
		var top=(screen.height-hauteur)/2;
		var left=(screen.width-largeur)/2;
		window.open(url,'portraits','toolbar=0,location=0,directories=0,status=1,scrollbars=1,resizable=1,copyhistory=0,menuBar=0,width='+largeur+',height='+hauteur+',left='+left+',top='+top+'');
	}
	else if (type == 6) { // 6 = portraits large
		var hauteur = 750;
		var largeur = 1000;
		var top=(screen.height-hauteur)/2;
		var left=(screen.width-largeur)/2;
		window.open(url,'portraits','toolbar=0,location=0,directories=0,status=1,scrollbars=1,resizable=1,copyhistory=0,menuBar=0,width='+largeur+',height='+hauteur+',left='+left+',top='+top+'');
	}
	else { void(0);	}
}

// ============== ouverture popup ==============
function popImg(imgsrc,imgwidth,imgheight) {
	var hauteur = Number(imgheight) + 40;
	var largeur = Number(imgwidth) + 40;
//alert(largeur+" "+hauteur);
	//popup centrée
	var top=(screen.height-hauteur)/2;
	var left=(screen.width-largeur)/2;
	window.open('popupimg.php?imgsrc='+imgsrc,'popup','toolbar=0,location=0,directories=0,status=1,scrollbars=1,resizable=1,copyhistory=0,menuBar=0,width='+largeur+',height='+hauteur+',left='+left+',top='+top+'');
}


// ============== fonction new window (target = blank) ==============
function openBlank(url) {
	if (window.open) {
		window.open(url);
	}
}

function hideAllSets()
{
	if ( document.getElementById ) {
		for (var i=1; i<=numSets; i++)
		{
			document.getElementById('set'+i).style.display='none';
		}
	}
} // end function

function showSet(sid)
{
	hideAllSets();
	if ( document.getElementById ) {
		document.getElementById('set'+sid).style.display='block';
	}
} // end function

function showFaq(sid)
{
	if ( document.getElementById ) {
		var currentState = document.getElementById('faqp'+sid).style.display;
//		alert(currentState);
//		alert(document.getElementById('faqa'+sid).className);
		if (currentState=='block')
		{
			document.getElementById('faqp'+sid).style.display='none';
			document.getElementById('faqa'+sid).className='closed';
		}
		else
		{
			document.getElementById('faqp'+sid).style.display='block';
			document.getElementById('faqa'+sid).className='open';
		}
	}
} // end function

function showDiv(sid)
{
	if ( document.getElementById ) {
		var currentState = document.getElementById('set'+sid).style.display;
//		alert(currentState);
//		alert(document.getElementById('faqa'+sid).className);
		if (currentState=='block')
		{
			document.getElementById('set'+sid).style.display='none';
			document.getElementById('link'+sid).style.display='block';
		}
		else
		{
			document.getElementById('set'+sid).style.display='block';
			document.getElementById('link'+sid).style.display='none';
		}
	}
} // end function

function showCalendar(sid)
{
	if ( document.getElementById ) {
		var currentState = document.getElementById('calendarp'+sid).style.display;
//		alert(currentState);
//		alert(document.getElementById('faqa'+sid).className);
		if (currentState=='block')
		{
			document.getElementById('calendarp'+sid).style.display='none';
			document.getElementById('calendara'+sid).className='closed';
		}
		else
		{
			document.getElementById('calendarp'+sid).style.display='block';
			document.getElementById('calendara'+sid).className='open';
		}
	}
} // end function

function hideme(id) {
//alert(id);
	if (document.getElementById('b'+id).className!='show')
	{
//alert(document.getElementById('m'+id).style.display);
		document.getElementById('m'+id).style.display='none';
		document.getElementById('b'+id).className='show';
	}
	else {
		document.getElementById('m'+id).style.display='block';
		document.getElementById('b'+id).className='hide';
	}
}

