

$(document).ready
(
 	function()
	{
 		emBossedLists();
		emBossedTeam();
		animateCat();
		quoteTerminator();
		$('a:not([href^="http://www.yellowcat"]):not([href^="http://yellowcat"])[href^="http://"] ').attr("target", "_blank");
		$('a[href$=".pdf"]').attr("target", "_blank");
		$('div.articles div.team_emboss h2').css('display','none');
		$('div.articles div.team_emboss ').css('display','none');
		
		$('ul.year_nav li span a').click(function() {
			if($(this).parents('li:first').hasClass('archive') )
			{
				return true;	
			}
			else if($(this).parents('li:first').hasClass('on') )
			{
				return false;	
			}
			else
			{
				$('ul.year_nav li').removeClass('on');
				$('div.articles div.team_emboss').removeClass('on');
				var a_link = $(this).attr('href');
				a_link = a_link.substr(1);
				$(this).parents('li:first').addClass('on');
				$('div.articles div#'+a_link).addClass('on');
			}
			return false;
		});
		
	}//ready function
);//ready




function animateCat() 
{
	var time = false;
	if($("div.blink_off:visible").length > 0)
	{
		time = 100;
		$('div.blink_off').hide();
		$('div.blink_on').show();
	}
	else if($("div.blink_on:visible").length > 0)
	{
		time = 5000;
		$('div.blink_off').show();
		$('div.blink_on').hide();
	}
	
	if(time != false)
	{
		window.setTimeout(animateCat, time);
	}
}
function emBossedTeam()
{
	var listCount = $('p.team_thumb').length;
	if(listCount > 0)
	{
		var emBossOpen='<div class="team_emboss"><div class="tc"></div><div>';
		var emBossClose = '</div><span><span></span></span></div>';
		var emBoss = '<div class="team_emboss"><div class="tc"></div><div class="emboss_body"></div><span><span></span></span></div>';
		$(emBoss).insertBefore('p.team_thumb:first');
		$('p.team_thumb').appendTo('div.team_emboss div.emboss_body');
		var tallest = 0;
		$('p.team_thumb').each(
			function(i)
			{	
				var h = $(this).height();
				tallest = Math.max(h,tallest);
			}
		);
		$('p.team_thumb').css('height', tallest);
		//alert(tallest);
	}//if list count
}

function emBossedLists()
{
	/*
	Only allowed max of 3 embossed lists on a page and in sequence - any more and subsequent lists are wrapped as singles
	*/
	var listCount = $('ul.embossed_lists').length;
	if(listCount > 0)
	{
		var emBossOpen=new Array('<div class="emboss"><div></div>','<div class="emboss emboss_single"><div></div>','<div class="emboss emboss_half"><div></div>');
		var openIndex = 0;//by default the opening options is a 1 thrid
		var emBossClose = '<span><span></span></span></div>';
		var testStr = 'testStr: ';
		
		switch(listCount)
		{
			case 1:
				openIndex = 1;
				break;
			case 2:
				openIndex = 2;
				break;
			default:
				openIndex = 0;
				break;
		}//switch
		$('ul.embossed_lists li:empty').html('&nbsp;');
		$('ul.embossed_lists').each(
			function(i)
			{	
				if(i > 2){openIndex = 1;}//more than 3 uls - subsequent uls are singles by default
				
				var thisHTML = '<ul class="embossed_lists">'+$(this).html()+'</ul>';
				$(this).replaceWith(emBossOpen[openIndex]+thisHTML+emBossClose);
			
			}//function
		);
		
		/*
		switch(listCount)
		{
			case 1:
				$('ul.embossed_lists').
				break;
			
		}//switch
		*/
		
	}//if embossed lists
}//function

function quoteTerminator()
{
	/***
		Quote wrapper
		Ensure parent p is positioned relative
		***/
		
		
		if(!isset(BASE_URL)){var base_url = '';}
		else
		{
			var base_url = BASE_URL+'/';
		}
		
		$('p.quote').each(
		function(index)
		{
			var padding_left = 20;
			var margin_top = 2;
			if($(this).find('span').length==0)
			{
				$(this).wrapInner('<span></span>');
			}
			
			
			$(this).find('span').after(' <span class="jq_close"><img src="'+base_url+'images/close_quote.gif" /></span>');
			
			var p_left = $(this).position().left;
			var p_width = $(this).width();
			var el = $(this).find('span.jq_close');
			var height = el.height();
			var width=el.width();
			var pos = el.position();
			var x = pos.left;
			var y = pos.top;
			
			if(x==padding_left)//then carriage return forced
			{
				x= p_width+5+width;
				y = y-height;
			}
			
			y = y + margin_top;
			
			el.css({'position' : 'absolute', 'left' : x,'top' : y,'display':'block','padding':'0'});
		}//function
		);//each
}//function

if(!Array.indexOf){//index of breaks ie
	Array.prototype.indexOf = function(obj){
		for(var i=0; i<this.length; i++){
			if(this[i]==obj){
				return i;
			}
		}
		return -1;
	}
}

try {//ie6 image swap cache problem
  document.execCommand("BackgroundImageCache", false, true);
} catch(err) {}


function isset( variable )
{
	return( typeof( variable ) != 'undefined' );

}


function eml_snd(part2,part1)
{
	mail_str = 'mailto: '+part1+'@'+part2;
	return mail_str;
}