// usage: log('inside coolFunc', this, arguments);
// paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/
window.log = function(){
  log.history = log.history || [];   // store logs to an array for reference
  log.history.push(arguments);
  arguments.callee = arguments.callee.caller; 
  if(this.console) console.log( Array.prototype.slice.call(arguments) );
};
// make it safe to use console.log always
(function(b){function c(){}for(var d="assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info, log,markTimeline,profile,profileEnd,time,timeEnd,trace,warn".split(","),a;a=d.pop();)b[a]=b[a]||c})(window.console=window.console||{});
 
 
// place any jQuery/helper plugins in here, instead of separate, slower script files.

$(function($){
  if ($("body").hasClass("fullsize-img-bg")) {
  	if ($("body").hasClass("ss-about")) {
	    $.supersized({
	      //Functionality
	      slideshow            : 1,    //Slideshow on/off
	      start_slide          : 0,    //Start slide (0 is random)
	      random               : 1,    //Randomize slide order (Ignores start slide)
	      slide_interval       : 7000, //Length between transitions
	      transition           : 1,    //0-None, 1-Fade, 2-Slide Top, 3-Slide Right, 4-Slide Bottom, 5-Slide Left, 6-Carousel Right, 7-Carousel Left
	      transition_speed     : 500,  //Speed of transition
	      keyboard_nav         : 0,    //Keyboard navigation on/off
	      performance          : 1,    //0-Normal, 1-Hybrid speed/quality, 2-Optimizes image quality, 3-Optimizes transition speed // (Only works for Firefox/IE, not Webkit)
	                           
	      //Size & Position      
	      fit_portrait         : 0,    //Portrait images will not exceed browser height
	    
	      //Components
	      navigation           : 0,    //Slideshow controls on/off
	      slide_counter        : 0,    //Display slide numbers
	      slide_captions       : 0,    //Slide caption (Pull from "title" in slides array)
	      slides  :  [ { image : '/-/img/slideshow/BG_women_store_01.jpg' },
	      { image : '/-/img/slideshow/BG_women_store_02.jpg' },
	      { image : '/-/img/slideshow/BG_women_store_04.jpg' },
	      { image : '/-/img/slideshow/BG_women_store_03.jpg' }]
	    });
	 } 
	 
	 else if ($("body").hasClass("ss-video")) {
	 	

     } else {
	    $.supersized({
	      //Functionality
	      slideshow            : 1,    //Slideshow on/off
	      start_slide          : 1,    //Start slide (0 is random)
	      random               : 0,    //Randomize slide order (Ignores start slide)
	      slide_interval       : 7000, //Length between transitions
	      transition           : 1,    //0-None, 1-Fade, 2-Slide Top, 3-Slide Right, 4-Slide Bottom, 5-Slide Left, 6-Carousel Right, 7-Carousel Left
	      transition_speed     : 500,  //Speed of transition
	      keyboard_nav         : 0,    //Keyboard navigation on/off
	      performance          : 1,    //0-Normal, 1-Hybrid speed/quality, 2-Optimizes image quality, 3-Optimizes transition speed // (Only works for Firefox/IE, not Webkit)
	                           
	      //Size & Position      
	      fit_portrait         : 0,    //Portrait images will not exceed browser height
	    
	      //Components
	      navigation           : 0,    //Slideshow controls on/off
	      slide_counter        : 0,    //Display slide numbers
	      slide_captions       : 0,    //Slide caption (Pull from "title" in slides array)
	      slides  :  [ { image : '/-/img/slideshow/BG_anzeige_102011.jpg' }]
	    });
	 };
  };
 
  function runEffect(container) {
    var effect    = "slide";
    var box       = "#content-box-" + container
    var tclass    = "#control-" + container

    var options   = { direction : "up" };

    $( box ).toggle( effect, options, 500 );
    $( tclass ).toggleClass( "transparent", 500 );
  };

  function renameLabel(flip, obj) {
    if (flip % 2 == 0) {
      obj.innerHTML = "einblenden +"
    } else {
      obj.innerHTML = "ausblenden &mdash;"
    }
  };

  var flipAboutUs = 0;
  $( "#btn-about-us" ).click(function() {
    renameLabel(flipAboutUs++, this);
    runEffect("about-us");
    return false;
  });

  var flipStores = 0;
  $( "#btn-stores" ).click(function() {
    renameLabel(flipStores++, this);
    runEffect("stores");
    return false;
  });
  
  var flipSidebar = 0;
  $( "#btn-sidebar" ).click(function() {
    if (flipSidebar++ % 2 == 0) {
      this.innerHTML = "Menü zuklappen"
      this.style.backgroundImage = "url('/-/img/btn-sidebar-control-down.png')";
    } else {
      this.innerHTML = "Menü ausklappen"
      this.style.backgroundImage = "url('/-/img/btn-sidebar-control-up.png')";
    }
    
    var effect    = "slide";
    var options   = { direction : "up" };
    
    $( ".aside-inner" ).toggle( effect, options, 500 );
    
    return false;
  });
  
  $("a.overlay").fancybox({
    'padding'        : '0',
    'width'          : '640',
    'autoDimensions' : 'false',
    'centerOnScroll' : 'true',
    'transitionIn'   : 'fade',
    'transitionOut'  : 'fade',
    'speedIn'        : 600, 
    'speedOut'       : 200
  });
  
  $("a.iframe").fancybox({
    'padding'        : '0',
    'width'          : 660,
    'height'         : 500,
    'autoScale'      : 'false',
    'centerOnScroll' : 'true',
    'transitionIn'   : 'fade',
    'transitionOut'  : 'fade',
    'speedIn'        : 600, 
    'speedOut'       : 200,
    'type'           : 'iframe'
  });
  
});

