	var ns = (document.layers)? true:false;
	var ie = (document.all)? true:false;
	
	var arCourseSearchFields = ["txtCourseTitle", 
							"txtCourseTitleKey1", 
							"txtCourseTitleKey2", 
							"txtCourseTitleKey3", 
							"txtCourseSubject", 
							"lstCourseTitleMatch", 
							"lstAndOr1", 
							"lstAndOr2", 
							"radioCourseTitle", 
							"radioTitleKeys"];
		
	function SetCourseSearch()
	{
		var CourseTitleChecked;
		if (ie)
			CourseTitleChecked = document.frmSearch.radioCourseTitle.checked
		else
			CourseTitleChecked = document.frmSearch.radioGrpCourseMode[0].checked

		if (CourseTitleChecked == true)
			SetCourseTitleSearch();
		else
			SetCourseKeywordSearch();
	}
	
	function SetCourseTitleSearch()
	{
		bCourseTitleSearchMode = true;
		EnableCourseTitleFields();
		DisableCourseKeywordFields();
	}
	
	function SetCourseKeywordSearch()
	{
		bCourseTitleSearchMode = false;
		DisableCourseTitleFields();
		EnableCourseKeywordFields();
	}
	
	function EnableCourseTitleFields()
	{
		if (ie)
		{
			document.frmSearch.txtCourseTitle.style.backgroundColor = "#ffffff";
			document.frmSearch.txtCourseTitle.disabled = false;
			document.frmSearch.lstCourseTitleMatch.style.backgroundColor = "#ffffff";
			document.frmSearch.lstCourseTitleMatch.disabled = false;
		}
	}
	
	function DisableCourseTitleFields()
	{
		if (ie)
		{
			document.frmSearch.txtCourseTitle.style.backgroundColor = "#eeeeee";
			document.frmSearch.txtCourseTitle.disabled = true;
			document.frmSearch.lstCourseTitleMatch.style.backgroundColor = "#eeeeee";
			document.frmSearch.lstCourseTitleMatch.disabled = true;
		}
		document.frmSearch.txtCourseTitle.value = "";
		document.frmSearch.lstCourseTitleMatch[0].selected = true;
	}
	
	function EnableCourseKeywordFields()
	{
		if (ie)
		{
			document.frmSearch.txtCourseTitleKey1.style.backgroundColor = "#ffffff";
			document.frmSearch.txtCourseTitleKey1.disabled = false;
			document.frmSearch.txtCourseTitleKey2.style.backgroundColor = "#ffffff";
			document.frmSearch.txtCourseTitleKey2.disabled = false;
			document.frmSearch.txtCourseTitleKey3.style.backgroundColor = "#ffffff";
			document.frmSearch.txtCourseTitleKey3.disabled = false;
			document.frmSearch.lstAndOr1.disabled = false;
			document.frmSearch.lstAndOr2.disabled = false;
		}
	}
	
	function DisableCourseKeywordFields()
	{
		if (ie)
		{
			document.frmSearch.txtCourseTitleKey1.style.backgroundColor = "#eeeeee";
			document.frmSearch.txtCourseTitleKey1.disabled = true;
			document.frmSearch.txtCourseTitleKey2.style.backgroundColor = "#eeeeee";
			document.frmSearch.txtCourseTitleKey2.disabled = true;
			document.frmSearch.txtCourseTitleKey3.style.backgroundColor = "#eeeeee";
			document.frmSearch.txtCourseTitleKey3.disabled = true;
			document.frmSearch.lstAndOr1.disabled = true;
			document.frmSearch.lstAndOr2.disabled = true;
		}
		document.frmSearch.txtCourseTitleKey1.value = "";
		document.frmSearch.txtCourseTitleKey2.value = "";
		document.frmSearch.txtCourseTitleKey3.value = "";
		document.frmSearch.lstAndOr1[0].selected = true;
		document.frmSearch.lstAndOr2[0].selected = true;
	}
	
			
	//Event Handlers
	function Body_OnLoad()
	{		
		document.onkeydown = handler; 
		window.onkeydown = handler; 
		document.frmSearch.onkeydown = handler;
		document.onkeypress = handler; 
		window.onkeypress = handler; 
		document.frmSearch.onkeypress = handler;
		
		SetCourseSearch();
		
		if (ns)
		{
			document.frmSearch.txtCourseTitle.onkeydown = handler;
			document.frmSearch.txtCourseTitleKey1.onkeydown = handler; 
			document.frmSearch.txtCourseTitleKey2.onkeydown = handler; 
			document.frmSearch.txtCourseTitleKey3.onkeydown = handler;
			document.frmSearch.txtCourseSubject.onkeydown = handler;
			document.frmSearch.lstCourseTitleMatch.onkeydown = handler;
			document.frmSearch.lstAndOr1.onkeydown = handler;
			document.frmSearch.lstAndOr2.onkeydown = handler;
			//document.frmSearch.radioGrpSearchMode.onkeydown = handler;
			document.frmSearch.radioGrpCourseMode.onkeydown = handler;
			document.frmSearch.txtInstitutionName.onkeydown = handler;
			document.frmSearch.lstInstitutionNameMatch.onkeydown = handler;
			document.frmSearch.lstInstitutionRegion.onkeydown = handler;
			document.frmSearch.lstInstitutionType.onkeydown = handler;
		}

	}
	
	function ShowHelpPopup(anchor)
	{	
		var popupwidth, popupheight;
		var popupleft, popuptop;
		var WindowOptions
		
		if(anchor == "showall")
		{
			popupwidth = window.screen.width - 200;
			popupheight = window.screen.height - 200;
		}
		else
		{
			popupwidth = 400;
			popupheight = 450;
		}
		
		popupleft = (window.screen.width - popupwidth) / 2;
		popuptop = (window.screen.height - popupheight) / 2;
		
		WindowOptions = "width=" + popupwidth + ",height=" + popupheight + "," + 
						"scrollbars=yes,top=" + popuptop + ",left=" + popupleft + "";
						
						
		
		window.open("TeLPHelp.aspx?anchor=" + anchor, "Help", WindowOptions);
	}
	
	function ShowSubjectTreePopup(mode)
	{	
		var popupwidth, popupheight;
		var popupleft, popuptop;
		var WindowOptions;
		
		popupheight = window.screen.height - 200;
		popupwidth = window.screen.width - 200;

		popupleft = (window.screen.width - popupwidth) / 2;
		popuptop = (window.screen.height - popupheight) / 2;
		
		//Netscape does not like spaces between window options 
		//(eg "width=500, height=500" is not going to work in NS)
		WindowOptions = "width=" + popupwidth + ",height=" + popupheight + "," + 
						"fullscreen=true,scrollbars=yes,top=" + popuptop + ",left=" + popupleft + "";
						
		var subjectWindow = window.open("PortalSubjectBrowse.aspx?subjectbrowseoriginator=" + mode, "Subject", WindowOptions);
		subjectWindow.focus();
	}
	
	function SetCourseSubject(vNzscedCode, vNzscedDesc)
	{
		var sDesc;
		sDesc = vNzscedDesc.replace(/\+/gi," ");
		document.frmSearch.txtCourseSubject.value = sDesc;
		document.frmSearch.hdnCourseSubject.value = vNzscedCode;
	}
	
	function txtCourseSubject_onfocus()
	{
		if (ns)
			document.frmSearch.txtCourseSubject.blur();
	}

	function txtCourseTitle_onfocus()
	{
		if (ns)
			if (document.frmSearch.radioGrpCourseMode[1].checked)
				document.frmSearch.txtCourseTitle.blur();
	}

	function lstCourseTitleMatch_onfocus()
	{
		if (ns)
			if (document.frmSearch.radioGrpCourseMode[1].checked)
				document.frmSearch.lstCourseTitleMatch.blur();
	}

	function txtCourseTitleKey1_onfocus()
	{
		if (ns)
			if (document.frmSearch.radioGrpCourseMode[0].checked)
				document.frmSearch.txtCourseTitleKey1.blur();
	}

	function txtCourseTitleKey2_onfocus()
	{
		if (ns)
			if (document.frmSearch.radioGrpCourseMode[0].checked)
				document.frmSearch.txtCourseTitleKey2.blur();
	}

	function txtCourseTitleKey3_onfocus()
	{
		if (ns)
			if (document.frmSearch.radioGrpCourseMode[0].checked)
				document.frmSearch.txtCourseTitleKey3.blur();
	}

	function lstAndOr1_onfocus()
	{
		if (ns)
			if (document.frmSearch.radioGrpCourseMode[0].checked)
				document.frmSearch.lstAndOr1.blur();
	}

	function lstAndOr2_onfocus()
	{
		if (ns)
			if (document.frmSearch.radioGrpCourseMode[0].checked)
				document.frmSearch.lstAndOr2.blur();
	}
	
	function handler(e)
	{	if(ie)
		{
			e = window.event;
			if (e.keyCode == 13)
				search();
		}		
		else
		{
			if(e.which == 13)
				search();
		}
	}

	function search()
	{
		document.frmSearch.hdnMode.value = "search";
		document.frmSearch.submit();
	}
