	function openOfficeFacilities() {
		alert("In Javascript");
		var urlString = "/AboutUs/OfficesAndFacilities/index.htm?Region=";
		var selectedRegion = this.options[this.selectedIndex];
		if (selectedRegion.value != "nothing") {
			window.location = urlString + selectedRegion.value;
		}
	}

  function findPosX(obj)
  {
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
  }

  function findPosY(obj)
  {
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
  }

function showinfo(item,top,left) {
	infobox = document.getElementById(item);
	infobox.style.display = 'block';
	infobox.style.top = top + 'px';
	infobox.style.left = left + 'px';
}

function hideinfo(item) {
	infobox = document.getElementById(item);
	infobox.style.display = 'none';
}

// This function call is duplicated on the Contact Us web forms since they load after the browser considers the page fully rendered. 
jQuery(document).ready(function(){
	customSelectBoxes();
	assignCssViaJQuery();



});

function populateDefaultFormFieldValues() {

	// This function uses the DefaultValue method in: /mwv/fragments/mwvcorpjavascripts/jquery.defaultformfields.js
	// It populates form fields with temporary default text and can assign a CSS class.
	// The text disappears when the field is active or had a non-empty value.
	
	// Any form fields with ids:"FirstName", "LastName", and "xEmail" are populated with "Enter Text" and assigned a class of "emptyField."
	jQuery("#FirstName,#LastName,#xEmail").DefaultValue("emptyField","Enter Text");
	
}

