<!--
// TDBC Client Javascripts
// Copyright Taunton Deane Borough Council
//

function dropdown(selstruct) {
	// Function to navigate to URL selected via dropdown list (<SELECT> structure)
	with (selstruct)
		ref = selstruct[selectedIndex].value;
		//Ref may include an optional target - delimited by an &
		//so look for & and split into url & target parts
		if (ref == "")
		{
			return;
		}
			
		splitchar = ref.lastIndexOf("&");
		
		if (splitchar != -1)
		{
			// found a &
			loc = ref.substring(0,splitchar);
			target = ref.substring(splitchar+1,1000);
			target = target.toLowerCase();
		}
		else
		{
			loc = ref;
			target = "_self";
		}
		
		lowloc=loc.toLowerCase();
		if (lowloc == "false")
		{
			// Location is empty (tolowercase has returned false)
			return;
		}
		if (target == "_self")
		{
			document.location = loc;
		}
		else
		{ 
			if (target == "_top")
			{
				top.location = loc;
			}
			else
			{
				if (target == "_blank")
				{
					window.open(loc);
				}
				else
				{
					if (target == "_parent")
					{
						parent.location = loc;
					}
					else
					{
						parent.frames[target].location = loc;
					}
				}
			}
		}
	}
	
function getCookie(NameOfCookie) { 
	if (document.cookie.length > 0) { 
		begin = document.cookie.indexOf(NameOfCookie+"="); 
		if (begin != -1) { 
			begin += NameOfCookie.length+1; 
			end = document.cookie.indexOf(";", begin);
			if (end == -1) end = document.cookie.length;
			return unescape(document.cookie.substring(begin, end)); 
		} 
	}
	return null; 
}



function setCookie(NameOfCookie, value, expiredays) { 
	var ExpireDate = new Date ();
	ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));
	document.cookie = NameOfCookie + "=" + escape(value) + ((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString());
}



function delCookie (NameOfCookie) { 
	if (getCookie(NameOfCookie)) {
		document.cookie = NameOfCookie + "=" + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}

}
 
function searchvalidate(form)
// Validate user responses
{
	with (window.document.forms[0] ) 
	{
		if (txtSearch.value == "")
		{
			alert("Please enter text to be searched for");
			txtSearch.focus();
			return false;
		}
	}
	return true;
} 

//-->
