/////////////////////////////////////////////////////////
//                                                     //
//          Developed by: Web Development Team         //
//                                                     //
//Copyright© 2000 University of Wisconsin - Platteville//
//                                                     //
//-----------------------------------------------------//
// This code will generate templates for departments   //
// at UW-Platteville. The departments simply call the  //
// appropriate code and the page will build itself.    //
/////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////
// DateUpdated variable is reset so the footer script  //
// will not error out.                                 //
/////////////////////////////////////////////////////////
var DateUpdated = "";

/////////////////////////////////////////////////////////
//                getBanner(area,dept)                 //
//-----------------------------------------------------//
// This code will return the banner for the UWP        //
// template. It also starts the table code up to the   //
// left hand links for the template.                   //
/////////////////////////////////////////////////////////
function getBanner(area,dept) {	
	if (dept == "") {
		alert ("Please enter a name in the 'var BannerDept' field.");
		} else if (dept.length > 46) {
			alert ("Please enter a smaller name in the 'var BannerDept' field. The longest lenght allowed is 46 characters and your lenght is: " + dept.length + " characters.");
			}
		document.write(	
			"<DIV ID='map'><TABLE BORDER='0' CELLPADDING='0' CELLSPACING='0' WIDTH='100%'><TR><TD WIDTH='130' VALIGN='top'><IMG SRC='http://www.uwplatt.edu/template/images/trans.gif' WIDTH='130' HEIGHT='1'></TD><TD ALIGN='center' WIDTH='100%'><IMG SRC='http://www.uwplatt.edu/template/images/mapfade.jpg' WIDTH='600'></TD></TR></TABLE></DIV>"
			+ "<DIV ID='banner'><TABLE BORDER='0' WIDTH='100%' CELLPADDING=0 CELLSPACING=0><TR><TD WIDTH='130' VALIGN='top'><IMG SRC='http://www.uwplatt.edu/template/images/trans.gif' WIDTH='130' HEIGHT='1'></TD>"
			+ "<TD ALIGN='center' WIDTH='100%'><TABLE BORDER='0' CELLSPACING=0 CELLPADDING=0 HEIGHT='100' WIDTH='100%'><TR><TD ALIGN='center' WIDTH=100%>"
		        + "<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=5><TR><TD><A HREF='http://www.uwplatt.edu'><IMG SRC='http://www.uwplatt.edu/template/images/banlogo.gif' WIDTH='90' HEIGHT='89' BORDER='0'></A></TD><TD><TABLE BORDER='0' CELLSPACING='2' CELLPADDING='0' WIDTH='100%'>"
		        );
	if (area != "") {
		document.write(	        
		      "<TR><TD ALIGN='left' COLSPAN=2><FONT CLASS='ban-title'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + area + "</FONT></TD></TR>"
		      );
		      }
		document.write(      
		        "<TR><TD ALIGN='center' COLSPAN=2 WIDTH='100%'><FONT CLASS='ban-main'>" + dept + "</FONT></TD></TR><TR><TD WIDTH=100% HEIGHT=3 BGCOLOR='#0063C3'><IMG SRC='http://www.uwplatt.edu/template/images/trans.gif'></TD></TR>"
		        + "<TR><TD ALIGN='right'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A HREF='http://www.uwplatt.edu' CLASS='ban-title'>University of Wisconsin-Platteville</A>&nbsp;&nbsp;</TD></TR></TABLE></TD></TR></TABLE></TD></TR></TABLE></TD></TR></TABLE></DIV>"
		        + "<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH='100%' HEIGHT='100%'><TR><TD BACKGROUND='http://www.uwplatt.edu/template/images/nav_bg.gif' WIDTH=130 HEIGHT='100%' VALIGN='top'><IMG BORDER=0 SRC='http://www.uwplatt.edu/template/images/trans.gif' WIDTH=130 HEIGHT=100><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=3 BACKGROUND='http://www.uwplatt.edu/template/images/trans.gif'><TR><TD CLASS='nav-link'>"
			);
}

/////////////////////////////////////////////////////////
//                    getUWPLinks()                    //
//-----------------------------------------------------//
// This code has no variables. It will add the UWP     //
// links on the left hand navigation for the template. //
/////////////////////////////////////////////////////////
function getUWPLinks() {
	var mac = ""
	if (navigator.userAgent.indexOf("Mac") != -1) {
		mac = "<BR><BR>"
		}
document.write(
//	"<BR><CENTER><IMG SRC='http://www.uwplatt.edu/template/images/bar.gif'></CENTER><BR><LI><A HREF='http://www.uwplatt.edu' CLASS='nav-link'>UWP Home</A>"
//	+ "<LI><A HREF='http://www.uwplatt.edu/tree.html' CLASS='nav-link'>Tree</A><LI><A HREF='http://search.uwplatt.edu' CLASS='nav-link'>Search</A>"
//	+ "<LI><A HREF='http://www.uwplatt.edu/help.html' CLASS='nav-link'>Help</A><LI><A HREF='http://www.uwplatt.edu/wwwmgr.html' CLASS='nav-link'>Web Master</A>"
	"</TD></TR></TABLE></TD><TD width='100%' background='http://www.uwplatt.edu/template/images/trans.gif' bgcolor='#FFFFFF' valign='top'><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=10 WIDTH=100% ALIGN=CENTER><TR><TD WIDTH=96%><BR><BR><BR><BR><BR><BR>" + mac
	);
}

