var validationErrors = Array();

function validateForm(){
	if(validationErrors.length > 0){
		jQuery.each(validationErrors, function( intIndex, objValue ){
			jQuery(".object-"+objValue).parent().addClass("form-input-error");
		});	
	}
}
jQuery.fn.ajaxSubmit = function(e) {
	// Change a form's submission type to ajax 
	this.submit(function(){
		var params = {};
    jQuery(this)
    .find("input:checked, input[type='text'], input:hidden, input[type='password'], input[type='submit'], option:selected, textarea")
    //.filter(":enabled")
    .each(function() {
    	//console.log(this.name+'---'+this.value);
      params[ this.name || this.id || this.parentNode.name || this.parentNode.id ] = this.value;
    });
    jQuery("body").addClass("curWait");
    jQuery("div#fancy_content").html("");
    jQuery("#fancy_loading").show();
		jQuery.post(this.getAttribute("action"), params, function(html){
			jQuery("body").removeClass("curWait");
			strError = "Unable to submit form. Please try again later.";
			jQuery("#fancy_loading").hide();
			jQuery("div#fancy_content").append(html).show();
	 		jQuery("div#fancy_content form#feedback-form").ajaxSubmit();
			validateForm();
		}, "html");
		return false;
	});
	return this;
}


jQuery(document).ready(function(){
 	if (jQuery('#s3slider').length > 0){
	  $('#slider').s3Slider({timeout:9000,fadeTime:500});
	}  
	jQuery("div.fancybox-image a, div.attribute-image a.fancybox").fancybox();
	jQuery('div#contact-tool-content').load("http://www.fusebox.dk/layout/set/popup/Info/Kontakt/Ring-mig-op/");
	jQuery("div.contactform a").fancybox({
		'frameWidth': 680, 
		'frameHeight': 450,
		'zoomSpeedIn':	300,
		'overlayShow': true,  
		'zoomSpeedOut':	0
	});
 	jQuery("a.case-link").fancybox({
			'frameWidth': 950, 
			'frameHeight': 450,
			'zoomSpeedIn':	300, 
			'zoomSpeedOut':	0
	});
});

