/*
* Information about scripts in truethemes_framework/global/javascript.php
*/

var TTjquery = jQuery.noConflict();

/* ------------------------------------------------------------------------
Main Navigation
 * ------------------------------------------------------------------------- */
TTjquery(document).ready(function () {
    initScrollTop(); //initialise scroll top
    //accordion and tabs initialisation moved to shortcode.php, dynamically generated by shortcode.
});

function initNav() {
    var nav = TTjquery("#menu-main-nav");
    var duration = 260;
    TTjquery(nav).find(".sub-menu").css({
        left: 0
    });
    TTjquery(nav).find("> li").each(function () {
        var height = TTjquery(this).find("> .drop").height();
        TTjquery(this).find("> .drop").css({
            display: "none",
            height: 0,
            overflow: "hidden"
        });
        TTjquery(this).find(".drop li > .drop").css({
            display: "none",
            width: 0
        });
        if (!TTjquery.browser.msie) {
            TTjquery(this).find("> .drop").css({
                "opacity": 0
            });
            TTjquery(this).find(".drop li > .drop").css({
                "opacity": 0
            })
        }
        TTjquery(this).mouseenter(function () {
            TTjquery(this).addClass("hover");
            var drop = TTjquery(this).find("> .drop");
            if (TTjquery.browser.msie) {
                TTjquery(drop).css({
                    display: "block"
                }).stop().animate({
                    "height": height
                }, duration, function () {
                    TTjquery(this).css({
                        "overflow": "visible"
                    })
                })
            } else {
                TTjquery(drop).css({
                    display: "block"
                }).stop().animate({
                    "height": height,
                    "opacity": 1
                }, duration, function () {
                    TTjquery(this).css({
                        "overflow": "visible"
                    })
                })
            }
        }).mouseleave(function () {
            var _this = TTjquery(this);
            if (TTjquery.browser.msie) {
                TTjquery(this).find("> .drop").stop().css({
                    "overflow": "hidden"
                }).animate({
                    "height": 0
                }, duration, function () {
                    TTjquery(_this).removeClass("hover")
                })
            } else {
                TTjquery(this).find("> .drop").stop().css({
                    "overflow": "hidden"
                }).animate({
                    "height": 0,
                    "opacity": 0
                }, duration, function () {
                    TTjquery(_this).removeClass("hover")
                })
            }
        });
        TTjquery(this).find(".drop ul > li ").mouseenter(function () {
            TTjquery(this).addClass("hover");
            var pageW = getPageSize()[2];
            if (pageW < TTjquery(this).offset().left + 236 * 2) {
                TTjquery(this).find("> .drop").css({
                    left: 'auto',
                    right: 236
                })
            }
            if (TTjquery.browser.msie) {
                TTjquery(this).find("> .drop").css({
                    display: 'block'
                }).stop().animate({
                    "width": 236
                }, duration, function () {
                    TTjquery(this).css({
                        overflow: 'visible'
                    })
                })
            } else {
                TTjquery(this).find("> .drop").css({
                    display: 'block'
                }).stop().animate({
                    "width": 236,
                    "opacity": 1
                }, duration, function () {
                    TTjquery(this).css({
                        overflow: 'visible'
                    })
                })
            }
        }).mouseleave(function () {
            TTjquery(this).removeClass("hover");
            if (TTjquery.browser.msie) {
                TTjquery(this).find("> .drop").stop().css({
                    overflow: 'hidden'
                }).animate({
                    width: 0
                }, duration, function () {
                    TTjquery(this).css({
                        display: 'none'
                    })
                })
            } else {
                TTjquery(this).find("> .drop").stop().css({
                    overflow: 'hidden'
                }).animate({
                    width: 0,
                    "opacity": 0
                }, duration, function () {
                    TTjquery(this).css({
                        display: 'none'
                    })
                })
            }
        })
    })
}



(function(B){B(document).ready(function(){var mainNav=B('#menu-main-nav');var lis=mainNav.find('li');var shownav=TTjquery("#menu-main-nav");lis.children('ul').wrap('<div class="c" / >');var cElems=B('.c');cElems.wrap('<div class="drop" / >');cElems.before('<div class="t"></div>');cElems.after('<div class="b"></div>');TTjquery(shownav).find(".sub-menu").css({display:"block"});initNav()})})(TTjquery);(function(C){C(document).ready(function(){TTjquery("#menu-main-nav li:has(ul)").addClass("parent")})})(TTjquery);





