// ############ 2003/08/20 tvidovic@metadesign.de ############
// ###########################################################
// ############ checking browser type & os ###################

window.onload=montre;
function BrowserCheck() {
var os= navigator.platform
	if (os.indexOf("Mac")!=-1) {
		this.os = "mac"
	} else {
		this.os = "pc"
	}
	var b = navigator.appName
	if (b=="Netscape") this.b = "ns"
	else if (b=="Microsoft Internet Explorer") this.b = "ie"
	else this.b = b
	this.v = parseInt(navigator.appVersion)
	this.ns = (this.b=="ns" && this.v>=4)
	this.ns4 = (this.b=="ns" && this.v==4)
	this.ns5 = (this.b=="ns" && this.v==5)
	this.ns6 = (this.b=="ns" && this.v==6)
	this.ie = (this.b=="ie" && this.v>=4)
	this.ie4 = (navigator.userAgent.indexOf('MSIE 4')>0)
	this.ie5 = (navigator.userAgent.indexOf('MSIE 5')>0)
	if (this.ie5) this.v = 5
	this.min = (this.ns||this.ie)
}

is = new BrowserCheck()

var OPEN_TYPE_NEW_WINDOW = 0;
var OPEN_TYPE_CURRENT_WINDOW = 0;
var TARGET_ATTRIBUTE = "TARGET";
var TARGET_ATTRIBUTE_BLANK = "BLANK";
var TARGET_ATTRIBUTE_SELF = "SELF";
var HELP_WINDOWS_WIDTH = "330";
var HELP_WINDOWS_HEIGHT = "350";

var which = "";
var actlink = "";
var actLayer = "";
var menuCoverDivId = ""; // cover DIV as solution of menu height and focus problem


/* 
 * Solution for menu height and focus problem
 * Shows menu cover 
 * function uses menu cover DIV 
 */
function showMenuCover() {
	if (is.ns4) {
		var coverDiv = eval('document.' + menuCoverDivId);
		if (typeof coverDiv != "undefined") {
			coverDiv.visibility = "show";
		}
	}
	if (is.ie){
		var coverDivStyle = eval(menuCoverDivId + '.style');
		if (typeof coverDivStyle != "undefined") {
			coverDivStyle.visibility = "visible";
		}
	}
	if (is.ns6 || is.ns5){
		var coverDivStyle = eval('document.getElementById("' + menuCoverDivId + '").style');
		if (typeof coverDivStyle != "undefined") {
			coverDivStyle .visibility = "visible";
		}
	}
} 
/* 
 * Solution for menu height and focus problem
 * Hides menu cover 
 * function uses menu cover DIV 
 */
function hideMenuCover() {
	if (is.ns4) {
		setTimeout("hidens4Cover()", 1000);
	} else {
		if (is.ie){
			var coverDivStyle = eval(menuCoverDivId + '.style');
			if (typeof coverDivStyle != "undefined") {
				coverDivStyle.visibility = "hidden";
			}
		} 
		if (is.ns6 || is.ns5) {
			var coverDivStyle = eval('document.getElementById("' + menuCoverDivId + '").style');
			if (typeof coverDivStyle != "undefined") {
				coverDivStyle .visibility = "hidden";
			}
		}
	}
}
/* 
 * Solution for menu height and focus problem
 * Hides menu cover in NS4
 * function uses menu cover DIV 
 */
function hidens4Cover() {
	var coverDiv = eval('document.' + menuCoverDivId);
	if (typeof coverDiv != "undefined") {
		coverDiv.visibility = "hide";
	}
}

function showIt(whichone, theLink) {
	which = whichone;
	actlink = theLink;
	show();
}

function hideIt(whichone,theLink) {
	which = whichone;
	actlink = theLink;
	hide();
}

function showL(whichone, theCol) {
	which = whichone;
	actlink.className = theCol;
	show();
}

function hideL(whichone,theCol) {
	which = whichone;
	actlink.className = theCol;
	hide();
}

