/*


  master javascript file for popsforchamgapgne.com
  v 1.0
  
  author: bryan@bryanlademann.com
------------------------------------------------------------ */


/* cufon replacements -----------
------------------------------ */
var CufonLoad = {};
CufonLoad.init = function() {
  Cufon
    .replace('#global a', { hover: true, fontFamily: 'Brandon Grotesque Bold' })
      ('#slidecaption', { hover: true, fontFamily: 'Brandon Grotesque Bold' })
      ('#menus dl dt', { hover: true, fontFamily: 'Brandon Grotesque Bold' });
}



/* gallery navigation -----------
------------------------------ */
var GalleryNav = {};
GalleryNav.init = function() {

  var nav   = jQuery('.gallery-nav', '#content-main .gallery'),
      link  = nav.find('a'),
      landmark = nav.find('a.landmark');
      panes = jQuery('.pane', '#content-main .gallery');
      

  

  link.bind('click', function() {
        
    var $this       = jQuery(this),
        destination = $this.attr('href'); 
    
    if( $this.hasClass('landmark') ) { 
      return false; 
    } else {

      link.removeClass('landmark');
      $this.addClass('landmark');
  
  		jQuery(panes).fadeOut(350) // when clicked previous images fade from view
  		jQuery(destination).fadeIn(400); // then the new image slowly appears in 800 milliseconds
  
      return false;
    }      
  })
} 



/* modal windows ----------------
------------------------------ */

var ModalWindow = {};
ModalWindow.init = function(){

  //select all the a tag with name equal to modal
  jQuery('a[name=modal]').bind('click', function(e) {

      //Get the A tag
      var id = jQuery(this).attr('href');
   
      jQuery('body').append('<div id="mask"></div>');

     //transition effect    
      jQuery('#mask').fadeIn(150);
        
      //transition effect
      jQuery(id).fadeIn(150); 

      //Cancel the link behavior
      e.preventDefault();   

/*
      //if mask is clicked 
      jQuery('#mask').bind('click', function () {
      jQuery(id).fadeOut(350);
        jQuery(this).fadeOut(350).remove();
      }); 
*/
      //if close button is clicked
      jQuery('.close', '.modal').bind('click', function (e) {
        //Cancel the link behavior
        e.preventDefault();
        jQuery(id).fadeOut(350);
        jQuery('#mask').fadeOut(350).remove();
      });     

  });
     
}



/* jQuery init calls -----------------------------------------
------------------------------------------------------------*/
jQuery(function($) { 

  CufonLoad.init();
  GalleryNav.init();
  ModalWindow.init();

});
