
/*----------------------------------------Folder ----------------------------------------------------------------------------*/
lastFolderSelected = ""
lastOpenFolder =""

//Selectionne le menu courant
function selectFolder(id_f)
{
	if (id_f != "")
	{
		findObj(id_f).className = findObj(id_f).className + "_selected"
	}
}

function openCloseFolder(id_f,obj_f)
{
	
//if id_f exist...
	if (id_f != "")
	{
		//obj_f = object who call function : ex : <a></a>
		if (findObj("tag_content_"+id_f).className.indexOf("hide") != -1)
		{
			openFolder(id_f,obj_f)
			//Test s'il il y a déjà un tag ouvert
			if (lastOpenFolder != "" && lastOpenFolder!=id_f)
			{
				//closeFolder(lastOpenFolder)
			}
			lastOpenFolder = id_f
		}
		else
		{
			closeFolder(id_f,obj_f)
		}
	}

}
	
function openFolder(id_f,obj_f)
{
		//change the sign btn on the folder left
		classNameCurrent = findObj("btn_"+id_f).className
		classNameNew = classNameCurrent.replace("close","open")
		findObj("btn_"+id_f).className = classNameNew

		//change the img of the folder closed to the folder opened
		classNameCurrent = findObj("tag_content_"+id_f).className
		classNameNew = classNameCurrent.replace("hide","show")
		findObj("tag_content_"+id_f).className = classNameNew
		
		//findObj("photo").style.display = "none"
		
}
function closeFolder(id_f,obj_f)
{
		//change the sign btn on the folder left
		classNameCurrent = findObj("btn_"+id_f).className
		classNameNew = classNameCurrent.replace("open","close")
		findObj("btn_"+id_f).className = classNameNew

		//change the img of the folder closed to the folder opened
		classNameCurrent = findObj("tag_content_"+id_f).className
		classNameNew = classNameCurrent.replace("show","hide")
		findObj("tag_content_"+id_f).className = classNameNew

		//findObj("photo").style.display = ""
}



/*----------------------------------------Pop-up----------------------------------------------------------------------------*/
popUp_i = 0
function popUp(url,width,height) {
  popUp_i ++
  if (!width)  {width="780"}
  if (!height) {height="580"}
  properties = "width="+width+",height="+height
  properties+= ",menubar=0,resizable=1,directories=0,scrollbars=1,status=0,titlebar=0,toolbar=0,location=0"
open(url,"popUp",properties);
//  newWindow.focus();
}

/*----------------------------------------Pop-up picture--------------------------------------------------------------------*/
popUp_i = 0
function popUpPict(url) {
  popUp_i ++
  width="271"
  height="407"
  properties = "width="+width+",height="+height
  properties+= ",menubar=0,resizable=1,directories=0,scrollbars=1,status=0,titlebar=0,toolbar=0,location=0"
open(url,"popUp",properties);
//  newWindow.focus();
}


/*---------------------------browser detection------------------------------------------------------------------------------*/
var ie4 = document.all;
var ns4 = document.layers;
var ns6 = document.getElementById && !document.all; 

/*---------------------------"document.all" ==> "findObj" for Netscape compatibility----------------------------------------*/
// Example: obj = findObj("image1");
function findObj(theObj, theDoc)
{
  var p, i, foundObj;
  
  if(!theDoc) theDoc = document;
  if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
  {
    theDoc = parent.frames[theObj.substring(p+1)].document;
    theObj = theObj.substring(0,p);
  }
  if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
  for (i=0; !foundObj && i < theDoc.forms.length; i++) 
    foundObj = theDoc.forms[i][theObj];
  for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 
    foundObj = findObj(theObj,theDoc.layers[i].document);
  if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);
  
  return foundObj;
}

/*---------------------------hide or show an object (netscape compliant-----------------------------------------------------*/
function hideDiv(obj_f)	{	findObj(obj_f).style.display = "none"	}
function showDiv(obj_f)	{	alert("obj_f : "+obj_f) ; findObj(obj_f).style.display = ""	}

//========================================== rb_subMenu ver 1.0 07/08/2005 ===============================================================

currentSubMenuOpened = null;
closeSubMenuNow = false;
isMouseOverSubMenu = true;

function rb_showSubMenu(p_obj)
{
	isMouseOverSubMenu = true; //la souris est au dessus d'un menu

	//Test si il y avait deja un subMenu ouvert si oui, le ferme
	if (currentSubMenuOpened != null)	{	currentSubMenuOpened.className = "displayNone";	}
	
	currentObj = findObj(p_obj); //récupère le div à traiter
	currentObj.className = ""; //cache le div
	
	currentSubMenuOpened = currentObj; //retient le nom du div ouvert
}

function rb_closeSubMenu()
{
	currentSubMenuOpened.className = "displayNone"; // cache le subMenu
	currentSubMenuOpened = null; // retient aucun subMenu ouvert
}

function rb_mouseOverSubMenu() { isMouseOverSubMenu = true; }

function rb_mouseOutSubMenu() {	isMouseOverSubMenu = false; }

