$(document).ready(attachFieldEvents);
	
function attachFieldEvents()
{

    $("input[type=text]").focus(function() {
	    if ($(this).val() == $(this).attr("title")) {
		    $(this).val("");
	    }
		var colour = $(this).closest('.twocolumn').find('h1').css("color");
		if (colour != null ) $(this).css("border", "1px solid " + colour);
    });
	
    $("input[type=text]").blur(function() {
	    if ($(this).val() == "") {
		    $(this).val($(this).attr("title"));
	    }
		if (!($(this).hasClass("calculatorinput")) && !($(this).hasClass("emailinput"))) {
		    $(this).css("border","1px solid #BFBFBF");
	    }
    });
	
    $("select").focus(function() {
		var colour = $(this).closest('.twocolumn').find('h1').css("color");
		if (colour != null) $(this).css("border", "1px solid " + colour);
    });
	
    $("select").blur(function() {
		$(this).css("border","1px solid #BFBFBF");
    });
	
	$("input[type=text], select").hover(function()
	{
	    var colour = $(this).closest('.twocolumn').find('h1').css("color");
		if(colour != null) $(this).css("border","1px solid " + colour);
	},
	function() {
		if (!($(this).hasClass("calculatorinput")) && !($(this).hasClass("emailinput"))) {
		    $(this).css("border","1px solid #BFBFBF");
	    }
	});
	
	$("#mainMenu li").hover(
	function() {
		
		$(this).addClass($(this).attr("id"));
    },
	function() {
		$(this).removeClass($(this).attr("id"));
    }
	);

}

Array.prototype.contains = function(obj) {
  var i = this.length;
  while (i--) {
    if (this[i] === obj) {
      return true;
    }
  }
  return false;
}