function show() {

	if (is.ns4) {
		lnk = eval('document.' + which);
		lnk.visibility = "show";
	}
	if (is.ie){
		lnk = eval(which + '.style');
		lnk.visibility = "visible";
	}
	if (is.ns6 || is.ns5){
		lnk = eval('document.getElementById("' + which + '").style');
		lnk.visibility = "visible";
	}
actLayer = lnk;

}

function hide() {
	if (is.ns4) {
		setTimeout("hidens4()", 1000);
	} else {
		actLayer.visibility = "hidden";
	}
}

function hidens4() {
	actLayer.visibility = "hide";
}

function imgOn(imgName) {
   if (preloaded) {
        if (document.images) {
           	document[imgName].src = eval(imgName + "on.src");
        }
     }
}

function imgOff(imgName) {
   if (preloaded) {
        if (document.images) {
            document[imgName].src = eval(imgName + "off.src");
        }
	}
}

function imgDown(imgName) {
   if (preloaded) {
        if (document.images) {
            document[imgName].src = eval(imgName + "down.src");
        }
	}
}

var w;

/* 
 * Added 01.10.2004 to handle the opening of the link in a new window
 * or not.
 */
function MM_openBrWindow(theURL,winName,features) { //v2.0
	var targetIndex = theURL.indexOf(TARGET_ATTRIBUTE+"=");
	if ( targetIndex!=-1 && theURL.substr(targetIndex+(TARGET_ATTRIBUTE.length+1))==TARGET_ATTRIBUTE_SELF) {
	  	window.location.href = theURL.substring(0,targetIndex-1);
		window.focus();
	}
	else if ( targetIndex!=-1 && theURL.substr(targetIndex+(TARGET_ATTRIBUTE.length+1))==TARGET_ATTRIBUTE_BLANK) {
	  	w = window.open(theURL.substring(0,targetIndex-1),winName,features);
		w.focus();
	}
	else if ( targetIndex!=-1 ) {
	  	w = window.open(theURL.substring(0,targetIndex-1),winName,features);
		w.focus();
	}
	else {
	  	w = window.open(theURL,winName,features);
		w.focus();
	}
}

/* 
 * Added 26.04.2004 to handle internal/external link, and if internal
 * link handle application context path
 * Dependencies 
 *  1. global variable contextPath
 *  2. MM_openBrWindow
 */
function MM_openBrWindowExt(isExternal,link,name,features) {
	var url = "";
	if ( isExternal=="1") {
		url = link;
	} else {	// internal link
		if ( link.indexOf("/content")==0 ) {	// probably a handle
			if (link.indexOf(".")<0) {
				link = link.substring(("/content").length,link.length) + ".html";
			} else {
				link = link.substring(("/content").length,link.length);
			}
		} else { // unlikely scenario but theoretically possible
			if (link.indexOf(".")<0) {
				link += ".html";
			} 
		} 

		if ( (typeof contextPath == "undefined") || (contextPath=="/") ) {
			url = link;
		} else {
			url = contextPath + link;
		}
    }
	MM_openBrWindow(url,name,features);
}

/* 
 * Added 04.05.2005 to handle help windows width and height
 * Dependencies 
 *  1. global variable contextPath
 *  2. MM_openBrWindowExt
 */
function MM_openBrHelpWindowExt(isExternal,link,name,menubar,scrollbars,resizable,width,height) {
	var completeFeatures = "";
	var realWidth = HELP_WINDOWS_WIDTH;
	var realHeight = HELP_WINDOWS_HEIGHT;

	if (typeof menubar != "undefined") {completeFeatures+="menubar="+menubar+","}
	if (typeof scrollbars != "undefined") {completeFeatures+="scrollbars="+scrollbars+","}
	if (typeof resizable != "undefined") {completeFeatures+="resizable="+resizable+","}
	if (typeof width != "undefined" && width.length>0) 
	{
		realWidth = width;
	}
	if (typeof height != "undefined" && height.length>0) {
		realHeight = height;
	}

	completeFeatures+="width="+realWidth+",";
	completeFeatures+="height="+realHeight;

	MM_openBrWindowExt(isExternal,link,name,completeFeatures);
}

