/*  LOVIS
 *  File: lovis.js
 *  Abstract: javascript for lovis.de
 
 *  Version: 1
 *  (cc) Team Tejat Hamburg 2009/ marcwright.de
 */

  jQuery.noConflict();
  
      
      /* some pre-loads */
      if (document.images)
             {
               pre = new Image();
               pre_image_url = new Array();
               
               pre_image_url[0] = '/wp-content/themes/lovis/images/pola.png';
               pre_image_url[1] = '/wp-content/themes/lovis/images/termine_before.png';
               pre_image_url[2] = '/wp-content/themes/lovis/images/termine_after.png';
               pre_image_url[3] = '/wp-content/themes/lovis/images/krepp.png';
               pre_image_url[4] = '/wp-content/themes/lovis/images/playing.png';
               pre_image_url[5] = '/wp-content/themes/lovis/images/stopping.png';
               
               var i = 0;
               for(i=0; i<= 5; i++) 
               pre.src = pre_image_url[i];
      }
      
jQuery(window).load(function() {
  /* count elemets; >2 init cycle */
  numImages = jQuery('#inner_images').children().size();
  if(numImages >= 2 ){
          /* show play/ pause*/
          jQuery("#pp").fadeIn('fast');
          /* init cycle */
          jQuery('#inner_images').each(function() {
      
              jQuery(this)
                .cycle({ 
                    fx:                 'fade',
                    random:             0,        // true for random, false for sequence (not applicable to shuffle fx) 
                    delay:              10,       // additional delay (in ms) for first transition (hint: can be negative)
                    speed:              0,     // speed of the transition (any valid fx speed value) 
                    timeout:            15000,    // milliseconds between slide transitions (0 to disable auto advance) 
                    pause:              true,     // true to enable "pause on hover" 
                    pauseOnPagerHover:  1,        // true to pause when hovering over pager link 
                    pager:              '#pager',
                    next:               '.ffw',
                    prev:               '#nav_overlay',
                    fastOnEvent:        1
          });
          
          
        });
        
         
  } // end if
  
})

jQuery(document).ready(function(){
    jQuery('#inner_images').fadeIn(3000);
    
      /* intro bg */
      jQuery(function(){  
        jQuery.fn.supersized.options = {  
            startwidth: 1440,
            startheight: 900,
            slideshow: 0      // 1 = slideshow on, anything else = off
        };
        jQuery('#supersize').supersized();  
      });
    jQuery("#pp").click(function(){
        playpauseevent();
        
      })
      
      jQuery("ul#ul_6 a").css({textDecoration: "none" })
      
      var bigCloudSpeed = 20000;
      
      
      /* ------------------------- ------------------------------*/
      /* 0.) */
      jQuery("#cloud_big").animate({
          left: '+=100'
        }, bigCloudSpeed, function() {
          reverseBigCloudTop();
      });
      
      /* 1.) */
      function reverseBigCloudTop(){
        jQuery("#cloud_big").animate({
            top: '-=50'
          }, bigCloudSpeed, function() {
            reverseBigCloudLeft();
          });
      }
      
      /* 2.) */
      function reverseBigCloudLeft(){
        jQuery("#cloud_big").animate({
            left: '-=100'
          }, bigCloudSpeed, function() {
            reverseBigCloudTopDown();
          });
      }
      
      /* 3.) */
      function reverseBigCloudTopDown(){
        jQuery("#cloud_big").animate({
            top: '+=50'
          }, bigCloudSpeed, function() {
            reverseBigCloudRight();
          });
      }
      
      /* 4.) */
      function reverseBigCloudRight(){
        jQuery("#cloud_big").animate({
            left: '+=100'
          }, bigCloudSpeed, function() {
            reverseBigCloudTop();
          });
      }
      /* ------------------------- ------------------------------*/
      
      
      
      
});


/* play stop slideshow */
var PLAY = 0;
function playpauseevent(){
  if(PLAY==1){
    jQuery('#inner_images').cycle('resume', true);
    jQuery('#pp').html('<img src="/wp-content/themes/lovis/images/playing.png" />');
    PLAY = 0;
  }else{
    jQuery('#inner_images').cycle('pause');
    jQuery('#pp').html('<img src="/wp-content/themes/lovis/images/stopping.png" />');
    PLAY = 1;
    }
}


/* the key bindings */
jQuery(document).keydown(function (e) {
      /* space */
      if (e.which == 32 ) {
        /* slideshow play & pause */
        playpauseevent();
      } 
      
      /* right */
      if (e.which == 39) {
        jQuery(".ffw").trigger('click');
        jQuery('#inner_images').cycle('pause');
        PLAY = 1;
      /* left */
      } 
       if (e.which == 37) {
        jQuery("#nav_overlay").trigger('click');
        jQuery('#inner_images').cycle('pause');
        PLAY = 1;
      }
});

function lovisEnDetail(popup2) {
  OpenWin = this.open(popup2, "CtrlWindow2", "toolbar=no,menubar=no,location=no,scrollbars=no,resize=yes, status=yes, width=1000,height=760");
}

