// begin custom

$(document).ready(function(){ 
    
    $(document).pngFix(); 
    var lKop1 = ($("#h4bedrijf").length > 0) ? $("#h4bedrijf").html().length : 0;
    var lKop2 = ($("#h4milieu").length > 0) ? $("#h4milieu").html().length : 0;
    var lKop3 = ($("#h4collectie").length > 0) ? $("#h4collectie").html().length : 0;
    if(lKop1 > 11)  changeFontSizeH4("#h4bedrijf", lKop1);
    if(lKop2 > 11)  changeFontSizeH4("#h4milieu", lKop2);
    if(lKop3 > 11)  changeFontSizeH4("#h4collectie", lKop3);
    
    
    $('#menuBedrijf h4, #menuBedrijfHover').mouseover(function(){
        $('#menuBedrijfText').show();  
        $('#menuBedrijfHover').show(); 
        $('#menuMilieuText').hide();  
        $('#menuMilieuHover').hide(); 
        $('#menuCollectieText').hide();  
        $('#menuCollectieHover').hide(); 
        
    });
    $('#menuBedrijfHover').mouseout(function(){
        $('#menuBedrijfText').hide();  
        $('#menuBedrijfHover').hide(); 
    });
    
    $('#menuMilieu h4, #menuMilieuHover').mouseover(function(){
        $('#menuMilieuText').show();  
        $('#menuMilieuHover').show(); 
        $('#menuBedrijfText').hide();  
        $('#menuBedrijfHover').hide(); 
        $('#menuCollectieText').hide();  
        $('#menuCollectieHover').hide(); 
    });
    $('#menuMilieuHover').mouseout(function(){
        $('#menuMilieuText').hide();  
        $('#menuMilieuHover').hide(); 
    });
    
    $('#menuCollectie h4, #menuCollectieHover, #menuCollectieColRight h4').mouseover(function(){
        $('#menuCollectieText').show();  
        $('#menuCollectieHover').show(); 
        $('#menuBedrijfText').hide();  
        $('#menuBedrijfHover').hide(); 
        $('#menuMilieuText').hide();  
        $('#menuMilieuHover').hide(); 
    });
    $('#menuCollectieHover').mouseout(function(){
        $('#menuCollectieText').hide();  
        $('#menuCollectieHover').hide(); 
    });
                 
}); 

function changeFontSizeH4(pId, pLengte){
     if(pLengte < 14) {
        $(pId).css("font-size","26px");  
        $(pId).css("padding", "11px 0 14px 0"); 
     }
     else if(pLengte < 15) {
         $(pId).css("font-size","24px");
         $(pId).css("padding", "12px 0 15px 0"); 
     }
     else if(pLengte < 17) {
         $(pId).css("font-size","22px");
         $(pId).css("padding", "13px 0 16px 0");  
     } 
     else if(pLengte < 20) {
        $(pId).css("font-size","20px"); 
        $(pId).css("padding", "14px 0 17px 0"); 
     }
     else {
          $(pId).css("font-size","18px");
          $(pId).css("padding", "15px 0 18px 0"); 
     }
}


function showProduct(product_id){
    $.ajax({ url: "load_product.php?product_id=" + product_id, context: document.body, success: function(data){
        var dArr = data.split('|');
        $('#colImage1').html(dArr[0]);
        $('#colImage2').html(dArr[1]);
        $('#menuColDetails').html(dArr[2]);
        //$('#menuColExtra').html(dArr[3]);
        $('#menuColExtraDiv').html(dArr[3]);
        if($('#menuColExtraDiv').height() > 182) {
            var verhoog = $('#menuColExtraDiv').height() - 172;
            $('#menuColExtra').height(182 + verhoog);
            $('#menuColDetails').height(182 + verhoog);
            $('#menuColItems').height(625 + verhoog);
        }
        else {
             $('#menuColExtra').height(182);
             $('#menuColDetails').height(182);
             $('#menuColItems').height(625);
        }
        Cufon.replace('#menuColDetails h2', { fontFamily: 'Futura Md BT'});
        
        
    }})   
}

function mycarousel_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });
 
    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });
 
    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};
 
jQuery(document).ready(function() {
    jQuery('#mycarousel').jcarousel({
        scroll: 1,
        auto: 1,
        wrap: 'circular',
        animation: 5000,
        initCallback: mycarousel_initCallback
    });
});

function fbs_click(urls,titles) {
    u=urls;
    t=titles;
    window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&amp;t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
    return false;
}

function checkemail(email){
    var str=email;
    var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
    if (filter.test(str))
        return true;
    else{
        return false;
    }
}





