	

	function InStr(String1, String2){ 
		var a = 0;
		if (String1 == null || String2 == null) return (false);
		String1 = String1.toLowerCase(); String2 = String2.toLowerCase();
		a = String1.indexOf(String2); 
		if (a == -1) return 0; else return a + 1;
	}
		
	function Webform_Repost()
	{
		var f = document.forms[0];
		//hide Messages
		var o = document.all("Webform_IsRepost");
		if (o != null) o.value = "1";
		f.submit();
	}
	
	function Webform_ConfirmSubmitAction(sConfirmMsg, sURL)
	{
		if (confirm(sConfirmMsg))
		{
			location.href = sURL;
		}
	}
	
	//--------------------------------------------
	function WebForm_SubmitButtonDisable_OnFormSubmitHandler()
	{
		DisableBtn('Webform_btnSubmit', true);
		
		//setup the onUnload handler to reeanble the button in case they go back in the browser to this page
		window.attachEvent("onunload", WebForm_OnUnload_RenableSubmitButton)
	}
	function DisableBtn(sName, enabledState) {
		var el = document.all.item(sName, 0); 
		if (el == null) return; 
		el.disabled = enabledState;
	}
	function WebForm_OnUnload_RenableSubmitButton()
	{
		DisableBtn('Webform_btnSubmit', false); //reenable
	}
	//--------------------------------------------
	
	
	var g_WebForm_MS_AllLists = new Array();
	var g_WebForm_SB_AllLists = new Array();

	function getElementByID(sID)
	{
		return document.all.item(sID)
	}
	function addOption(oSelect, sText, sValue, iIndex)
	{
		var o = document.createElement("OPTION");
		o.value = sValue;
		o.text = sText;
		oSelect.options.add(o, iIndex);
	}
	function removeOption(oSelect, iIndex)
	{
		oSelect.options.remove(iIndex);
	}
	function split(s, sSep)
	{
		var Result = new Array();
		var iArrIndex = 0;
		var iLast = 0;
		
		for(i=0;i<s.length;i++)
		{
			if (s.substring(i, i+1) == sSep)
			{
				//copy from last to i-1
				Result[iArrIndex++] = s.substring(iLast, i);
				iLast = i+1;
			}
		}
		
		//any left?
		if ((i >= iLast))
		{
			Result[iArrIndex++] = s.substring(iLast, i);
		}
		
		return Result;
	}
	
//--------------------------------------	

	//default window.onload handler
	function WebForm_OnWindowLoadHandler()
	{
		//loop through all handlers defined
		for(var i=0;i<g_Webform_WindowLoadHandlers.length;i++)
		{
			var o = g_Webform_WindowLoadHandlers[i];
			o();
		}
		
		//init the form submit handler		
		var oForm = document.forms[0];
		if (oForm) 
		{
			oForm.attachEvent("onsubmit", WebForm_OnFormSubmitHandler);
		}
	}	
	window.attachEvent("onload", WebForm_OnWindowLoadHandler);

//------------------------------------------

	function WebForm_OnFormSubmitHandler()
	{
		//loop through all handlers defined
		for(var i=0;i<g_Webform_SubmitHandlers.length;i++)
		{
			var o = g_Webform_SubmitHandlers[i];
			o();
		}
	}
	