function customSelectBoxes() {

	// Ironworks MWV-specific code.
	// Remove everything with selectME class and the attribute values from almost all select boxes 
	//   so that most select boxes are re-rendered (except ones with the value "hidden").
	jQuery(".selectME").remove(); 
	jQuery("select[alt!=hidden]").attr("alt","");

	// from http://gerrendesign.com/weblog/2009/06/how_to_make_custom_select_boxe.php
	// modified by Ironworks Consulting specifically for MWV
	// first locate all of the select tags on the page and hide them
	jQuery("select[alt!=hidden]").css('display','none');
	//now, for each select box, run this function
	jQuery("select[alt!=selectBoxCustomized][alt!=hidden]").each(function(){
		var multi = jQuery(this).attr("multiple");
		if(multi==true){
			jQuery(this).css("visibility","visible").css("display","block");
		}
		else {
			// find the id of the select instance
			var instanceID = jQuery(this).attr("id");
			var instanceParentID = jQuery(this).parent().attr("id");
			var curSel = $(this);
			var curSel = jQuery(this);
			// get the CSS width from the original select box
			var gddWidth = jQuery(curSel).css('width');
			var gddWidthL = gddWidth.slice(0,-2);
			var gddWidth2 = gddWidthL - 36;
			var curSelDisabled = jQuery(curSel).attr("disabled");
			var curSelDisabledClass;
			if(curSelDisabled==true){
				curSelDisabledClass="disabled";
			}
			// build the new div structure
			var gddTop = '<div style="width:' + gddWidthL + 'px" class="selectME ' + curSelDisabledClass + '" id="selectME' + instanceID + '" tabindex="0"><div class="middle"><div><div><div><ul class="selectME"><li>';
			//get the default selected option
			var whatSelected = jQuery(curSel).children('option:selected').text();
			//write the default
			var gddFirst = '<span class="selectME gselected" style="width:'+ gddWidth2 +  'px;">'+ whatSelected +'</span><span id="arrowImg"></span><div class="clears"></div><dl class="selectME" lang="22" style="display:none; width:' + gddWidthL + 'px;">';
			// create a new array of div options from the original's options
			var addItems = new Array();      
			jQuery(curSel).children('option').each( function() {           
				var text = jQuery(this).text();  
				var selVal = jQuery(this).attr('value');
				var optionClass = jQuery(this).attr('class');
				var before =  '<dd style="width:' + gddWidthL + 'px;"><a class="' + optionClass + '" rel="' + selVal + '" tabindex="0">';
				var after = '</a></dd>';           
				addItems.push(before + text + after);
			});
			//hide the default from the list of options 
			//var removeFirst = addItems.shift();
			// create the end of the div selectbox and close everything off
			var gddBottom ='</dl></li></ul></div></div></div></div></div>'
			//write everything after each selectbox
			var GDD = gddTop + gddFirst + addItems.join('') + gddBottom;
			jQuery(curSel).after(GDD);
			//this var selects the div select box directly after each of the origials
			var nGDD = jQuery(curSel).next('div.selectME');
			jQuery(nGDD).find('dd:first').addClass("first");
			//set the height of the select box options list if number of options is greater than a fixed number
			if(addItems.length > 8) {
				jQuery(nGDD).find('dl').css('height','210px');
			}
			//handle the on click functions - push results back to old text box
			if(curSelDisabled!=true){
				jQuery(nGDD).click( function(e) {
					var myTarA = jQuery(e.target).attr('rel');
					var myTarT = jQuery(e.target).text();
					var myTar = jQuery(e.target);
					//if closed, then open
					if( jQuery(nGDD).find('dl').css('display') == 'none') {
						//this next line closes any other selectboxes that might be open
						jQuery('div.selectME dl').css('display','none');
						jQuery(nGDD).find('dl').css('display','block');
						//if user clicks off of the div select box, then shut the whole thing down
						jQuery('body').click( function(f) {
							var myTar2 = jQuery(f.target);
							if (myTar2 != nGDD) {jQuery(nGDD).find('dl').css('display','none');}
						});
						return false;
					}
					else {      
						if (myTarA == null){
							jQuery(nGDD).find('dl').css('display','none');
							return false;
						}
						else {
							//set the value of the old select box
							jQuery(curSel).val(myTarA);
							//Set a trigger value called update to key off of 
							jQuery(curSel).trigger("updateCorpOfficeFacilSidebarSelection");
							//set the text of the new one
							jQuery(nGDD).find('span.gselected').text(myTarT)

							//commenting out title attribute. It's creating alt text onhover
							//jQuery(nGDD).attr('title',myTarT);

							jQuery(nGDD).find('dl').css('display','none');
							if(instanceID=="Region"){
								postValue('Region');
								return false;
							}
							else if(instanceID=="Country"){
								postValue('Country');
								return false;
							}
							else if(instanceID=="State"){
								postValue('State');
								return false;
							}
							else if(instanceID == "Location"){
								postValue('Location');
								return false;
							}
							else if(instanceID == "Industry"){
								postValue('Industry');
								return false;
							}
							else if(instanceID=="CorpProdCategoryFilter"){
							   if ($('DropDownSelectedFilter')) {
							   	$('DropDownSelectedFilter').value='Category';
								}
								$('productsearchresultform').submit();
								return false;
							}
							else if(instanceID=="CorpProdPropertyFilter"){
							   if ($('DropDownSelectedFilter')) {
							   	$('DropDownSelectedFilter').value='Property';
								}
								$('productsearchresultform').submit();
								return false;
							}
							else if(instanceID=="CorpProdIndustryFilter"){
								$('productsearchresultform').submit();
								return false;
							}
							else if(instanceID=="NewsReleaseYearFilter" || instanceID=="NewsReleaseCategoryFilter"){
								$('NewsReleaseForm').submit();
								return false;
							}
							else if(instanceID=="xSalesFinderIndustry"){
								loadBusinessCard();
								return false;
							}
							else if(instanceID=="xIndustry"){
								changeIndustryContactInformation();
								return false;
							}
							else if(instanceID=="xCountryContactUs"){
								changeStateSublist();
								return false;
							}
						}
					}
				//handle the tab index functions
				}).focus( function(e) {                   
					jQuery(nGDD).find('dd:first').addClass('currentDD');
					jQuery(nGDD).find('dd:last').addClass('lastDD');
					function checkKey(e){
						//on keypress handle functions
						function moveDown() {
							var current = jQuery(nGDD).find('.currentDD:first');
							var next = jQuery(nGDD).find('.currentDD').next();
							if (jQuery(current).is('.lastDD')){
								return false;
							} else {
								jQuery(next).addClass('currentDD');
								jQuery(current).removeClass('currentDD');
							}
						}
						function moveUp() {
							var current = jQuery(nGDD).find('.currentDD:first');
							var prev = jQuery(nGDD).find('.currentDD').prev();
							if (jQuery(current).is('.first')){
								return false;
							} else {
								jQuery(prev).addClass('currentDD');
								jQuery(current).removeClass('currentDD');
							}
						}
						var curText = jQuery(nGDD).find('.currentDD:first').text();
						var curVal = jQuery(nGDD).find('.currentDD:first a').attr('rel');
						switch (e.keyCode) {
							case 40:
								jQuery(curSel).val(curVal);
								jQuery(nGDD).find('span.gselected').text(curText);
								moveDown();
								return false;
								break;
							case 38:
								jQuery(curSel).val(curVal);
								jQuery(nGDD).find('span.gselected').text(curText);
								moveUp();
								return false;
								break;
							case 13:
								jQuery(nGDD).find('dl').css('display','none');
						}
					}
					jQuery(document).keydown(checkKey);	
				}).blur( function() {
					jQuery(document).unbind('keydown');
				});
			}
			jQuery(curSel).attr("alt","selectBoxCustomized");
		}
	});
}


