function precharge(iObj,iSrc) {
	if (document.images) {
		eval(iObj+" = new Image()");
		eval(iObj+".src = \""+iSrc+"\"");}
}
function roll(nom,iObj)
{
	if (document.images)
   		document.images[nom].src = eval(iObj+".src");
   	
}

var lastimagelock=null;

function roll_lock(nom,iObj)
{
	if(nom!=lastimagelock)
		roll(nom,iObj);
}

function rolldiv(calque,nom,iObj)
{
	if (document.getElementById)
   		document.images[nom].src = eval(iObj+".src");
   	else
   		document.layers[calque].document.images[nom].src = eval(iObj+".src");
   	
}

function lien(nom,url)
{
if(nom!=lastimagelock){
	if(lastimagelock!=null)
		roll(lastimagelock,lastimagelock+"_off");
	lastimagelock=nom
	roll_lock(nom,nom+"_on");
}
	parent.master.location=url

}

var MinWin=null;
function openWin(url, nom, winOpts)
{
	if(MinWin==null)
	{
		MinWin = window.open(url, nom, winOpts);
		MinWin.focus()
	}
	else if(!MinWin.closed)
	{
		MinWin.close()
		MinWin = window.open(url, nom, winOpts);
		MinWin.focus()
	}	
	else
	{
		MinWin = window.open(url, nom, winOpts);
		MinWin.focus()
	}
	
}

function openAnnexe(type,id)
{
 if (type=="texte" || type=="pdf") {
 		openWin('/secondaire/html/popup/annexe_'+type+'.asp?annexe_id='+id,'galmm','top=50,left=50,width=760,height=430,resizable='+((type=='pdf')?'yes':'no')+',scrollbars=no,menubar=no')
 } else {
 	 	openWin('/secondaire/html/popup/annexe_'+type+'.asp?annexe_id='+id,'galmm','top=50,left=50,width=560,height=330,resizable=no,scrollbars=no,menubar=no')
 }
}

function openSite(id)
{
	openWin('/secondaire/html/popup/annexe_site.asp?article_id='+id,'galmm','top=50,left=50,width=560,height=330,resizable=no,scrollbars=no,menubar=no')
}

function validateFormQuizz(obj)
{
	for(i=0;i<obj.question.length;i++)
	{
		if(obj.question[i].checked)
			return true;
	}
	alert("Vous n'avez pas répondu.")
	return false;
}

function chercheLettre(id)
{
	myY=chercheY("ancre"+id)
	parent.def.mainDiv.scrollBy(-10000000)
	parent.def.mainDiv.scrollBy(myY)
}

function chercheY(MyImg)
{
	if(document.all)
	{
		return parent.def.document.images[MyImg].offsetTop
	}
	if(document.layers)
	{
		return parent.def.document.mainContentDiv.document.images[MyImg].y
	}
		return parent.def.document.images[MyImg].y
}

function estuneadressemail(monemail)
{
flag=false;
	if(monemail!="")
	{
	longueur=monemail.substring(monemail.lastIndexOf("."),monemail.length).length
		if(monemail.indexOf("@")!=-1&&(longueur==3||longueur==4))
		{
			if(monemail.indexOf("@")<monemail.lastIndexOf(".")+1)
				flag= true;
		}
	}
return flag;
}

function openRename(id)
{
	openWin('/secondaire/html/popup/rename.asp?urlcasier_id='+id,'rename','top=50,left=50,width=560,height=320,resizable=no,scrollbars=no,menubar=no')
}

function lien2(url)
{
if(lastimagelock!=null)
	roll(lastimagelock,lastimagelock+"_off");
	lastimagelock=null
	parent.master.location=url
}

function chercheYNews(MyImg)
{
	if(document.all)
	{
		return document.images[MyImg].offsetParent.offsetTop
	}
	if(document.layers)
	{
		return document.mainContentDiv.document.images[MyImg].y
	}
		return document.images[MyImg].y
}

function structureUrl(obj1,obj2)
{
	obj1.value=modifieUrl(rechercheUrl(window.opener))
	obj2.value=window.opener.document.title
}

