// JavaScript Document
function UL2Menu_ShowHead(){
	var li=this;
	AddClass(li,'active');
	var xy=FindXYWH(li);
	if (li.isTop){
		li.sub.style.left=(xy.x+(!li.isHorizontal?xy.w:0))+'px';
		li.sub.style.top=(xy.y+(li.isHorizontal?xy.h:0)-(li.isTop?0:1))+'px';
	} else {
		li.sub.style.left=li.offsetWidth+'px';
		li.sub.style.top=li.offsetTop+'px';
	}
	li.sub.style.display='block';
}
function UL2Menu_HideHead(){
	var li=this;
	li.sub.style.display='none';
	KillClass(li,'active');
}
function UL2Menu_ConvertMenu(){
	var menu=document.getElementById('menu');
	if (!menu) return;
	var menuIsHorizontal=HasClass(menu,'horizontal');
	var lis = menu.getElementsByTagName('li');
	for (var i=0,len=lis.length;i<len;i++){
		var li=lis[i];
		var uls = li.getElementsByTagName('ul');
		if (!uls || uls.length==0) continue;
		var ul=uls[0];
		li.sub=ul;
		li.onmouseover=UL2Menu_ShowHead;
		li.onmouseout=UL2Menu_HideHead;
		li.isTop = li.parentNode==menu;
		li.isHorizontal = (menuIsHorizontal && li.isTop);

		if (li.addedArrow || li.isTop) continue;
		var arrow=document.createElement('span');
		arrow.innerHTML='&nbsp;<b>&rsaquo;</b>';
		var a = li.getElementsByTagName('a');
		if (a && a.length>0 && a[0].parentNode==li) a[0].innerHTML+='&nbsp;<b>&rsaquo;</b>';
		else li.insertBefore(arrow,li.childNodes[1]);
		li.addedArrow=true;
	}
}

AttachEvent(window,'load',UL2Menu_ConvertMenu,false);

//***Generic Library Functions Follow
function FindXY(obj){
	var x=0,y=0;
	while (obj){
		x+=obj.offsetLeft - (obj.scrollLeft || 0);
		y+=obj.offsetTop - (obj.scrollTop || 0);
		obj=null;
	}
	return {x:x,y:y};
}

function FindXYWH(obj){
	if (!obj) return { x:0, y:0, w:0, h:0 };
	var objXY = FindXY(obj);
	return { x:objXY.x, y:objXY.y, w:obj.offsetWidth||0, h:obj.offsetHeight||0 };
}

function AttachEvent(obj,evt,fnc,useCapture){
	if (obj.addEventListener){
		obj.addEventListener(evt,fnc,useCapture);
		return true;
	} else if (obj.attachEvent) return obj.attachEvent("on"+evt,fnc);
	else obj['on'+evt]=fnc;
	return true;
}

function HasClass(obj,cName){ return (!obj || !obj.className)?false:(new RegExp("\\b"+cName+"\\b")).test(obj.className) }
function AddClass(obj,cName){ if (!obj) return; if (obj.className==null) obj.className=''; return obj.className+=(obj.className.length>0?' ':'')+cName; }
function KillClass(obj,cName){ if (!obj) return; return obj.className=obj.className.replace(RegExp("^"+cName+"\\b\\s*|\\s*\\b"+cName+"\\b",'g'),''); }

function closeWindow() {
	window.close();
}
function popup(url){
	window.open(
		url,
		'window',
		'width=600, height=600, resizable=yes, scrollbars=yes, location=no,  toolbar=no, menubar=no, status=no'
	);
}
function openWindow(url,w,h,shortcut){
	if ( shortcut )
	{
		url += "?shortcut=" + shortcut + "&";
		newWindow=window.open(url,'thewindow','width=' + w + ',height=' + h);  newWindow.focus();
	} else {
		newWindow=window.open(url,'_blank','width=' + w + ',height=' + h);  newWindow.focus();
	}
}

// Date functions
function GetMonth(nMonth) {
	var Months = new Array("January","February","March","April","May","June",
	                       "July","August","September","October","November","December");
	return Months[nMonth] 	  	 
}

function GetDay(nDay) {
	var Days = new Array("Sunday","Monday","Tuesday","Wednesday",
	                     "Thursday","Friday","Saturday");
	return Days[nDay]
}

function dateString() {
	var Today = new Date();
	var suffix = "th";
	switch (Today.getDate())
	{
		case 1:
		case 21:
		case 31: 
			suffix = "st"; break;
		case 2:
		case 22:
			suffix = "nd"; break;
		case 3:
		case 23:
			suffix = "rd"; break;
	};

	var strDate = GetDay(Today.getDay()) + ", " + GetMonth(Today.getMonth()) +  " " + Today.getDate() + suffix + ", " + Today.getFullYear();	return strDate
}
function yearString(publishedYear){
	var Today = new Date();
	var strYear = Today.getFullYear();           
	if (!publishedYear) {
				publishedYear = strYear;
	}
	if (strYear == publishedYear) {
				return strYear
	} else {
		strObject = publishedYear + "-" + strYear;
		return strObject;
	}           
}

