jQuery(document).ready(function(){
    changeToMail("mails-place-0", 0);
    setStyles();
    autoHeight(false);
    setCoups();
    setProducts();
});

function setCoups() {
    var minHeight = 0;

    var arrCoupsProductsContent = jQuery("#coups .product-content");
    jQuery.each(arrCoupsProductsContent, function(i, val){
        if (jQuery(this).outerHeight() > minHeight) {
            minHeight = jQuery(this).outerHeight();
        }
    });
    jQuery.each(arrCoupsProductsContent, function(i, val){
        jQuery(this).height(minHeight);
    });

    jQuery("#productController").jFlow({
        slides: "#productSlides",  // the div where all your sliding divs are nested in
        controller: ".jFlowControl", // must be class, use . sign
        slideWrapper : "#jFlowSlide", // must be id, use # sign
        selectedWrapper: "jFlowSelected",  // just pure text, no sign
        auto: true,
        width: "238px",  // this is the width for the content-slider
        height: minHeight + 50 + "px",  // this is the height for the content-slider
        duration: 400,  // time in miliseconds to transition one slide
        prev: ".jFlowPrev", // must be class, use . sign
        next: ".jFlowNext" // must be class, use . sign
    });
}

function setProducts() {
    var minHeight = 0;
    var productsRows = jQuery("#products .products-row");
    jQuery.each(productsRows, function(i, val1){
        minHeight = 0;
        var arrProductContent = jQuery(this).find(".product-content");
        jQuery.each(arrProductContent, function(j, val2){
            if (jQuery(this).outerHeight() > minHeight) {
                minHeight = jQuery(this).outerHeight();
            }
        });
        jQuery.each(arrProductContent, function(j, val2){
            jQuery(this).height(minHeight);
        });
    });
}
