// for undefined testing
var undef;
/////////// lt IE9 detection //////////
var ie = (function(){
var v = 3,div = document.createElement('div'),all = div.getElementsByTagName('i');
while (div.innerHTML = '',all[0]);
return v > 4 ? v : undef;
}());
var ltIE9 = (ie && ie < 9);
// mobile detection
var isAMobile = FMD.isTouch;
//////////////// keeps the menu vertically fixed and the widths of submenus sized right /////////////
// modified fixed center plugin to only fix the y coord
(function(){jQuery.fn.fixedCenter=function(){return this.each(function(){var element=jQuery(this),win=jQuery(window);centerElement();jQuery(window).bind('resize',function(){centerElement();});function centerElement(){var elementHeight,windowHeight,Y2;elementHeight=element.outerHeight();windowHeight=win.height();Y2=(windowHeight/2-elementHeight/2)+"px";jQuery(element).css({'top':Y2,'position':'fixed'});}});}})();
//////////////// keeps the menu vertically fixed and the widths of submenus sized right /////////////
function exitBoxBtnClick(i)
{
jQuery('#exit-box-id'+i+'').parent().animate({opacity:0}, 'fast').slideUp('slow');
}
// for processing button rollovers
var buttonRollover = function()
{
var ref = jQuery(this).children('.btn-hover');
var bgColor = ref.css('background-color');
var brdrClr = ref.css('border-top-Color');
jQuery(this).stop(true,true).animate({backgroundColor:bgColor,borderColor:brdrClr},'fast');
}
var buttonRollout = function()
{
var ref = jQuery(this).children('.btn-orig');
var bgColor = ref.css('background-color');
var brdrClr = ref.css('border-top-color');
jQuery(this).stop(true,true).animate({backgroundColor:bgColor,borderColor:brdrClr},'normal');
}
// to watch for youtube HTML5 API being ready
var youTubeApiIsReady = false;
var ytQueuedCalls = [];
function onYouTubePlayerAPIReady() {
youTubeApiIsReady = true;
var i,ii=ytQueuedCalls.length;
for (i = 0; i < ii; i++)
ytQueuedCalls[i]();
}
// import youtube HTML5 api
var tag = document.createElement('script');
tag.src = "http://www.youtube.com/player_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
// if it's a mobile, notify the mbbox
if (FMD.isTouch)
mbbox.makeMobile();
///////////////// this will be used by the ajax contact form
var formvars = '', errMsgArea, succMsgArea;
var isProcessingContact = false;
function processContactForm()
{
// to prevent multi-clicking sending a ton of messages
if (isProcessingContact) return;
formvars = '';
errMsgArea = jQuery('.contact-form .error-msg');
succMsgArea = jQuery('.contact-form .success-msg');
errMsgArea.text('');
succMsgArea.text('');
jQuery('.contact-form input, .contact-form textarea').each(function(i){
var nm = jQuery(this).attr('name');
var val = jQuery(this).val();
if (nm == 'name') {
if (val.length <= 0) errMsgArea.text(CFE_NAME);
} else if (nm == 'message') {
if (val.length <= 0) errMsgArea.text(CFE_MSG);
} else if (nm == 'email') {
if (!(new RegExp(/\S+@.+\.\S+/i)).test(val)) errMsgArea.text(CFE_EMAIL);
} else if (nm == 'phone') {
if (val.length <= 0) errMsgArea.text(CFE_PHONE);
}
formvars += (i==0?'':'&')+nm+'='+escape(val);
});
if (errMsgArea.text() != '') { errMsgArea.hide().slideDown(); return false; }
isProcessingContact = true;
var sendTo = jQuery('.contact-form').attr('action');
if (sendTo == undef) sendTo = jQuery('.contact-form form').attr('action');
//alert(formvars); return;
jQuery.ajax(sendTo, {
type: "POST",
data: formvars,
success: function(data) {
succMsgArea.text(data);
succMsgArea.hide().fadeIn();
isProcessingContact = false;
},
error: function() {
succMsgArea.text('Error, check internet connection.');
succMsgArea.hide().fadeIn();
isProcessingContact = false;
}
});
succMsgArea.text(CF_SENDING);
succMsgArea.hide().slideDown();
return true;
}
///////////////// this will be used by the ajax mailchimp subscription form
var isProcessingSubscribe = false;
function processMailChimpSubscribe()
{
// to prevent multi-clicking sending a ton
if (isProcessingSubscribe) return;
$container = jQuery(this);
$form = $container.children('form');
$button = $form.children('.mailchimp-ajax-submit');
$replyArea = $container.children('.mailchimp-subscribe-result');
var mailchimpformvars = '';
$button.bind('click', function()
{
var action = $form.children('input[name="action"]').val();
var datacenter = $form.children('input[name="datacenter"]').val();
var list = $form.children('input[name="list"]').val();
var success = $form.children('input[name="success"]').val();
var failure = $form.children('input[name="failure"]').val();
var sending = $form.children('input[name="sending"]').val();
var emailerror = $form.children('input[name="emailerror"]').val();
var email = $form.children('input[name="email"]').val();
if (!(new RegExp(/\S+@.+\.\S+/i)).test(email)) { $replyArea.text(emailerror).hide().fadeIn(); return; }
// get together vars into query string
$form.children('input').each(function(i){
var $inp = jQuery(this);
mailchimpformvars += i==0 ? '' : '&';
mailchimpformvars += $inp.attr('name');
mailchimpformvars += '=';
mailchimpformvars += encodeURIComponent( $inp.val() );
});
$replyArea.text(sending);
$replyArea.hide().fadeIn();
isProcessingSubscribe = true;
jQuery.ajax($form.attr('action'), {
type: "POST",
data: mailchimpformvars,
success: function(data) {
$replyArea.html(data);
$replyArea.hide().fadeIn();
isProcessingSubscribe = false;
$form.children('input[name="email"]').val('');
},
error: function() {
$replyArea.text('Error, check internet connection.');
$replyArea.hide().fadeIn();
isProcessingSubscribe = false;
}
});
});
}
//////////// functions for setting up galleries and hover effects for images ///////////
// this function adds hover colors/images for images
var addHover = function(className, obj) {
var img = obj.children('img');
var overlay = jQuery('
').css({
'height': '100%','width': '100%',
'position': 'absolute','top': 0,'left': 0,
'opacity': 0.0
});
obj.append(overlay);
obj.bind('mouseover', function(){ var o = obj.children('.'+className).stop().animate({ 'opacity': 0.6 }, 'fast'); });
obj.bind('mouseout', function(){ var o = obj.children('.'+className).stop().animate({ 'opacity': 0.0 }, 'fast'); });
}
// this function processes colorbox stuff and adds the lightbox functionality and parses the href for swfs, iframes or video
function processForLightBox(groupName, obj)
{
var href = obj.attr('href');
var ext = href.substr(href.length-3);
if (groupName != null) obj.attr('rel', groupName);
var vars = new Object();
var hClass = 'lightbox-h-div';
if (obj.hasClass('lightbox-youtube')) {
href = href.match(/(&|\?)v=(.*?)($|&)/i)[2];
obj.attr('href', 'http://www.youtube.com/embed/'+href+'?autohide=1&autoplay=1&modestbranding=1&showinfo=0&showsearch=0');
vars.type = 'iframe';
vars.showNavArrows = false;
hClass = 'video-h-div';
}
else if (obj.hasClass('lightbox-vimeo')) {
href = href.match(/(vimeo.com\/)(.*?)(\/|\?|$)/i)[2];
obj.attr('href', 'http://player.vimeo.com/video/'+href+'?autoplay=1&color=ffffff&title=0&byline=0&portrait=0');
vars.type = 'iframe';
vars.showNavArrows = false;
hClass = 'video-h-div';
}
else if (obj.hasClass('lightbox-video')) {
obj.attr('href', THEME_ROOT+'/flash/hostedvideo.swf');
vars.type = 'swf';
vars.swf = {flashvars:'video='+href+'&autoplay=y', allowfullscreen:'true', wmode:'opaque'};
vars.showNavArrows = false;
hClass = 'video-h-div';
}
else if (obj.hasClass('lightbox-flash')) {
vars.type = 'swf';
hClass = 'swf-h-div';
}
else if (obj.hasClass('lightbox-iframe')) {
vars.type = 'iframe';
vars.showNavArrows = false;
hClass = 'iframe-h-div';
}
vars.overlayColor = '#000';
obj.fancybox(vars);
addHover(hClass, obj);
}
/////////////// for making elastic input boxes //////////////////
(function(jQuery){jQuery.fn.extend({elastic:function(){var mimics=['paddingTop','paddingRight','paddingBottom','paddingLeft','fontSize','lineHeight','fontFamily','width','fontWeight','border-top-width','border-right-width','border-bottom-width','border-left-width','borderTopStyle','borderTopColor','borderRightStyle','borderRightColor','borderBottomStyle','borderBottomColor','borderLeftStyle','borderLeftColor'];return this.each(function(){if(this.type!=='textarea'){return false}var $textarea=jQuery(this),$twin=jQuery('').css({'position':'absolute','display':'none','word-wrap':'break-word'}),lineHeight=parseInt($textarea.css('line-height'),10)||parseInt($textarea.css('font-size'),'10'),minheight=parseInt($textarea.css('height'),10)||lineHeight*3,maxheight=parseInt($textarea.css('max-height'),10)||Number.MAX_VALUE,goalheight=0;if(maxheight<0){maxheight=Number.MAX_VALUE}$twin.appendTo($textarea.parent());var i=mimics.length;while(i--){$twin.css(mimics[i].toString(),$textarea.css(mimics[i].toString()))}function setTwinWidth(){curatedWidth=Math.floor(parseInt($textarea.width(),10));if($twin.width()!==curatedWidth){$twin.css({'width':curatedWidth+'px'});update(true)}}function setHeightAndOverflow(height,overflow){var curratedHeight=Math.floor(parseInt(height,10));if($textarea.height()!==curratedHeight){$textarea.css({'height':curratedHeight+'px','overflow':overflow});$textarea.trigger('resize')}}function update(forced){var textareaContent=$textarea.val().replace(/&/g,'&').replace(/ {2}/g,' ').replace(/<|>/g,'>').replace(/\n/g,' ');var twinContent=$twin.html().replace(/ /ig,' ');if(forced||textareaContent+' '!==twinContent){$twin.html(textareaContent+' ');if(Math.abs($twin.height()+lineHeight-$textarea.height())>3){var goalheight=$twin.height()+lineHeight;if(goalheight>=maxheight){setHeightAndOverflow(maxheight,'auto')}else if(goalheight<=minheight){setHeightAndOverflow(minheight,'hidden')}else{setHeightAndOverflow(goalheight,'hidden')}}}}$textarea.css({'overflow':'hidden'});$textarea.bind('keyup change cut paste',function(){update()});jQuery(window).bind('resize',setTwinWidth);$textarea.bind('resize',setTwinWidth);$textarea.bind('update',update);$textarea.bind('blur',function(){if($twin.height()minheight){$textarea.height($twin.height())}else{$textarea.height(minheight)}}});$textarea.bind('input paste',function(e){setTimeout(update,250)});update()})}})})(jQuery);
////////////// tipsy /////////////////////
(function($){function fixTitle($ele){if($ele.attr('title')||typeof($ele.attr('original-title'))!='string'){$ele.attr('original-title',$ele.attr('title')||'').removeAttr('title');}}function Tipsy(element,options){this.$element=$(element);this.options=options;this.enabled=true;fixTitle(this.$element);}Tipsy.prototype={show:function(){var title=this.getTitle();if(title&&this.enabled){var $tip=this.tip();$tip.find('.tipsy-inner')[this.options.html?'html':'text'](title);$tip[0].className='tipsy';$tip.remove().css({top:0,left:0,visibility:'hidden',display:'block'}).appendTo(document.body);var pos=$.extend({},this.$element.offset(),{width:this.$element[0].offsetWidth,height:this.$element[0].offsetHeight});var actualWidth=$tip[0].offsetWidth,actualHeight=$tip[0].offsetHeight;var gravity=(typeof this.options.gravity=='function')?this.options.gravity.call(this.$element[0]):this.options.gravity;var tp;switch(gravity.charAt(0)){case 'n':tp={top:pos.top+pos.height+this.options.offset,left:pos.left+pos.width/2-actualWidth/2};break;case 's':tp={top:pos.top-actualHeight-this.options.offset,left:pos.left+pos.width/2-actualWidth/2}; break;case 'e':tp={top:pos.top+pos.height/2-actualHeight/2,left:pos.left-actualWidth-this.options.offset};break;case 'w':tp={top:pos.top+pos.height/2-actualHeight/2,left:pos.left+pos.width+this.options.offset};break;}if(gravity.length==2){if(gravity.charAt(1)=='w'){tp.left=pos.left+pos.width/2-15;}else{tp.left=pos.left+pos.width/2-actualWidth+15;}}$tip.css(tp).addClass('tipsy-'+gravity);if(this.options.fade){$tip.stop().css({opacity:0,display:'block',visibility:'visible'}).animate({opacity:this.options.opacity});}else{$tip.css({visibility:'visible',opacity:this.options.opacity});}}},hide:function(){if(this.options.fade){this.tip().stop().fadeOut(function(){$(this).remove();});}else{this.tip().remove();}},getTitle:function(){var title,$e=this.$element,o=this.options;fixTitle($e);var title,o=this.options;if(typeof o.title=='string'){title=$e.attr(o.title=='title'?'original-title':o.title);}else if(typeof o.title=='function'){title=o.title.call($e[0]);}title=(''+title).replace(/(^\s*|\s*$)/,"");return title||o.fallback;},tip:function(){if(!this.$tip){this.$tip=$('').html('');}return this.$tip;},validate:function(){if(!this.$element[0].parentNode){this.hide();this.$element=null;this.options=null;}},enable:function(){this.enabled=true;},disable:function(){this.enabled=false;},toggleEnabled:function(){this.enabled=!this.enabled;}};$.fn.tipsy=function(options){if(options===true){return this.data('tipsy');}else if(typeof options=='string'){return this.data('tipsy')[options]();}options=$.extend({},$.fn.tipsy.defaults,options);function get(ele){var tipsy=$.data(ele,'tipsy');if(!tipsy){tipsy=new Tipsy(ele,$.fn.tipsy.elementOptions(ele,options));$.data(ele,'tipsy',tipsy);}return tipsy;}function enter(){var tipsy=get(this);tipsy.hoverState='in';if(options.delayIn==0){tipsy.show();}else{setTimeout(function(){if(tipsy.hoverState=='in')tipsy.show();},options.delayIn);}};function leave(){var tipsy=get(this);tipsy.hoverState='out';if(options.delayOut==0){tipsy.hide();}else{setTimeout(function(){if(tipsy.hoverState=='out')tipsy.hide();},options.delayOut);}};if(!options.live)this.each(function(){get(this);});if(options.trigger!='manual'){var binder=options.live?'live':'bind',eventIn=options.trigger=='hover'?'mouseenter':'focus',eventOut=options.trigger=='hover'?'mouseleave':'blur';this[binder](eventIn,enter)[binder](eventOut,leave);}return this;};$.fn.tipsy.defaults={delayIn:0,delayOut:0,fade:false,fallback:'',gravity:'n',html:false,live:false,offset:0,opacity:0.8,title:'title', trigger:'hover'};$.fn.tipsy.elementOptions=function(ele,options){return $.metadata?$.extend({},options,$(ele).metadata()):options;};$.fn.tipsy.autoNS=function(){return $(this).offset().top>($(document).scrollTop()+$(window).height()/2)?'s':'n';};$.fn.tipsy.autoWE=function(){return $(this).offset().left>($(document).scrollLeft()+$(window).width()/2)?'e':'w';};})(jQuery);
////////////// color animation plugin //////////////////
(function(d){function i(){var b=d("script:first"),a=b.css("color"),c=false;if(/^rgba/.test(a))c=true;else try{c=a!=b.css("color","rgba(0, 0, 0, 0.5)").css("color");b.css("color",a)}catch(e){}return c}function g(b,a,c){var e="rgb"+(d.support.rgba?"a":"")+"("+parseInt(b[0]+c*(a[0]-b[0]),10)+","+parseInt(b[1]+c*(a[1]-b[1]),10)+","+parseInt(b[2]+c*(a[2]-b[2]),10);if(d.support.rgba)e+=","+(b&&a?parseFloat(b[3]+c*(a[3]-b[3])):1);e+=")";return e}function f(b){var a,c;if(a=/#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})/.exec(b))c=[parseInt(a[1],16),parseInt(a[2],16),parseInt(a[3],16),1];else if(a=/#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])/.exec(b))c=[parseInt(a[1],16)*17,parseInt(a[2],16)*17,parseInt(a[3],16)*17,1];else if(a=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(b))c=[parseInt(a[1]),parseInt(a[2]),parseInt(a[3]),1];else if(a=/rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9\.]*)\s*\)/.exec(b))c=[parseInt(a[1],10),parseInt(a[2],10),parseInt(a[3],10),parseFloat(a[4])];return c}
d.extend(true,d,{support:{rgba:i()}});var h=["color","backgroundColor","borderBottomColor","borderLeftColor","borderRightColor","borderTopColor","outlineColor"];d.each(h,function(b,a){d.fx.step[a]=function(c){if(!c.init){c.a=f(d(c.elem).css(a));c.end=f(c.end);c.init=true}c.elem.style[a]=g(c.a,c.end,c.pos)}});d.fx.step.borderColor=function(b){if(!b.init)b.end=f(b.end);var a=h.slice(2,6);d.each(a,function(c,e){b.init||(b[e]={a:f(d(b.elem).css(e))});b.elem.style[e]=g(b[e].a,b.end,b.pos)});b.init=true}})(jQuery);
// for processing tab content
var curTabAnimId, curTabAnimSpeed, tabTimer;
var showTab = function(id, speed)
{
if (speed == undefined) speed = 400;
curTabAnimId = id;
curTabAnimSpeed = speed;
jQuery('#'+id).stop(true,true).fadeIn(speed);
jQuery('#'+id).parent().children('.tab-content-pane:not(#'+id+')').stop(true,true).fadeOut(0);
jQuery('#'+id+'-anchor').parent().children('a').removeClass('focused');
jQuery('#'+id+'-anchor').addClass('focused');
}
// for processing toggle boxes
var toggleClick = function()
{
var icon = jQuery(this).children('.toggle-icon-1, .toggle-icon-2');
var isOpen = icon.hasClass('open');
// if in a group and opening close all others first
if (jQuery(this).parent().parent().hasClass('toggle-box-group') && !isOpen)
{
jQuery(this).parent().parent().children('.toggle-box').each(function(){
var closeIcon = jQuery(this).children('.toggle-box-title').children('.toggle-icon-1, .toggle-icon-2');
var closeIsOpen = closeIcon.hasClass('open');
if (closeIsOpen)
{ jQuery(this).children('.toggle-box-content').stop(true,true).slideUp('normal'); closeIcon.removeClass('open'); }
});
}
var ref = jQuery(this).parent().children('.toggle-box-content');
if (isOpen)
{
icon.removeClass('open');
ref.stop(true,true).slideUp('normal');
}
else
{
icon.addClass('open');
ref.stop(true,true).slideDown('normal');
}
}
// for processing accordions
var accordionClick = function()
{
var $title = jQuery(this);
var $item = $title.parent();
var $accordion = $item.parent();
var $items = $accordion.children('.accordion-item');
if (!$item.hasClass('active')) // if not open
{
$items.removeClass('active');
$items.children('.accordion-body').stop(true).slideUp('normal');
$item.addClass('active');
$item.children('.accordion-body').stop(true).slideDown('normal');
}
else
{
$item.removeClass('active');
$item.children('.accordion-body').stop(true).slideUp('normal');
}
}
//////////////// calls when page is ready ///////////////////
jQuery(document).ready(function($)
{
// set up the menu
$('#nav').children('li').bind('mouseover', menu_overHandler);
$('#nav').children('li').bind('mouseout', menu_outHandler);
$('#nav').children('li').children('ul').css('visibility', 'visible');
$('#nav').children('li').children('ul').hide();
// fade in anything marked to (if not IE8 or lower)
var dontFade = ltIE9 || FMD.isTouch;
$('.fade-in-slow').animate({opacity:0}, 0).delay(2400).animate({opacity:1}, dontFade?0:1500);
$('.fade-in').animate({opacity:0}, 0).delay(1000).animate({opacity:1}, dontFade?0:700);
$('.fade-in-first').animate({opacity:0}, 0).delay(1000).animate({opacity:1}, dontFade?0:700);
$('.fade-in-second').animate({opacity:0}, 0).delay(1200).animate({opacity:1}, dontFade?0:700);
$('.fade-in-third').animate({opacity:0}, 0).delay(1400).animate({opacity:1}, dontFade?0:700);
$('.fade-in-fourth').animate({opacity:0}, 0).delay(1600).animate({opacity:1}, dontFade?0:700);
$('.fade-in-fifth').animate({opacity:0}, 0).delay(1800).animate({opacity:1}, dontFade?0:700);
$('.fade-in-sixth').animate({opacity:0}, 0).delay(2000).animate({opacity:1}, dontFade?0:700);
// make the zebra tables actually zebra
$('.horizontal-zebra tr:odd').addClass('odd');
$('.vertical-zebra tr').each(function(){ $(this).children('tr td, tr th').filter(':odd').addClass('odd'); });
$('.vertical-zebra tr').each(function(){ $(this).children('tr td, tr th').filter(':even').addClass('even'); });
// set up functionality for the exit-box class
$('.exit-box').each(function(i){
var addition = $('');
$(this).append(addition);
});
// add gallery hovering/lightbox abilities to the thumbs
$('.gallery-2-columns').children('a').each(function(){ processForLightBox('gallery', $(this)); });
$('.gallery-3-columns').children('a').each(function(){ processForLightBox('gallery', $(this)); });
$('.gallery-4-columns').children('a').each(function(){ processForLightBox('gallery', $(this)); });
$('.lightbox').each(function(){ processForLightBox(null, $(this)); });
$('.lightbox-link').fancybox({type:'iframe'}); // add lightbox directly without any hover stuff, open link in iframe
// add other hover types using the addHover function
$('.magnify-hover').each(function(){ addHover('magnify-h-div', $(this)); });
$('.arrow-hover').each(function(){ addHover('arrow-h-div', $(this)); });
$('.plus-hover').each(function(){ addHover('plus-h-div', $(this)); });
$('.swf-hover').each(function(){ addHover('swf-h-div', $(this)); });
$('.video-hover').each(function(){ addHover('video-h-div', $(this)); });
$('.iframe-hover').each(function(){ addHover('iframe-h-div', $(this)); });
// social bar icon hover events
jQuery("#social-slider-bar a").bind('mouseover', function(){
jQuery(this).parent().children('a').stop(true,false).fadeTo(200, .5);
jQuery(this).stop(true,false).fadeTo(200, 1);
});
jQuery("#social-slider-bar a").bind('mouseout', function(){
jQuery(this).parent().children('a').stop(true,false).fadeTo(200, 1);
});
// add preloading images to the end of the body
$('body').append($(hoverLoader));
// add hover states to each of the icons in the footer
$('.social-icons-left a img, .social-icons-right a img').each(function(){ $(this).bind('mouseover', function(){
var s = $(this).attr('src');
$(this).attr('src', s.substring(0,s.length-7)+'.png');
}).bind('mouseout', function(){
var s = $(this).attr('src');
$(this).attr('src', s.substring(0,s.length-4)+'-bw.png');
}); });
// make the contact form and comment form textareas elastic
$('.contact-form textarea').elastic();
$('#commentform textarea').elastic();
// make ajax mailchimp signup work
$('.mailchimp-subscribe').each(processMailChimpSubscribe);
// enable tipsy support on anything with class .tooltip
$('.tooltip').tipsy({gravity:'s', delayIn:500});
// make menu links without an href show the default cursor
$("#nav li a:not([href])").css('cursor', 'default');
// fade the buttons...it's a bit more elegant
$('.small-btn').bind('mouseover', buttonRollover).bind('mouseout', buttonRollout).children('.btn-hover').css('visibility', 'hidden');
$('.medium-btn').bind('mouseover', buttonRollover).bind('mouseout', buttonRollout).children('.btn-hover').css('visibility', 'hidden');
$('.large-btn').bind('mouseover', buttonRollover).bind('mouseout', buttonRollout).children('.btn-hover').css('visibility', 'hidden');
// to make the toggle boxes work
$('.toggle-box-title').bind('click', toggleClick).parent().children('.toggle-box-content').slideUp(0);
// to make accordions work
$('.accordion-container').children('.accordion-item').not('.active').children('.accordion-body').slideUp(0);
$('.accordion-title').bind('click', accordionClick);
// make pagination smaller if needed
if ($('.pagination a').length > 12)
{
var $pagination = $('.pagination');
var $pLinks = $pagination.children('a');
var $curPage = $pagination.children('.current');
var curInd = parseInt($curPage.text())-1;
var i, len = $pLinks.length;
if (curInd < 5)
{
$pLinks.eq(len-3).after(' ... ');
for (i = 9; i < len-2; i++)
$pLinks.eq(i).remove();
}
else
{
$pLinks.eq(len-3).after(' ... ');
$pLinks.eq(0).before(' ... ');
for (i = 0; i < curInd-4; i++)
$pLinks.eq(i).remove();
for (i = curInd+5; i < len-2; i++)
$pLinks.eq(i).remove();
}
}
// runs to find galleries and work on them
jQuery('.sc-lightbox-gallery').each(function()
{
var $this = jQuery(this);
var $thumbs = $this.children('.sc-thumb');
// figure out the column count by class
var columns = 0;
while (columns < 20)
if ($this.hasClass((++columns)+'-columns'))
break;
// find how many will be in bottom row (to remove bottom margin from them)
var botRowCnt = $thumbs.length % columns;
if (botRowCnt == 0) botRowCnt = columns;
// figure out the rest of the info to use for measurement
var padding = Number($thumbs.css('paddingLeft').split('px')[0]);
var border = Number($thumbs.css('borderLeftWidth').split('px')[0]);
var margin = Number($thumbs.css('marginBottom').split('px')[0]);
var columnW = Number(jQuery('#content-area').css('width').split('px')[0]);
// make correct column count
var thumbSize = Math.floor(((columnW - (columns-1)*margin) / columns) - padding*2 - border*2);
$thumbs.css({marginRight:margin+'px',width:thumbSize+'px',height:thumbSize+'px'});
$this.children('.sc-thumb:nth-child('+columns+'n+'+columns+')').css({marginRight:'0px'});
$this.children('.sc-thumb').slice(-botRowCnt).css('margin-bottom',0);
// setup rollover blur
$thumbs.each(function()
{
var $this = jQuery(this);
var $anchor = $this.find('a');
$anchor.data('title', $anchor.attr('title')); // mbbox can take title info as part of jQuery's data, or as title attribute
$anchor.removeAttr('title');
var img = new Image();
img.onload = function()
{
var typeExt = $this.children('.sc-img-hit').attr('href').split('.').reverse()[0].toLowerCase();
typeExt = typeExt.length >= 3 ? typeExt.substr(0,3) : '';
var typeClass = typeExt=='jpg' || typeExt=='gif' || typeExt=='png' || typeExt=='jpe' || typeExt == 'swf' ? 'img' : 'vid';
//blurrollover//var blurCanv = jQuery('').css({opacity:0});
var cover = jQuery('').css({opacity:0});
var icon = jQuery('').css({opacity:0});
//blurrollover//$this.children('.sc-img-hit').append(blurCanv)
$this.children('.sc-img-hit').append(cover).append(icon);
//blurrollover//var blurStg = new Stage(blurCanv.get(0));
//blurrollover//var blurMap = new Bitmap(img);
//blurrollover//blurStg.addChild(blurMap);
// uses weird transparency methods to fake a blur for quick blurring
//blurrollover//redneckBlur(blurMap, blurStg, 9);
//blurrollover//redneckBlur(blurMap, blurStg, 6);
//blurrollover//redneckBlur(blurMap, blurStg, 3);
//blurrollover//blurStg.update();
//blurrollover//blurStg.removeAllChildren(); // don't need to render again, clean a little
}
img.src = $this.find('img').attr('src');
});
// bind the mouse over/out handlers
$thumbs.bind('mouseover', function()
{
var $this = jQuery(this);
//blurrollover//$this.find('.blur-over').stop().animate({opacity:1}, 200);
$this.find('.icon').stop().animate({opacity:.8}, 200);
//$this.find('.cover').stop().animate({opacity:.4}, 200); // for now fading image out instead to avoid color and covering issues
$this.find('img').stop().animate({opacity:.6}, 200);
})
.bind('mouseout', function()
{
var $this = jQuery(this);
//blurrollover//$this.find('.blur-over').stop().animate({opacity:0}, 200);
$this.find('.icon').stop().animate({opacity:0}, 200);
//$this.find('.cover').stop().animate({opacity:0}, 200);
$this.find('img').stop().animate({opacity:1}, 200);
});
// deprecated to allow multiple image galleries per page, now on click sets up mbbox
// initialize the lightbox for this gallery
//mbbox.initialize($thumbs.find('a'));
// new way replacing above lines
$thumbs.bind('click', function(e)
{
var $this = jQuery(e.currentTarget);
var index = $this.parent().children('.sc-thumb').index($this);
mbbox.initialize($this.parent().find('.sc-thumb a'), true, true);
mbbox.showByIndex(index);
e.preventDefault();
return false;
});
});
// edit all the menu links to instead call javascript to transition the page out BEFORE changing page
var editHref = function()
{
var $this = jQuery(this);
var href = $this.attr('href');
var targ = $this.attr('target');
// if no href, then don't do anything
if (href == undef || href == null || href == '' || href.substr(0,1) == '#' || href.substr(0,11) == 'javascript:' || targ == '_blank')
return;
var proto = href.length > 7 ? href.substr(0,7) : '';
// otherwise make it call JS to transition out before changing page
$this.attr('onclick','transitionOutAndChangePage("'+href+'"); event.returnValue = false; return false;');
}
if (!isAMobile && !ltIE9)
jQuery('#nav a').each(editHref);
});
// The page transitions itself in nicely on load, but to make a truly "app" type feel you also need
// to transition out before the page changes. This lets you do that, and jQuery can redo the menu
// links to trip this function instead of just change the page all boring-like
function transitionOutAndChangePage(newP)
{
// forces the menu closed if it is open, and unbind the rollover event so it stays faded out
jQuery('#menu-wrapper').fadeOut(400);
jQuery('#nav').children('li').unbind('mouseover', menu_overHandler);
// transition out the social slider panel
jQuery('#social-slider-bar').delay(200).fadeOut(400);
// for good measure now, fade out the whole body too
jQuery('body').delay(300).fadeOut(400);
// wait for transition outs to happen, then change the page
setTimeout(function(){ document.location.href = newP; }, 700);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////// Used to embed video in a div
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
function embedVideo(objStr, url, autoplay, width, height, qual, callback, useDefaultYouTube)
{
// if is string, make jquery obj, if not, assume it is a jquery obj
$cont = (objStr.substring != undef) ? jQuery(objStr) : objStr;
// if no width or height given, assume it's supposed to be 100%
if (width == undef) width = '100%';
if (height == undef) height = '100%';
if (!isNaN(width)) width = width+'px';
if (!isNaN(height)) height = height+'px';
// if a youtube url, use flash youtube player or youtube iframe embedding if no flash
if (url.toLowerCase().indexOf('youtube.com') > -1 && url.indexOf('v=') > -1)
{
var ytid = url.match(/(&|\?)v=(.*?)($|&)/i)[2];
$cont.addClass('youtube-video-container');
embedYouTubeVideo($cont, ytid, autoplay, width, height, qual, callback, useDefaultYouTube);
return;
}
// if a vimeo url, use vimeo iframe embedding, they don't allow a skinned player
if (url.toLowerCase().indexOf('vimeo.com') > -1)
{
vimid = url.match(/(vimeo.com\/)(.*?)(\/|\?|$)/i)[2];
$cont.addClass('vimeo-video-container');
embedVimeoVideo($cont, vimid, autoplay, width, height, qual, callback);
return;
}
// if none of the above then it's local...use a flash player for .flv, .f4v & .mp4 but HTML5 for anything else
$cont.addClass('hosted-video-container');
embedHostedVideo($cont, url, autoplay, width, height, qual, callback);
}
var ytEmbedCnt = 0;
function embedYouTubeVideo($cont, id, autoplay, width, height, qual, callback, useDefaultYouTube)
{
var fid = $cont.attr('id');
if (fid == null || fid == undef || fid == '')
{ fid = 'youtube-custom-'+ytEmbedCnt; $cont.attr('id', fid); ytEmbedCnt++; }
// if want to use classic youtube
if (useDefaultYouTube)
{
var apNum = autoplay ? '1' : '0';
$cont.html('');
return;
}
// if we have flash available, use the custom player
if (swfobject.hasFlashPlayerVersion('10.0.0'))
{
var q = (qual == undef || qual == '') ? 'default' : qual;
var fv = { id:id, autoplay:autoplay?'true':'false', quality:q };
swfobject.embedSWF(THEME_ROOT+'/flash/youtube-player'+(DEFAULT_BG_COLOR=='#000000'?'-dark':'')+'.swf', fid, width, height, '10.0.0', false, fv, {wmode:'opaque', bgcolor:'#000000', allowScriptAccess:'always', allowFullScreen:'true'});
if (callback) callback();
return;
}
// otherwise we use the youtube HTML5 api so we still have a custom player, just not quite as nice
this.embedYouTubeHtml5Player = function()
{
var vid, $chrome, $cover, $stream, $playhead, $hitbar, $playPause, $replay, $centerPlay;
$cont.html('
');
$cont.css({ width:width, height:height });
$chrome = $cont.children('.video-chrome');
$stream = $chrome.children('.vc-stream-bar');
$playhead = $chrome.children('.vc-playhead-bar');
$replay = $cont.children('.vc-replay');
$centerPlay = $cont.children('.vc-center-play');
$replay.hide();
$centerPlay.hide();
$chrome.hide();
var playing = false;
var qualIsSet = false;
var onPlayerStateChange = function(event)
{
// the youtube JS API has 2 serious fualts with the quality setting. 1) it doesn't work on the onReady...so you have to load, set qual, then reload
// 2) it doesn't default to the next lowest one if qual suggestion is higher than available, like the API says it will
// so because of that, quality has to be set here, and has to have some logic done to find the right setting
if (!qualIsSet && qual != 'default' && qual != vid.getPlaybackQuality()) {
qualIsSet = true;
var qualities = ['highres','hd1080','hd720','large','medium','small'];
var available = vid.getAvailableQualityLevels();
if (qual!='default' && available.indexOf(qual)==-1)
{
var start = qualities.indexOf(qual);
for (i=start; i -1)
{ qual = qualities[i]; break; }
}
vid.setPlaybackQuality(qual);
}
var state = event.data;
if (state == 0) // video ended
onVideoEnded();
if (state == 1) // playing
onVideoPlaying();
if (state == 2) // paused
onVideoPaused();
if (state == 3) // buffering
onVideoBuffering();
}
var waitingAtEnd = false;
var onVideoEnded = function()
{
playing = false;
vid.pauseVideo();
vid.seekTo(vid.getDuration()-1);
vid.pauseVideo();
$playPause.addClass('paused');
waitingAtEnd = true;
$replay.fadeIn();
$replay.bind('click', onPlayPauseToggle);
}
var onVideoPlaying = function() { playing = true; }
var onVideoPaused = function() { playing = false; }
var onVideoBuffering = function() { playing = false; }
var chromeOutDel;
var firstMouseMove = function()
{
$cover.unbind('mousemove', firstMouseMove);
showChrome();
}
var showChrome = function()
{
if (isWaitingToPlay) return; // only applies if not autoplay, and center button not clicked yet
clearTimeout(chromeOutDel);
$chrome.stop().animate({opacity:1}, 'normal');
}
var hideChrome = function()
{
clearTimeout(chromeOutDel);
chromeOutDel = setTimeout(actualHideChrome, 100);
}
var actualHideChrome = function()
{
$chrome.stop().animate({opacity:0}, 'normal');
}
var onMuteToggle = function()
{
$this = jQuery(this);
var isMuted = $this.hasClass('muted');
$this.toggleClass('muted');
vid.setVolume(isMuted ? 100 : 0);
}
var isWaitingToPlay = false;
var onPlayPauseToggle = function()
{
var isPaused = $playPause.hasClass('paused');
$playPause.toggleClass('paused');
if (isWaitingToPlay) // if at start with big center play button
{
$centerPlay.unbind('click', onPlayPauseToggle);
$centerPlay.stop(true,true).fadeOut();
isWaitingToPlay = false;
}
if (isPaused && waitingAtEnd)
{
vid.seekTo(0);
vid.playVideo();
waitingAtEnd = false;
$replay.fadeOut();
$replay.unbind('click', onPlayPauseToggle);
return;
}
if (isPaused)
vid.playVideo();
else
vid.pauseVideo();
}
var playAfterScrub = false;
var scrubbing = false;
var scrubFalseDel; // delay setting to false or playhead jumps around after scrub
var trackScrubStart = function(event)
{
clearTimeout(scrubFalseDel);
scrubbing = true;
playAfterScrub = playing;
vid.pauseVideo();
jQuery(document).bind('mousemove', trackScrubMove);
jQuery(document).bind('mouseup', trackScrubEnd);
trackScrubMove(event);
return false;
}
var trackScrubMove = function(event)
{
var scrubPct = (event.pageX - $hitbar.offset().left) / 338;
var max = (vid.getVideoBytesLoaded() / vid.getVideoBytesTotal()) - .01; // only scrub within 99% of loaded
if (scrubPct > max) scrubPct = max;
if (scrubPct < 0) scrubPct = 0;
$playhead.css('width', scrubPct * 338);
vid.seekTo(vid.getDuration() * scrubPct, false);
return false;
}
var trackScrubEnd = function(event)
{
jQuery(document).unbind('mousemove', trackScrubMove);
jQuery(document).unbind('mouseup', trackScrubEnd);
trackScrubMove(event);
if (playAfterScrub) vid.playVideo();
clearTimeout(scrubFalseDel);
scrubFalseDel = setTimeout(function(){ scrubbing = false; }, 500);
}
var playheadUpdate = function()
{
// show the stream progress correctly
var newStreamW = (vid.getVideoBytesLoaded() / vid.getVideoBytesTotal()) * 338;
if (newStreamW > 338) newStreamW = 338;
if (newStreamW < 0) newStreamW = 0;
$stream.css('width', newStreamW+'px');
if (scrubbing) return;
// show the playhead properly
var newPlayHW = (vid.getCurrentTime() / vid.getDuration()) * 338;
if (newPlayHW > 338) newPlayHW = 338;
if (newPlayHW < 0) newPlayHW = 0;
$playhead.css('width', newPlayHW+'px');
}
var playheadInt;
var onPlayerReady = function()
{
$cover = $cont.children('.vid-cover');
$hitbar = $chrome.children('.vc-hit-bar');
$playPause = $chrome.children('.vc-play-pause');
if (!autoplay) $playPause.addClass('paused');
$cover.bind('mousemove', firstMouseMove); // if mouse started over the video, this makes it fade in chrome on first mouse move
$cover.bind('mouseover', showChrome);
$cover.bind('mouseout', hideChrome);
$cover.bind('click', onPlayPauseToggle);
$centerPlay.bind('click', onPlayPauseToggle);
$chrome.bind('mouseover', showChrome);
$centerPlay.bind('mouseover', showChrome);
$replay.bind('mouseover', showChrome);
$playPause.bind('click', onPlayPauseToggle);
$chrome.children('.vc-sound-toggle').bind('click', onMuteToggle);
$hitbar.bind('mousedown', trackScrubStart);
$chrome.show();
$chrome.css('opacity', 0);
if (!autoplay) { $centerPlay.show(); isWaitingToPlay = true; }
if (callback) callback();
playheadInt = setInterval(playheadUpdate, 200);
}
vid = new YT.Player('html5-'+fid,
{
height: "100%",
width: "100%",
videoId: id,
playerVars: {
'autoplay': autoplay?1:0,
'controls': 0,
'modestbranding': 1,
'showinfo': 0,
'showsearch': 0,
'wmode': 'opaque',
'rel':0
},
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange
}
});
}
if (youTubeApiIsReady) this.embedYouTubeHtml5Player();
else ytQueuedCalls.push(this.embedYouTubeHtml5Player);
}
function embedVimeoVideo($cont, id, autoplay, width, height, notusedqual, callback)
{
var apNum = autoplay ? '1' : '0';
$cont.html('');
if (callback) callback();
}
function embedHostedVideo($cont, url, autoplay, width, height, notusedqual, callback)
{
// once the web settles on standard video formats, and IE8 is obsolete, then we'll worry about implementing
// hosted video. Until then, upload your vid to YouTube or Vimeo to ensure cross-browser/device
alert("Check your shortcodes, that is not a valid Vimeo or YouTube URL.");
}
//////////////// below this line is a great place to put your analytics scripts ///////////////