jQuery(window).load(function() {
	
	if (jQuery.browser.msie && jQuery.browser.version.substr(0,1) < 8) {
		// Do nothing
	} else {
		
		// CMS CONTENT PAGES
		if(jQuery('.cms-content').length > 0 && jQuery('.col-left .left_menu_wrapper').length > 0 && jQuery('.col-left .block .block-content').length == 1) {
		
			if(jQuery('.cms-content').height() > jQuery('.col-left').height()) {
			
				//jQuery('.col-left .block .block-content').height(jQuery('.cms-content .std').height()+8);
		
			} else if(jQuery('.cms-content').height() < jQuery('.col-left').height()) {
			
				jQuery('.cms-content .std').height(jQuery('.col-left').height()-78);
			
			
			}
		
		}
	
	}
	
	// HOMEPAGE
	
	if(jQuery('.product_new_wrapper').length > 0 && jQuery('.left_menu_wrapper').length > 0) {
		
		if(jQuery('.left_menu_wrapper').height() > 479) {
		
			//jQuery('.product_new_wrapper .new_product_items_main').height(jQuery('.left_menu_wrapper .block .block-content').height()+47);
			
			jQuery('.product_new_wrapper .new_product_items_main').css("minHeight", (jQuery('.left_menu_wrapper .block .block-content').height()+47));
	
		} else if(jQuery('.product_new_wrapper').height() < jQuery('.left_menu_wrapper').height()) {
		
			jQuery('.left_menu_wrapper .block .block-content').height(jQuery('.product_new_wrapper .new_product_items_main').height());
		
		}
	
	}
	
	// RIGHT COLUMN PAGES
	
	if(jQuery('.col-right').length > 0 && jQuery('.col-main').length > 0) {
		
		var right_height = jQuery('.col-right').height();
		var main_height = jQuery('.col-main').height();
		var height_diff = right_height-main_height;
		
		if(height_diff > 0) {
			if(jQuery('.product-view').length > 0) jQuery('.product-view').height(jQuery('.product-view').height()+height_diff);
			if(jQuery('.category-products').length > 0) jQuery('.category-products').height(jQuery('.category-products').height()+height_diff);
		}
		
		
	}
	
	// button[data-action]
	jQuery("button[data-action]").bind("click", function(e){
	
	    var action = jQuery(this).attr("data-action");
	    
	    switch(action)  {
	    
	        case "por":
	        
	            var product_id = jQuery(this).attr("data-product-id");
	            
	            if(product_id != "0") {
	                showFancyboxPopup("/popup_por.php?product_id=" + product_id, "Prijs op aanvraag", 480, 395);
	            }
	            
	            break;
	            
	        case "availability":
	        
	            var product_id = jQuery(this).attr("data-product-id");
	            
	            if(product_id != "0") {
	                showFancyboxPopup("/popup_availability.php?product_id=" + product_id, "Informatie levering", 480, 395);
	            }
	            
	            break;
	            
	        default:
	        
	    }
	    
	});
	
	jQuery("button.btn-contactform").bind("click", function(e){
	
	    showFancyboxPopup("/popup_contact.php", "Contactformulier", 480, 335);
	    
	});
	
});

function orderSalt() {
	
	jQuery('.std').hide();
	jQuery('.direct_order').show();
	
}

function setCookie(c_name, value, exdays) {

    var exdate = new Date();
    exdate.setDate(exdate.getDate() + exdays);
    
    var c_value = escape(value) + ((exdays==null) ? "" : "; expires=" + exdate.toUTCString());
    document.cookie = c_name + "=" + c_value;
    
}

function showFancyboxPopup(href, title, width, height) {

    jQuery.fancybox({
			'padding'		: 20,
			'autoScale'		: false,
			'transitionIn'	: 'none',
			'transitionOut'	: 'none',
			//'title'			: title,
			'title'			: false,
			'width' 		: width,
			'height'		: height,
			'href'			: href,
			'type'			: 'ajax'
	});
	
}

