//Globally accessed javascript functions
function getRandomNumber(maxValue, excludingThisNumber)
{
	var randomNumber = Math.floor(Math.random() * (maxValue));
	
	if(excludingThisNumber != -1)
	{
		while (randomNumber == excludingThisNumber){ 
			randomNumber = Math.floor(Math.random() * (maxValue));
		} 		
	}
	
	return randomNumber;
}

function checkSearchBoxForEnter(event) 
{
	if (event.keyCode == 13) {
		searchSubmit()
	}  
}

function openNewWindow(pageURL, pageName, height, width)
{
	newWindow = window.open(pageURL, pageName, "location=1,status=1,scrollbars=1,resizable=1,width=" + width + ",height=" + height);
	newWindow.moveTo(0,0);
}

function showhideaccountnumbers() 
{
	if(document.getElementById('accountnumbers').style.display == 'none')
	{
		document.getElementById('accountnumbers').style.display = '';
		document.getElementById('closeaccountlist').style.display = '';
		document.getElementById('restoreaccountlist').style.display = 'none';
	}
	else
	{
		document.getElementById('accountnumbers').style.display = 'none';
		document.getElementById('closeaccountlist').style.display = 'none';
		document.getElementById('restoreaccountlist').style.display = '';
	}
}
 
  
//selects a specific tab menu item and displays its content simply by calling this function
function selectSpecificTabItemManually(idOfTabToSelect)
{
	if(idOfTabToSelect != "")
	{
		//first check that the specified tab exists on the page, if so, continue
		if(document.getElementById(idOfTabToSelect) != null)
		{
			//unselect all tabs
			$('.ui-tabs-nav .ui-tabs-selected').removeClass('ui-tabs-selected ui-state-active').addClass('ui-state-default');
			
			//hide all tab content
			$('.ui-tabs-panel').addClass('ui-tabs-hide');
			
			//manually select the specified tab
			$('#link-' + idOfTabToSelect).removeClass('ui-state-default').addClass('ui-tabs-selected ui-state-active');
			
			//now display the contents of the specified tab
			$('#' + idOfTabToSelect).removeClass('ui-tabs-hide');			
		}
	}
}  

//gets the ID of the selected drop list item, given the ID of a fancy select list
function getSelectedItemIDFromFancySelectList(idOfSelectList) 
{
	return $("#" + idOfSelectList + "_holder .selectedclass").attr('id');
}

//get the Value of the selected drop list item, given the ID of the fancy select list
function getSelectedItemValueFromFancySelectList(idOfSelectList)
{
	var itemValue = "";
	
	try
	{
		itemValue = document.getElementById(idOfSelectList + '_customselect').value;
	}
	catch(anError){}
	
	return itemValue;		
}

//get the Display Text of the selected drop list item, given the ID of the fancy select list
function getSelectedItemTextFromFancySelectList(idOfSelectList)
{
	var itemText = "";
	var selectedItemID;
	var selectedItemsPosition; 

	try
	{
		selectedItemID = ( $("#" + idOfSelectList + "_holder .selectedclass").attr('id') );
		selectedItemsPosition = selectedItemID.substring(selectedItemID.lastIndexOf("_") + 1, selectedItemID.length);			
		itemText = $("#" + idOfSelectList + '_options_item_text_' + selectedItemsPosition).text();
	}
	catch(anError){}
	
	return itemText;
}

//this will redirect the browser to the value stored in a fancy drop list
function redirectToSelectedItemValueOfFancySelectList(idOfSelectList)
{
	var selectedValue = getSelectedItemValueFromFancySelectList(idOfSelectList);
	
	if((selectedValue != "") && (selectedValue != "#"))
	{
		location.href = selectedValue;
	}
}