/* 
 * Added 29.01.2007 to respond to PC needs 
 */
function OpenPCBrWindow(theURL,winName,features, myWidth, myHeight, isCenter) { //v3.0 
  if(window.screen)if(isCenter)if(isCenter=="true"){ 
    var myLeft = (screen.availWidth-myWidth)/2; 
    var myTop = (screen.availHeight-myHeight)/2; 
    features+=(features!='')?',':''; 
    features+=',left='+myLeft+',top='+myTop; 
  } 
  window.open(theURL,winName,features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight); 
} 


function getOffsetTopFromParent (el) { 
	var ot = el.offsetTop; 
	if ( el.offsetParent != null ) {
		ot += el.offsetParent.offsetTop; 
	}
	return ot;
}

// use in sitemap and acknowledgement
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_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 MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location=\""+selObj.options[selObj.selectedIndex].value+"\"");
  if (restore) selObj.selectedIndex=0;
}

function MM_jumpMenuExternal(name,selObj,openType){ //v1.0
  if (!name) {
	name = "External";
  }
  if (!openType) {
	openType = OPEN_TYPE_NEW_WINDOW;
  }
  if (selObj.options[selObj.selectedIndex].value != "") {
    // if openType = OPEN_TYPE_NEW_WINDOW, open in a new window
    if (openType == OPEN_TYPE_NEW_WINDOW) {
	  window.open(selObj.options[selObj.selectedIndex].value,name);
    }
    // Otherwise, open in the current user window
    else {
	  this.location.href=selObj.options[selObj.selectedIndex].value;
    }
  }
}

function reloadOpenerWindow(theURL) {
  if (opener && theURL) {
    opener.window.location.href = theURL;
	opener.focus();
  }
}

function getCookie(name) {
	if (typeof name == "undefined" || name == "") {
		return null;
	}
	var cname = name + "=";               
	var dc = document.cookie;
	if (dc.length > 0) {              
		var begin = dc.indexOf(cname);
		if (begin != -1){
			begin += cname.length;       
			var end = dc.indexOf(";", begin);
			if (end == -1) {
		  		end = dc.length;
			}
			
		  return unescape(dc.substring(begin, end));
		} 
	}
	return null;
}

function setCookie(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}

function checkAcknowledgement(name, acknowledgements, ackUrls, handle, handleParamName, ackParamName, redirectHandle) {
	if ( (typeof name == "undefined") || (typeof acknowledgements == "undefined") || (typeof ackUrls == "undefined") || (typeof handle == "undefined") || (typeof handleParamName == "undefined") || (typeof ackParamName == "undefined") ) {
		return;
	}
	var thisHandle = window.location.pathname.substring(0,window.location.pathname.indexOf("."));
	for (var i in acknowledgements) {
		if ( (thisHandle == acknowledgements[i]) || (thisHandle.indexOf(acknowledgements[i]+"/") >-1) ) {
			if (getCookie(name)) {
				document.cookie = name+"="+getCookie(name)+"; path=/";
				if ((getCookie(name).indexOf("|"+acknowledgements[i]+"|")>-1) ){
					return;
				} 
			}
			if (typeof redirectHandle == "undefined") {
				// remember to synchronize the parameter names here as needed
				window.location.href = ackUrls[i] + "?"+ handleParamName + "=" + handle + "&" + ackParamName + "=" + acknowledgements[i];
			}
			else {
				// remember to synchronize the parameter names here as needed
				window.location.href = ackUrls[i] + "?"+ handleParamName + "=" + handle + "&" + ackParamName + "=" + acknowledgements[i] + "&ackRedirecthandle=" + redirectHandle;
			}
		} 
	} 
}

