var serverURL=location.protocol+'//'+location.host+'/web2/';

//MENU FUNCTIONS
function show(e,menu){
	e.style.cursor='pointer';
	var items=document.getElementById(menu+'_items');
	items.style.display='block';
}

function hide(e,menu){
	var items=document.getElementById(menu+'_items');
	items.style.display='none';
}

function highlight(e){
	e.style.backgroundColor='#3399cc';
}

function lowlight(e){
	e.style.backgroundColor='#000066';
}

//OTHER FUNCTIONS

function loadpage(x,y){
	if(y==1){
		window.open(x,'loadpage','toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=no');
	}
	else if(y==2){
		location.href=x;
	}
	else{
		location.href=serverURL+x;
	}
}

var popupWin;
function popup(url,w,h,s){
	if(popupWin){
		if(!popupWin.closed) popupWin.close();
	}
	if(s){s='yes';}
	else{s='no';}
	popupWin=window.open(serverURL+url,'popupWin','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars='+s+',resizable=yes,copyhistory=yes,width='+w+',height='+h);
}
var eventWin;
function eventDetail(eventId){
	if(eventWin){
		if(!eventWin.closed) eventWin.close();
	}
	popupWin=window.open(serverURL+'calendar/view.jsp?eventId='+eventId,'eventWin','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=487,height=300');
}
var mailtoWin;
function mailto(email){
	if(mailtoWin){
		if(!mailtoWin.closed) mailtoWin.close();
	}
	popupWin=window.open(serverURL+'ContactUs.do?to='+email,'mailtoWin','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width=585,height=590');
}

function submitform(form){
	document.getElementById(form).submit();
}

var _img,_pics,_captionText,_captions,_baseRef,_index,_timeout,_timer;

function startShow(imgId,arrayofPics,arrayofCaptions,baseRef,timeout){
	_img=document.getElementById(imgId);
	_pics=arrayofPics;
	_captions=arrayofCaptions;
	if(_captions!=null) _captionText=document.getElementById(imgId+'Caption');
	_baseRef=baseRef;
	_index=0;
	_timeout=timeout;
	swapPic();
	_timer=setInterval('swapPic()',_timeout);
}

function stopShow(){
	clearInterval(_timer);
}

function continueShow(){
	clearInterval(_timer);
	swapPic();
	_timer=setInterval('swapPic()',_timeout);
}

function nextInShow(){
	swapPic();
}

function prevInShow(){
	_index-=2;
	if(_index<0){ _index+=_pics.length; }
	swapPic();
}

function swapPic(){
	_img.src=_baseRef+'/'+_pics[_index];
	if(_captions!=null)	_captionText.innerHTML='<strong>'+(_index+1)+" of "+(_pics.length)+"&nbsp;&nbsp;&nbsp;"+_captions[_index]+'</strong>';
	_index=(_index+1)%_pics.length;
}

function printPage(queryString){
	if(!queryString){
		var queryString=location.search;
	}
	
	if(popupWin){
		if(!popupWin.closed) popupWin.close();
	}
	popupWin=window.open(serverURL+'print.jsp'+queryString,'popupWin','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=1,height=1');
}

function keypress(e,l,n){
	if(String(e.value).length==l) document.getElementById(n).focus();
}

function resizeIframe(iframeId) {
	var iframe = document.getElementById(iframeId);
	var height = null;
	try {
		height = iframe.contentWindow.document.body.scrollHeight;
	}
	catch (e) {
		var winHeight = 0;
		if (typeof(window.innerWidth) == 'number') {
			// Non-IE
			winHeight = window.innerHeight;
		}
		else if ((document.documentElement) &&
				 (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
			// IE 6+
			winHeight = document.documentElement.clientHeight;
		}
		else if ((document.body) &&
				 (document.body.clientWidth || document.body.clientHeight)) {
			// IE 4 compatible
			winHeight = document.body.clientHeight;
		}
		// The value 139 here is derived (tab_height * num_tab_levels) +
		// height_of_banner + bottom_spacer. 139 just happend to work in
		// this instance in IE and Firefox at the time.
		iframe.height = (winHeight);
		return true;
	}
	iframe.height = height + 50;
	return true;
}