//--------------------------------------	


	
	
	
	
	
	function WebForm_MS_oAvailable(sName)
	{
		return getElementByID(sName + '_Available');
	}
	function WebForm_MS_oSelected(sName)
	{
		return getElementByID(sName + '_Selected');
	}

	function WebForm_MSMoveSelected(oSrc, oDest)
	{
		if ((!oSrc) || (!oDest)) return;
		
		for(var i=oSrc.options.length-1;i>=0;i--)
		{
			var o = oSrc.options.item(i);
			if (o.selected) 
			{
				addOption(oDest, o.text, o.value, 0);
				removeOption(oSrc, i);
			}
		}
	}

	function WebForm_MSAvailableToSelected(sName)
	{
		//move all selected items from avail to selected
		WebForm_MSMoveSelected(WebForm_MS_oAvailable(sName), WebForm_MS_oSelected(sName))
	}
	function WebForm_MSSelectedToAvailable(sName)
	{
		WebForm_MSMoveSelected(WebForm_MS_oSelected(sName), WebForm_MS_oAvailable(sName))
	}
	
	//get all selected values and comma sep them
	function WebForm_MSPrepareSubmit(sName)
	{
		var oSel = WebForm_MS_oSelected(sName)
		var oHidden = getElementByID(sName)
		if ((!oSel) || (!oHidden)) return;
		
		var s = '';
		for(var i=oSel.options.length-1;i>=0;i--)
		{
			var o = oSel.options.item(i);
			if (s != '') s += ',';
			s += o.value;
		}
		oHidden.value = s;
	}
	
	function WebForm_MSReset(sName)
	{
		//move all values into selected that are in the hidden field
		var oHidden = getElementByID(sName);
		var Vals = split(oHidden.value, ',');

		var oAvail = WebForm_MS_oAvailable(sName);
		var oSel = WebForm_MS_oSelected(sName);
		if ((!oAvail) || (!oSel)) return;

		//select each value
		for(var j=0;j<oAvail.options.length;j++)
		{
			var o = oAvail.options.item(j);
			for(var i=0;i<Vals.length;i++)
			{
				if (Vals[i] == o.value)
				{
					o.selected = true;
					break;
				}
			}
		}
		
		//move selected
		if (Vals.length > 0)
		{
			WebForm_MSMoveSelected(oAvail, oSel);
		}
	}
	
	//on submit of the form, move all selected values into value of parent control
	function WebForm_MS_OnFormSubmitHandler()
	{
		for(var i=0;i<g_WebForm_MS_AllLists.length;i++)
		{
			WebForm_MSPrepareSubmit(g_WebForm_MS_AllLists[i]);
		}
	}
	
	function WebForm_MS_OnWindowLoad()
	{
		for(var i=0;i<g_WebForm_MS_AllLists.length;i++)
		{
			WebForm_MSReset(g_WebForm_MS_AllLists[i]);
		}
	}
	

	function WebForm_MS_InitFormHandler(sName)
	{
		//remember name of control 
		g_WebForm_MS_AllLists[g_WebForm_MS_AllLists.length++] = sName;
		
		//override the window.onload event to initialise select boxes
		WebForm_AddHandler(g_Webform_WindowLoadHandlers, WebForm_MS_OnWindowLoad);
		
		//add handler for form submit
		WebForm_AddHandler(g_Webform_SubmitHandlers, WebForm_MS_OnFormSubmitHandler);
	}	




