// This JavaScript Document 
// Created By Will Morrison
// 7-18-06
// Updated by Adam Murphy
// 7-20-08
var strHeader;
var strFooter;
var httpsecure;
var thedate = new Date();
var thisyear = thedate.getFullYear();

function getHttpSecure()
{	
	var myURL = location.href;
	
	if (myURL.indexOf("https") >= 0)
	{
		httpsecure = "https";	
	}
	else
	{
		httpsecure = "http";	
	}
}
function getHeader()
{	
	getHttpSecure();
	strHeader = ""
		+		"<div id='globalnav'>"
		+			"<ul>"
		+				"<li><a href='http://index.wsu.edu/'>A-Z Index</a></li>"
		+				"<li><a href='http://www.about.wsu.edu/statewide/'>Campuses</a></li>"
		+				"<li><a href='https://my.wsu.edu/'>myWSU</a></li>"
		+ 				"<li><a href='http://www.wsu.edu/'>WSU Home</a></li>"
		+ 				"<li>" + getSearchBar() +"</li>" 
		+			"</ul>"
		+		"</div>"
		+ "<div id='logo'><a href='http://ext.wsu.edu'><img src='" + httpsecure + "://ext.wsu.edu/diversity/images/logo.jpg' alt='Washington State University - World Class Face to Face' height='105' width='185'/></a></div><div></div>"
		;    
	return strHeader;
}


function getFooter()
{
	getHttpSecure();
	strFooter = ""
	    +       "<div id='wsufooter'>"
		+			"Copyright &copy; " + thedate.getFullYear() + " Board of Regents, "
		+			"<a href='http://www.wsu.edu'>Washington State University</a>"
		+			" | <a href='http://access.wsu.edu/'>Accessibility</a> | <a href='http://policies.wsu.edu/'>Policies</a> | <a href='http://publishing.wsu.edu/copyright/WSU.html'>Copyright</a>"
		+		"</div>";
	return strFooter;
}

//Following function borrowed from
//http://snook.ca/archives/javascript/your_favourite_1/
function getElementsByClassName(classname, node)
{
 if (node == "" || node == undefined)
 { // this next line is basically a check to see if the page is done loading.
 // document.body is undefined till the page has fully loaded.
 if (document.body)
 { node = document.body; }
 }
 var a = [];
 // the regular expression tests against word boundaries, in case
 // this item has several CSS classes assigned to it.
 var re = new RegExp('\\b' + classname + '\\b');
 var els = node.getElementsByTagName("*");
 for(var i=0,j=els.length; i<j; i++)
 if(re.test(els[i].className))
 a.push(els[i]);
 return a;
}

function getImageButton()
{
 var str;
 str = '<a href="#" onclick="document.search.submit(); return false;">';
 str = str + '<img border="0" alt="Submit" id="searchbuttonimg" src="'+ httpsecure + '://images.wsu.edu/global/global-search-button.gif" align="middle">';
 str = str + '</a>';
 return str;
}

function getSearchBar()
{
	var searchhtml = '<form name="search" method="get" action="http://search.wsu.edu/Default.aspx" id="globalnavsearchform"><input name="cx" value="013644890599324097824:kbqgwamjoxq" type="hidden"/><input name="cof" value="FORID:11" type="hidden"/> <input name="sa" value="Search" type="hidden"/> <input name="fp" value="true" type="hidden"/> <input class="txtsearch2" name="q" type="text" value="Search Web/People" onClick="erasetextbox();" onBlur="checktextbox();" id="my_filter" />';
	searchhtml += getImageButton();
	//searchhtml += '<script language="Javascript" type="text/javascript"> getElementsByClassName("btnSubmit")[0].style.display = "none";</script>';
	searchhtml += "</form>";
	return searchhtml;
}


function checktextbox()
 {

 if (document.search.my_filter.value.replace(/\s+/g,'') == '')
 {
 document.search.my_filter.value = 'Search Web/People';
 }
 return false;
 }


 function erasetextbox()
 {
 if ( document.search.my_filter.value.toUpperCase() == 'SEARCH WEB/PEOPLE')
 {
 document.search.my_filter.value = '';
 }
 return false;
 }