jQuery.fn.fadeDelay = function() {delay = 0;return this.each(function() {$(this).delay(delay).fadeIn(250); delay += 400; });
};
$(document).ready(function() {
//menus setup
$("#keylinks").hide().delay(1550).slideDown('slow');
$('.hotspot').hide();
$('.hotspot').delay(2000).fadeDelay();

$tooltip = $('.hotspot');
$tooltip.live('mouseover mouseout', function(event){
if (event.type == 'mouseover') {
$(this).find('.spot-tip').stop(true, true).show();
} else {
$(this).find('.spot-tip').stop(true, true).hide();
}
});
$("#nav a, #subnav a").each(function() {var hreflink = $(this).attr("href");if (hreflink.toLowerCase()==location.href.toLowerCase()) {$(this).addClass("current");$(this).parents("ul li").children("a").addClass("current");}});
	$("#nav li a").hover(function () {$(this).parent().addClass("active");},function () {$(this).parent().removeClass("active");});
	
var $casestudy = jQuery('#casestudy .casestudyitem'); 
$casestudy.after('<div id="casestudypager">').cycle({fx: 'fade',timeout: 0, randomizeEffects: false,speed:500,timeout:0,pager:'#casestudypager',next:'.next',prev:'.prev', pauseOnPagerHover: true, pause: true,before:function(){$(this).children('.hcstatement').hide();},after: function(){$(this).children('.hcstatement').delay(200).fadeIn(1200);}});


var $homecarousel = jQuery('#homecarousel .carouselitems'); 
$homecarousel.after('<div id="carouseldots">').cycle({fx: 'growX',timeout: 0, randomizeEffects: false,speed:500,timeout:4500,next:'.next',prev:'.prev',pager:'#carouseldots', pauseOnPagerHover: true, pause: true,before:function(){$(this).children('.hcstatement').hide();},after: function(){$(this).children('.hcstatement').delay(200).fadeIn(1200);}});

 $('a.expand[href*=#]').click(function() {if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {var $target = $(this.hash);$target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');if ($target.length) {var targetOffset = $target.offset().top - 50;$('html,body').animate({scrollTop: targetOffset}, 1000);return false;}}}); 
 
 $("a.bigtarget, a.readmore").bigTarget({hoverClass: 'over',clickZone : 'li:eq(0)' });
});
