$().ready(function() {
//populate country locations
var allWebsites = new Array();
try {
    allWebsites = bdoWebsites;
}
catch (err) {
    allWebsites = bdoWebsitesLocal;
}
var theDNS = location.host;
$.each(allWebsites, function(key, data) {
    var thisDataDNS = data.dns;
    var thisDataDNStrimmed = thisDataDNS.slice((thisDataDNS.indexOf('//') + 2), thisDataDNS.length);
    if (thisDataDNStrimmed != theDNS) {
        $('<li><a href="' + data.dns + '" target="new">' + data.country + '</a></li>').appendTo(".dropDownListMenu1 ul");
    }
});

									 
	/* make div's same height */
	/* JT: Don't do this since the customer uses dynamic height individually per box now
	if (media = screen) {
		$(".jqColumn").vjustify(); 
	} */
	
	//remove "Søk" from search button
	$(".searchbutton").val("");
	$(".searchbuttonenglish").val("");
	
	/*--- drop down list menus ---*/
	//add class for correct height for the scrollable list
	$(".scroll-pane").addClass("scroll-pane-jq");
	//add class for javascript enabled browsers
	$(".dropDownListMenu").addClass("jqDDLM");
	//set scrollpane on drop down list menus
	$('#dropDownListMenuContent').jScrollPane({showArrows:true,scrollbarWidth:18,scrollbarWidth:18}); 
	$('#dropDownListMenuContent2').jScrollPane({showArrows:true,scrollbarWidth:18,scrollbarWidth:18});
	//set selected item from list as header
	$("#dropDownListMenuContent").parent().parent().prepend("<h3><span>" + $("#dropDownListMenuContent a.selected").text() + " Velg land</span>   <img src='/Templates/Noraudit/Styles/gfx/dropDownMenuArrow.png' alt=''/></h3>");
	$("#dropDownListMenuContent2").parent().parent().prepend("<h3><span>" + $("#dropDownListMenuContent2 a.selected").text() + "Velg kontor</span> <img src='/Templates/Noraudit/Styles/gfx/dropDownMenuArrow.png' alt=''/></h3>");
	//hide the list
	$(".jScrollPaneContainer").hide();
	
	//hide dropdown lists when clicking anywhere (if open)
	$("body").click(function() {
		$(".jScrollPaneContainer").hide();
		$("#main").removeAttr("style");
	});
	//show list when triggered
	$(".dropDownListMenu h3 img").click(function(event) {
		//hide previous
		$("#main").removeAttr("style");
		$(".dropDownListMenu .jScrollPaneContainer").not($(this).parent().parent().find(".jScrollPaneContainer")).each(function(){
			if ($(this).css('display')=='block') {
				$(this).hide();
			}
		});
		event.stopPropagation();
		$(this).parent().parent().find(".jScrollPaneContainer").toggle();
		if ($(this).parent().parent().find(".jScrollPaneContainer").css('display')=='block') {
			$("#main").css("min-height", $(this).offset().top + 250);
		}
	});
	//keep list open when clicking on scrollbar
	$(".jScrollPaneTrack").click(function(event) {
		event.stopPropagation();
		$(this).parent().show();
	});
	
	//form transform
	$('form').jqTransform({imgPath:'js/jqtransform/jqtransformplugin/img/'});
	
	//add - (hyphen) to sitemap items below level 1
	$("#SiteMap li li").prepend("- ");
	
});
