
	// **** Municipality Codes ****
	//  a = All Oxford County (insert this when not wanting "All Oxford County" to show up last (by default))
	//	b = Blandford-Blenheim
	//	e = East Zorra-Tavistock
	//	i = Ingersoll
	//	n = Norwich
	//	s = South-West Oxford
	//	t = Tillsonburg
	//	w = Woodstock
	//	z = Zorra 
	
	// **** Colour Options ****
	//	green
	//	red
	//	blue


// *******************************************************************************************
// ******************                      ALL CODE                      *********************
// *******************************************************************************************

 	/* Copy variables from call over to local variables */
	var theCOOL_Municipality = cool_SEMunicipality;
	var theCOOL_Colour = cool_SEColour;
 
	/* Municipal Codes */
	var optionMunicipality = "";
	var allCounty;	
	if (typeof theCOOL_Municipality != "undefined") {	
		var separatedValues = theCOOL_Municipality.split(",");
		for (var i=0; i<separatedValues.length; i++) {
			if (theCOOL_Municipality.indexOf(separatedValues[i])!=-1 ) optionMunicipality = optionMunicipality + '<option ';
			if (theCOOL_Municipality.indexOf(separatedValues[i])!=-1 && i == 0) optionMunicipality = optionMunicipality + 'selected ';
			switch (separatedValues[i]) {
				case "a": optionMunicipality = optionMunicipality + 'value="">All Oxford County'; allCounty=1; break;			
				case "b": optionMunicipality = optionMunicipality + 'value="b">Blandford-Blenheim'; break;
				case "e": optionMunicipality = optionMunicipality + 'value="e">East Zorra-Tavistock'; break;
				case "i": optionMunicipality = optionMunicipality + 'value="i">Ingersoll'; break;
				case "n": optionMunicipality = optionMunicipality + 'value="n">Norwich'; break;
				case "s": optionMunicipality = optionMunicipality + 'value="s">South-West Oxford'; break;
				case "t": optionMunicipality = optionMunicipality + 'value="t">Tillsonburg'; break;
				case "w": optionMunicipality = optionMunicipality + 'value="w">Woodstock'; break;				
				case "z": optionMunicipality = optionMunicipality + 'value="z">Zorra'; break;
			}
			if (theCOOL_Municipality.indexOf(separatedValues[i])!=-1 ) optionMunicipality = optionMunicipality + '</option>';
		}
	}
	
	/* Colour Options */
	if (typeof theCOOL_Municipality != "undefined") {
		switch (theCOOL_Colour) {
			case "green": 
				colourEventButton = "http://www.cooloxford.ca/images/button_green.gif";
				colourEventBackground = "#0a9c78";
				colourEventBackgroundTrim = "#1BB6AD";
				colourEventViewEvent = "midnightblue";
				colourEventViewEvent = "midnightblue";				
				colourEventLink = "steelblue";
				colourEventHover = "green";
				colourEventPostLink = "green";
				colourEventPostHover = "steelblue";	
				break;
			case "red": 
				colourEventButton = "http://www.cooloxford.ca/images/button_red.gif";
				colourEventBackground = "#FF0033";
				colourEventBackgroundTrim = "#FF5E7D";
				colourEventViewEvent = "#82001A";				
				colourEventLink = "#BB0025";
				colourEventHover = "midnightblue";
				colourEventPostLink = "82001A";
				colourEventPostHover = "midnightblue";								
				break;
			case "blue": 
				colourEventButton = "http://www.cooloxford.ca/images/button_blue.gif";
				colourEventBackground = "#2B4688";
				colourEventBackgroundTrim = "#5276C9";
				colourEventViewEvent = "midnightblue";				
				colourEventLink = "steelblue";
				colourEventHover = "green";
				colourEventPostLink = "green";
				colourEventPostHover = "steelblue";						
				break;
			default :
				colourEventButton = "http://www.cooloxford.ca/images/button_green.gif";
				colourEventBackground = "#0a9c78";
				colourEventBackgroundTrim = "#1BB6AD";
				colourEventViewEvent = "midnightblue";				
				colourEventLink = "steelblue";
				colourEventHover = "green";
				colourEventPostLink = "green";
				colourEventPostHover = "steelblue";				
			}
	}

	function validateSearch() {
		if (document.frmSearchEvent.txtSearch.value.replace(/^\s*|\s*$/g,"")=="") {
			alert("Please enter a keyword for your search!");
			document.frmSearchEvent.txtSearch.focus(); }
		 else {
		 	document.frmSearchEvent.key.value =	document.frmSearchEvent.txtSearch.value;
			window.open("http://www.cooloxford.ca/calendar/?advanced_searchEvents=&constraint_class=&constraint_suit=&key=" + escape(document.frmSearchEvent.txtSearch.value) + "&sel_city=" + document.frmSearchEvent.selMunicipality.value + "&constraint_city=" + document.frmSearchEvent.selMunicipality.value);
		 }
	}
	
	function whichMunicipality(theHref,theType) {
		theType ? newType = "&view_type=" + theType : newType = "";
		var newHref = theHref + "?sel_city=" + document.frmSearchEvent.selMunicipality.value + newType;
		theHref = newHref;
		window.open(newHref);
	}		
		
	document.write ('<style type="text/css">');
	document.write ('.cool_searchTable {font-family:arial;font-size:8pt}');
	document.write ('.cool_searchTrim {font-family:arial;font-size:8pt;background-color:'+ colourEventBackgroundTrim + '}');
	document.write ('.cool_searchEvents {font-family:arial;font-size:8pt;background-color:ivory}');
	document.write ('.cool_searchButton {font-family:arial;font-size:8pt;background-color:white;background-image: url(' + colourEventButton + ');border-width:1;border-color:#ffffff;border-style:ridge}');
	document.write ('.cool_searchEventLink {font-family:arial;font-size:8pt;color:black;text-decoration:none;color:' + colourEventLink + '}');
	document.write ('.cool_searchEventLink:hover {color:' + colourEventHover + '}');
	document.write ('.cool_searchEventPostLink {font-family:arial;font-size:9pt;color:black;text-decoration:none;color:' + colourEventPostLink + '}');
	document.write ('.cool_searchEventPostLink:hover {color:' + colourEventPostHover + '}');
	document.write ('</style>');
	document.write ('<table width="180" border="0" align="center" cellpadding="1" cellspacing="1" class="cool_searchTrim">');
	document.write ('<form name="frmSearchEvent" method="post" onSubmit="javascript:validateSearch();return false">');	
	document.write ('<tr>');
	document.write ('<td width="180" bgcolor="' + colourEventBackground + '" colspan="2" align="center" ><b style="font-size:9pt;color:white">Upcoming Events:</b></td>');
	document.write ('</tr>');
	document.write ('<tr>');
	document.write ('<td width="135" bgcolor="' + colourEventBackground + '"><input type="text" name="txtSearch" class="cool_searchTable" style="width:130px"></td>');
	document.write ('<td width="45" bgcolor="' + colourEventBackground + '" align="center"><input type="submit" value="&nbsp;GO!&nbsp;" class="cool_searchButton"></td>');
	document.write ('</tr>');
	document.write ('<tr> ');
	document.write ('<td bgcolor="' + colourEventBackground + '" colspan="2"> <select name="selMunicipality" class="cool_searchTable" style="width:175px">');
	document.write (optionMunicipality);
	if (allCounty != 1) document.write ('<option value="">All Oxford County</option>');
	document.write ('</select>');
	document.write ('</td>');
	document.write ('</tr>');
	document.write ('<tr>');
	document.write ('<td colspan="2">');
	document.write ('<table  width="100%" border="0" class="cool_searchTable" style="background-color:ivory">');
	document.write ('<tr> ');
	document.write ('<td colspan="2"> <b><span style="font-size:9pt;color:' + colourEventViewEvent + '">View Events:</span><br>&nbsp;&nbsp;&#187; <a class="cool_searchEventLink" target="_blank" href="http://www.cooloxford.ca/calendar/" onClick="document.frmSearchEvent.txtSearch.value=\'%\';validateSearch();document.frmSearchEvent.txtSearch.value=\'\';return false;">All Events</a><br>&nbsp;&nbsp;&#187; <a class="cool_searchEventLink" target="_blank" href="http://www.cooloxford.ca/calendar/" onClick="whichMunicipality(this.href);return false;">Today\'s Events</a><br>&nbsp;&nbsp;&#187; <a class="cool_searchEventLink" target="_blank" href="http://www.cooloxford.ca/calendar/" onClick="whichMunicipality(this.href,2);return false;">This Week\'s Events</a><br>&nbsp;&nbsp;&#187; <a class="cool_searchEventLink" target="_blank" href="http://www.cooloxford.ca/calendar/" onClick="whichMunicipality(this.href,3);return false;">This Month\'s Events</a><br></b> </td>');
	document.write ('</tr>');
	document.write ('</table>');
	document.write ('<table width="100%" border="0" cellpadding="0" cellspacing="0" class="cool_searchTable" style="background-color:white">');
	document.write ('<tr>');
	document.write ('<td align="center"><a target="_blank" href="http://www.cooloxford.ca/calendar/?p=add_event1" class="cool_searchEventPostLink"><img src="http://www.cooloxford.ca/images/cal.gif" width="24" height="24" border="0"></a></td>');
	document.write ('<td width="180"><a target="_blank" href="http://www.cooloxford.ca/calendar/?p=add_event1" class="cool_searchEventPostLink">Post an Event On-line</a> </td>');
	document.write ('</tr>');
//	document.write ('<tr>');
//	document.write ('<td colspan="2" align="center"> <a target="_blank" href="http://www.informationoxford.ca"><img src="http://www.cooloxford.ca/images/logo-cooloxford-small.gif" width="100" height="21" border="0" style="margin-bottom:3px"></a></td>');
//	document.write ('</tr>');
	document.write ('</table></td>');
	document.write ('</tr>');
	document.write ('<input type="hidden" name="key">');
	document.write ('<input type=hidden name="advanced_searchEvents" value="">');
	document.write ('<input type=hidden name="constraint_class" value="">');
	document.write ('<input type=hidden name="constraint_suit" value="">');
	document.write ('<input type=hidden name="sel_city" value="t">');
	document.write ('</form>');	
	document.write ('</table>');
