$(document).ready(function() {
    $('.acc-content').css('display', 'none');
    $('.acc-title').css('cursor', 'pointer');
    $('.acc-title').click(function(){
        if($(this).hasClass('acc-active')) {
            $(this).removeClass('acc-active').next().slideUp('fast');
        } else {
            $(this).addClass('acc-active').siblings('.acc-title').removeClass('acc-active').end().next().slideDown('fast').siblings('.acc-content').slideUp('fast');
        }
    });
    //video icons 
    $('.video-icon').append('<span class="play-button" />');
    $('.sidebar-video').append('<span class="video-player" />');
    //insert slide selector
    $('#home-slides').parent().append('<ul id="change-slide" class="change-slide" />');
    $('.home-slide').each(function(){
        $('#change-slide').append('<li class="change-button" />');
    });
    $('#home-slides').cycle({
        fx:     'scrollHorz',
        speed:   350,
        timeout: 10000,
        activePagerClass:       'change-active',
        pager:                  '#change-slide',
        pagerAnchorBuilder:     function(idx, slide) { 
            // return selector string for existing anchor 
            return '#change-slide li:eq(' + idx + ')'; 
        },
        //easing: 'easeOutBack',
        cleartypeNoBg:          true
    });
    $('#products').parent().append('<span class="product-arrow" id="product-prev" /><span class="product-arrow" id="product-next" />');
    $('#products').cycle({
        fx:     'scrollHorz',
        speed:   450,
        timeout: 0,
        next: '#product-next',
        prev: '#product-prev',
        cleartypeNoBg:          true
    });




// process popup classes, depending on flash version ...
    if (!DetectFlashVer(7, 0, 0))
    $( ".popup" ) . each(function(idx,v){

        $.log( "mp4", typeof($(v).attr( "mp4" ) ) ) ;

        if ( typeof( $(v).attr( "mp4" ) ) != "undefined" )
        {
          var nc = $(v).attr("class").replace("popup","popup_");
          $(v).attr( "class", nc );
          $(v).attr( "href" , $(v).attr( "mp4") );
        }
       });

//Siblings, ye, they can be 2 names.
    $('.video-player').click(function(){
        $(this).siblings('.popup').click();
        $(this).siblings('.popup_').click();
        return false; 
    });


//pseudo click cacher
    $('.popup_').click( function(){

            var h_ = $(this).attr("href");
            var m_ = $(this).attr("mp4");
            $.log( "Catch click." )
            $.log( "href=",h_,"mp4",m_ )
            location.href =  m_;
            return false;
        });


    $('.popup').fancybox({
        padding: 20,
        transitionIn: 'none',
        onComplete: function() {
            Cufon.refresh();
        }
    });

    //submenu - don't need it at the moment
    //$('.nav-link').click(function(){
    //    if (!$(this).parent().hasClass('nav-active')) {
    //        $(this).next().slideDown('fast').parent().addClass('nav-active');
    //        return false;
    //    } else {
    //        $(this).next().slideUp('fast', function() {
    //            $(this).parent().removeClass('nav-active');
    //        });
    //        return false;            
    //    }
    //});
});

Cufon.replace('.font1', { fontFamily: 'condensed', hover: true });
Cufon.replace('.font1-light', { fontFamily: 'condensedLight' });
Cufon.replace('.font1-bold, .font1-bolditalic', { fontFamily: 'condensedBold' });

Cufon.replace('.top-link', {
    textShadow: '#333537 1px 1px',
    fontFamily: 'condensedLight',
    hover: true
});
Cufon.replace('.city-link', {
    textShadow: '#333537 1px 1px',
    fontFamily: 'condensed',
    hover: true
});    

