/* main.js
 * Created by Dawid Zarrach
 ****************************************/

var jq = jQuery.noConflict('main.js');

function log(value)
{
    if(typeof(console) == 'object' && typeof(console.log) == 'function') {
        console.log(value);
    }
}

jq(document).ready(function($){
    
    $('#subnavi .head').each(function(){
        $(this).removeClass('head');
    });
    
    $('#subnavi > li').each(function(){
        if($(this).find('ul').length > 0 ) {
            $(this).find('a:first').addClass('head').attr('href', '#');
            
        }
    });
    
    function onAfter(curr, next, opts) {
        if(jq('#content .main-col .r-col .slideshow .clipping-mask-button').length > 0) {
            jq('#content .main-col .r-col .slideshow .clipping-mask-button').attr('href', this.href/*jq(opts.elements[opts.currSlide]).attr('href')*/);
        }
    }
    
    $('#content .main-col .r-col .slideshow .slides').cycle({
        pager:  '#pager',
        next:   '#content .main-col .slideshow-triggers .triggers a.next', 
        prev:   '#content .main-col .slideshow-triggers .triggers a.prev',
        after: onAfter,
        speed:  'slow',
        startingSlide: 0
    });
    
    $("#subnavi").accordion({
        active: true,
        header: 'a.head',
        animated: false,
        autoHeight: false,
        selectedClass: '.current'
    });
    
    $("#subnavi").accordion("activate" , "a.current");
    $("#subnavi").accordion("option", "navigation", true );
    $("#subnavi").accordion({animated: true});
    
    
    $('.logo-bar a').css("opacity", 0.5).hover(function(){
        $(this).animate({"opacity": 1}, 400);
    },function(){
        $(this).animate({"opacity": 0.5}, 400);
        //$(this).css("opacity", 0.5);
    });
    
    $('.sidebar-button').hover(function(){
         $(this).find('img').animate({"opacity": 0.7}, 400);
    }, function(){
         $(this).find('img').animate({"opacity": 1}, 400);
    });
    
    
    $('a[rel=lightbox]').colorbox({
        maxWidth : '100%',
        maxHeight: '100%',
        opacity: 0.5,
        current: '',
        scalePhotos: true
    });
    
});