//this will redirect the browser to the value stored in the parent fancy drop list, or if a fancy child
//list has a value specified then the browser will redirect to the selected child value instead
function redirectToSelectedParentOrChildListValue(idOfParentSelectList) 
{
	//get the value of the currently selected parent
	var selectedItemID = ( $("#" + idOfParentSelectList + "_holder .selectedclass").attr('id') );
	var selectedItemsPosition = selectedItemID.substring(selectedItemID.lastIndexOf("_") + 1, selectedItemID.length);		
	var parentsValue = $("#" + idOfParentSelectList + '_options_item_value_' + selectedItemsPosition).text();
	
	
	//now get the value of the parents selected child
	//using the parents currently selected value, find the relevant child list to display
	var idOfChildSelectList = idOfParentSelectList + '_children_' + selectedItemsPosition;
	var selectedChildItemID = ( $("#" + idOfChildSelectList + "_holder .selectedclass").attr('id') );
	var selectedChildItemsPosition = selectedChildItemID.substring(selectedChildItemID.lastIndexOf("_") + 1, selectedChildItemID.length);		
	var childsValue = $("#" + idOfChildSelectList + '_options_item_value_' + selectedChildItemsPosition).text();
		
	if(childsValue == "")
	{
		location.href = parentsValue;
	}
	else
	{
		location.href = childsValue;
	}
}
  
//this is useful when there is a parent drop list with multiple dependant 'child' drop lists, 
//and only 1 child drop list should be visible at a time  
function createandshowcurrentchilddropdown(idOfParentSelectList, selectedItemID) 
{
	hideallchildropdownlists(idOfParentSelectList);
	
	//get the position of the selected child from its ID
	var selectedItemsPosition = selectedItemID.substring(selectedItemID.lastIndexOf("_") + 1, selectedItemID.length);
	
	//using the parents currently selected value, find the relevant child list to display
	var idOfChildSelectList = idOfParentSelectList + '_children_' + selectedItemsPosition;
	
	//if the child list does not already exist as a fancy drop down, create it first
	if(document.getElementById(idOfChildSelectList + '_iconselect') == null)
	{
		createFancySelectListManually(idOfChildSelectList, 0);
	}
	
	//pre-select the first item on the child drop list
	selectFancyListItemManually(idOfChildSelectList, 0);
	
	//now show the outer container which contains the child list. this can be done because the class name is the same as the select lists ID
	$('.' + idOfChildSelectList).removeClass('not-visible');
}

function hideallchildropdownlists(idOfParentSelectList)
{
	$('.' + idOfParentSelectList + '_children').addClass('not-visible');
}
  
function createandshowdropdown(num, idOfSelectList, autosubmit) 
{
	//if the list does not already exist as a fancy drop down, create it first
	if(document.getElementById(idOfSelectList + '_iconselect') == null)
	{
		createFancySelectListManually(idOfSelectList, autosubmit);
	}
	
	showdropdown(num);
}

function showdropdown(num) 
{
	if(document.getElementById('checkbox-'+num).checked == true)
	{
		document.getElementById('dropdown-'+num).style.display = '';
		
		if(document.getElementById('datadisplaylabel-'+num) != null) 
		{
			document.getElementById('datadisplaylabel-'+num).style.display = 'none';
		}
	}
	if(document.getElementById('checkbox-'+num).checked == false)
	{
		document.getElementById('dropdown-'+num).style.display = 'none';
		
		if(document.getElementById('datadisplaylabel-'+num) != null) 
		{
			document.getElementById('datadisplaylabel-'+num).style.display = '';
		}
	}
}	

// in scenarios where pre-creating large numbers of select lists is not practical, we can dynamically create select lists only when they are needed
// e.g. when a row is selected for editing. Otherwise simply use the class "fancy" within the HTML.
function createFancySelectListManually(idOfSelectList, autosubmit) 
{
		
	$('#' + idOfSelectList).addClass('fancy');
	$('#' + idOfSelectList).SelectCustomizer();
	//window.open(newurl,target)

	
	if(autosubmit == '1') {
		// Bind autosubmit behaviour to select list
		$('#' + idOfSelectList).each(function(i,o){
			
			$('#' + o.id + '_options').click(
				function() {
					window.location = $('#' + o.id + '_customselect').val();
				});			
		});
	}
}