function rb_closeSubMenuLater()
{
	if ( isMouseOverSubMenu == true)
	{
		cycleBeforReInitiateMenus = 5;
	}
	else
	{
	//CountDown for automatic reinitiate menu by default
		cycleBeforReInitiateMenus --;
		if (cycleBeforReInitiateMenus==0) {rb_closeSubMenu();}
	}

	timerID = setTimeout("rb_closeSubMenuLater()", 150);
}
rb_closeSubMenuLater();
//=======================================================================================================================================

// writeCookie("myCookie", "my name", 24);
// Stores the string "my name" in the cookie "myCookie" which expires after 24 hours.
function writeCookie(name, value, hours)
{
  var expire = "";
  if(hours != null)
  {
    expire = new Date((new Date()).getTime() + hours * 3600000);
    expire = "; expires=" + expire.toGMTString();
  }
  document.cookie = name + "=" + escape(value) + expire;
}

// alert( readCookie("myCookie") );
function readCookie(name)
{
  var cookieValue = "";
  var search = name + "=";
  if(document.cookie.length > 0)
  { 
    offset = document.cookie.indexOf(search);
    if (offset != -1)
    { 
      offset += search.length;
      end = document.cookie.indexOf(";", offset);
      if (end == -1) end = document.cookie.length;
      cookieValue = unescape(document.cookie.substring(offset, end))
    }
  }
  return cookieValue;
}

//------------------------------------------------------------------------------------------------------
var currentLng //language courant

currentUrl=(document.location+"").toLowerCase() //adresse courante de la page

//recherche _nl _fr _en dans l'adresse
startPosIndexNl=currentUrl.toLowerCase().indexOf("_nl")
startPosIndexFr=currentUrl.toLowerCase().indexOf("_fr")
startPosIndexEn=currentUrl.toLowerCase().indexOf("_en")
  
//trouve la langue courante	
if (startPosIndexNl>0) { currentLng="nl" }
if (startPosIndexEn>0) { currentLng="en" }
if (startPosIndexFr>0) { currentLng="fr" }


function swapToLng(f_LngToSwap)
  {
  //génère le string de la nouvelle adresse	
//  newUrl=currentUrl.replace("_"+currentLng.toLowerCase(),"_"+f_LngToSwap)
  newUrl=currentUrl.replace("_"+currentLng.toLowerCase()+".","_"+f_LngToSwap+".")

//	alert(readCookie("cookie précédent --> lng :"+readCookie("lng")));
	//alert("cookie précédent --> lng :"+readCookie("lng"));

	writeCookie("lng", f_LngToSwap);

  //Envoie à la nouvelle adresse
  document.location=newUrl
  }



/*----------------------------------------Pop-up----------------------------------------------------------------------------*/
popUp_i = 0
function popUp2(url,width,height) {
  popUp_i ++
  if (!width)  {width="780"}
  if (!height) {height="580"}
  properties = "width="+width+",height="+height
  properties+= ",menubar=1,resizable=1,directories=1,scrollbars=1,status=1,titlebar=1,toolbar=1,location=1"
open(url,"popUp",properties);
//  newWindow.focus();
}

function popUp3(url,width,height) {
  popUp_i ++
  if (!width)  {width="300"}
  if (!height) {height="300"}
  properties = "width="+width+",height="+height
  properties+= ",menubar=1,resizable=1,directories=1,scrollbars=1,status=1,titlebar=1,toolbar=1,location=1"
open(url,"popUp",properties);
//  newWindow.focus();
}

function popUp4(url,width,height) {
  popUp_i ++
  if (!width)  {width="780"}
  if (!height) {height="580"}
  properties = "width="+width+",height="+height
  properties+= ",menubar=0,resizable=1,directories=0,scrollbars=1,status=0,titlebar=0,toolbar=0,location=0"
open(url,"popUp",properties);
//  newWindow.focus();
}
function popUp5(url,width,height) {
  popUp_i ++
  if (!width)  {width="1000"}
  if (!height) {height="650"}
  properties = "width="+width+",height="+height
  properties+= ",menubar=0,resizable=1,directories=0,scrollbars=1,status=0,titlebar=0,toolbar=0,location=0"
open(url,"popUp",properties);
//  newWindow.focus();
}

function gotoBannerUrl(f_Lng)
{
	if (f_Lng=="fr")
	{
		popUp5("http://www.dieteo.be/cereal");
	}
	else
	{
		popUp5("http://www.dieteo.be/cereal/index_nl.html");
	} 
}

//Banner public gauche
function gotoBannerPubLeft(f_Lng)
{
	if (f_Lng=="fr")
	{
		//popUp4("http://www.dieteo.be/contest/contest_fr.htm","786","580");
		//popUp2("http://www.updlf.be/portes_ouvertes.htm");
		document.location.href="http://www.dieteo.be/dossiers/dossier_08_vitalinea_fr.htm";
	}
	else
	{
		document.location.href="http://www.dieteo.be/dossiers/dossier_08_vitalinea_nl.htm";
		//popUp4("http://www.dieteo.be/contest/contest_nl.htm");
		//popUp2("http://www.vvvd.be/actueel.html");
	} 
}