//form valiation
	// trim functions
	function trim(str) { return rtrim(ltrim(str)); }
	function rtrim(str) { return str.replace(/\s+$/, ''); }
	function ltrim(str) { return str.replace(/^\s+/, ''); }
	// determines whether or not the element has anything in it
	function hasContent(el) { return el.value!=''; }
	function hasCheck(el) { return el.checked; }
	function hasSelectionValue(el) {
		for(var i = 0; i < el.length; i++) {
			if(el.options[i].selected) {
				if(el.options[i].value.length) { return true; }
			}
		}
		return false;
	}
	function anyWithCheck(ss) {
		for(var i = 0; i < ss.length; i++) {
			if(ss[i].checked) { return true; }
		}
		return false;
	}
	// special validation functions
	function validEmail(str) { return str.match(/^[a-z0-9]+([-_\.]?[a-z0-9])+@[a-z0-9]+([-_\.]?[a-z0-9])+\.[a-z]{2,4}$/i); }
	function validSSN(str) { return str.match(/^\d{3}-*\d{2}-*\d{4}$/); }
	function validDate(str) { return str.match(/^\d{1,2}[-\/]+\d{1,2}[-\/]+(\d{2}|\d{4})$/); }
	function validPhone(str) { return str.match(/^[\+1\( -]*\d{3}[ -\.\)]*\d{3}[ -\.]*\d{4}.*\d*$/); }
	function validZip(str) { return str.match(/^\d{5}-*($|\d{4}$)/); }
	// massage functions
	function massageSSN(el) { el.value=el.value.replace(/[^\d]/g,''); }
	function massagePhone(el) { el.value=el.value.replace(/[^\d]/g,'').replace(/^1/,''); }
	function massageZip(el) { el.value=el.value.replace(/[^\d]/g,''); }
	// functions that talk directly to or are called directly from the form
	function resetForm() { return confirm("Are you sure you want to undo all your changes?"); }
	function confirmDelete() { return confirm("Are you sure you want to delete this item?"); }

// Flash Javascript
function putFlash(src, width, height, FlashVars) {
    var strObject = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" "
                  + "        codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\" "
                  + "        width=\"" + width + "\" height=\"" + height + "\">"
                  + "    <param name=\"movie\" value=\"" + src + "\" /> "
                  + "    <param name=\"quality\" value=\"high\" /> ";

    if (FlashVars && FlashVars != "") {
        strObject += "<param name=\"FlashVars\" value=\"" + FlashVars + "\" /> ";
    }

    strObject += "<embed src=\"" + src + "\" quality=\"high\" "
                  + "           pluginspage=\"http://www.macromedia.com/go/getflashplayer\" "
                  + "           type=\"application/x-shockwave-flash\" ";

	if (FlashVars && FlashVars != "") {
		strObject += "FlashVars=\"" + FlashVars + "\" ";
	}
	
	strObject += "width=\"" + width + "\" height=\"" + height + "\">"
               + "    </embed>"
               + "</object>";

    document.write(strObject);
}
// Flash Transparent BG Javascript
function putFlashTrans(src, width, height, FlashVars) {
    var strObject = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" "
                  + "        codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\" "
                  + "        width=\"" + width + "\" height=\"" + height + "\">"
                  + "    <param name=\"movie\" value=\"" + src + "\" /> "
				  + "	 <param name=\"wmode\" value=\"transparent\" /> "
                  + "    <param name=\"quality\" value=\"high\" /> ";

    if (FlashVars && FlashVars != "") {
        strObject += "<param name=\"FlashVars\" value=\"" + FlashVars + "\" /> ";
    }

    strObject += "<embed src=\"" + src + "\" quality=\"high\" "
                  + "           pluginspage=\"http://www.macromedia.com/go/getflashplayer\" "
                  + "           type=\"application/x-shockwave-flash\" "
				  + "			wmode=\"transparent\" ";

	if (FlashVars && FlashVars != "") {
		strObject += "FlashVars=\"" + FlashVars + "\" ";
	}
	
	strObject += "width=\"" + width + "\" height=\"" + height + "\">"
               + "    </embed>"
               + "</object>";

    document.write(strObject);
}
	//Calling Flash Header
	function putHeader(FlashVars) {
    	putFlash("/flash/header.swf", 766, 283, FlashVars);
	}

//Main Nav dropdowns
function showMenu(id) {
	if (document.getElementById) {
		var show_menu=document.getElementById(id);
		show_menu.style.display="block";
	}
}

function hideMenu(id) {
	if (document.getElementById) {
		var hide_menu=document.getElementById(id);
		hide_menu.style.display="none";
	}
}