function clearFancyListManually(idOfSelectList)
{	
	//un-highlight any highlighted list items in the drop list
	$("#" + idOfSelectList + "_holder .selectedclass").removeClass("selectedclass");
	
	//clear hidden input field that stores selected value
	try {
		document.getElementById(idOfSelectList + "_customselect").value = "";	
	}catch(anError){}
	
	//clear displayed label
	$("#" + idOfSelectList + "_iconselect").html("");
}

function selectFancyListItemManually(idOfSelectList, positionToSelect) 
{
	$("#" + idOfSelectList + "_holder .selectedclass").removeClass("selectedclass");
	$("#" + idOfSelectList + "_options_item_" + positionToSelect).addClass("selectedclass");
	$("#" + idOfSelectList + "_iconselect").html($("#" + idOfSelectList + "_options_item_" + positionToSelect).html());
	
	//update the hidden input field with the newly selected value
	try {
		document.getElementById(idOfSelectList + "_customselect").value = $("#" + idOfSelectList + '_options_item_value_' + positionToSelect).text();
	}catch(anError){}	

}

function hideElementWithID(elementID) 
{
	if(document.getElementById(elementID) != null)
	{
		document.getElementById(elementID).style.display='none';
	}	
}

function showElementWithID(elementID) 
{
	if(document.getElementById(elementID) != null)
	{
		document.getElementById(elementID).style.display='block';
	}	
}
	
function showMessagePopup(lightboxID) 
{
	document.getElementById(lightboxID).style.display = 'block';
	document.getElementById('filter').className = 'filter-cover-visible';
	document.getElementsByTagName('html')[0].style.overflow = 'hidden';
	document.body.style.overflow = 'hidden';		
}	

function hideMessagePopup(lightboxID) 
{
	document.getElementById(lightboxID).style.display='none';
	$('#filter').removeClass("filter-cover-visible");
	document.getElementsByTagName('html')[0].style.overflow = '';
	document.body.style.overflow = '';	
}
			  
//displays a lightbox popup given its ID as a parameter
function showLightBoxPopup(lightboxID) 
{
	document.getElementById(lightboxID).className = 'box-content-active';
	document.getElementById(lightboxID).style.display = 'block';
	document.getElementById('filter').className = 'filter-cover-visible';
	document.getElementsByTagName('html')[0].style.overflow = 'hidden';
	document.body.style.overflow = 'hidden';															
}
  
//prepares screen for a print view of a lightbox which can potentially contain content hidden within a scrollable area
function printLightBoxPopup(lightboxID) 
{		
	//undo effect on the body of displaying the lightbox so that the entire lightbox div will appear in print preview
	document.getElementsByTagName('html')[0].style.overflow = 'visible';
	document.body.style.overflow = 'visible';

	//hide all common page components
	$('#header').addClass("notprinted");
	$('#menu-primary').addClass("notprinted");
	$('#menu-secondary').addClass("notprinted");
	$('#menu-tertiary').addClass("notprinted");	
	
	//hide all components within body area, scenario where there is only one body column
	$('#col-0-of-one-full-col-layout').children().each(  
		function(){ 
			$(this).addClass("notprinted");
		} 
	);	
	
	//hide all components within body area, scenario where body content is part of a three col layout
	$('#col-2-of-three-col-layout').children().each(  
		function(){ 
			$(this).addClass("notprinted");
		} 
	);
		
	//popup itself should be only thing printable, so make sure there is no 'notprinted' class assigned to it
	$('.box-content-active').removeClass("notprinted");
	
	//print the lightbox contents (new styles applied in print CSS) will cause the lightbox to appear properly for a printer)
	window.print();
	
	//when the lightbox is closed through the function call 'hideLightBoxPopup', these changes to body styles will be undone
}
			  