/////////////////////////////////////////////////////////
//         getFooter(search,stamp,name,username)       //
//-----------------------------------------------------//
// This code will add the footer and check to see if   //
// there needs to be a search bar, data of last update //
// and add a Content Owner if one is requested.        //
/////////////////////////////////////////////////////////
function getFooter(search,stamp,name,username) {
var searchVal = search.toUpperCase()
stamp = document.lastModified;	//stamp is the DateUpdated field re-written.
if (searchVal == "Y") {
document.write(
	"<TABLE BGCOLOR='CCDDFF' BORDER='1' CELLSPACING='0' CELLPADDING='0' ALIGN=center>"
	+ "<TR><TD><TABLE BGCOLOR='CCDDFF' CELLPADDING='0' CELLSPACING='0' BORDER='0'><TR><TD WIDTH='330' HEIGHT='70' COLSPAN='3'><CENTER>"
	+ "<FORM NAME='AdvSearchForm' ACTION='http://search.uwplatt.edu/NSearch/SearchServlet' METHOD='get' onSubmit='javascript:return doQuery(this);'>"
	+ "<INPUT TYPE='hidden' NAME='country' VALUE='en'><INPUT TYPE='HIDDEN' NAME='version' VALUE='1' DISABLED>"
	+ "<INPUT TYPE='hidden' NAME='operator0' VALUE='0'><INPUT TYPE='hidden' NAME='numhits' VALUE='30'>"
	+ "<INPUT TYPE='hidden' NAME='template' VALUE=''><INPUT TYPE='hidden' NAME='date' VALUE=''>"
	+ "<INPUT TYPE='hidden' NAME='country' VALUE='en'><INPUT TYPE='hidden' NAME='lang' VALUE='English'>"
	+ "<INPUT TYPE='HIDDEN' NAME='queryitems' VALUE='1'>"
	+ "<FONT CLASS='title'>UWP Site Search</FONT><BR><INPUT TYPE='TEXT' NAME='query0' SIZE='35'><BR>"
	+ "<A HREF='http://search.uwplatt.edu' CLASS='advanced'>(Click Here For Advanced Options)</A></CENTER></FORM></TD><TD WIDTH='50'>"
	+ "<A HREF='javascript:doQuery(document.AdvSearchForm)' onMouseOver='qfind.src=qfindb.src; return true' onMouseOut='qfind.src=qfinda.src; return true'><IMG NAME='qfind' SRC='http://www.uwplatt.edu/search/qfinda.gif' ALT='Search' BORDER='0'></A></TD>"
	+ "<TD WIDTH='50'><A HREF='javascript:doHelp()' onMouseOver='uhelp.src=helpb.src; return true' onMouseOut='uhelp.src=helpa.src; return true'><IMG NAME='uhelp' SRC='http://www.uwplatt.edu/search/helpa.gif' ALT='Help' BORDER='0'></A></TD>"
	+ "</TR></TABLE></TD></TR></TABLE>"
	+ "<TABLE BORDER=0 WIDTH=90% CELLSPACING=0 CELLPADDING=5 ALIGN=CENTER><TR><TD ALIGN=CENTER>| <A HREF='http://www.uwplatt.edu' CLASS='nav-link'>UWP-Home </A>| <A HREF='http://www.uwplatt.edu/tree.html' CLASS='nav-link'>Tree </A>"
	+ "| <A HREF='http://search.uwplatt.edu' CLASS='nav-link'>Search </A>| <A HREF='http://www.uwplatt.edu/help.html' CLASS='nav-link'>Help </A>| <A HREF='http://www.uwplatt.edu/web/contact.html' CLASS='nav-link'>Web Master </A>|<BR><FONT CLASS='nav-foot'> Document Last Modified: "
	+ stamp +"</FONT><BR><FONT CLASS='nav-foot'>Copyright © 2001, University of Wisconsin - Platteville<BR>& The Board of Regents - University of Wisconsin System</FONT>"
	);
} else {	
document.write(
	"<BR><HR WIDTH=80% ALIGN=CENTER><TABLE BORDER=0 WIDTH=90% CELLSPACING=0 CELLPADDING=5 ALIGN=CENTER><TR><TD ALIGN=CENTER>| <A HREF='http://www.uwplatt.edu' CLASS='nav-link'>UWP-Home </A>| <A HREF='http://www.uwplatt.edu/tree.html' CLASS='nav-link'>Tree </A>"
	+ "| <A HREF='http://search.uwplatt.edu' CLASS='nav-link'>Search </A>| <A HREF='http://www.uwplatt.edu/help.html' CLASS='nav-link'>Help </A>| <A HREF='http://www.uwplatt.edu/web/contact.html' CLASS='nav-link'>Web Master </FONT></A>|<BR><FONT CLASS='nav-foot'> Document Last Modified: "
	+ stamp +"</FONT><BR><FONT CLASS='nav-foot'>Copyright © 2001, University of Wisconsin - Platteville<BR>& The Board of Regents - University of Wisconsin System</FONT>"
	);	
}
if (name == "") {
	alert ("Please enter a name in the 'var PageOwner' field.");	
} else if (username == "" ){
document.write(
	"<BR><FONT CLASS='nav-foot'>Page Maintained By: " + name + "</FONT></TD></TR></TABLE></TD><TD WIDTH=5%>&nbsp;</TD></TR></TABLE></TD></TR></TABLE>"
	);
} else {	
document.write(
	"<BR><FONT CLASS='nav-foot'>Page Maintained By: </FONT><A HREF='mailto:" + username + "@uwplatt.edu' CLASS='nav-link'>" + name + "</A></TD></TR></TABLE></TD></TR></TABLE></TD></TR></TABLE>"
	);	
	}
}

