/* Specific JS for precisionprinting.com
 * Ben Hayes, Aug 2010 */

Cufon.replace('h1:not(.split), h1.split em');
Cufon.replace('h2:not(.split, .list), h2.split em');
Cufon.replace('.content h3:not(.small)');
Cufon.replace('.content h4:not(.list)');

/*

   -- -- -- -- -- -- --
   Fading background image powered by JQuery
   Initial idea taken from Dave Shea (http://www.brightcreative.com)
   Adapted and extended by Ben Hayes, Sep 2010
   -- -- -- -- -- -- --

*/

$(document).ready(function(){

		// control hover in/out fade speed
		var fadeSpeed = 300;

		// remove link background images since we're re-doing the hover interaction below 
		// (doing it this way retains the CSS default hover states for non-javascript-enabled browsers)
		// However, we don't want to remove it from the 'current' nav item
		$("#mainnav li").children("a").not(".current").css({backgroundImage:"none"});


		// toggle colour bar shift on hover of nav items
		attachNavEvents("home");
		attachNavEvents("about");
		attachNavEvents("services");
		attachNavEvents("clients");
		attachNavEvents("accreditations");

		function attachNavEvents(id) {

			function turnOn() {
				// create pseudo-link and fade it in. We make this a class not an ID, so it's easy to destroy more than one of them onmouseout
				$("#mainnav").prepend('<div class="nav-' + id + '"></div>');
				$("div.nav-" + id).css({display:"none"}).fadeIn(fadeSpeed);
			}

			function turnOff() {
				// fade out & destroy all pseudo-links with this class (there may be more than 1 by now!)
				$("div.nav-" + id).fadeOut(fadeSpeed, function() {
					$(this).remove();
					});
			}

			$("#mainnav #" + id).mouseover(turnOn);
			$("#mainnav #" + id).mouseout(turnOff);
		}

});

$(document).ready(function() {
		$('#slideshow').cycle({
			fx:     'scrollHorz', 
			slideExpr: 'div',
			prev:   '.prev', 
			next:   '.next', 
			cleartype: 1,
			cleartypeNoBg: true,
			timeout: 7000 
		});
});


/*

   -- -- -- -- -- -- --
   Set up fancybox:
   -- -- -- -- -- -- --

*/
jQuery(document).ready(function($){
	$('a[href$=".jpg"],a[href$=".JPG"],a[href$=".bmp"],a[href$=".BMP"],a[href$=".gif"],a[href$=".GIF"],a[href$=".jpeg"],a[href$=".JPEG"],a[href$=".png"],a[href$=".PNG"]')
		.attr('rel', 'gallery')
		.addClass('fancybox');
	$('a.fancybox').fancybox({
		'titlePosition'	: 'over',
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic',
		'onComplete'	: function() {
			$('#fancybox-wrap').hover(function() {
				$('#fancybox-title').show();
			}, function() {
				$('#fancybox-title').hide();
			});
		}
	});
});


