/************************************************************
Design and development by Webtraders Internet Solutions B.V.
URL:          http://webtraders.nl
Phone:        +31 (0) 70 306 0002
E-mail:       info@webtraders.nl
Completed:    # Mei 2010
*************************************************************/ 

function createhover(id,item,color,hover){
    $(id).hover(
        function(){
            $(item,this).attr("style", "color: " + color);
            Cufon.replace(this);
            Cufon.now();
        },
        function(){
            $(item,this).attr("style", "color: " + hover);
            Cufon.replace(this);
            Cufon.now(); 
        }
    );
}

$(function() { 
    // Functions 
    $.fn.carouselarrows123 = function(location){ 
        var imgPrev = $('.prev img');  
        var imgNext = $('.next img');   
        
        if ($('.prev').hasClass('disabled')){
            imgPrev.attr('src', img_path+'selector-arrow-left-inactive.png'); 
            $('#selector-navigator-left').stopSelectorBounce();
        }else{
            imgPrev.attr('src', img_path+'selector-arrow-left-active.png'); 
            $('#selector-navigator-left').startSelectorBounce();
        }
        
        if ($('.next').hasClass('disabled')){
            imgNext.attr('src', img_path+'selector-arrow-right-inactive.png');
            $('#selector-navigator-right').stopSelectorBounce(); 
        }else{
            imgNext.attr('src', img_path+'selector-arrow-right-active.png');
            $('#selector-navigator-right').startSelectorBounce(); 
        } 
    };
    
    // Functions 
    $.fn.carouselarrows = function(divname, location){
        var container  = $(divname);
        if (container.hasClass('disabled')){
            $('img', container).attr('src', img_path+'selector-arrow-'+location+'-inactive.png');    
            //left.stopSelectorBounce();
        }else{
            $('img', container).attr('src', img_path+'selector-arrow-'+location+'-active.png');
            //left.startSelectorBounce('left');
        }
    };     
    
    $.fn.startSelectorBounce = function(location){
        if ($(this).hasClass('disabled') == ""){
            $('img', this).startBounce(location);          
        }
    }
    
    $.fn.stopSelectorBounce = function(){
        $('img', this).stopTime();  
    }        
    
    $.fn.carouselarrowhide = function(location){  
        $('img', this).attr('src', img_path+'selector-arrow-'+location+'-inactive.png');
    };         
    
    $.fn.startBounce = function(location){ 
        if (location == ""){
            location = 'Left';          
        }
        else if(location == "left"){
            location = 'Left';    
        } 
        else if(location == "right"){
            location = 'Right';    
        } 
           
        var props1 = {};
        var props2 = {};
        props1["margin" + location] = '5px';
        props2["margin" + location] = '0px'; 
        
        $(this).everyTime(100, function(){ 
            $(this).animate(props1, 200)
                   .animate(props2, 200)
                   .animate(props1, 200)
                   .animate(props2, 200); 
        });
    };
    
    // Actions      
    $('.prev').addClass('disabled');
    
    if ($('#jquery-selector ul li').size() == carrousel_visable){
        $('.next').addClass('disabled').carouselarrowhide('right');
    }  
    
    $("#jquery-selector").jCarouselLite({
        btnNext: ".next",
        btnPrev: ".prev",
        circular: false,
        mouseWheel: true,
        visible: carrousel_visable,
        scroll: carrousel_scroll,       
        afterEnd: function(){ 
           $.fn.carouselarrows('#selector-navigator-left', 'left');
           $.fn.carouselarrows('#selector-navigator-right', 'right'); 
        }
    });
    
    if ($('.carrousel-items ul li').size() == carrousel_visable){
        $('.carrousel-navigator-right').addClass('disabled').carouselarrowhide('right');
    }
    
    $(".carrousel-items").jCarouselLite({
        btnNext: ".carrousel-navigator-right",
        btnPrev: ".carrousel-navigator-left",
        circular: false,
        mouseWheel: true,
        visible: carrousel_visable,
        scroll: carrousel_scroll,      
        afterEnd: function(){ 
           $.fn.carouselarrows('.carrousel-navigator-left', 'left');
           $.fn.carouselarrows('.carrousel-navigator-right', 'right');
        }
    }); 
    
    // Left side
    /*
    $('#selector-navigator-background-left').css({opacity:'0'}).hide();  
    $('#selector-navigator-left').startSelectorBounce();         
        
    $("#selector-navigator-left").hover(function(){ 
        $(this).stop(true).animate({
            width: '52px',
            paddingTop: '137px'   
        }, 200, 'linear');
         
        $('img', this).stop(true).stopTime().animate({
            width: '52px',
            height: '52px'
        }, 200, 'linear');
         
        $('#selector-navigator-background-left').stop(true).show().animate({
            opacity: 1,
        }, 200, 'linear'); 
    }, function(){ 
        $(this).animate({
            width: '25px',    
            paddingTop: '150px'   
        }, 200, 'linear');
         
        $('img', this).animate({
            width: '25px',
            height: '25px' 
        }, 200, 'linear');
         
        $(this).startSelectorBounce();                                       
         
        $('#selector-navigator-background-left').hide().animate({
            opacity: 0
        }, 200, 'linear'); 
    });
    */ 
           
    // Right side                         
    /*
    $('#selector-navigator-background-right').css({opacity:'0'}).hide();  
    $('#selector-navigator-right').startSelectorBounce();  
        
    $("#selector-navigator-right").hover(function(){ 
        $(this).stop(true).animate({
            width: '52px',
            marginLeft: '938px',   
            paddingTop: '137px'   
        }, 200, 'linear'); 
         
        $('img', this).stop(true).stopTime().animate({
            width: '52px',
            height: '52px'
        }, 200, 'linear');
                          
        $('#selector-navigator-background-right').stop(true).show().animate({
            opacity: 1,
        }, 200, 'linear');  
    }, function(){ 
        $(this).animate({
            width: '25px',
            marginLeft: '965px',   
            paddingTop: '150px'   
        }, 200, 'linear'); 
         
        $('img', this).animate({
            width: '25px',
            height: '25px'
        }, 200, 'linear');        
        
         $(this).startSelectorBounce();
                          
         $('#selector-navigator-background-right').animate({
            opacity: 0,
         }, 200, 'linear').hide(); 
    });
    */
    
    Cufon.refresh();

	Cufon.replace('#navigation-1 li span a', {forceHitArea: true}); 

    Cufon.replace('span.selector-title, .selector-subtitle', {forceHitArea: true});    
    Cufon.replace('#jquery-selector ul li h2', {forceHitArea: true});
    
    Cufon.replace('#footer-navigation h2.font', {forceHitArea: true});
    Cufon.replace('span.content-title, .content-subtitle, .content-data h1, #content h1, #content h2, .content-data h2', {forceHitArea: true}); 
    
    // Catalogus    
    Cufon.replace('.catalogus-blok-3 h3', {forceHitArea: true});  
    Cufon.replace('#blok3-description-text h3, #blok3-description-text h4', {forceHitArea: true});
    Cufon.replace('.catalogus.overview h3', {forceHitArea: true});     
   
    Cufon.now();
    
    createhover('#navigation-1 li','span.level-1 a', '#fff', '#000'); // First level must be placed in the item for selection  
    createhover('#navigation-1 li span.level-2','a', '#d962af', '#fff');     
    createhover('#navigation-1 li span.level-3','a', '#d962af', '#fff');       
    
    $('p.pressimg a').fancyZoom({scaleImg:true, closeOnClick:true, directory:"/layouts/jpchenet.com/images/fancybox"}); 
});

var youTubeEmbed = function(id, box){ 
    var params = { allowScriptAccess: "always" }; 
    swfobject.embedSWF("http://www.youtube.com/v/"+id+"?enablejsapi=1&amp;version=3&amp;border=0", box, "576", "356", "8", null, null, param);  
    //swfobject.embedSWF('http://www.youtube.com/v/'+ytVideoID+"&hl=en&fs=1&rel=0&color1=0x000000&color2=0x2d2d2d&enablejsapi=1&playerapiid=ytplayer", box, "640px", "385px", "8", null, null, atts);
}; 


