/*-----------------------------------------------------------+
 | addLoadEvent: Add event handler to body when window loads |
 +-----------------------------------------------------------*/
function addLoadEvent(func) {
	var oldonload = window.onload;
	
	if (typeof window.onload != "function") {
		window.onload = func;
	} else {
		window.onload = function () {
			oldonload();
			func();
		}
	}
}

/*------------------------------------+
 | Functions to run when window loads |
 +------------------------------------*/
addLoadEvent(function () {
	initChecklist();
});

/*----------------------------------------------------------+
 | initChecklist: Add :hover functionality on labels for IE |
 +----------------------------------------------------------*/
function initChecklist() {
	if (document.all && document.getElementById) {
		// Get all unordered lists
		var lists = document.getElementsByTagName("ul");
		
		for (i = 0; i < lists.length; i++) {
			var theList = lists[i];
			
			// Only work with those having the class "checklist"
			if (theList.className.indexOf("checklist") > -1) {
				var labels = theList.getElementsByTagName("label");
				
				// Assign event handlers to labels within
				for (var j = 0; j < labels.length; j++) {
					var theLabel = labels[j];
					theLabel.onmouseover = function() { this.className += " hover"; };
					theLabel.onmouseout = function() { this.className = this.className.replace(" hover", ""); };
				}
			}
		}
	}
}


function checkAll(field)
{
for (i = 0; i < field.length; i++){
	field[i].checked = true ;
	}
	searchIt('0', 1);
}

function uncheckAll(field)
{
for (i = 0; i < field.length; i++){
	field[i].checked = false ;
	}
	
	searchIt('0', 1);
}


function get_check_value()
{

	var c_value = "";
	for (var i=0; i < document.myform.theTowns1.length; i++)
   {
   if (document.myform.theTowns1[i].checked)
      {
      c_value = c_value + document.myform.theTowns1[i].value + "^";
      }
   }
   return c_value;
}

function get_check_value2()
{

	var c_value = "";
	for (var i=0; i < document.myform.theTowns2.length; i++)
   {
   if (document.myform.theTowns2[i].checked)
      {
      c_value = c_value + document.myform.theTowns2[i].value + "^";
      }
   }
   return c_value;
}
