/** 
 * @projectDescription	The Yard Creative JavaScript
 * @author 	Matt Hobbs m.r.hobbs@gmail.com
 * @version 	0.1 
 */

/** @id domReady
* @classDescription Function fires once the DOM is ready.
*/
jQuery(function($){
	$('body').addClass("hasJS");
	//Open external links in a new window
	$("a[href^='http']").attr('target','_blank');
	
	$("a[href^='http://www.theyardcreative.com/']").attr('target','');

	$("a[href^='http://theyardcreative.com/']").attr('target','');
	
	if($('body').is('.portfolioPage')){
		//Remove unused images from the page
		$('div#projectImages a img').each(function(){
			var tSrc = $(this).attr('src');
			if(typeof tSrc == 'undefined' || tSrc === ''){
				$(this).parent().remove();
			}
		});
		
		//Depending on the number of images in the page, change the number graphic.
		var imgNumber = $('div#projectImages a img').length;
		switch(imgNumber){
			case 2:
				$('div#projectImages ul').css({'backgroundPosition':'-242px -42px'});
				break;
			case 3:
				$('div#projectImages ul').css({'backgroundPosition':'-442px -42px'});
				break;
			case 4:
				$('div#projectImages ul').css({'backgroundPosition':'-642px -42px'});
				break;
			case 5:
				$('div#projectImages ul').css({'backgroundPosition':'-842px -42px'});
				break;
			default:
				$('div#projectImages ul').css({'backgroundPosition':'-242px -42px'});
				break;
		}
	}
	
	$('a[rel*=hkSet], a#newsStoryImage, a[rel*=projectGallery]').lightBox({
		imageLoading: '/assets/templates/theYardAssets/images/lightbox-ico-loading.gif',
		imageBtnClose: '/assets/templates/theYardAssets/images/lightbox-btn-close.gif',
		imageBtnPrev: '/assets/templates/theYardAssets/images/lightbox-btn-prev.gif',
		imageBtnNext: '/assets/templates/theYardAssets/images/lightbox-btn-next.gif',
		imageBlank : '/assets/templates/theYardAssets/images/lightbox-blank.gif'
	});
	/**
	 * SIFR Text
	 */
	$("#newHomepage #headerBox h1").sifr({
		path: '/assets/templates/theYardAssets/font',
		font: 'rockwell-bold'
	});
	
	
});
	
