/* ******************************************************
     Datei fancybox_custom.jss fuer niggemann.de
     steuert die Fancybox
     created:    27.08.2010            
     created by: c. majert          
  ****************************************************** */
$(document).ready(function() {
  
   /* *** LoginFormular ******************************** */
   $("#shop").fancybox({
      'scrolling'      : 'no',
      'width'          : 300,
      'height'         : 340,
      'autoScale'      : true,
      /*'transitionIn' : 'none',
      'transitionOut'  : 'none',*/
      'type'           : 'iframe',
      'onStart': function(){ 
         $('#fancybox-outer').addClass('grey'); 
        }, 
      'onClosed':function() { 
         $('#fancybox-outer').removeClass('grey'); 
        } 
   });
  
   /* *** Sharebox mit Infos ********************** */  
   $(".showShare").fancybox({
      'scrolling'      : 'no',
      'titleShow'      : false,
      'hideOnOverlayClick'  : true,
      'onStart': function(){ 
         $('#fancybox-outer').addClass('grey'); 
        }, 
      'onClosed':function() { 
         $('#fancybox-outer').removeClass('grey'); 
        }
   });
        
   /* *** Login intern ******************************** */   
   /*$("#shop2").fancybox({
      'scrolling'      : 'no',
      'titleShow'      : false,
      'hideOnOverlayClick'  : false,
      'onClosed'      : function() {
         $("#login_error").hide();
       }
   });*/
      
   /* *** Passwort vergessen ************************ */
   /*$("#pwv").fancybox({
      'scrolling'      : 'no',
      'width'        : 300,
      'height'        : 340,
      'autoScale'      : true,
      'hideOnOverlayClick'  : false,
      'transitionIn'    : 'none',
      'transitionOut'    : 'none',
      'type'        : 'iframe',
      'onStart': function(){ 
         $('#fancybox-outer').addClass('grey'); 
      }, 
      'onClosed':function() { 
         $('#fancybox-outer').removeClass('grey'); 
      } 
   });*/
      
   $("a.fancy").fancybox({      
      'titlePosition'    : 'inside',
      'titleFormat'      : function(title) {
         return '<p class="p_fancy">' + (title.length ? title : '') + '&nbsp;</p>';
         }
   });
      
   $("a.fancygal").fancybox({      
      'titlePosition'    : 'inside',
      'titleFormat'      : function(title, currentArray, currentIndex, currentOpts) {
         return '<p class="p_fancy"><span>Bild ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' </span><br /> ' + title : '') + '</p>';
         }
   });
      
   /*$("a.fancyinline").fancybox({
      'titlePosition'   : 'inside',
      'transitionIn'    : 'none',
      'transitionOut'   : 'none',
      'titleFormat'     : function(title) {
         return '<p class="p_fancy"><strong>' + (title.length ? title : '') + '</strong></p>';
         }
   });*/


/* *** Bildwechsel in Galerien ******************************** */
   var points =  $('.galChange');
   var galimages = $('.galImages div');
   var galtexte = $('.galTexte div');

   $('.galImages div').addClass('hideImg');
   $('.galImages div:eq(0)').removeClass('hideImg');
   $('.galImages div:eq(0)').addClass('showImg');
   $('.galTexte div').addClass('hideImg');
   $('.galTexte div:eq(0)').removeClass('hideImg');
   $('.galTexte div:eq(0)').addClass('showImg');

   var showImage = function(event){
      // get index for current image
      var index = points.index($(this));
      $('.galImages div').removeClass('showImg');
      $('.galImages div').addClass('hideImg');
      $('.galImages div:eq('+index+')').addClass('showImg');
      $('.galTexte div').removeClass('showImg');
      $('.galTexte div').addClass('hideImg');
      $('.galTexte div:eq('+index+')').addClass('showImg');
      };

   var hideImage = function(event){
      var index = points.index($(this));
      $('.galImages div:eq('+index+')').addClass('hideImg');
      $('.galTexte div:eq('+index+')').addClass('hideImg');
      };

   points.hover(showImage,hideImage);    

   /*points.click(function(){
      galimages.removeClass("showImg");
      var index = points.index($(this));
      $('.galImg:eq('+index+')').addClass('showImg');
   });*/

/* *** Videodarstellung Flash ************************************** */
   $(".video").click(function() {
      $.fancybox({
         'padding'       : 10,
         'autoScale'     : false,
         'transitionIn'  : 'none',
         'transitionOut' : 'none',
         'titleShow'     : 'true',
         'titlePosition' : 'inside',
         'title'         : this.title,
         'href'          : this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
         'type'          : 'swf',
         'swf'           : {
            'wmode'           : 'opaque',
            'allowfullscreen' : 'true'
         }
      });
      return false;
   });
  
/* *** Videodarstellung Vimeo ************************************** */  
   $("a.vimeo").click(function() {
     $.fancybox({
        'padding'         : 10,
        'autoScale'       : false,
        'transitionIn'    : 'none',
        'transitionOut'   : 'none',
        'titleShow'       : 'true',
        'titlePosition'   : 'inside',
        'title'           : this.title,
        /*'width'           : 800,
        'height'          : 450,*/
        'href'            : this.href.replace(new RegExp("([0-9])","i"),'moogaloop.swf?clip_id=$1'),  
        'type'            : 'swf',
        'swf'             : {
           'wmode'           : 'opaque',
           'allowfullscreen' : 'true'
        }
     });
     return false;
   });
  
});
