// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --
//
// Title : script.js
// Author : ThemeShaper
// URL : http://www.theme-shaper.net
//
// Description : Theme Scriptin
//
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
	

jQuery(document).ready(function () {

/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
// STYLING DYNAMIC SCRIPT + CSS SETUP
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

	var a=navigator.userAgent.toLowerCase();jQuery.browser.chrome=/chrome/.test(navigator.userAgent.toLowerCase());if(jQuery.browser.msie){jQuery('body').addClass('browserIE');jQuery('body').addClass('browserIE'+jQuery.browser.version.substring(0,1))}if(jQuery.browser.chrome){jQuery('body').addClass('browserChrome');a=a.substring(a.indexOf('chrome/')+7);a=a.substring(0,1);jQuery('body').addClass('browserChrome'+a);jQuery.browser.safari=false}if(jQuery.browser.safari){jQuery('body').addClass('browserSafari');a=a.substring(a.indexOf('version/')+8);a=a.substring(0,1);jQuery('body').addClass('browserSafari'+a)}if(jQuery.browser.mozilla){if(navigator.userAgent.toLowerCase().indexOf('firefox')!=-1){jQuery('body').addClass('browserFirefox');a=a.substring(a.indexOf('firefox/')+8);a=a.substring(0,1);jQuery('body').addClass('browserFirefox'+a)}else{jQuery('body').addClass('browserMozilla')}}if(jQuery.browser.opera){jQuery('body').addClass('browserOpera')}

	jQuery('a[href=#top]').click(function(){
    jQuery('html, body').animate({scrollTop:0}, 800, 'easeOutQuint');
      return false;
    });
	
	//jQuery('.menu ul li ul li a').addClass('letterpress');
	jQuery('.flickr_badge_image').addClass('thumb-rollover');	
	jQuery('.flickr_badge_image img').addClass('large-wide-frame');
	jQuery('#accordion').css({"visibility":"hidden"}); //little hack to deal with the accordion and its somewhat ungraceful loading
  	jQuery('#accordion').parent().parent().addClass('accordion-holder ');
    jQuery('.comment-reply-link').addClass('arrow-link letterpress caps button_link small');	 //force styling onto comment-reply-link (grrr)
		
	//FOUC I am latching this onto modernizr for now.
	
	jQuery('.js h1, .js h2,.js h3,.js h4,.js h5,.js h6, .js .cuf, #slider-holder,.js #myslidemenu a,.js #fullcolumn img').css({'visibility':'visible'}); 
		
	// TABS
	jQuery("ul.tabs").tabs("> .content");
	
	//TOGGLES
	jQuery(".toggle .header_box").hide(); 

	jQuery(".toggle h3").toggle(function(){
		jQuery(this).addClass("minus");
		jQuery(this).removeClass("plus");
		}, function () {
		jQuery(this).addClass("plus");
		jQuery(this).removeClass("minus");
	});

	jQuery(".toggle h3").click(function(){
		
		jQuery(this).parent().next(".header_box").slideToggle();
	});
	
 	//SET UP THUMBNAILS AND GENERATE CLASSES
    jQuery('.rollover').each(function () {
		jQuery(this).addClass('preloader');
        jQuery('.caption', this).addClass('sleek-black').wrapInner('<div class="caption-header cuf caps no-arrow">');
        jQuery('.caption', this).append('<span class= "white-magnify"></span>');
        jQuery('.caption', this).css({
            opacity: 0
        }, 400);
    });
    jQuery('.thumb-rollover').each(function (index) {
		 jQuery(this).addClass('preloader');
        var width = jQuery('.large-wide-frame', this).outerWidth();
        var height = jQuery('.large-wide-frame', this).outerHeight();
        jQuery('a', this).append('<span class= "thumb-magnify" style="width:' + width + 'px;height:' + height + 'px"></span>');
    });
	
    var start = (jQuery('img', this).outerHeight()) * -1 - 150;
    jQuery('.thumb-magnify').css({
        top: +start
    });09

	jQuery.expr[':'].focus = function( elem ) {
	  return elem === document.activeElement && ( elem.type || elem.href );
	};
	
	//SMALL THUMB ROLLOVERS
    jQuery('.thumb-rollover').hover(function () {
        var height = jQuery('img', this).outerHeight();
        jQuery('img', this).stop().animate({
            opacity: 0.5
        }, 400);
        jQuery('.thumb-magnify', this).css({
            top: 3,
            left: 2
        });
    }, function () {
        var height = jQuery('img', this).outerHeight();
        jQuery('img', this).stop().animate({
            opacity: 1
        }, 400);
        jQuery('.thumb-magnify', this).css({
            top: -height / 2 - 20
        });
    });
	

	var ie8 = $.browser.msie && +$.browser.version == 8; //had to use this, cufon not fading out on portfolios / rollovers properly on ie, unless include a left animation too :( (grr)

	if ( ie8 ) 
	{
		 jQuery('.rollover').live({
			mouseenter:
			   function()
			   {
					jQuery("a[rel^='prettyPhoto']").prettyPhoto({animation_speed: 'slow'});
					var captionheight = jQuery('.caption', this).height();
					var imageheight = jQuery('img', this).height();
					var captionposn = (imageheight) * .5 - (15);
					
					jQuery('.caption', this).stop().css({
						top: captionposn,
						width: "50%"
					}).animate({
						opacity: 1,
						width: "66%",
						left:0
					}, 400).animate({
						left:0
					}, 0);
					jQuery('img', this).stop().animate({
						opacity: 0.7
					}, 400);
			   },
			mouseleave:
			   function()
			   {
					var imageheight = jQuery('img', this).outerHeight();
					jQuery('img', this).stop().animate({
						opacity: 1
					}, 400);
					jQuery('.caption', this).stop().animate({
						opacity: 0,
						width: "50%"
					}, 400).animate({
						left:-150
					}, 0);
			   }
		   }
		);
	}
	else
	{
		jQuery('.rollover').live({
			mouseenter:
			   function()
			   {
					jQuery("a[rel^='prettyPhoto']").prettyPhoto({animation_speed: 'slow'});
					var captionheight = jQuery('.caption', this).height();
					var imageheight = jQuery('img', this).height();
					var captionposn = (imageheight) * .5 - (15);
					
					jQuery('.caption', this).stop().css({
						top: captionposn,
						width: "50%"
					}).animate({
						opacity: 1,
						width: "66%",
						left:0
					}, 400);
					jQuery('img', this).stop().animate({
						opacity: 0.7
					}, 400);
			   },
			mouseleave:
			   function()
			   {
					var imageheight = jQuery('img', this).outerHeight();
					jQuery('img', this).stop().animate({
						opacity: 1
					}, 400);
					jQuery('.caption', this).stop().animate({
						opacity: 0,
						width: "50%"
					}, 400);
				}
		   }
		);
	}
	if(jQuery('.gallery-container').hasClass('lightbox'))
	{
		jQuery('.gallery-item a').attr('rel', 'prettyphoto[gall]');
	}
	jQuery("a[rel^='prettyPhoto']").prettyPhoto();

	//PORTFOLIOS	
	jQueryclientsHolder = jQuery('ul.portfolio');
	jQueryclientsClone = jQueryclientsHolder.clone(); 
 
	jQuery('.filterPortfolio a').click(function(e) {
    e.preventDefault();
 
    jQueryfilterClass = jQuery(this).attr('class');
 
    jQuery('.filterPortfolio li').removeClass('active');
    jQuery(this).parent().addClass('active');
 
    if(jQueryfilterClass == 'all'){
        jQueryfilters = jQueryclientsClone.find('li');
    } else {
        jQueryfilters = jQueryclientsClone.find('li[data-type~='+ jQueryfilterClass +']');
    }
	
 	
    jQueryclientsHolder.quicksand(jQueryfilters, {
        duration: 800,
        easing: 'easeOutQuad',
		enhancement: function() {
			jQuery('.preloader').css({'background-image':'none'});
      		Cufon.replace('.gallery.cuf,.gallery h4');
			Cufon.replace('.gallery .letterpress', { hover: 'true' , textShadow: '1px 1px white'});
   		}
    });
	});

	jQuery('#content').preloader();
	//IMAGE ROLLOVERS

	//ACCORDION ROLLOVER
	jQuery('#accwrapper .subtle-white .arrow').hover(
    function () {
        jQuery(this).addClass('arrow-down');
    }, function () {
		
       		jQuery(this).removeClass('arrow-down');
		
    });

    
	//ACCORDION BUTTON ACTION	
    jQuery('div.accordionButton').click(function () {

        jQuery('#accwrapper .accordionButton').removeClass('sleek-black').addClass('subtle-white');
        jQuery('#accwrapper .arrow-down').removeClass('arrow-down').addClass('arrow');
        jQuery(this).removeClass('subtle-white').addClass('sleek-black');
        jQuery('.arrow', this).removeClass('arrow').addClass('arrow-down');
        jQuery('.accordionContent').slideUp();

        Cufon.replace('.header-content-left');
        jQuery(this).next().slideDown();
    });
	
    //HIDE THE DIVS ON PAGE LOAD	
    jQuery("div.accordionContent").hide();
    jQuery("#open").trigger('click');
    jQuery.easing.def = "easeOutQuad";
	
   //PRETTYPHOTO
   jQuery("a[rel^='prettyPhoto']").prettyPhoto({animation_speed: 'slow'});

  
});


$(window).load(function() { //accordion display hack
    jQuery('#accordion').css({"visibility":"visible"});
 	jQuery('#accordion').parent().parent().removeClass('accordion-holder ');
});

