(function($){
			
	$(function(){

		/* Hide pager if only one page */
    $(".pager ul").each(function(){ $(this).etpPagerVisability(3); });
		$(".layout-section-4-col, .layout-section-2-col").each(function(){ $(this).etpEqualHeights(true);	});				

		// Epost
		$("#f8_1").click(function() { $("#erform1").valid(); });
		
		// Telefon
		$("#f8_2").click(function() { $("#erform1").valid(); });
		
		$(".sponsors-lc").randomize(".sponsors-lc-item");

	});
	

	$.validator.setDefaults({ 
		submitHandler: function() { ValidateAndSubmitForm(); }, 	
		highlight: function(input) { $(input).addClass("ui-state-highlight");	}, 
		unhighlight: function(input) { $(input).removeClass("ui-state-highlight"); }});
	
	$.fn.etpFormValidation = function()
	{

		$form = $("#erform1");

    var valcontainer = $(".validation-container");

		$form.validate({
			rules: {
				f4: { required: true }
				,f5: { required: "#f8_1:checked", email: "#f8_1:checked" }
				,f6: { required: true }
			},
			messages: {
				f4: { required: "Fyll inn navnet ditt" }
				,f5: { required: "Fyll inn din epostadresse", email: "Fyll inn en gyldig epostadresse"}
				,f6: { required: "Fyll inn en henvendelse" }
				,f7: { required: "Fyll inn ditt telefonnummer", number: "Feltet kan bare inneholde tall", minlength: "Fyll inn minst 8 siffer" }
			}
			//,errorContainer: valcontainer
			//,errorLabelContainer: $("ul.validation-status-error", valcontainer)
			//,wrapper: 'li'  			
		});
	
	}	

	$.fn.randomize = function(childElem) {
		return this.each(function() {
				var $this = $(this);
				var elems = $this.children(childElem);
	
				elems.sort(function() { return (Math.round(Math.random())-0.5); });  
	
				$this.remove(childElem);  
	
				for(var i=0; i < elems.length; i++)
				{	
					var $el = $(elems[i]);
					if(i == 0){ $el.addClass("first"); }
					$this.append($el);      
				}
	
		});    
	} 
	
})(jQuery)