function adjustNavMenus() {
  if (document.getElementById && (typeof spacerImgIds != "undefined") && (typeof navMenuIds != "undefined") ) {
    for (var i in navMenuIds) {
      var menuId = navMenuIds[i];
      var imgId = spacerImgIds[i];
      var menu = document.getElementById(menuId);
      var img = document.getElementById(imgId);
      if (menu!=null && img!=null) {
        menu.style.top = (getOffsetTopFromParent(img) + 1) + "px";
      }
    }
  }
}

preloaded = false;

function formSubmit(aFormId) {
   var formEle = $(aFormId);
   if (formEle) {
      formEle.submit();
   }
}

function voidForm() {
   return true;
}


// ###########################################################
// #################### FAQ and JOBMap functions ########################
// ###########################################################

function changeImg(type, row) {

	rowTable = document.getElementById(row+'Table');
	if (rowTable.style.display=="none") {
		if (type=="Off") {
			imgOff(row+'Img');
		}
		else {
			imgOn(row+'Img');
		}		
	}
}


function changeViewGroupFaq(action, row)
{
	for(i = 0; i < row.length; i++)
	{
		rowTable = document.getElementById(row[i]+'Table');
		rowLink = document.getElementById(row[i]);
		if(action == 'close')
		{
			rowTable.style.display="none";
			imgOff(row[i]+'Img');
			rowLink.style.fontWeight = '';
		}
		if(action == 'open')
		{
			rowTable.style.display="";
			imgDown(row[i]+'Img');
			rowLink.style.fontWeight = 'bold';
		}
	}
}		

function changeViewSingleFaq(row)
{
	rowTable = document.getElementById(row+'Table');
	rowLink = document.getElementById(row);
	if (rowTable.style.display=="none") {
		rowLink.style.fontWeight = 'bold';
		imgDown(row+'Img');
		rowTable.style.display="";
		rowTable.focus();
	}
	else {
		rowLink.style.fontWeight = '';
		rowTable.style.display="none";
		imgOff(row+'Img');
	}
}

function changeViewJobMap(action, nbOfSectors)
{
	for(i = 0; i <= nbOfSectors; i++)
	{
		divJob = document.getElementById('jobsector' + i + 'Table');
		sectorLink = document.getElementById('jobsector' + i);
		if(action == 'close')
		{
			divJob.style.display="none";
			imgOff('jobsector' + i +'Img');
			sectorLink.style.fontWeight = '';
		}
		if(action == 'open')
		{
			divJob.style.display="";
			imgDown('jobsector' + i +'Img');
			sectorLink.style.fontWeight = 'bold';
		}
	}
}	

// ###########################################################
// #################### URL functions ########################
// ###########################################################

function createUrl(ndnavSelector)
{
	var urlWithoutNav = window.location.pathname.substring(0, window.location.pathname.lastIndexOf("."));
	return urlWithoutNav + "." + ndnavSelector + ".html";
}


// ###########################################################
// #################### Show and Hide div functions ########################
// ###########################################################


function montre(id)  
{      
  var d;
  d = $(id); 
  
  for (var i = 1; i<=10; i++){      
    if($('smenu'+i)){
//      $('smenu'+i).style.display='none';   
       $('smenu'+i).hide();
    }    
  }    
  if(d){
       $('smenu'+i).show();
  } 
}


function showImage(map, image){
    if (image) {
		document.write('<img  border="0"' + map +  ' src="'+image+ '" />');
	}
	
}



//
// Events loading after the DOM tree is completely built
//
$(document).ready(function(){
	
	
	
	$("#tools dl dt").hover(function(){
		
		if ($(this).siblings("dd .toolsRightEffect").find("li").size() > 0)
		{
			  $(this).siblings("dd .toolsRightEffect").show();
		}

	}, function(){

			$(this).siblings("dd .toolsRightEffect").hide();

	});
	
	$(".toolsRightEffect").hover(function(){
		
		$(this).parent().show();	
	
	}, function(){
		
		$(this).parent().hide();
	
	});

});
