// BEGIN BROWSER DETECT
agt = navigator.userAgent.toLowerCase();
mac = agt.indexOf("mac") != -1;
win = agt.indexOf("win") != -1;
ns = (document.layers)? true:false;
ie = (document.all)? true:false;
dom = (document.getElementById)?true:false;

// use browser detect for the correct stylesheet
if(ns && mac) {
	document.write("<link rel=stylesheet href=/inc/css/mac_ns.css type=\"text/css\">"); // Netscape 4 for Mac
} else if(ns && ie) {
	document.write("<link rel=stylesheet href=/inc/css/mac_ie.css type=\"text/css\">"); // IE, Netscape 6 for Mac
} else if(win && ns) {
	document.write("<link rel=stylesheet href=/inc/css/win_ns.css type=\"text/css\">"); // Netscape 4 for Windows
} else if(win && ie) {
	document.write("<link rel=stylesheet href=/inc/css/win_ie.css type=\"text/css\">"); // IE, Netscape 6 for Windows
} else {
	document.write("<link rel=stylesheet href=/inc/css/win_ie.css type=\"text/css\">"); // All other browsers
}

// END BROWSER DETECT

// clear the words "Enter Zip Code" from branch locator search boxes
function clearZip() {
	if(document.zipForm.zip.value.toLowerCase().indexOf("enter zip code") > -1) {
		document.zipForm.zip.value = "";
		typed = 1;
	}
}

// open a popup window
// parameters:
//  page - filename that will be loaded in the popup
//  winName - window name
//  width - width of the popup window
//  height - height of the popup window
function popUp(page, winName, width, height) 
{
	properties = 'width=' + width + ',height=' + height + ',resizable=yes,scrollbars=yes,';
	if(ns) properties+= 'screenX=15,screenY=15';
	else properties+= 'left=5,top=5';
	newwin = window.open(page, winName, properties); 
	newwin.focus();
}

// open a popup window
// parameters:
//  page - filename that will be loaded in the popup
//  winName - window name
//  width - width of the popup window
//  height - height of the popup window
function popPrint(page, winName, width, height) {
	properties = 'width=' + width + ',height=' + height + ',resizable=yes,scrollbars=yes,toolbar=1,menubar=1';
	if(ns) properties+= 'screenX=15,screenY=15';
	else properties+= 'left=5,top=5';
	newwin = window.open(page, winName, properties);
	newwin.focus();
}

// BEGIN IMAGE SWAP CODE

// image swap, on state
function imgOn(imgName) {
	if(document.images)
		document [imgName].src = eval(imgName + '_on.src');
}

// image swap, off state
function imgOff(imgName) {
	if(document.images)
		document [imgName].src = eval(imgName + '_off.src');
}	

// swap text for home page and case studies
function textOn(imgName) {
	if(document.images)
		document ['imageText'].src = eval(imgName + '.src');	
}
function textOff() {
	if(document.images)
		document ['imageText'].src = imageText.src;	
}	




function toggle(div_id) {

	var el = document.getElementById(div_id);
	if ( el.style.display == 'none' ) 
{	
el.style.display = 'block';}
else {el.style.display = 'none';}}

function blanket_size(popUpDivVar) {	
if (typeof window.innerWidth != 'undefined') 
{
viewportheight = window.innerHeight;
	} 
else {
		viewportheight = document.documentElement.clientHeight;
	}	
if ((viewportheight > document.body.parentNode.scrollHeight) && (viewportheight > document.body.parentNode.clientHeight)) 
{
		blanket_height = viewportheight;
	} 
else 
{
	if (document.body.parentNode.clientHeight > document.body.parentNode.scrollHeight) {
			blanket_height = document.body.parentNode.clientHeight;
		} 
else {
			blanket_height = document.body.parentNode.scrollHeight;
		}
	}
	var blanket = document.getElementById('blanket');
	blanket.style.height = blanket_height + 'px';
	var popUpDiv = document.getElementById(popUpDivVar);
	popUpDiv_height=blanket_height/2-150;//150 is half popup's height
	popUpDiv.style.top = popUpDiv_height + 'px';
}
function window_pos(popUpDivVar) {	if (typeof window.innerWidth != 'undefined') {
		viewportwidth = window.innerHeight;
	} else {
		viewportwidth = document.documentElement.clientHeight;
	}
	if ((viewportwidth > document.body.parentNode.scrollWidth) && (viewportwidth > document.body.parentNode.clientWidth)) {
		window_width = viewportwidth;	} else {
		if (document.body.parentNode.clientWidth > document.body.parentNode.scrollWidth) {
			window_width = document.body.parentNode.clientWidth;
		} else {
			window_width = document.body.parentNode.scrollWidth;		}	}
	var popUpDiv = document.getElementById(popUpDivVar);
	window_width=window_width/2-150;//150 is half popup's width
	popUpDiv.style.left = window_width + 'px';}
function Newpopup(windowname) {	

blanket_size(windowname);
window_pos(windowname);	
toggle('blanket');	
toggle(windowname);		
}

