// JavaScript Document
/******************************************************/
// FUNCTION: openWindow
// PARAMS: newURL - the URL of the page you wish to load in the new window
//         windowName - the name of the window to load the new URL in
//
// RETURNS: none
// PURPOSE: open the target URL into a new window

function openWindow(newUrl,windowName){
	newWindow = window.open(newUrl,windowName);
	newWindow.focus();
}



/******************************************************/
// FUNCTION: placeAllCorners
// PARAMS: top_parent - the "id" attribute of the container holding the top left/right corner div
//         top_left - the "class" attribute of the top left corner div
//         top_right - the "class" attribute of the top right corner div
//         bottom_parent - the "id" attribute of the container holding the bottom left/right corner div
//         bottom_left - the "class" attribute of the bottom left corner div
//         bottom_right - the "class" attribute of the bottom right corner div
//         hasBorderArray - an array of 4 bools indicating whether the top, right, bottom, left sides of the container have a border -- needed for proper calculation
//
// RETURNS: none
// PURPOSE: Place the rounded corners -- built specifically for IE6 to look right, however the other browsers will degrade just fine with the CSS

function placeAllCorners(top_parent, top_left, top_right, bottom_parent, bottom_left, bottom_right, hasBorderArray){
	// place the top corners
	if (top_parent != ""){
		placeTopCorners(top_parent, top_left, top_right, hasBorderArray);
	}
	
	// place the bottom corners
	if (bottom_parent != ""){
		placeBottomCorners(bottom_parent, bottom_left, bottom_right, hasBorderArray);
	}
}

function placeTopCorners(top_parent, top_left, top_right, hasBorderArray){
	// get the div containers that have the corner images as their background
	var topParent = document.getElementById(top_parent);
	var divArray = topParent.getElementsByTagName("div");
	var i = 0;
	var topLeft;
	var topRight;
	for (i = 0; i < divArray.length; i++){
		if (divArray[i].className.indexOf(top_left) >= 0){
			topLeft = divArray[i];
			continue;
		}
		if (divArray[i].className.indexOf(top_right) >= 0){
			topRight = divArray[i];	
		}
	}
	
	//place the top left corner, adjusting for any border
	if (hasBorderArray[0]){
		topLeft.style.top = "-1px";	
	} else {
		topLeft.style.top = "0px";
	}
	
	if (hasBorderArray[3]){
		topLeft.style.left = "-1px";		
	} else {
		topLeft.style.left = "0px";
	}
	
	//place the top right corner using the top left (0,0) point as a reference, adjusting for any border
	var width = topParent.offsetWidth;
	var leftDistance = width - topRight.offsetWidth;
	
	if (hasBorderArray[0]){
		topRight.style.top = "-1px";
	} else {
		topRight.style.top = "0px";
	}
	
	if (hasBorderArray[1]){
		leftDistance -= 1;
	}
	topRight.style.left = leftDistance + "px";
}

function placeBottomCorners(bottom_parent, bottom_left, bottom_right, hasBorderArray){
	// get the div containers that have the corner images as their background
	if (bottom_parent != ""){
		var bottomParent = document.getElementById(bottom_parent);
		var divArray = bottomParent.getElementsByTagName("div");
		var bottomLeft;
		var bottomRight;
		for (i = 0; i < divArray.length; i++){
			if (divArray[i].className.indexOf(bottom_left) >= 0){
				bottomLeft = divArray[i];
				continue;
			}
			if (divArray[i].className.indexOf(bottom_right) >= 0){
				bottomRight = divArray[i];	
			}
		}
	}
	
	//place the bottom left corner, adjusting for any border
	var height = bottomParent.offsetHeight;
	var topDistance = height - bottomLeft.offsetHeight;
	if (hasBorderArray[3]){
		bottomLeft.style.left = "-1px";	
	} else {
		bottomLeft.style.left = "0px";
	}
	
	if (hasBorderArray[2]){		
		topDistance -= 1;
	}
	bottomLeft.style.top = topDistance + "px";
	//place the bottom right corner using the top left (0,0) point as a reference, adjusting for any border
	var width = bottomParent.offsetWidth;
	var leftDistance = width - bottomRight.offsetWidth;
	
	if (hasBorderArray[1]){
		leftDistance -= 1;
	}
	
	bottomRight.style.top = topDistance + "px";
	bottomRight.style.left = leftDistance + "px";
}
/******************************************************/