//hides a lightbox popup given its ID as a parameter
function hideLightBoxPopup(lightboxID) 
{
	document.getElementById(lightboxID).className = 'box-content';
	document.getElementById(lightboxID).style.display = 'none';
	
	$('#filter').removeClass("filter-cover-visible");	
	
	//un-hide all common page components for print view
	$('#header').removeClass("notprinted");
	$('#menu-primary').removeClass("notprinted");
	$('#menu-secondary').removeClass("notprinted");
	$('#menu-tertiary').removeClass("notprinted");	
	
	//un-hide all components within body area, scenario where there is only one body column
	$('#col-0-of-one-full-col-layout').children().each(  
		function(){ 
			$(this).removeClass("notprinted");
		} 
	);	
	
	//un-hide all components within body area, scenario where body content is part of a three col layout
	$('#col-2-of-three-col-layout').children().each(  
		function(){ 
			$(this).removeClass("notprinted");
		} 
	);
			
	document.getElementsByTagName('html')[0].style.overflow = '';
	document.body.style.overflow = '';									
}


//prepares screen for a print view of the mobile services screen
function printMobileServicesScreen()
{
	window.print();
}

function showhidetooltext() 
{
	if(document.getElementById('aboutThisTool').style.display == 'none')
	{
		 document.getElementById('aboutThisTool').style.display = ''
		 document.getElementById('closeaboutthistool').style.display = 'inline';
		 document.getElementById('restoreaboutthistool').style.display = 'none';
	}
	else if(document.getElementById('aboutThisTool').style.display == '')
	{
		 document.getElementById('aboutThisTool').style.display = 'none';
		 document.getElementById('closeaboutthistool').style.display = 'none';
		 document.getElementById('restoreaboutthistool').style.display = 'inline';
	}
}	

function displayRandomHomePageArticles()
{
	//hide all feature articles, and randomize display for two random results to be shown
	var numberOfHomePageFeatureArticles = 0;
	var randomnumber_one = 0;
	var randomnumber_two = 0;
	
	numberOfHomePageFeatureArticles = $('#home-feature-articles .preview').size();	
	
	if(numberOfHomePageFeatureArticles > 0)
	{
		if(numberOfHomePageFeatureArticles <= 2)
		{
			$('#home-feature-articles .preview').show();
		}
		else
		{
			randomnumber_one = getRandomNumber(numberOfHomePageFeatureArticles, -1);
			randomnumber_two = getRandomNumber(numberOfHomePageFeatureArticles, randomnumber_one);	
			$('#home-feature-article-' + randomnumber_one).show();
			$('#home-feature-article-' + randomnumber_two).show();
		}
	}
	
	//hide all feature stories, and randomize display for two random results to be shown
	var numberOfHomePageFeatureStories = 0;	
	numberOfHomePageFeatureStories = $('#home-feature-stories .preview').size();	
		
	if(numberOfHomePageFeatureStories > 0)
	{
		if(numberOfHomePageFeatureStories <= 2)
		{
			//show the single feature story
			$('#home-feature-stories .preview').show();
		}
		else
		{
			randomnumber_one = getRandomNumber(numberOfHomePageFeatureStories, -1);
			randomnumber_two = getRandomNumber(numberOfHomePageFeatureStories, randomnumber_one);	
			$('#home-feature-story-' + randomnumber_one).show();
			$('#home-feature-story-' + randomnumber_two).show();
		}
	}
}

