// write "js" class to HTML tag for use by CSS selectors
var HTMLTag = document.getElementsByTagName('html');
HTMLTag[0].setAttribute((document.all ? "className" : "class"),"js");

//function for adding jQuery core script to a page
function loadjQuery() {
    document.write("<scr"+"ipt type=\"text/javascript\" src=\"/benelux/scripts_jquery_min_12803.js\"></scr"+"ipt>");   
}

// preload global nav images
if(document.images) {
    
    image3226 = new Image();
    image3226.src = "/images/bg_menu.gif";
    //
    image3228 = new Image();
    image3228.src = "/images/bg_menu_over.gif";
    //
    image5092 = new Image();
    image5092.src = "/images/bg_topmenu_over.gif";
    //
    image5097 = new Image();
    image5097.src = "/images/bg_currentmenu_over.gif";
    //
    image5098 = new Image();
    image5098.src = "/images/bg_fo-menulnk.gif";
    //
    image5099 = new Image();
    image5099.src = "/images/bg_fo-menulnk_over.gif";
    //
    image5100 = new Image();
    image5100.src = "/images/bg_menu_dotted-line.gif";
    //
    image5101 = new Image();
    image5101.src = "/images/bg_l3menu.gif";
    //
    image5102 = new Image();
    image5102.src = "/images/bg_l3menu_dotted.gif";
    //
    image5103 = new Image();
    image5103.src = "/images/bg_menulogin.gif";
    //
    image12154 = new Image();
    image12154.src = "/images/surveybtn_over.gif";
    //
}
//end


function showDiv (DivID) {
document.getElementById(DivID).style.display = 'block';
}
function hideDiv (DivID) {
document.getElementById(DivID).style.display = 'none';
}

//preferred function for "image" rollovers
/*
    Standards Compliant Rollover Script
    Author : Daniel Nolan
    http://www.bleedingego.co.uk/webdev.php
    
    Implementation: set class="imgover" inside <img> tag. No other classes should be set.
*/
function initRollovers() {
    if (!document.getElementById) return
    
    var aPreLoad = new Array();
    var sTempSrc;
    var aImages = document.getElementsByTagName('img');
    for (var i = 0; i < aImages.length; i++) {        
        if (aImages[i].className == 'imgover') {
            var src = aImages[i].getAttribute('src');
            var ftype = src.substring(src.lastIndexOf('.'), src.length);
            var hsrc = src.replace(ftype, '_over'+ftype);
            aImages[i].setAttribute('hsrc', hsrc);
            
            aPreLoad[i] = new Image();
            aPreLoad[i].src = hsrc;
            
            aImages[i].onmouseover = function() {
                sTempSrc = this.getAttribute('src');
                this.setAttribute('src', this.getAttribute('hsrc'));
            }    
            
            aImages[i].onmouseout = function() {
                if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_over'+ftype, ftype);
                this.setAttribute('src', sTempSrc);
            }
            
            aImages[i].onclick = function() {
                if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_over'+ftype, ftype);
                this.setAttribute('src', sTempSrc);
            }
            
        }
    }
}
//end
 

//navigation from pull-down menus
function forward (whichItem) {
    var whichDest = whichItem[whichItem.selectedIndex].value;
    if (whichDest == "nothing") {
        whichItem.selectedIndex = 0;
    } else {
        document.location = whichDest; 
    }
} 
//end
 

//functions for enlarging/reducing embedded diagrams
var currentDiagram = '';
function showDiagram(DiagramID) {
        currentDiagram=DiagramID;
    
        smDiagramHeight=document.getElementById(currentDiagram+'_sm').height;
        lgDiagramHeight=document.getElementById(currentDiagram+'_lg').height;
        var newTop=smDiagramHeight-lgDiagramHeight+30;    
        
  document.getElementById(currentDiagram+'_popup').style.top=newTop+'px';
  //document.getElementById(currentDiagram+'_popup').style.right=17+'px';
  setTimeout("document.getElementById(currentDiagram+'_popup').style.visibility='visible'",100);
}
function hideDiagram() {
 document.getElementById(currentDiagram+'_popup').style.visibility='hidden';
}
//end

//gets the country name selected
function getCookieVal (offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}
//end

//cookie functions for the worldwide pulldown menus
//variables for the cookie functions
var expDays = 365; //sets expiration time
var exp = new Date();
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
exp = exp.toGMTString();

//gets the cookie that contains the selection then returns the selected value using getCookieVal()
function GetCookie (name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return getCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}
function SetCookie (name, value, exp) {
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
document.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" + exp)) +
"; path=/" +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}
//end

//used to delete the cookie if necessary
function DeleteCookie (name) {
var exp = new Date();
exp.setTime (exp.getTime() - 1);
var cval = GetCookie (name);
document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
} 
//end
//end of cookie functions


//FUNCTIONS FOR AUTO-HEIGHT EMBEDDED "Content" IFRAME 
function resizeContentFrame(frame) {
    var currentFrame = frame;
    var iFrameID = document.getElementById(currentFrame);
    iFrameID.style.height = 0;
    var iFrameName = window.frames[currentFrame];
    var iFrameDocBodyHeight = '';        
    var iFrameDoc = iFrameName.document;
    var iFrameDocURL = iFrameDoc.URL;        
    var iFrameDocBody = iFrameDoc.getElementsByTagName('body');
    iFrameDocBodyHeight = iFrameDocBody[0].offsetHeight;
    iFrameID.style.height = parseInt(iFrameDocBodyHeight) + 0 + 'px';
    //top.document.location.hash = '#pgheader';
}
//end
 

//load ajax data into ajaxModule
function loadAjaxData(ajaxModule) {
    ajaxModule.each(function(){
        currAjaxModule = $(this);
        currAjaxModule.find(".ajaxContent").addClass("loading active");
    //$("body").animate({opacity:1},0,function(){
        currAjaxModule.find(".ajaxContent").load(currAjaxModule.attr("ajax-url"),function(){
            currAjaxModule.find(".ajaxContent").removeClass("loading active").not(".ajaxHide").fadeIn("slow",function(){
                $(this).css("display","block");
            });    
            if(currAjaxModule.find(".ajaxModule.ajaxAuto").length > 0) {
                loadAjaxData(currAjaxModule.find(".ajaxModule.ajaxAuto"));
                //ajaxLoaded();
            }            
            else {
                //ajaxLoaded();
            }
        });
    //});
    });
} //loadAjaxData

function windowInit() {
    initRollovers();
    initSelects();
}

$(document).ready(function(){

    //ajax auto load
    $(".ajaxModule.ajaxAuto").not(".tab > .ajaxModule.ajaxAuto").each(function(){
        loadAjaxData($(this));
    });

}); //document.ready
