$(document).ready(function() {
	
	/* 
	* attach a function to open all links with a class of "external" in a new window 
	* this avoids the use of target="_blank" and allows us to validate as XHTML strict
	*/
	$("a[rel^='external']").click( function() {
		window.open(this.href);
		return false;
	});
	
	// prevent ie from flickering with css backgrounds
	try {
		document.execCommand('BackgroundImageCache', false, true);
	} catch(e) {}   
	
	if($("#slides > div").size() == 1 ){
		$('#slides div').show();
	} else {
		$('#slides').cycle({
			fx: 'fade',
			timeout: 8000, 
			speed:  400,
			pager:  '#slideNav'
		});
	}
	
	$("a[rel^='prettyPhoto']").prettyPhoto({
		animationSpeed: 'normal', /* fast/slow/normal */
		opacity: 0.8, /* Value between 0 and 1 */
		showTitle: true, /* true/false */
		allow_resize: false,
		theme: 'light_rounded'
	});

	//Slide Toggles
	$('.slide_toggle').toggle( function(){
		$(this).text('- (minimize)').siblings('div').toggle('blind');
		$(this).siblings('p.teaserText').toggle('blind');
	},function(){
		$(this).text('+ (read more)').siblings('div').toggle('blind');
		$(this).siblings('p.teaserText').toggle('blind');
	})
	
	//Default Action
	$(".tab_content").hide(); //Hide all content
	$("ul.tabs li:first").addClass("active").show(); //Activate first tab
	$(".tab_content:first").show(); //Show first tab content
	
	//On Click Event
	$("ul.tabs li").click(function() {
		$("ul.tabs li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".tab_content").hide(); //Hide all tab content
		var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active content
		return false;
	});
		
});


