
// -------------------------------------------------------------------------------------------------------------------
// Positions background image based on browser's current window size at page load/resize, so that "D" image is always
// cropping off in the right hand corner of the page


function positionImage() {

var myWidth = 0;		// width of the browser window.
var imgWidth = 174;		// width of background image to be positioned ("images/shared/background_D.gif")
var imgXpos;			// final value for the horizontal poisition of the background image
var imgYpos = 0;		// final value for the vertical poistion of the background image ("0"  poxels in this layout)
var minXpos = 845;		// minimum value for the horizontal poisition of the background image (doesn't let the image go any further to the left)

  	
// Determine the current width of the browser window
if( typeof( window.innerWidth ) == 'number' ) {
	//Non-IE browsers
	myWidth = window.innerWidth;
	//myHeight = window.innerHeight;
} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
	//IE 6+ in 'standards compliant mode'
	myWidth = document.documentElement.clientWidth;
} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
	myWidth = document.body.clientWidth;
}
  
// Determine final value for horizintal position by subtracting image width form window width
imgXpos = (myWidth - imgWidth);

// If the determined position is not less than the minimum horizontal positioning point, go ahead and move it to its new position.
if (imgXpos >= minXpos) {
	document.getElementById("background").style.backgroundPosition = imgXpos +"px " + imgYpos +"px";
}
// otherwise, place it in its default position
else {
	document.getElementById("background").style.backgroundPosition = minXpos +"px " + imgYpos +"px";
}

}



// -------------------------------------------------------------------------------------------------------------------
// Preloads and manages rollovers for all main nav images 


function preloadMenuImages() {
	if (document.images) {
			if (typeof(document.menuImages) == 'undefined'){
      document.menuImages = new Object();
    	}
    	document.menuImages.loadedImages = new Array();
    		document.menuImages.loadedImages[0] = new Image();
    		document.menuImages.loadedImages[0].src = '/images/shared/nav_home_over.gif';
    		document.menuImages.loadedImages[1] = new Image();
    		document.menuImages.loadedImages[1].src = '/images/shared/nav_about_over.gif';
			document.menuImages.loadedImages[2] = new Image();
    		document.menuImages.loadedImages[2].src = '/images/shared/nav_recognition_over.gif';
    		document.menuImages.loadedImages[3] = new Image();
    		document.menuImages.loadedImages[3].src = '/images/shared/nav_projects_over.gif';
    		document.menuImages.loadedImages[4] = new Image();
    		document.menuImages.loadedImages[4].src = '/images/shared/nav_bidding_over.gif';
			document.menuImages.loadedImages[5] = new Image();
    		document.menuImages.loadedImages[5].src = '/images/shared/nav_contact_over.gif';
	}	
}


// This function is called on page load after the main menu builds on. It checks to see what section the current page falls
// under and updates the main menu configuration to reflect this, switching the section's respective button to it's "on" state.

function updateNav (currentSection) {
	// If the page calling this script falls under one of the main sections, dpo this script.
	// Additional pages like "email.htm" don't fall under any section so current Section is set as "false on those pages.
	if (currentSection) {
		var currentSection_img = '/images/shared/nav_' + currentSection + '_on.gif';
		document.getElementById('nav_' + currentSection).src = currentSection_img;
	}
}


// This function swaps menu images when user rolls over them

function swapNavItem ( currentSection, swapSection) {
	// If the page calling this script falls under one of the main sections, dpo this script.
	// Additional pages like "email.htm" don't fall under any section so current Section is set as "false on those pages.
	if (currentSection) {	
		// If User is not mousing over the Menu Button for the section of the website that User is currently in,
		// swap the "off state" for the "on state" of the Menu Button that the User is mousing over.
		if (swapSection != currentSection) {
				var swapSection_img = '/images/shared/nav_' + swapSection + '_over.gif'
				document.getElementById('nav_' + swapSection).src = swapSection_img;	
		}
	}
 }
 
 
// This function swaps menu images back when user rolls back out

function swapNavItemBack ( currentSection, swapBackSection) {
	// If the page calling this script falls under one of the main sections, dpo this script.
	// Additional pages like "email.htm" don't fall under any section so current Section is set as "false on those pages.
	if (currentSection) {	
		// If User is not mousing out of the Menu Button for the section of the website that User is currently in,
		// swap the "on state" back to the "off state" of the Menu Button that the User is mousing out of.
		if (swapBackSection != currentSection) {
				var swapBackSection_img = '/images/shared/nav_' + swapBackSection + '_off.gif';
				document.getElementById('nav_' + swapBackSection).src = swapBackSection_img;
		}
	}
}



// -------------------------------------------------------------------------------------------------------------------
// Called at the bottom of each page, handles page initialization after document loads

function pageInit(currentSection) {
	// preload rollover images
	preloadMenuImages();	
	// Update main nav block to show the current section only if the page falls within one of the main sections.
	// Additional pages like "email.htm" don't fall under any section so current Section is set as "false on those pages
	if (currentSection) { updateNav(currentSection); }
	//Set intial position of background "D" image based on user's window size.
	positionImage();
}



// -------------------------------------------------------------------------------------------------------------------
// Used to open larger version of photos embedded in the page (Awards, Community pages)

function openLgPhoto(url) { 
	popWin = window.open(url, '', 'width=640,height=480,status=0,scrollbars=yes,toolbar=no,resizable=yes');
	popWin.focus();

}


// -------------------------------------------------------------------------------------------------------------------
// Used to open larger version of photos embedded in the page (Awards, Community pages)

function openArticleDetail(id) {

	var url = 'articleDetail.php?ID='+id;
	popupWin = window.open(url, 'site', 'width=500, height=600, status=0,scrollbars=yes,toolbar=no,resizable=yes');
	window.self.name = 'MAIN';
	popupWin.focus();
	return;
}