//sort box---------------------

	function WebForm_SB_InitFormHandler(sName)
	{
		//remember name of control 
		g_WebForm_SB_AllLists[g_WebForm_SB_AllLists.length++] = sName;
		
		//override the window.onload event to initialise
		WebForm_AddHandler(g_Webform_WindowLoadHandlers, WebForm_SB_OnWindowLoad);
		
		//add handler for form submit
		WebForm_AddHandler(g_Webform_SubmitHandlers, WebForm_SB_OnFormSubmitHandler);
	}	
	
	//on submit of the form, move all items into comma sep list
	function WebForm_SB_OnFormSubmitHandler()
	{
		for(var i=0;i<g_WebForm_SB_AllLists.length;i++)
		{
			WebForm_SB_SetValue(g_WebForm_SB_AllLists[i]);
		}
	}
	
	function WebForm_SB_SetValue(sID)
	{
		var oSelect = getElementByID(sID);
		if (!oSelect) return;
	
		var s = '';
		for(var i=0;i<oSelect.options.length;i++)
		{
			var o = oSelect.options.item(i);
			if (s != '') s += ',';
			s += o.value;
		}
		
		addOption(oSelect, '', s, oSelect.options.length);
		oSelect.selectedIndex = oSelect.options.length-1;
	}
	
	function WebForm_SB_OnWindowLoad()
	{
		for(var i=0;i<g_WebForm_MS_AllLists.length;i++)
		{
			WebForm_MSReset(g_WebForm_MS_AllLists[i]);
		}
	}
	

	function WebForm_SB_GetOption(oSelect, index)
	{
		if (index < 0) return null;
		if (index >= oSelect.options.length) return null;
		return oSelect.options.item(index);
	}
	
	function WebForm_SB_SwapOptions(o1, o2)
	{
		//get values of current
		var sName = o1.text; var sVal = o1.value;
		o1.text = o2.text; o1.value = o2.value;
		o2.text = sName; o2.value = sVal;
	}
	
	function WebForm_SB_CurrentIndex(sID)
	{
		var oSelect = document.all(sID);
		if (!oSelect) return -1;
		return oSelect.selectedIndex;
	}
	
	function WebForm_SB_Count(sID)
	{
		var oSelect = document.all(sID);
		if (!oSelect) return -1;
		return oSelect.options.length;
	}
	
	function WebForm_SB_Move(sID,index1,index2)
	{
		var oSelect = document.all(sID);
		if (!oSelect) return;
		
		//get options
		var oCurrent = WebForm_SB_GetOption(oSelect, index1);
		var oOther = WebForm_SB_GetOption(oSelect, index2);
		if ((!oCurrent) || (!oOther)) return;
	
		WebForm_SB_SwapOptions(oCurrent, oOther);	
		
		oSelect.selectedIndex = index2;
	}
	
	function WebForm_SB_MoveABS(sID,index1,index2)
	{
		var oSelect = document.all(sID);
		if (!oSelect) return;
		
		//get options
		var oCurrent = WebForm_SB_GetOption(oSelect, index1);
		if (!oCurrent) return;
		
		var sValue = oCurrent.value;
		var sText = oCurrent.text;
		
		oSelect.options.remove(index1);
		addOption(oSelect, sText, sValue, index2);
		oSelect.selectedIndex = index2;
	}

	function WebForm_SB_MoveUp(sID)
	{
		WebForm_SB_Move(sID, WebForm_SB_CurrentIndex(sID), WebForm_SB_CurrentIndex(sID)-1);
	}
	
	function WebForm_SB_MoveDown(sID)
	{
		WebForm_SB_Move(sID, WebForm_SB_CurrentIndex(sID), WebForm_SB_CurrentIndex(sID)+1);
	}

	function WebForm_SB_MoveTop(sID)
	{
		WebForm_SB_MoveABS(sID, WebForm_SB_CurrentIndex(sID), 0);
	}
	
	function WebForm_SB_MoveBottom(sID)
	{
		WebForm_SB_MoveABS(sID, WebForm_SB_CurrentIndex(sID), WebForm_SB_Count(sID)-1);
	}
	
	function WebForm_Help_Show(ID) {
		//alert('WebForm_Help_Show(' + ID + ')');
		var oToolTip = (document.getElementById) ? document.getElementById(ID) : eval("document.all['" + ID + "']");
		var oShad = (document.getElementById) ? document.getElementById('divDropShadow') : eval("document.all['divDropShadow']");		

		if (oToolTip != null) {
			var iWidth = oToolTip.offsetWidth?oToolTip.offsetWidth:(oToolTip.style.pixelWidth?oToolTip.style.pixelWidth:380);
			var iHeight = oToolTip.offsetHeight?oToolTip.offsetHeight:(oToolTip.style.pixelHeight?oToolTip.style.pixelHeight:20);

			var tooltipLft = (document.body.offsetWidth?document.body.offsetWidth:document.body.style.pixelWidth) - (iWidth) - 30;
			if (navigator.appName == 'Netscape') {
				var tooltipTop = 10;
				oToolTip.style.left = tooltipLft; oToolTip.style.top = tooltipTop;
			}
			else {
				var tooltipTop = (document.body.scrollTop>=0?document.body.scrollTop+10:event.clientY+10);
				if ((event.clientX > tooltipLft) && (event.clientY < (oToolTip.scrollHeight?oToolTip.scrollHeight:oToolTip.style.pixelHeight) + 10)) {
					tooltipTop = (document.body.scrollTop?document.body.scrollTop:document.body.offsetTop) + event.clientY + 20;
				}
				oToolTip.style.pixelLeft = tooltipLft; oToolTip.style.pixelTop = tooltipTop;
			}
			oToolTip.style.zIndex = 99;
			oToolTip.style.visibility = "visible";
			
			oShad.style.pixelTop = oToolTip.style.pixelTop;
			oShad.style.pixelLeft = oToolTip.style.pixelLeft;
			oShad.style.pixelWidth = iWidth;
			oShad.style.pixelHeight = iHeight;
			oToolTip.style.zIndex = 98;
			oShad.style.visibility = "visible";
		}
	}

	function WebForm_Help_Hide(ID) {
		var oToolTip = (document.getElementById) ? document.getElementById(ID) : eval("document.all['" + ID + "']");
		var oShad = (document.getElementById) ? document.getElementById('divDropShadow') : eval("document.all['divDropShadow']");		

		if (oToolTip != null) {
			oToolTip.style.visibility = "hidden";
			oShad.style.visibility = "hidden";
		}
	}

	/********************************************************************************************************/

	var g_activePanel;
	var g_activeTab;

	function showTab(tab)
	{
		if(!g_activeTab)
		{
			g_activeTab = document.getElementById("tab0");
			g_activePanel = document.getElementById("tab0panel");
		}

		theTab = document.getElementById(tab);
		thePanel = document.getElementById(tab + "panel");

		g_activeTab.className = "InActiveTab";
		g_activePanel.style.display = "none";

		theTab.className = "ActiveTab";
		thePanel.style.display = "inline";
		g_activePanel = thePanel;
		g_activeTab = theTab;
	}
	