function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function () {
			if (oldonload) {
				oldonload();
			}
			func();
		}
	}
}

/**
* The script that autoloads.
*/
addLoadEvent(function () {
	var j = jQuery.noConflict();
	
	j(document).ready(function () {
		j("#minSideForm").validate();
		j("#global-search").validate();
		j("#loginForm").validate();
		j("#search-store").validate();
		j("#tipsEnVennForm").validate();
	});
})


$(document).ready(function () {
		jQuery('form#artCommentForm').validate({

		rules: {
			cname: {
				required: true
			},
			cemail: {
				required: true,
				email: true
			},
			ccomment: {
				required: true
			}
		},
		messages: {
			cname: {
				required: "Navn er påkrevd"
			},
			cemail: {
				required: "E-post er påkrevd",
				email: "E-post må angis på riktig format. Eksempel: navn@domain.com"
			},
			ccomment: {
				required: "Du må skrive noe i kommentarfeltet."
			}
		},
		errorPlacement: function (error, element) {
			error.appendTo(element.parent());
		},
		submitHandler: function (form) {
			jQuery(form).attr('action', 'http://www.jernia.no/userservices?op=create&handler=content');			
			form.submit();
		}
	});
});
