open_menu = function(elem,id){
	if($('#'+id).css('display')=='block')
	{
  	  $('ul#menu > li').removeClass('active');
	  $('div.rubrik-list > div').hide();
	  $('div.rubrik').hide();
	  return false;
	}
	$('ul#menu > li').removeClass('active');
	$(elem).parent().addClass('active');
	$('div.rubrik').show();
	$('div.rubrik-list > div').hide();
	$('#'+id).show();
}



$(document).ready(function (){

    



    $('.add-to-cart').click(function(e){
        $('.overlay').fadeIn();
        var popup = $(this).siblings('.popup-item');
        centerBlock(popup);
        popup.fadeIn();
    });


    $("#pass-recovery").click(function() {
       // hideAuth();

        showPass();
        return false;
    });

    


    $("#enter").click(function() {
        showAuth();
        return false;
    });

    $('.auth-blk').click(function() {
        hidePass();

        showAuth();
        return false;
    });

    $("#registration").click(function() {
        showReg();
        return false;
    });
    $('.or').click(function() {
        hideReg();
        showAuth();
        return false;
    });
    $('#reg-block').click(function() {
        hideAuth();
        showReg();
        return false;
    });

    $('.overlay').click(function(){
        $(this).fadeOut();
        $('.auth-popup, .popup-registration,.popup-item').fadeOut();
        $('.msg').remove();
    })

    function showReg(){
        centerBlock($('.popup-registration'));
        $('.overlay, .popup-registration').fadeIn();
    }

    function hideReg(){
         $('.popup-registration').fadeOut();
        $('.msg').remove();
    }

    function showAuth(){
        centerBlock($('.auth-popup'));
        $('#auth-block').show();
        $('#pass-rec').hide();
        $('.overlay, .auth-popup').fadeIn();//.find(".popup-bg").css("height", $("#auth-block").css("height"));
    }

    function hideAuth(){
        $('.auth-popup').fadeOut();
        $('.msg').remove();
    }

    function showPass(){

        $('#auth-block').hide();
        $('.msg').remove();

        $('#pass-rec').fadeIn();//.parent().parent().find(".popup-bg").css("height",$("#pass-rec").css("height"));
        document.forms['loginreminder'].txtpwdrem.value = 1;

    }

    function hidePass(){
        $('#pass-rec').fadeOut();
        document.forms['loginreminder'].txtpwdrem.value = 0;
        $('.msg').remove();
    }

    function centerBlock(block){
        var whight = $(window).height(),
            bhight = $(block).height();
        $(block).css({
           'top' : (whight - bhight)/2
        })
    }





    var galleries = $('.ad-gallery').adGallery({
  loader_image: '/assets/templates/bsdm/images/loader.gif',
  width: 340, // Width of the image, set to false and it will read the CSS width
  height: 254, // Height of the image, set to false and it will read the CSS height
  thumb_opacity: 0.7, // Opacity that the thumbs fades to/from, (1 removes fade effect)
                      // Note that this effect combined with other effects might be resource intensive
                      // and make animations lag
  start_at_index: 0, // Which image should be displayed at first? 0 is the first image
  description_wrapper: false, // Either false or a jQuery object, if you want the image descriptions
                                           // to be placed somewhere else than on top of the image
  animate_first_image: false, // Should first image just be displayed, or animated in?
  animation_speed: 400, // Which ever effect is used to switch images, how long should it take?
  display_next_and_prev: false, // Can you navigate by clicking on the left/right on the image?
  display_back_and_forward: false, // Are you allowed to scroll the thumb list?
  scroll_jump: 0, // If 0, it jumps the width of the container
  slideshow: {
    enable: true,
    autostart: true,
    speed: 5000,
    start_label: 'Start',
    stop_label: 'Stop',
    stop_on_scroll: true, // Should the slideshow stop if the user scrolls the thumb list?
    countdown_prefix: '(', // Wrap around the countdown
    countdown_sufix: ')',
    onStart: function() {
      // Do something wild when the slideshow starts
    },
    onStop: function() {
      // Do something wild when the slideshow stops
    }
  },
  effect: 'fade', // or 'slide-vert', 'resize', 'fade', 'none' or false
  enable_keyboard_move: true, // Move to next/previous image with keyboard arrows?
  cycle: true, // If set to false, you can't go from the last image to the first, and vice versa
  // All callbacks has the AdGallery objects as 'this' reference
  callbacks: {
    // Executes right after the internal init, can be used to choose which images
    // you want to preload
    init: function() {
      // preloadAll uses recursion to preload each image right after one another
      //this.preloadAll();
        

    },
    // This gets fired right after the new_image is fully visible
    afterImageVisible: function() {
      // For example, preload the next image
      //var context = this;


      //this.loading(true);
     // this.preloadImage(this.current_index + 1,
     //   function() {
          // This function gets executed after the image has been loaded
         // context.loading(false);
      //  }
     // );
    },
    // This gets fired right before old_image is about to go away, and new_image
    // is about to come in
    beforeImageVisible: function(new_image, old_image) {
      // Do something wild!
    }
  }
});


$('a[rel=gallery]').live('click', function() {
  url = this.href; // this is the url of the element event is triggered from
  $.fn.colorbox({href: url,photo :true});
  return false;
});



});


function fillCartCallback(el){

    //$(el).hide();
};