// Page initialisation calls made after the page is ready
$(document).ready(function () {

	//randomize home page feature articles
	displayRandomHomePageArticles();
	
	$('.sIFR-hasFlash .button-style-tabs h6').each(function(i,o){
		try {				
			if( ($('#' + o.id ).html().length)  > '60' ) {
				$('#' + o.id ).addClass("multi-lined");		
			}
		}
		catch(anError)
		{
		}
	});	

	//<![CDATA[	
	if(typeof sIFR == "function"){
		sIFR.replaceElement(".button-style-tabs h5.optusdincond", named({sFlashSrc: "/dafiles/OBCA/Furniture/optus.com.au/base/fonts/new_optusdincond-medium.swf", sWmode: "transparent", sColor: "#FFD100", sCase: "upper", nPaddingRight: "30"}));
		
		sIFR.replaceElement(".button-style-tabs h6.optusdincond", named({sFlashSrc: "/dafiles/OBCA/Furniture/optus.com.au/base/fonts/new_optusdincond-medium.swf", sWmode: "transparent", sColor: "#FFFFFF", sCase: "upper", nPaddingRight: "110"}));
	};	
	//]]>
	
	$('.sIFR-hasFlash .button-style-tabs h6').each(function(i,o){
		try {			
			if( ($('#' + o.id ).html().length)  > '60' ) {
				$('.button-style-tabs h6 .sIFR-flash').addClass("multi-lined");				
			}
		}
		catch(anError)
		{
		}
	});		
	
	// Initialise primary navigation menu
	try {
		$('#menu-primary ul').superfish({
			delay:500,
			speed:'fast'
		});
	}catch(anError){}
	
	// sIFR font replacement
	if(typeof sIFR == "function"){
	    sIFR.replaceElement("#campaigns .primary h4", named({sFlashSrc: "/dafiles/OBCA/Furniture/optus.com.au/base/fonts/optusdincond-medium.swf", sWmode: "transparent", sColor: "#FACB00", sCase: "upper"}));
		sIFR.replaceElement("#campaigns .primary p", named({sFlashSrc: "/dafiles/OBCA/Furniture/optus.com.au/base/fonts/optusdincond-medium.swf", sWmode: "transparent", sColor: "#ffffff"}));
	    // NOT IN USE: sIFR.replaceElement(".banner-MainText-BigWhite a.optusdincond", named({sFlashSrc: "/dafiles/OBCA/Furniture/optus.com.au/base/fonts/optusdincond-medium.swf", sWmode: "transparent", sColor: "#ffffff", sCase: "upper"}));
		// NOT IN USE: sIFR.replaceElement(".banner-MainText-Yellow a.optusdincond", named({sFlashSrc: "/dafiles/OBCA/Furniture/optus.com.au/base/fonts/optusdincond-medium.swf", sWmode: "transparent", sColor: "#FACB00"}));
			
		// Assuming replacement successful, we can now hide the HTML
		$('#campaigns .primary h4 span').css('display','none');
		$('#campaigns .primary p span').css('display','none');
	};
					 
	// Add styling to #authentication
	$('#account-controls > a:first-child').after('<span>/</span>');
	
	// Remove surplus styling from breadcrumb list
	$('#breadcrumbs > ul > li:first-child').css('border','none');
	
	// Remove surplus styling from footer list
	$('#footer-links > ul > li:first-child').css('border','none');
	
	
	// For new snippets with class 'hideable', Add Hide Panel links after all H3s
	$('.snippet-container.hideable h3').after('<p class="hide-box"><a href="#" title="Hide this panel"><span>Hide this panel</span></a></p>');
	
	
	// For boxes with class 'hideable', Add Hide Panel links after all H4s, or div placeholders with class of 'hideable-content-toggle'
	$('.content-box.hideable h4').after('<p class="hide-box"><a href="#" title="Hide this panel"><span>Hide this panel</span></a></p>');
	$('.content-box.hideable .hideable-content-toggle').after('<p class="hide-box"><a href="#" title="Hide this panel"><span>Hide this panel</span></a></p>');
	
	// Binds box/panel hide and show behaviours to all Hide Panel links. 'hideable-content' is an optional class assigned to additional div content that should be toggled.
	// 'hideable-content-reverse' behaves in the opposite way to 'hideable-content', i.e. when the person closes the toggled area, items of this class will APPEAR.
	$('.hide-box a').bind('click', function() {
		var contentboxinner = $(this).parents('.content-box:eq(0)').find('.content-box-inner');
		var hideablecontent = $(this).parents('.content-box:eq(0)').find('.hideable-content');
		var hideablecontentreverse = $(this).parents('.content-box:eq(0)').find('.hideable-content-reverse'); 
		var hideablesnippetcontent = $(this).parents('.snippet-container:eq(0)').find('.body');
		
		if (contentboxinner.css('display')=='none') {			
			contentboxinner.css('display','block');
			$(this).css('background','url(/dafiles/OBCA/Furniture/optus.com.au/base/images/minimise.gif)');
		} else { 
			contentboxinner.css('display','none');
			$(this).css('background','url(/dafiles/OBCA/Furniture/optus.com.au/base/images/restore.gif)');
		}
		
		//optional hideable content
		if(hideablecontent.length > 0)
		{
			if (hideablecontent.css('display')=='none') { 
				hideablecontent.css('display','block');
				hideablecontentreverse.css('display','none');
				$(this).css('background','url(/dafiles/OBCA/Furniture/optus.com.au/base/images/minimise.gif)');
			} else { 
				hideablecontent.css('display','none');
				hideablecontentreverse.css('display','block');
				$(this).css('background','url(/dafiles/OBCA/Furniture/optus.com.au/base/images/restore.gif)');
			}	
		}	

		//new snippet-container boxes
		if(hideablesnippetcontent.length > 0)
		{
			if (hideablesnippetcontent.css('display')=='none') { 
				hideablesnippetcontent.css('display','block');
				$(this).css('background','url(/dafiles/OBCA/Furniture/optus.com.au/base/images/minimise.gif)');
			} else { 
				hideablesnippetcontent.css('display','none');
				$(this).css('background','url(/dafiles/OBCA/Furniture/optus.com.au/base/images/restore.gif)');
			}		
		}
			
	});
	
	// News ticker
	try {
		$('#news-items').newsticker();
	}catch(anError){}
	
	// Initialise all "fancy" SelectCustomizer selects
	$('select.fancy').SelectCustomizer();	
		
	// Bind autosubmit behaviour to any select with "autosubmit" class
	$('select.autosubmit').each(function(i,o){		
		$('#' + o.id + '_options').click(
			function() {
				window.location = $('#' + o.id + '_customselect').val();
			});	

		//$('#' + o.id + '_options .targetblank').click(
		//	function() {
		//		alert( o.id + " " + i);
		//	});				
	});
	
	$('.fancy-parent').each(function(i,o){		
		$('#' + o.id + '_options').click(
			function() {
				createandshowcurrentchilddropdown( o.id, getSelectedItemIDFromFancySelectList(o.id) );
			});			
	});	

	
	// Initialise the detailed help dialog box
	try {
		$('#dialogTest').dialog({ autoOpen: false, position: 'right', height: 400 })
	}catch(anError){}		
	
	// Bind site search defaults and behaviours
	$('#search-site #searchword').val('Search Optus Business');
	$('#search-site #searchword').addClass('default');
	$('#search-site #searchword').bind('focus', function() {
		if ($(this).val()=='Search Optus Business') {
			$(this).val('');
			$(this).removeClass('default');
		}
	});
	$('#search-site #searchword').bind('blur', function() {
		if ($(this).val()=='') {
			$(this).val('Search Optus Business');
			$(this).addClass('default');
		}
	});
	
	// Detect tabs and initialise
	try {
		if ($('.tabs').length>0) {
			$('.tabs').tabs({
				selected: 0
			});	
		}
	}catch(anError){}
	
	// Detect accordions and initialise
	$(".accordion").accordion({
		collapsible: true,
		autoHeight: false,
		active: 5 
	});
	
	// Yuval's news/overview hide/show cookie code
	//Ticker newsContainer-Content hide
	$('.news-collapse').click(function() {
		$('.news-collapse').css("display","none");
		$('.news-expand').css("display","block");
		$('#news-inner').css("display","none");
		$('#news').css("height","16px");
		$.cookie('news', 'collapsed');
	});
	//Ticker newsContainer-Content resume
	$('.news-expand').click(function() {
		$('.news-expand').css("display","none");
		$('.news-collapse').css("display","block");
		$('#news-inner').css("display","block");
		$('#news').css("height","");
		$.cookie('news', 'expanded');
	});
	
	//Campaign contentOverviewContainer hide 
	$('.overview-container-collapse').click(function() {
		$('.overview-container-expand').css("display","block");
		$('.overview-container-collapse').css("display","none");
		$('#overview-container-inner').css("display","none");
		$('#overview-container').css("height","16px");
		$.cookie('overview-container', 'collapsed');
	});
	//Campaign contentOverviewContainer resume
	$('.overview-container-expand').click(function() {
		$('.overview-container-expand').css("display","none");
		$('.overview-container-collapse').css("display","block");
		$('#overview-container-inner').css("display","block");
		$('#overview-container').css("height","");
		$.cookie('overview-container', 'expanded');
	});
	// COOKIES
	// newsContainer column state 
	var news = $.cookie('news');
	var overviewcontainer = $.cookie('overview-container');
	// If the news item is hidden in the cookie hide it.
	if (news == 'collapsed') {
		$('.news-collapse').css("display","none");
		$('.news-expand').css("display","block");
		$('#news-inner').css("display","none");
		$('#news').css("height","16px");
	};//"images/icons/minimise.gif"
	// If the Campaign item is hidden in the cookie hide it.
	if (overviewcontainer == 'collapsed') {
		$('.overview-container-collapse').css("display","none");
		$('.overview-container-expand').css("display","block");
		$('#overview-container-inner').css("display","none");
		$('#overview-container').css("height","16px");
	};//"/dafiles/OBCA/Furniture/images/icons/minimise.gif or restore.gif"
	
	// Stacking context initialisation
	// Was original just content-box but due to menu issue now
	// expanded to cover all elements of page. Should be cleaned up
	var default_Z_Index = 200;	
	
	//All drop lists will have a high priority by default
	$(".selectwrapper .selectitems").css('z-index',9999);
	
	//All vignette menus will have an ID that begins with "bannerMenu_", make sure these have highest z-indexes
	//as an exception
	$("layer[id^=bannerMenu_]").css('z-index',9999);
	$("layer[id^=bannerMenu_]").children().each(function() {
		$(this).css('z-index',9999);
	});	
	
	$('#header').css('z-index',default_Z_Index); default_Z_Index = default_Z_Index - 10;
	$('#menu-primary').css('z-index',default_Z_Index); default_Z_Index = default_Z_Index - 10;
	$('#campaigns').css('z-index',default_Z_Index); default_Z_Index = default_Z_Index - 10;
	$('#news').css('z-index',default_Z_Index); default_Z_Index = default_Z_Index - 10;
	$('#overview-container').css('z-index',default_Z_Index); default_Z_Index = default_Z_Index - 10;
	$('.content-box').each(function(i,o) {
		$(o).css('z-index',default_Z_Index);
		default_Z_Index = default_Z_Index - 10;
	});
	
	$('#breadcrumbs').css('z-index',default_Z_Index); default_Z_Index = default_Z_Index - 10;
	$('#footer').css('z-index',default_Z_Index); default_Z_Index = default_Z_Index - 10;
	//All drop lists will have a high priority by default
	$(".selectwrapper .selectitems").css('z-index',9999);
	
	//allow the search box on the header to accept the enter key as a search submit request
	if ($.browser.mozilla) { 
		$('#searchword').keypress(checkSearchBoxForEnter); 
	}
	else {
		$('#searchword').keydown(checkSearchBoxForEnter);
	}
	
	//The server may generate a javascript variable called activeTab, if set, then this tab should be
	//pre-selected on the current page
	try {
		selectSpecificTabItemManually(activeTab);
	}catch(anError){}
		
});