function modifieUrl(myUrl)
{
	myUrl=myUrl+""
	//recherche du nom du serveur
	myregExp=new RegExp("http://[^/]*")
	racine=myregExp.exec(myUrl) 
	//recherche du reste de l'url
	resteUrl=myUrl.substring(myUrl.lastIndexOf("/")+1,myUrl.length)
	autre=resteUrl.substring(0,resteUrl.indexOf("."))
	complement=resteUrl.substring(resteUrl.indexOf("?")+1,resteUrl.length)
	while(complement.indexOf("&")!=-1)
		complement=complement.replace("&","%26")
	dossier_id=""
	if(autre=="article"||autre=="dossier")
	{
		myregExp=new RegExp("dossier_id=[0-9]*")
		dossier_id=myregExp.exec(complement)+""
		dossier_id=dossier_id.substring(dossier_id.indexOf("dossier_id=")+11,dossier_id.length)
	}
	return racine+"/index.asp?autre="+autre+"&complement="+complement+"&dossier_id="+dossier_id
}

function casierWPopup()
{
	myUrl=rechercheUrl(window)
	myTitle=window.document.title
	while(myUrl.indexOf("&")!=-1)
		myUrl=myUrl.replace("&","%26")
	while(myTitle.indexOf(" ")!=-1)
		myTitle=myTitle.replace(" ","+")
	myUrl=modifieUrl(myUrl)
	myImg=new Image()
	myImg.src="/secondaire/html/popup/casier.asp?myUrl="+myUrl+"&myTitle="+myTitle
	//return "/html/popup/casier.asp?myUrl="+myUrl+"&myTitle="+myTitle
}

function openCasier()
{
	myUrl=rechercheUrl(window)
	myTitle=window.document.title
	while(myUrl.indexOf("&")!=-1)
		myUrl=myUrl.replace("&","%26")
	while(myTitle.indexOf(" ")!=-1)
		myTitle=myTitle.replace(" ","+")
	myUrl=modifieUrl(myUrl)
	openWin('/secondaire/html/popup/casier_popup.asp?myUrl='+myUrl+'&myTitle='+myTitle,'casier','top=50,left=50,width=560,height=320,resizable=no,scrollbars=no,menubar=no')
}

function rechercheUrl(myUrl)
{
	myUrltxt=myUrl.location+""
	myregExp=new RegExp("popup/[^.]*")
	existAnnexe=myregExp.exec(myUrltxt)+""
	if(existAnnexe=="popup/annexe")
		return myUrl.parent.location+""
	else if(myUrltxt.indexOf("dico_head")!=-1)
		{
			myUrltxt=myUrl.parent.liste.location+""
			lettre=myUrltxt.substring(myUrltxt.length-1,myUrltxt.length)
			return myUrl.parent.location+"?lettre="+lettre
		}
		else
			return myUrltxt
}

function casierNotLog()
{
	myUrl=rechercheUrl(window)
	myTitle=window.document.title
	while(myUrl.indexOf("&")!=-1)
		myUrl=myUrl.replace("&","%26")
	while(myTitle.indexOf(" ")!=-1)
		myTitle=myTitle.replace(" ","+")
	myUrl=modifieUrl(myUrl)
	if(window.opener)
	window.opener.location='/secondaire/html/casier.asp?myUrl='+myUrl+'&myTitle='+myTitle
	else
	window.location='/secondaire/html/casier.asp?myUrl='+myUrl+'&myTitle='+myTitle
}

function openPrint()
{
	openWin('/secondaire/html/popup/print.asp','print','top=50,left=50,width=600,height=320,resizable=no,scrollbars=yes,menubar=yes')
}

function openCasierAide()
{
	openWin('/secondaire/html/popup/caiser_aide.asp','aide','top=50,left=50,width=560,height=320,resizable=no,scrollbars=no,menubar=no')
}
function maximize(){
  parent.moveTo(0,0);
  parent.resizeTo(screen.width,screen.height);
}