﻿//jCarousel function
 
function mycarousel_initCallback(carousel) {
    jQuery('#mycarousel-controls a').bind('click', function() {
        carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
        return false;
    });
 }
 
//jCarousel - highlight link in focus
function mycarousel_itemFirstInCallback(carousel, item, idx, state) {
    jQuery('#mycarousel-control-' + idx).addClass("mycarousel-controls-on");
}
 
//jCarousel - de-highlight link no longer in focus
function mycarousel_itemFirstOutCallback(carousel, item, idx, state) {
    jQuery('#mycarousel-control-' + idx).removeClass("mycarousel-controls-on");
}
 
jQuery(document).ready(function() {
	//make external links open in a new window - content div only
	jQuery('a').filter(function() {
        	return this.hostname && this.hostname !== location.hostname;
    	}).addClass("external").attr({target: "_blank"});

	//make external area links open in a new window - homepage image map
	jQuery('area').filter(function() {
        	return this.hostname && this.hostname !== location.hostname;
    	}).addClass("external").attr({target: "_blank"});

     	//make first link of footer nav have class strong
    	jQuery("#first .widget_pages ul li a").addClass("strong");
    	jQuery("#first .widget_pages ul li ul li a").removeClass("strong");
    	
    	//jCarousel  	
    	jQuery('#mycarousel').jcarousel({
	        // Configuration goes here
	        scroll: 1,
	        auto: 5,
	        initCallback: mycarousel_initCallback,
	        buttonNextHTML: "<a title='Next' class='homeCarouselbuttonNext' href='#'>Next</a>",
	        buttonPrevHTML: "<a title='Previous' class='homeCarouselbuttonPrev' href='#'>Previous</a>",
	        itemFirstInCallback:  mycarousel_itemFirstInCallback,
	        itemFirstOutCallback: mycarousel_itemFirstOutCallback,
	        wrap:'both'
        });    	

        //Case Studies expansion
     	jQuery(".jsCaseStudyBody").hide();
        jQuery(".jsCaseStudyExpand").click(function() {
        	jQuery(this).find(".jsCaseStudyBody").slideToggle("fast");
        });
	
	//404 Page Rollover
	jQuery(".four04-link").hover(function() {
		jQuery(".four04-content").addClass("four04-roll")
		},
	function() {
		jQuery(".four04-content").removeClass("four04-roll")
		});
		
});