var zch = zch || [];
zch.client = {
	oInterval:null,
	seeSite:function(e) {
		$(".client .figure").hover(function(e) {
			$(".link-client-site").fadeIn();
		},function(e) {
			$(".link-client-site").fadeOut();	
		});
	},	
	toggle:function(e) {
		$(".show-case aside a").click(function(e) {
			e.preventDefault();
			$(".show-case .figure img").hide();
			var sTarget = $(this).data("imageToShow");
			$("#" + sTarget).show();
			$(".show-case aside a").removeClass("selected");
			$(this).addClass("selected");
		})
	},
	deepLink:function(e) {
		if($(".client").length > "0") {
			var sHash = window.location.hash;
			if(sHash != "") {
				//removed "." + from before sHash below.
				var oTarget = $(sHash + " a");				
				zch.client.toggle.call(oTarget);
			}
		}
	},
	homepageRotateDo:function(e){
		$(".homepage .strapline hgroup").fadeToggle("fast");
	},
	homepageRotate:function(e){
		zch.client.oInterval = setInterval(function(){zch.client.homepageRotateDo();},4000);
		
		$(".homepage .rotating-banner-nav a").click(function(){
			zch.client.homepageRotateDo();
			clearInterval(zch.client.oInterval);
			return false;
		});
	}
};

$(document).ready(function() {
	$(".show-case .figure img:not(:first)").hide();
	$(".show-case aside a:first").addClass("selected");
	zch.client.seeSite();
	zch.client.toggle();
	zch.client.deepLink();
	zch.client.homepageRotate();	
	$('a:not([href=""])').each(function() {		
		if (this.hostname !== location.hostname) {
			$(this).addClass('external-link').attr('target', "_blank");
		}
	});
});

