﻿/* select box cross-site navigation in service menu */ 
function changeSiteFromSelect(paramSiteAdresse){ 
  if (paramSiteAdresse=='1'){ 
    return; 
  } 
  else { 
    window.location=paramSiteAdresse; 
  } 
}

/* moving of undermenu from sitelayout to sidelayout */ 
function moveUndermenu(){

  var undermenuContainer =  document.getElementById('mergefield_navigation_level2'); 
  var newUndermenuContainer = document.getElementById('undermenuSidelayout');
  
    if (undermenuContainer && newUndermenuContainer) { 
	Tangora.DOM.MoveElement('mergefield_navigation_level2', 'undermenuSidelayout'); 
	undermenuContainer.style.display = "block"; 
    } 
  
}

/**/
function populateFirstNiveau(){

  var land = document.domain;
  landPosition =  land.lastIndexOf('.');
  land = land.slice(landPosition+1);
  //console.log(land);
  

  var firstNiveauName = document.getElementById('firstNiveauName');
  var selectedFirstNiveauPoint = Tangora.DOM.GetCollectionByClassName('mergefield_navigation_level1', 'a', 'active');
  if (selectedFirstNiveauPoint.length > 0) {
	selectedFirstNiveauPoint = selectedFirstNiveauPoint[0].firstChild.innerHTML;
    firstNiveauName.innerHTML = "<a href='/"+selectedFirstNiveauPoint+"-"+land+"' target='_top'>"+selectedFirstNiveauPoint+"<\/a>";
  }
}

 /* ---------- employee link selector id finder function (no longer used) ---------- */
 function findRelevantEmployeePageId() {
    var employeeLink = document.getElementById('employeeLink').firstChild.href;
    employeeLink  = employeeLink.split('.');
    alert (employeeLink[employeeLink.length-2]);
 }
 


/* ---------- random selection of 'did you know' blocks ---------- */

function chooseDidYouKnow(){
  var itemArray = new Array();
  itemArray = document.getElementById('vidsteDuWrapper').getElementsByTagName('DIV');
  var itemArrayLength = itemArray.length;
  var itemArrayDisplayNumber = Math.floor(Math.random()*itemArrayLength);
   itemArray[itemArrayDisplayNumber].style.display = 'block';

  itemAnchorArray = document.getElementById('vidsteDuWrapper').getElementsByTagName('A');
  for (var i=0; i<itemAnchorArray.length; i++){
    itemAnchorArray[i].target = "_top";
  }
 }



/* ------------ get set cookie for catetory frontpage ---------- */

function setCookie(paramCookieName,paramCookieValue,paramExpiredays){
    /* removed to ensure that there are no SEO problems */
    /*
  var preferredCategory=getCookie('preferredCategory');

  if(preferredCategory!=null && preferredCategory!=""){  
    return; 
  }
//alert (paramCookieName+' | '+paramCookieValue+' | '+paramExpiredays);

	var expiredate=new Date();
	expiredate.setDate(expiredate.getDate()+paramExpiredays);
	document.cookie=paramCookieName+ "=" +escape(paramCookieValue)+((paramExpiredays==null) ? "" : ";expires="+expiredate.toGMTString());
}

function getCookie(paramCookieName){
if (document.cookie.length>0){  
  cookieStart=document.cookie.indexOf(paramCookieName + "=");
  if (cookieStart!=-1){ 
    cookieStart=cookieStart + paramCookieName.length+1; 
    cookieEnd=document.cookie.indexOf(";",cookieStart);
    if (cookieEnd==-1) cookieEnd=document.cookie.length;
    return unescape(document.cookie.substring(cookieStart,cookieEnd));
    } 
}  
return "";
*/
}

function clearCookie(){
/* removed to ensure that there are no SEO problems */
    /*
 if (getCookie('preferredCategory')){
     document.cookie =  'preferredCategory='+getCookie("preferredCategory")+';expires=Thu, 01-Jan-1970 00:00:01 GMT';
 }
 */
}


function checkVisitCookie(){
/* removed to ensure that there are no SEO problems */
    /*
	var preferredCategory=getCookie('preferredCategory');
	   if(preferredCategory==""){  
	return; 
    }
	if(preferredCategory!=null && preferredCategory!=""){  
    window.location = preferredCategory;
	} 
	*/
}


/* ---------- showcase details thumbnail flash player ---------- */


function playFlash(paramFileName, paramThis){
  createFlashControl('showcaseFlash', 6, 'showcaseFlashObject', 480, 385, '/media/'+paramFileName);
  
  var thumbNames = new Array();
  thumbNames = Tangora.DOM.GetCollectionByClassName('mergefield_main', 'div', 'thumbText');
    for (var i=0; i<thumbNames.length; i++){
	thumbNames[i].className = 'thumbText thumbTextNormal';
    }
    
  var textDiv = paramThis.parentNode.nextSibling;
  textDiv.className='thumbText thumbTextActive';
}
