function loaded() {
	fancyTables();
	hideBios();
	$('img').not('.logoImg').ifixpng();
}
function hideBios() {
	$(".bio").toggle();
}
function fancyTables() {
	$("table").find("tr:even").css({backgroundColor:"#FFFFCC"}); 
	$("th").css({fontWeight:"bold"});
	$("#theAddress").find("tr").css({backgroundColor:"#FFFFFF"});
}

function showBio(i) {
	bio=document.getElementById("bio"+i);
	$(bio).toggle();
}

function doScrollTo(x) {
	window.scrollTo(0,x);
}

function getElementHeight(Elem) {
	elem=document.getElementById(Elem);
	return(elem.offsetHeight);

}

function showImageToFit(s) {
	
	im=new Image();
	im.name='something.jpg'
	im.onload=function () { display_fullsize(s,im.width,im.height) };
	im.src="/intranet/include/img/"+s;

}

function display_fullsize(s,w,h) {
	
	$("#wrapper").css({visibility:"hidden"}); 
	
	// set new height and width 
	new_h=h
	new_w=w;
	
	// make it fit across the width
	if(w>getWidth()) {
		new_w=getWidth()-20;
		new_h=new_w*w/h;
	} 
		

	if(h>getHeight()) {
		// height is now too great

		new_h=getHeight()-20;
		new_w=new_h*w/h;
	}

	im=new Image(new_w,new_h);
	im.src="/scripts/resample.php?image="+s+"&width="+new_w;
	document.body.appendChild(im);
	im.id="fullsizeImage";
	im.style.top=(getOffsetY()+((getHeight()-new_h)/2))+"px";
	im.style.left=(getOffsetX()+((getWidth()-new_w)/2))+"px";
	im.style.position="absolute";
	im.style.zIndex="999";
	im.style.border="1px solid #000";
	im.style.cursor="pointer";
	im.title='Click to close';
	im.onclick=function() { 
		document.body.removeChild(im);
		$("#wrapper").css({visibility:"visible"}); 
		
	};
}

// offset and dimensions functions
function getOffsetX() {
	if(!window.pageYOffset && document.documentElement.scrollTop) return document.documentElement.scrollLeft;
	if(!window.pageYOffset) return document.body.scrollLeft;
	return window.pageXOffset;
}
function getOffsetY() {
	if(!window.pageYOffset && document.documentElement.scrollTop) return document.documentElement.scrollTop;
	if(!window.pageYOffset) return document.body.scrollTop;
	return window.pageYOffset;
}
function getHeight() {
	if(!window.innerWidth && (!(document.documentElement.clientWidth == 0))) return document.documentElement.clientHeight;
	if(!window.innerWidth) return document.body.clientHeight;
	return window.innerHeight;
}
function getWidth() {
	if(!window.innerWidth && (!(document.documentElement.clientWidth == 0))) return document.documentElement.clientWidth;
	if(!window.innerWidth) return document.body.clientWidth;
	return window.innerWidth;
}

function addRandom(s) {
        s+="&random="+Math.random();
        return s;
}

function calc() {
		lhsunit=document.getElementById("lhsunit");
		rhsunit=document.getElementById("rhsunit");
		if(lhsunit.selectedIndex==0 && rhsunit.selectedIndex==0) multiply=1;
		if(lhsunit.selectedIndex==0 && rhsunit.selectedIndex==1) multiply=0.1;
		if(lhsunit.selectedIndex==0 && rhsunit.selectedIndex==2) multiply=0.001;
		if(lhsunit.selectedIndex==0 && rhsunit.selectedIndex==3) multiply=0.03937;
		if(lhsunit.selectedIndex==0 && rhsunit.selectedIndex==4) multiply=0.003281;
		if(lhsunit.selectedIndex==0 && rhsunit.selectedIndex==5) multiply=0.001094;

		if(lhsunit.selectedIndex==1 && rhsunit.selectedIndex==0) multiply=10;
		if(lhsunit.selectedIndex==1 && rhsunit.selectedIndex==1) multiply=1;
		if(lhsunit.selectedIndex==1 && rhsunit.selectedIndex==2) multiply=0.01;
		if(lhsunit.selectedIndex==1 && rhsunit.selectedIndex==3) multiply=0.3937;
		if(lhsunit.selectedIndex==1 && rhsunit.selectedIndex==4) multiply=0.03281;
		if(lhsunit.selectedIndex==1 && rhsunit.selectedIndex==5) multiply=0.01094;

		if(lhsunit.selectedIndex==2 && rhsunit.selectedIndex==0) multiply=1000;
		if(lhsunit.selectedIndex==2 && rhsunit.selectedIndex==1) multiply=100;		
		if(lhsunit.selectedIndex==2 && rhsunit.selectedIndex==2) multiply=1;
		if(lhsunit.selectedIndex==2 && rhsunit.selectedIndex==3) multiply=39.37;
		if(lhsunit.selectedIndex==2 && rhsunit.selectedIndex==4) multiply=3.281;
		if(lhsunit.selectedIndex==2 && rhsunit.selectedIndex==5) multiply=1.0936;

		if(lhsunit.selectedIndex==3 && rhsunit.selectedIndex==0) multiply=25.4;
		if(lhsunit.selectedIndex==3 && rhsunit.selectedIndex==1) multiply=2.54;
		if(lhsunit.selectedIndex==3 && rhsunit.selectedIndex==2) multiply=0.0254;
		if(lhsunit.selectedIndex==3 && rhsunit.selectedIndex==3) multiply=1;
		if(lhsunit.selectedIndex==3 && rhsunit.selectedIndex==4) multiply=0.083333;
		if(lhsunit.selectedIndex==3 && rhsunit.selectedIndex==5) multiply=0.02778;

		if(lhsunit.selectedIndex==4 && rhsunit.selectedIndex==0) multiply=304.8;
		if(lhsunit.selectedIndex==4 && rhsunit.selectedIndex==1) multiply=30.48;
		if(lhsunit.selectedIndex==4 && rhsunit.selectedIndex==2) multiply=0.3048;
		if(lhsunit.selectedIndex==4 && rhsunit.selectedIndex==3) multiply=12;
		if(lhsunit.selectedIndex==4 && rhsunit.selectedIndex==4) multiply=1;
		if(lhsunit.selectedIndex==4 && rhsunit.selectedIndex==5) multiply=0.3333;

		if(lhsunit.selectedIndex==5 && rhsunit.selectedIndex==0) multiply=914.4;
		if(lhsunit.selectedIndex==5 && rhsunit.selectedIndex==1) multiply=91.44;
		if(lhsunit.selectedIndex==5 && rhsunit.selectedIndex==2) multiply=0.9144;
		if(lhsunit.selectedIndex==5 && rhsunit.selectedIndex==3) multiply=36;
		if(lhsunit.selectedIndex==5 && rhsunit.selectedIndex==4) multiply=3;
		if(lhsunit.selectedIndex==5 && rhsunit.selectedIndex==5) multiply=1;

		document.getElementById("rhs").value=document.getElementById("lhs").value*multiply;

}

function setCookie(cookie,value) {
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+3650);
	document.cookie=cookie+"="+escape(value)+";expires="+exdate.toGMTString();
}

function expireCookie(cookie) {
	var exdate=new Date();
	document.cookie=cookie+"=null;expires="+exdate.toGMTString();
}

function getCookie(cookie) {
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f
	
	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );
		
		
		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
	
		// if the extracted name matches passed check_name
		if ( cookie_name == cookie )
		{
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return null;
	}

}