function getPageSize(){var xScroll,yScroll;if(window.innerHeight&&window.scrollMaxY){xScroll=document.body.scrollWidth;yScroll=window.innerHeight+window.scrollMaxY}else if(document.body.scrollHeight>document.body.offsetHeight){xScroll=document.body.scrollWidth;yScroll=document.body.scrollHeight}else if(document.documentElement&&document.documentElement.scrollHeight>document.documentElement.offsetHeight){xScroll=document.documentElement.scrollWidth;yScroll=document.documentElement.scrollHeight}else{xScroll=document.body.offsetWidth;yScroll=document.body.offsetHeight}var windowWidth,windowHeight;if(self.innerHeight){windowWidth=self.innerWidth;windowHeight=self.innerHeight}else if(document.documentElement&&document.documentElement.clientHeight){windowWidth=document.documentElement.clientWidth;windowHeight=document.documentElement.clientHeight}else if(document.body){windowWidth=document.body.clientWidth;windowHeight=document.body.clientHeight}if(yScroll<windowHeight){pageHeight=windowHeight}else{pageHeight=yScroll}if(xScroll<windowWidth){pageWidth=windowWidth}else{pageWidth=xScroll}return[pageWidth,pageHeight,windowWidth,windowHeight]}





/* ------------------------------------------------------------------------
Portfolio Image Fade
 * ------------------------------------------------------------------------- */

(function (TTjquery) {
    TTjquery(window).load(function () {

        	TTjquery('[class^="attachment"]').each(function(index){
			var t = TTjquery('[class^="attachment"]').length;
			if(t>0){ // if there is image length, we fade in
				TTjquery(this).delay(400*index).fadeIn(500);
				}  
     		});

   });
})(TTjquery);



/* ------------------------------------------------------------------------
Portfolio Image Hover
 * ------------------------------------------------------------------------- */
(function(TTjquery){TTjquery(document).ready(function(){TTjquery('.preload').hover(function(){TTjquery(this).children().first().children().first().stop(true);TTjquery(this).children().first().children().first().fadeTo('normal',.90)},function(){TTjquery(this).children().first().children().first().stop(true);TTjquery(this).children().first().children().first().fadeTo('normal',0)})})})(TTjquery);





/* ------------------------------------------------------------------------
Button Hover
 * ------------------------------------------------------------------------- */
if (TTjquery.browser.msie) { /* time to download a new browser */ } else {
TTjquery(document).ready(function(){TTjquery(".ka_button, #ka-submit, #searchform #searchsubmit, .ka-form-submit, #mc_signup #mc_signup_submit, .fade-me").hover(function(){TTjquery(this).stop().animate({opacity:0.7},250)},function(){TTjquery(this).stop().animate({opacity:1.0},250)})});
TTjquery(document).ready(function(){TTjquery(".social_icons a").hover(function(){TTjquery(this).stop().animate({opacity:0.65},200)},function(){TTjquery(this).stop().animate({opacity:1},200)})});
}









/* ------------------------------------------------------------------------
Scroll to Top
 * ------------------------------------------------------------------------- */
function initScrollTop(){var change_speed=1200;TTjquery('a.link-top').click(function(){if(!TTjquery.browser.opera){TTjquery('body').animate({scrollTop:0},{queue:false,duration:change_speed})}TTjquery('html').animate({scrollTop:0},{queue:false,duration:change_speed});return false})}








