var parkeringidrammen = function() {
	var
	defaultValues = {
		"navn":"Navn",
		"adresse":"Adresse",
		"postnr":"Postnr.",
		"poststed":"Poststed",
		"epost":"Epost",
		"telefon":"Telefon",
		"antall":"Antall",
		"kommentar":"Evt. kommentar"
	};
	
	checkCurrent = function() {
		var that = $(this);
		
		if(typeof topmenupoint == "undefined") {
			topmenupoint = "none-";
		}
		
		that.find("a").each(function() {
			if($(this).attr("href") == window.location.pathname.toString() || $(this).attr("href").indexOf(topmenupoint) != -1) {
				$(this).parent().addClass("current");
			}
		});
	},
	
	handleBoxMouseOver = function() {
		var $that = $(this);
		var img = $that.find("img");
		
		img.animate({ 
			top: "0px"
		}, {queue: false, duration: 140});
	},
	
	handleBoxMouseOut = function() {
		var $that = $(this);
		var img = $that.find("img");
		
		img.animate({ 
			top: "20px"
		}, {queue: false, duration: 140});
	},
	
	init = function() {	    
	    $("#menu li").each(checkCurrent);
	    
	    $("#frontpage-boxes .box")	.bind("mouseover", handleBoxMouseOver)
									.bind("mouseout", handleBoxMouseOut);
	    
		$("#maaned")	.bind("click", function() {  $(this).find("option[value=0]").attr("disabled", "disabled");   });
		
		
		$(".clear-on-focus")	.bind("focus", 
									function() {  
										var that = $(this);
										
										if(defaultValues[that.attr("name")] == that.attr("value")) {
											that.attr("value", "");
										}
									}
								)
								.bind("blur", 
									function() {  
										var that = $(this);
										
										if(that.attr("value") == "")
											that.attr("value", defaultValues[that.attr("name")]);
									}
								);
	}
	;

	return {
		init: init
	};
}();


$(document).ready(function() {
	parkeringidrammen.init();
});