function assignCssViaJQuery() {

	/*
	=======================
	table.hasBorders
	=======================
	*/

	// Set cellspacing to 0
	jQuery("table.hasBorders").attr("cellspacing","0");

	// Any th in last row: gray bottom border
	jQuery("table.hasBorders tr:last th:first-child").addClass("lastInColumn");

	// Any th or td in last column: no right border
	jQuery("table.hasBorders td:last-child").addClass("lastInRow");

	// Empty first th or td in thead: bg image
	jQuery("table.hasBorders tr th:first-child:empty").addClass("empty");

	// Non-breaking spacer first th or td in thead: bg image
	jQuery("table.hasBorders tr th:first-child").each(function()
	{
		var testString = jQuery(this).text();
	
		if (jQuery.trim(testString) == "")
		{
			jQuery(this).addClass("empty");
		}
		});

	// Empty td or th: add non-breaking spacer
	jQuery("table.hasBorders tr th:first-child:empty").append("&nbsp;");

}


/*
====================================================================================================
Contact Us Dependent Dropdown Functions
*/


// Function here was broken apart to adapt to customized dropdowns: http://www.ajaxray.com/blog/2007/11/08/jquery-controlled-dependent-or-cascading-select-list-2/
function makeStateSublist()
{
	var parent="xCountryContactUs";
	var child="xStateContactUs";
	var isSubselectOptional=false;
	var childVal="";

	jQuery("body").append("<select style='display:none' id='"+parent+child+"' alt='hidden'></select>");
	jQuery('#'+parent+child).html(jQuery("#"+child+" option"));

	// Get index of selected country.
	//var parentValue = jQuery('#'+parent+ ' option').index(jQuery('#'+parent +' option:selected'));
	var parentValue = jQuery('#'+parent).attr('value');

	// remove non-alphanumeric characters
	parentValue = parentValue.replace(/\W/g,'');

	jQuery('#'+child).html(jQuery("#"+parent+child+" .sub_"+parentValue).clone());

	var childValue = jQuery("#"+parent+child+" .sub_"+parentValue);
	if (childValue.length==0){
		jQuery('#'+child).attr("disabled", true); 
	} else {
		jQuery('#'+child).attr("disabled", false); 
		childVal = (typeof childVal == "undefined")? "" : childVal ;
		jQuery("#"+child).val(childVal).attr('selected','selected');
	}

	// Re-render the custom dropdown.
	customSelectBoxes();
}

function changeStateSublist()
{
	var parent="xCountryContactUs";
	var child="xStateContactUs";
	var isSubselectOptional=false;
	var childVal="";

	//var parentValue = jQuery('#'+parent+' option').index(jQuery('#'+parent +' option:selected'));
	var parentValue = jQuery('#'+parent).attr('value');

	// remove non-alphanumeric characters
	parentValue = parentValue.replace(/\W/g,'');
	
	var childValue = jQuery("#"+parent+child+" .sub_"+parentValue);
	jQuery('#'+child).html(jQuery("#"+parent+child+" .sub_"+parentValue).clone());

	if (childValue.length==0){
		jQuery('#'+child).attr("disabled", true); 
	} else {
		jQuery('#'+child).attr("disabled", false); 
		if(isSubselectOptional) jQuery('#'+child).prepend("<option value='none' selected='selected'> -- Select -- </option>");

		jQuery('#'+child).trigger("change");
		jQuery('#'+child).focus();
	}

	// Re-render the custom dropdown.
	customSelectBoxes();
}

/*
====================================================================================================
fixes issue addressed in: http://www.mix-fx.com/flash-prompt.htm
May cause brief screen load blank page in IE7.
Code calling this function is in the corporate footer.
*/

function fixActivatePrompt() {
	theObjects = document.getElementsByTagName("object");
	for (var i = 0; i < theObjects.length; i++) {
		theObjects[i].outerHTML = theObjects[i].outerHTML;
	}
}

/*
=====================================================================================================
Hiding flash from Firefox when printing
*/
jQuery(document).ready(function(){
	if(!jQuery.browser.msie  && !jQuery.browser.safari) {
		jQuery('object').addClass('hideThisWhenPrinting');
		jQuery('embed').addClass('hideThisWhenPrinting');
	}
});