/////////////////////////////////////////////////////////
//                  Begin search code                  //
/////////////////////////////////////////////////////////
qfinda = new Image();
qfinda.src = "http://search.uwplatt.edu/images/qfinda.gif";
qfindb = new Image();
qfindb.src = "http://search.uwplatt.edu/images/qfindb.gif";
helpa = new Image();
helpa.src = "http://search.uwplatt.edu/images/helpa.gif";
helpb = new Image();
helpb.src = "http://search.uwplatt.edu/images/helpb.gif";

function autoSelectLocale(SearchForm)
{
 //Set focus to the query text box
 SearchForm.query0.focus();
 //Only auto-select on the first load (by checking if a search has already been entered)
 if (VerifySearchData(SearchForm) == true) return;
 var country = "";
 var locale = navigator.language;  //Navigator
 if (locale == navigator.asdf)
    locale = navigator.browserLanguage;  //IE
 if (locale == navigator.asdf) return;  //Undefined
 if (locale.length > 2)
 {
    country = locale.substring(3,5);
    country = country.toUpperCase();
    locale = locale.substring(0,2);
    locale = locale.toLowerCase();
 }
 //Select the appropriate language option in the LANG select box
 if (country == "CN")
 {
    SearchForm.lang.selectedIndex = 0;
 }
 else if (country == "TW")
 {
    SearchForm.lang.selectedIndex = 1;
 }
 else
 {
    var languages = SearchForm.lang;
    for (var i = 2; i < languages.length; i++)
    {
       if (languages[i].value == locale)
       {
          SearchForm.lang.selectedIndex = i;
	  break;
       }
    }
 }
 //Make sure the Country is also updated
 setCountry(SearchForm.lang);
}

function setCountry(langSelection)
{
 //Init country to "no country"
 country.value = "";
 //Country only used on some selections
 if (langSelection.selectedIndex == 0)
    country.value = "CN";
 if (langSelection.selectedIndex == 1)
    country.value = "TW";
}

function doHelp()
{
 var wLeft  = 0;
 var wTop   = 0;
 if (window.screenX != window.asdf)
 {//Nav
    wLeft  = window.screenX;
    wTop   = window.screenY;
 }
 if (window.screenLeft != window.asdf)
 {//IE
    wLeft  = window.screenLeft;
    wTop   = window.screenTop;
 }
 wLeft = wLeft+30;
 wTop  = wTop+30;
 var location = "location=no,dependent=yes,toolbar=no,menubar=yes,status=yes,scrollbars=yes,resizable=yes,left=" + wLEft + ",top=" + wTop + ",wIDth=700,height=500";
 var w=window.open("http://search.uwplatt.edu/novellsearch/SearchHelp.html",'NWSCHelp',location);
 w.focus();
}

function VerifySearchData(SearchForm)
{
 //return true only if we have a user-entered query
 return (SearchForm.query0.value.length > 0);
}

function doQuery(SearchForm)
{
 if (VerifySearchData(SearchForm) == true)
 {
    //Submit the form
    SearchForm.submit();
    //Restore all form elements to their operational state
    SearchForm.operator0[1].disabled = false;
    SearchForm.numhits.disabled = false;
    SearchForm.template.disabled = false;
    SearchForm.date.disabled = false;
    SearchForm.lang.disabled = false;
    SearchForm.country.disabled = false;
 }
}
/////////////////////////////////////////////////////////
//                   End search code                   //
/////////////////////////////////////////////////////////