// jQuery functions v.1.0

function initMenu() {

};

    Cufon.replace("h1, h2, h3, h4, h5, h6", {'hover':true, 'fontFamily':'Gotham-Medium'});
    /* garamond semi bold and regular have been bundled in one 54k js file
     * use both typefaces where needed and set weight with the Cufon fontWeight either 400 or 600
     * property (as seen below)
     */
	Cufon.replace(".contactForm p, .contactForm label, #sidebar li", {'hover':true, 'fontFamily':'Adobe Garamond Pro', 'fontWeight':400});
    Cufon.replace(".topNavitation li, ul#menu li a, .navigation ul li, .accordationMenu .btn", {'hover':true, 'fontFamily':'Gotham-Medium'});
    /* if performance is an issue, turn Cufon below off*/
    Cufon.replace('.inside p',{'fontFamily':'Adobe Garamond Pro', 'fontWeight':400});

/**
 * accordionCustomHover()
 * @returns Nothing
 * this function is meant to overcom any cufon hover issues
 * it implements a custom hover event
 * firstly it sets all elements to the desired font
 * after it binds hover and hover out events
 * on hover it adds an attribute to the element
 * so that cufon nows to style ONLY that element
 * with the hover color (font must be reapplied to)
 * on hover out the color is reverted, font reapplied
 * and the ID attribute is removed so that no cufon will
 * accidentally restyle the wrong element
**/

function accordionCustomHover(){

   Cufon.replace('.acc-header',{
       'fontFamily' : 'Gotham-Medium'
     });

  $('.acc-header').hover(
  function(){
     $(this).attr('id' , 'cufonStyleThis');
     Cufon.replace('#cufonStyleThis',{
       'fontFamily' : 'Gotham-Medium',
       'color' : '#fff'
     });
  },
  function(){
    if($('#cufonStyleThis').hasClass('ui-state-active')){
      //do nothing
    }else{
      //revert to black type
       Cufon.replace('#cufonStyleThis',{
       'fontFamily' : 'Gotham-Medium',
       'color' : '#000'
       });
    }
     $(this).removeAttr('id');
  });
}

/**
 * accordionSelectedHeader()
 * @returns Nothing
 * this function runs when the animation on
 * the accordion has ended
 * it checks the headers for the css ui-state-active class
 * (meaning the accordion pane is open)
 * if the header has the ui-state-active class Cufon will
 * style it white, otherwise it will style it black
**/

function accordionSelectedHeader(){

  $('.acc-header').each(function(){
     if($(this).hasClass('ui-state-active')){
       $(this).attr('id', 'cufonStyleThis');
       //revert to black type
       Cufon.replace('#cufonStyleThis',{
       'fontFamily' : 'Gotham-Medium',
       'color' : '#FFF'
       });
       $(this).removeAttr('id');
     }else{
       $(this).attr('id', 'cufonStyleThis');
       //revert to black type
       Cufon.replace('#cufonStyleThis',{
       'fontFamily' : 'Gotham-Medium',
       'color' : '#000'
       });
       $(this).removeAttr('id');
     }
  });
}

$(document).ready(function(){
	/* cufon text */
    Cufon.now();
	/* books page - accordation menu */

    initMenu();
	
	/* navigation */
	$(".navigation ul li:last").css({margin:"0"});

/*
	$(".navigation ul li a").append("<span class='menubg'></span>");
	$(".navigation ul li a").hover(function(){
		$(this).append("<span class='menubg'></span>");
	},function(){
		$('.menubg').remove();
	});
	$(".navigation ul li a.active").append("<span class='menubg'></span>").hover(function(){
		$(this).append("<span class='menubg'></span>");																				  
	});
*/

	/* top navigation */
	$("#header .topNavitation li:last").css({border:"none", padding:"0 0 0 8px"});
	
	/* textarea resizer */

});

