//CUFON	 

Cufon.replace('body.home h3');
Cufon.replace('#subheading');
Cufon.replace('.breadcrumb', { hover: true });

var J = jQuery.noConflict();

J(document).ready(function(){ 
							   
							   			
			// apple check
			
if(navigator.platform == 'iPad' || navigator.platform == 'iPhone' || navigator.platform == 'iPod') {
	//alert('apple');
     J("#video_tabs div a").removeClass("vimeo");
}

// handheld check

if ((screen.width<=960) && (screen.height<=480)) {
//alert('Small screen');
     J("#video_tabs div a").removeClass("vimeo");
}

if ((screen.height<=960) && (screen.width<=480)) {
//alert('Small screen');
     J("#video_tabs div a").removeClass("vimeo");
}
							      
							   
         J(".sf-menu").supersubs({ 
            minWidth:    13,  
            maxWidth:    16,   
            extraWidth:  2   
                               
        }).superfish({
			autoArrows:    true, 
			dropShadows:   false
		}); 
		
		
	// add icons
					 
					 J("a[href$='.pdf']").addClass("pdf");
					 J("a[href$='.doc']").addClass("doc");
					 J("a[href$='.docx']").addClass("doc");
					 J("a[href$='.ppt']").addClass("ppt");
					 J("a[href$='.pptx']").addClass("ppt");
					 
		
		// FANCYBOX
		
		
						J.fn.getTitle = function() {
			var arr = J("a.fancybox");
			J.each(arr, function() {
				var title = J(this).children("img").attr("alt");
				if (title =="") {title = J(this).next().children("p").html()}; // create title from PWA + PHP captions
				if (title == "") {title = J(this).attr("title")}; // if nothing else, set title to that of the page
				J(this).attr('title',title);
			})
		}

		// Supported file extensions
		var thumbnails = 'a:has(img)[href$=".bmp"],a:has(img)[href$=".gif"],a:has(img)[href$=".jpg"],a:has(img)[href$=".jpeg"],a:has(img)[href$=".png"],a:has(img)[href$=".BMP"],a:has(img)[href$=".GIF"],a:has(img)[href$=".JPG"],a:has(img)[href$=".JPEG"],a:has(img)[href$=".PNG"]';

	
		J(thumbnails).addClass("fancybox").attr("rel","fancybox").getTitle();

		//J(thumbnails).addClass("fancybox").attr("rel","fancybox");

			J("a.fancybox").fancybox({
			'imageScale': true,
			'padding': 10,
			'zoomOpacity': true,
			'zoomSpeedIn': 500,
			'zoomSpeedOut': 500,
			'zoomSpeedChange': 300,
			'overlayShow': true,
			'overlayColor': "#666666",
			'overlayOpacity': 0.3,
			'enableEscapeButton': true,
			'showCloseButton': true,
			'hideOnOverlayClick': true,
			'hideOnContentClick': false,
			'frameWidth':  560,
			'frameHeight':  340,
			'callbackOnStart': null,
			'callbackOnShow': null,
			'callbackOnClose': null,
			'centerOnScroll': true,
			'title'			: this.title,
			'titlePosition'	:	'over'


		});
			
						J(".vimeoBadge .clip a").click(function() {
		J.fancybox({
			'padding'		: 0,
			'autoScale'		: false,
			'transitionIn'	: 'none',
			'transitionOut'	: 'none',
			'title'			: this.title,
			'width'			: 640,
			'height'		: 427,
			'href'			: this.href.replace(new RegExp("([0-9])","i"),'moogaloop.swf?clip_id=$1'),
			'type'			: 'swf'
		});

		return false;
	});
		
		
		
			J("a.video_play").fancybox({
		'hideOnContentClick': false,
		'width'				: 720,
		'height'			: 410,
        'autoScale'     	: false,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe',
		'titleShow'			: false,
		'padding'			: 0
	});

	
	
			J(".vimeo").click(function() {
		J.fancybox({
			'padding'		: 0,
			'autoScale'		: false,
			'transitionIn'	: 'none',
			'transitionOut'	: 'none',
			'title'			: this.title,
			'width'			: 640,
			'height'		: 427,
			'href'			: this.href.replace(new RegExp("([0-9])","i"),'moogaloop.swf?clip_id=$1'),
			'type'			: 'swf'
		});

		return false;
	});
			
			
	J(".partner_logos a.modal").fancybox({
			'imageScale': true,
			'padding': 20,
			'zoomOpacity': true,
			'zoomSpeedIn': 500,
			'zoomSpeedOut': 500,
			'zoomSpeedChange': 300,
			'overlayShow': true,
			'overlayColor': "#666666",
			'overlayOpacity': 0.3,
			'enableEscapeButton': true,
			'showCloseButton': true,
			'hideOnOverlayClick': true,
			'hideOnContentClick': false,
			'width'			: 540,
			'height'		: 300,
			'autoDimensions': false,
			'centerOnScroll': true,
			'titleShow'			: false
		});


						

		// XHTML TARGET FIX
J('a.newwin').attr('target', '_blank');


// SHOW HIDE
J('#showhide a').toggle(
  function () {
    J('#wrap').addClass("hide");
	J.cookie("dontdim", "true", { path: '/' }); // if full background is shown, set a cookie to prevent dimming
	J('body.home #backstretch img').removeClass("dim");
	J(this).html('Show Website');
  },
  function () {
	J('#wrap').removeClass("hide");
	J.cookie("dontdim", null);
	J('body.home #backstretch img').addClass("dim"); // on the home page, allow dimming, since the website (content) is being shown
    J(this).html('Show Background');
  }
);

}); // end doc ready
	