/* ------------------------------------------------------------------------
	Class: prettyPhoto
	Use: Lightbox clone for jQuery
	Author: Stephane Caron (http://www.no-margin-for-errors.com)
	Version: 3.1.2
------------------------------------------------------------------------- */
(function(TTjquery){TTjquery.prettyPhoto={version:'3.1.2'};TTjquery.fn.prettyPhoto=function(pp_settings){pp_settings=jQuery.extend({animation_speed:'normal',slideshow:5000,autoplay_slideshow:false,opacity:0.80,show_title:false,allow_resize:true,default_width:500,default_height:344,counter_separator_label:'/',theme:'light_square',horizontal_padding:20,hideflash:false,wmode:'transparent',autoplay:true,modal:false,deeplinking:false,overlay_gallery:false,keyboard_shortcuts:true,changepicturecallback:function(){},callback:function(){},ie6_fallback:true,markup:'<div class="pp_pic_holder"><div class="ppt">&nbsp;</div><div class="pp_top"><div class="pp_left"></div><div class="pp_middle"></div><div class="pp_right"></div></div><div class="pp_content_container"><div class="pp_left"><div class="pp_right"><div class="pp_content"><div class="pp_loaderIcon"></div><div class="pp_fade"><a href="#" class="pp_expand" title="Expand the image">Expand</a><div class="pp_hoverContainer"><a class="pp_next" href="#">next</a><a class="pp_previous" href="#">previous</a></div><div id="pp_full_res"></div><div class="pp_details"><div class="pp_nav"><a href="#" class="pp_arrow_previous">Previous</a><p class="currentTextHolder">0/0</p><a href="#" class="pp_arrow_next">Next</a></div><p class="pp_description"></p>{pp_social}<a class="pp_close" href="#">Close</a></div></div></div></div></div></div><div class="pp_bottom"><div class="pp_left"></div><div class="pp_middle"></div><div class="pp_right"></div></div></div><div class="pp_overlay"></div>',gallery_markup:'<div class="pp_gallery"><a href="#" class="pp_arrow_previous">Previous</a><div><ul>{gallery}</ul></div><a href="#" class="pp_arrow_next">Next</a></div>',image_markup:'<img id="fullResImage" src="{path}" />',flash_markup:'<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="{width}" height="{height}"><param name="wmode" value="{wmode}" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="{path}" /><embed src="{path}" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="{width}" height="{height}" wmode="{wmode}"></embed></object>',quicktime_markup:'<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" height="{height}" width="{width}"><param name="src" value="{path}"><param name="autoplay" value="{autoplay}"><param name="type" value="video/quicktime"><embed src="{path}" height="{height}" width="{width}" autoplay="{autoplay}" type="video/quicktime" pluginspage="http://www.apple.com/quicktime/download/"></embed></object>',iframe_markup:'<iframe src ="{path}" width="{width}" height="{height}" frameborder="no"></iframe>',inline_markup:'<div class="pp_inline">{content}</div>',custom_markup:'',social_tools:''},pp_settings);var matchedObjects=this,percentBased=false,pp_dimensions,pp_open,pp_contentHeight,pp_contentWidth,pp_containerHeight,pp_containerWidth,windowHeight=TTjquery(window).height(),windowWidth=TTjquery(window).width(),pp_slideshow;doresize=true,scroll_pos=_get_scroll();TTjquery(window).unbind('resize.prettyphoto').bind('resize.prettyphoto',function(){_center_overlay();_resize_overlay();});if(pp_settings.keyboard_shortcuts){TTjquery(document).unbind('keydown.prettyphoto').bind('keydown.prettyphoto',function(e){if(typeof TTjquerypp_pic_holder!='undefined'){if(TTjquerypp_pic_holder.is(':visible')){switch(e.keyCode){case 37:TTjquery.prettyPhoto.changePage('previous');e.preventDefault();break;case 39:TTjquery.prettyPhoto.changePage('next');e.preventDefault();break;case 27:if(!settings.modal)
TTjquery.prettyPhoto.close();e.preventDefault();break;};};};});};TTjquery.prettyPhoto.initialize=function(){settings=pp_settings;if(settings.theme=='pp_default')settings.horizontal_padding=16;if(settings.ie6_fallback&&TTjquery.browser.msie&&parseInt(TTjquery.browser.version)==6)settings.theme="light_square";theRel=TTjquery(this).attr('rel');galleryRegExp=/\[(?:.*)\]/;isSet=(galleryRegExp.exec(theRel))?true:false;pp_images=(isSet)?jQuery.map(matchedObjects,function(n,i){if(TTjquery(n).attr('rel').indexOf(theRel)!=-1)return TTjquery(n).attr('href');}):TTjquery.makeArray(TTjquery(this).attr('href'));pp_titles=(isSet)?jQuery.map(matchedObjects,function(n,i){if(TTjquery(n).attr('rel').indexOf(theRel)!=-1)return(TTjquery(n).find('img').attr('alt'))?TTjquery(n).find('img').attr('alt'):"";}):TTjquery.makeArray(TTjquery(this).find('img').attr('alt'));pp_descriptions=(isSet)?jQuery.map(matchedObjects,function(n,i){if(TTjquery(n).attr('rel').indexOf(theRel)!=-1)return(TTjquery(n).attr('title'))?TTjquery(n).attr('title'):"";}):TTjquery.makeArray(TTjquery(this).attr('title'));set_position=jQuery.inArray(TTjquery(this).attr('href'),pp_images);rel_index=(isSet)?set_position:TTjquery("a[rel^='"+theRel+"']").index(TTjquery(this));_build_overlay(this);if(settings.allow_resize)
TTjquery(window).bind('scroll.prettyphoto',function(){_center_overlay();});TTjquery.prettyPhoto.open();return false;}
TTjquery.prettyPhoto.open=function(event){if(typeof settings=="undefined"){settings=pp_settings;if(TTjquery.browser.msie&&TTjquery.browser.version==6)settings.theme="light_square";pp_images=TTjquery.makeArray(arguments[0]);pp_titles=(arguments[1])?TTjquery.makeArray(arguments[1]):TTjquery.makeArray("");pp_descriptions=(arguments[2])?TTjquery.makeArray(arguments[2]):TTjquery.makeArray("");isSet=(pp_images.length>1)?true:false;set_position=0;_build_overlay(event.target);}
if(TTjquery.browser.msie&&TTjquery.browser.version==6)TTjquery('select').css('visibility','hidden');if(settings.hideflash)TTjquery('object,embed,iframe[src*=youtube],iframe[src*=vimeo]').css('visibility','hidden');_checkPosition(TTjquery(pp_images).size());TTjquery('.pp_loaderIcon').show();if(TTjqueryppt.is(':hidden'))TTjqueryppt.css('opacity',0).show();TTjquerypp_overlay.show().fadeTo(settings.animation_speed,settings.opacity);TTjquerypp_pic_holder.find('.currentTextHolder').text((set_position+1)+settings.counter_separator_label+TTjquery(pp_images).size());if(pp_descriptions[set_position]!=""){TTjquerypp_pic_holder.find('.pp_description').show().html(unescape(pp_descriptions[set_position]));}else{TTjquerypp_pic_holder.find('.pp_description').hide();}
movie_width=(parseFloat(getParam('width',pp_images[set_position])))?getParam('width',pp_images[set_position]):settings.default_width.toString();movie_height=(parseFloat(getParam('height',pp_images[set_position])))?getParam('height',pp_images[set_position]):settings.default_height.toString();percentBased=false;if(movie_height.indexOf('%')!=-1){movie_height=parseFloat((TTjquery(window).height()*parseFloat(movie_height)/100)-150);percentBased=true;}
if(movie_width.indexOf('%')!=-1){movie_width=parseFloat((TTjquery(window).width()*parseFloat(movie_width)/100)-150);percentBased=true;}
TTjquerypp_pic_holder.fadeIn(function(){(settings.show_title&&pp_titles[set_position]!=""&&typeof pp_titles[set_position]!="undefined")?TTjqueryppt.html(unescape(pp_titles[set_position])):TTjqueryppt.html('&nbsp;');imgPreloader="";skipInjection=false;switch(_getFileType(pp_images[set_position])){case'image':imgPreloader=new Image();nextImage=new Image();if(isSet&&set_position<TTjquery(pp_images).size()-1)nextImage.src=pp_images[set_position+1];prevImage=new Image();if(isSet&&pp_images[set_position-1])prevImage.src=pp_images[set_position-1];TTjquerypp_pic_holder.find('#pp_full_res')[0].innerHTML=settings.image_markup.replace(/{path}/g,pp_images[set_position]);imgPreloader.onload=function(){pp_dimensions=_fitToViewport(imgPreloader.width,imgPreloader.height);_showContent();};imgPreloader.onerror=function(){alert('Image cannot be loaded. Make sure the path is correct and image exist.');TTjquery.prettyPhoto.close();};imgPreloader.src=pp_images[set_position];break;case'youtube':pp_dimensions=_fitToViewport(movie_width,movie_height);movie='http://www.youtube.com/embed/'+getParam('v',pp_images[set_position]);(getParam('rel',pp_images[set_position]))?movie+="?rel="+getParam('rel',pp_images[set_position]):movie+="?rel=1";if(settings.autoplay)movie+="&autoplay=1";toInject=settings.iframe_markup.replace(/{width}/g,pp_dimensions['width']).replace(/{height}/g,pp_dimensions['height']).replace(/{wmode}/g,settings.wmode).replace(/{path}/g,movie);break;case'vimeo':pp_dimensions=_fitToViewport(movie_width,movie_height);movie_id=pp_images[set_position];var regExp=/http:\/\/(www\.)?vimeo.com\/(\d+)/;var match=movie_id.match(regExp);movie='http://player.vimeo.com/video/'+match[2]+'?title=0&amp;byline=0&amp;portrait=0';if(settings.autoplay)movie+="&autoplay=1;";vimeo_width=pp_dimensions['width']+'/embed/?moog_width='+pp_dimensions['width'];toInject=settings.iframe_markup.replace(/{width}/g,vimeo_width).replace(/{height}/g,pp_dimensions['height']).replace(/{path}/g,movie);break;case'quicktime':pp_dimensions=_fitToViewport(movie_width,movie_height);pp_dimensions['height']+=15;pp_dimensions['contentHeight']+=15;pp_dimensions['containerHeight']+=15;toInject=settings.quicktime_markup.replace(/{width}/g,pp_dimensions['width']).replace(/{height}/g,pp_dimensions['height']).replace(/{wmode}/g,settings.wmode).replace(/{path}/g,pp_images[set_position]).replace(/{autoplay}/g,settings.autoplay);break;case'flash':pp_dimensions=_fitToViewport(movie_width,movie_height);flash_vars=pp_images[set_position];flash_vars=flash_vars.substring(pp_images[set_position].indexOf('flashvars')+10,pp_images[set_position].length);filename=pp_images[set_position];filename=filename.substring(0,filename.indexOf('?'));toInject=settings.flash_markup.replace(/{width}/g,pp_dimensions['width']).replace(/{height}/g,pp_dimensions['height']).replace(/{wmode}/g,settings.wmode).replace(/{path}/g,filename+'?'+flash_vars);break;case'iframe':pp_dimensions=_fitToViewport(movie_width,movie_height);frame_url=pp_images[set_position];frame_url=frame_url.substr(0,frame_url.indexOf('iframe')-1);toInject=settings.iframe_markup.replace(/{width}/g,pp_dimensions['width']).replace(/{height}/g,pp_dimensions['height']).replace(/{path}/g,frame_url);break;case'ajax':doresize=false;pp_dimensions=_fitToViewport(movie_width,movie_height);doresize=true;skipInjection=true;TTjquery.get(pp_images[set_position],function(responseHTML){toInject=settings.inline_markup.replace(/{content}/g,responseHTML);TTjquerypp_pic_holder.find('#pp_full_res')[0].innerHTML=toInject;_showContent();});break;case'custom':pp_dimensions=_fitToViewport(movie_width,movie_height);toInject=settings.custom_markup;break;case'inline':myClone=TTjquery(pp_images[set_position]).clone().append('<br clear="all" />').css({'width':settings.default_width}).wrapInner('<div id="pp_full_res"><div class="pp_inline"></div></div>').appendTo(TTjquery('body')).show();doresize=false;pp_dimensions=_fitToViewport(TTjquery(myClone).width(),TTjquery(myClone).height());doresize=true;TTjquery(myClone).remove();toInject=settings.inline_markup.replace(/{content}/g,TTjquery(pp_images[set_position]).html());break;};if(!imgPreloader&&!skipInjection){TTjquerypp_pic_holder.find('#pp_full_res')[0].innerHTML=toInject;_showContent();};});return false;};TTjquery.prettyPhoto.changePage=function(direction){currentGalleryPage=0;if(direction=='previous'){set_position--;if(set_position<0)set_position=TTjquery(pp_images).size()-1;}else if(direction=='next'){set_position++;if(set_position>TTjquery(pp_images).size()-1)set_position=0;}else{set_position=direction;};rel_index=set_position;if(!doresize)doresize=true;TTjquery('.pp_contract').removeClass('pp_contract').addClass('pp_expand');_hideContent(function(){TTjquery.prettyPhoto.open();});};TTjquery.prettyPhoto.changeGalleryPage=function(direction){if(direction=='next'){currentGalleryPage++;if(currentGalleryPage>totalPage)currentGalleryPage=0;}else if(direction=='previous'){currentGalleryPage--;if(currentGalleryPage<0)currentGalleryPage=totalPage;}else{currentGalleryPage=direction;};slide_speed=(direction=='next'||direction=='previous')?settings.animation_speed:0;slide_to=currentGalleryPage*(itemsPerPage*itemWidth);TTjquerypp_gallery.find('ul').animate({left:-slide_to},slide_speed);};TTjquery.prettyPhoto.startSlideshow=function(){if(typeof pp_slideshow=='undefined'){TTjquerypp_pic_holder.find('.pp_play').unbind('click').removeClass('pp_play').addClass('pp_pause').click(function(){TTjquery.prettyPhoto.stopSlideshow();return false;});pp_slideshow=setInterval(TTjquery.prettyPhoto.startSlideshow,settings.slideshow);}else{TTjquery.prettyPhoto.changePage('next');};}
TTjquery.prettyPhoto.stopSlideshow=function(){TTjquerypp_pic_holder.find('.pp_pause').unbind('click').removeClass('pp_pause').addClass('pp_play').click(function(){TTjquery.prettyPhoto.startSlideshow();return false;});clearInterval(pp_slideshow);pp_slideshow=undefined;}
TTjquery.prettyPhoto.close=function(){if(TTjquerypp_overlay.is(":animated"))return;TTjquery.prettyPhoto.stopSlideshow();TTjquerypp_pic_holder.stop().find('object,embed').css('visibility','hidden');TTjquery('div.pp_pic_holder,div.ppt,.pp_fade').fadeOut(settings.animation_speed,function(){TTjquery(this).remove();});TTjquerypp_overlay.fadeOut(settings.animation_speed,function(){if(TTjquery.browser.msie&&TTjquery.browser.version==6)TTjquery('select').css('visibility','visible');if(settings.hideflash)TTjquery('object,embed,iframe[src*=youtube],iframe[src*=vimeo]').css('visibility','visible');TTjquery(this).remove();TTjquery(window).unbind('scroll.prettyphoto');settings.callback();doresize=true;pp_open=false;delete settings;});};function _showContent(){TTjquery('.pp_loaderIcon').hide();projectedTop=scroll_pos['scrollTop']+((windowHeight/2)-(pp_dimensions['containerHeight']/2));if(projectedTop<0)projectedTop=0;TTjqueryppt.fadeTo(settings.animation_speed,1);TTjquerypp_pic_holder.find('.pp_content').animate({height:pp_dimensions['contentHeight'],width:pp_dimensions['contentWidth']},settings.animation_speed);TTjquerypp_pic_holder.animate({'top':projectedTop,'left':(windowWidth/2)-(pp_dimensions['containerWidth']/2),width:pp_dimensions['containerWidth']},settings.animation_speed,function(){TTjquerypp_pic_holder.find('.pp_hoverContainer,#fullResImage').height(pp_dimensions['height']).width(pp_dimensions['width']);TTjquerypp_pic_holder.find('.pp_fade').fadeIn(settings.animation_speed);if(isSet&&_getFileType(pp_images[set_position])=="image"){TTjquerypp_pic_holder.find('.pp_hoverContainer').show();}else{TTjquerypp_pic_holder.find('.pp_hoverContainer').hide();}
if(pp_dimensions['resized']){TTjquery('a.pp_expand,a.pp_contract').show();}else{TTjquery('a.pp_expand').hide();}
if(settings.autoplay_slideshow&&!pp_slideshow&&!pp_open)TTjquery.prettyPhoto.startSlideshow();if(settings.deeplinking)
setHashtag();settings.changepicturecallback();pp_open=true;});_insert_gallery();};function _hideContent(callback){TTjquerypp_pic_holder.find('#pp_full_res object,#pp_full_res embed').css('visibility','hidden');TTjquerypp_pic_holder.find('.pp_fade').fadeOut(settings.animation_speed,function(){TTjquery('.pp_loaderIcon').show();callback();});};function _checkPosition(setCount){(setCount>1)?TTjquery('.pp_nav').show():TTjquery('.pp_nav').hide();};function _fitToViewport(width,height){resized=false;_getDimensions(width,height);imageWidth=width,imageHeight=height;if(((pp_containerWidth>windowWidth)||(pp_containerHeight>windowHeight))&&doresize&&settings.allow_resize&&!percentBased){resized=true,fitting=false;while(!fitting){if((pp_containerWidth>windowWidth)){imageWidth=(windowWidth-200);imageHeight=(height/width)*imageWidth;}else if((pp_containerHeight>windowHeight)){imageHeight=(windowHeight-200);imageWidth=(width/height)*imageHeight;}else{fitting=true;};pp_containerHeight=imageHeight,pp_containerWidth=imageWidth;};_getDimensions(imageWidth,imageHeight);if((pp_containerWidth>windowWidth)||(pp_containerHeight>windowHeight)){_fitToViewport(pp_containerWidth,pp_containerHeight)};};return{width:Math.floor(imageWidth),height:Math.floor(imageHeight),containerHeight:Math.floor(pp_containerHeight),containerWidth:Math.floor(pp_containerWidth)+(settings.horizontal_padding*2),contentHeight:Math.floor(pp_contentHeight),contentWidth:Math.floor(pp_contentWidth),resized:resized};};function _getDimensions(width,height){width=parseFloat(width);height=parseFloat(height);TTjquerypp_details=TTjquerypp_pic_holder.find('.pp_details');TTjquerypp_details.width(width);detailsHeight=parseFloat(TTjquerypp_details.css('marginTop'))+parseFloat(TTjquerypp_details.css('marginBottom'));TTjquerypp_details=TTjquerypp_details.clone().addClass(settings.theme).width(width).appendTo(TTjquery('body')).css({'position':'absolute','top':-10000});detailsHeight+=TTjquerypp_details.height();detailsHeight=(detailsHeight<=34)?36:detailsHeight;if(TTjquery.browser.msie&&TTjquery.browser.version==7)detailsHeight+=8;TTjquerypp_details.remove();TTjquerypp_title=TTjquerypp_pic_holder.find('.ppt');TTjquerypp_title.width(width);titleHeight=parseFloat(TTjquerypp_title.css('marginTop'))+parseFloat(TTjquerypp_title.css('marginBottom'));TTjquerypp_title=TTjquerypp_title.clone().appendTo(TTjquery('body')).css({'position':'absolute','top':-10000});titleHeight+=TTjquerypp_title.height();TTjquerypp_title.remove();pp_contentHeight=height+detailsHeight;pp_contentWidth=width;pp_containerHeight=pp_contentHeight+titleHeight+TTjquerypp_pic_holder.find('.pp_top').height()+TTjquerypp_pic_holder.find('.pp_bottom').height();pp_containerWidth=width;}
function _getFileType(itemSrc){if(itemSrc.match(/youtube\.com\/watch/i)){return'youtube';}else if(itemSrc.match(/vimeo\.com/i)){return'vimeo';}else if(itemSrc.match(/\b.mov\b/i)){return'quicktime';}else if(itemSrc.match(/\b.swf\b/i)){return'flash';}else if(itemSrc.match(/\biframe=true\b/i)){return'iframe';}else if(itemSrc.match(/\bajax=true\b/i)){return'ajax';}else if(itemSrc.match(/\bcustom=true\b/i)){return'custom';}else if(itemSrc.substr(0,1)=='#'){return'inline';}else{return'image';};};function _center_overlay(){if(doresize&&typeof TTjquerypp_pic_holder!='undefined'){scroll_pos=_get_scroll();contentHeight=TTjquerypp_pic_holder.height(),contentwidth=TTjquerypp_pic_holder.width();projectedTop=(windowHeight/2)+scroll_pos['scrollTop']-(contentHeight/2);if(projectedTop<0)projectedTop=0;if(contentHeight>windowHeight)
return;TTjquerypp_pic_holder.css({'top':projectedTop,'left':(windowWidth/2)+scroll_pos['scrollLeft']-(contentwidth/2)});};};function _get_scroll(){if(self.pageYOffset){return{scrollTop:self.pageYOffset,scrollLeft:self.pageXOffset};}else if(document.documentElement&&document.documentElement.scrollTop){return{scrollTop:document.documentElement.scrollTop,scrollLeft:document.documentElement.scrollLeft};}else if(document.body){return{scrollTop:document.body.scrollTop,scrollLeft:document.body.scrollLeft};};};function _resize_overlay(){windowHeight=TTjquery(window).height(),windowWidth=TTjquery(window).width();if(typeof TTjquerypp_overlay!="undefined")TTjquerypp_overlay.height(TTjquery(document).height()).width(windowWidth);};function _insert_gallery(){if(isSet&&settings.overlay_gallery&&_getFileType(pp_images[set_position])=="image"&&(settings.ie6_fallback&&!(TTjquery.browser.msie&&parseInt(TTjquery.browser.version)==6))){itemWidth=52+5;navWidth=(settings.theme=="facebook"||settings.theme=="pp_default")?50:30;itemsPerPage=Math.floor((pp_dimensions['containerWidth']-100-navWidth)/itemWidth);itemsPerPage=(itemsPerPage<pp_images.length)?itemsPerPage:pp_images.length;totalPage=Math.ceil(pp_images.length/itemsPerPage)-1;if(totalPage==0){navWidth=0;TTjquerypp_gallery.find('.pp_arrow_next,.pp_arrow_previous').hide();}else{TTjquerypp_gallery.find('.pp_arrow_next,.pp_arrow_previous').show();};galleryWidth=itemsPerPage*itemWidth;fullGalleryWidth=pp_images.length*itemWidth;TTjquerypp_gallery.css('margin-left',-((galleryWidth/2)+(navWidth/2))).find('div:first').width(galleryWidth+5).find('ul').width(fullGalleryWidth).find('li.selected').removeClass('selected');goToPage=(Math.floor(set_position/itemsPerPage)<totalPage)?Math.floor(set_position/itemsPerPage):totalPage;TTjquery.prettyPhoto.changeGalleryPage(goToPage);TTjquerypp_gallery_li.filter(':eq('+set_position+')').addClass('selected');}else{TTjquerypp_pic_holder.find('.pp_content').unbind('mouseenter mouseleave');}}
function _build_overlay(caller){settings.markup=settings.markup.replace('{pp_social}',(settings.social_tools)?settings.social_tools:'');TTjquery('body').append(settings.markup);TTjquerypp_pic_holder=TTjquery('.pp_pic_holder'),TTjqueryppt=TTjquery('.ppt'),TTjquerypp_overlay=TTjquery('div.pp_overlay');if(isSet&&settings.overlay_gallery){currentGalleryPage=0;toInject="";for(var i=0;i<pp_images.length;i++){if(!pp_images[i].match(/\b(jpg|jpeg|png|gif)\b/gi)){classname='default';img_src='';}else{classname='';img_src=pp_images[i];}
toInject+="<li class='"+classname+"'><a href='#'><img src='"+img_src+"' width='50' alt='' /></a></li>";};toInject=settings.gallery_markup.replace(/{gallery}/g,toInject);TTjquerypp_pic_holder.find('#pp_full_res').after(toInject);TTjquerypp_gallery=TTjquery('.pp_pic_holder .pp_gallery'),TTjquerypp_gallery_li=TTjquerypp_gallery.find('li');TTjquerypp_gallery.find('.pp_arrow_next').click(function(){TTjquery.prettyPhoto.changeGalleryPage('next');TTjquery.prettyPhoto.stopSlideshow();return false;});TTjquerypp_gallery.find('.pp_arrow_previous').click(function(){TTjquery.prettyPhoto.changeGalleryPage('previous');TTjquery.prettyPhoto.stopSlideshow();return false;});TTjquerypp_pic_holder.find('.pp_content').hover(function(){TTjquerypp_pic_holder.find('.pp_gallery:not(.disabled)').fadeIn();},function(){TTjquerypp_pic_holder.find('.pp_gallery:not(.disabled)').fadeOut();});itemWidth=52+5;TTjquerypp_gallery_li.each(function(i){TTjquery(this).find('a').click(function(){TTjquery.prettyPhoto.changePage(i);TTjquery.prettyPhoto.stopSlideshow();return false;});});};if(settings.slideshow){TTjquerypp_pic_holder.find('.pp_nav').prepend('<a href="#" class="pp_play">Play</a>')
TTjquerypp_pic_holder.find('.pp_nav .pp_play').click(function(){TTjquery.prettyPhoto.startSlideshow();return false;});}
TTjquerypp_pic_holder.attr('class','pp_pic_holder '+settings.theme);TTjquerypp_overlay.css({'opacity':0,'height':TTjquery(document).height(),'width':TTjquery(window).width()}).bind('click',function(){if(!settings.modal)TTjquery.prettyPhoto.close();});TTjquery('a.pp_close').bind('click',function(){TTjquery.prettyPhoto.close();return false;});TTjquery('a.pp_expand').bind('click',function(e){if(TTjquery(this).hasClass('pp_expand')){TTjquery(this).removeClass('pp_expand').addClass('pp_contract');doresize=false;}else{TTjquery(this).removeClass('pp_contract').addClass('pp_expand');doresize=true;};_hideContent(function(){TTjquery.prettyPhoto.open();});return false;});TTjquerypp_pic_holder.find('.pp_previous, .pp_nav .pp_arrow_previous').bind('click',function(){TTjquery.prettyPhoto.changePage('previous');TTjquery.prettyPhoto.stopSlideshow();return false;});TTjquerypp_pic_holder.find('.pp_next, .pp_nav .pp_arrow_next').bind('click',function(){TTjquery.prettyPhoto.changePage('next');TTjquery.prettyPhoto.stopSlideshow();return false;});_center_overlay();};if(!pp_alreadyInitialized&&getHashtag()){pp_alreadyInitialized=true;hashIndex=getHashtag();hashRel=hashIndex;hashIndex=hashIndex.substring(hashIndex.indexOf('/')+1,hashIndex.length-1);hashRel=hashRel.substring(0,hashRel.indexOf('/'));setTimeout(function(){TTjquery("a[rel^='"+hashRel+"']:eq("+hashIndex+")").trigger('click');},50);}
return this.unbind('click.prettyphoto').bind('click.prettyphoto',TTjquery.prettyPhoto.initialize);};function getHashtag(){url=location.href;hashtag=(url.indexOf('#!')!=-1)?decodeURI(url.substring(url.indexOf('#!')+2,url.length)):false;return hashtag;};function setHashtag(){if(typeof theRel=='undefined')return;location.hash='!'+theRel+'/'+rel_index+'/';};function getParam(name,url){name=name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");var regexS="[\\?&]"+name+"=([^&#]*)";var regex=new RegExp(regexS);var results=regex.exec(url);return(results==null)?"":results[1];}})(jQuery);var pp_alreadyInitialized=false;

//init script for prettyPhoto
TTjquery(document).ready(function(){
TTjquery("a[rel^='prettyPhoto']").prettyPhoto();
if (TTjquery.browser.msie || TTjquery.browser.opera) { TTjquery(window).load(function() {TTjquery('.big-banner #main .main-area').css("padding-top", "118px");}); } else {}
});