var timer;
	
$(document).ready(function(){

	// ================================================================================================
	// Activate menu
	$("ul.topnav li span").hover(function() { //When trigger is clicked...
		//Following events are applied to the subnav itself (moving subnav up and down)
		$(this).parent().find("ul.subnav").slideDown(300).show(); //Drop down the subnav on click

		$(this).parent().hover(function() {
		}, function(){
			$(this).parent().find("ul.subnav").slideUp(300); //When the mouse hovers out of the subnav, move it back up
		});

		//Following events are applied to the trigger (Hover events for the trigger)
		}).hover(function() {
			$(this).addClass("subhover"); //On hover over, add class "subhover"
		}, function(){	//On Hover Out
			$(this).removeClass("subhover"); //On hover out, remove class "subhover"
	});

	// ================================================================================================
	// Activate thumbnail viewer if there is one
	jQuery.noConflict();
	$(".shots").yoxview({
			backgroundColor: '#000000',
			playDelay: 5000
	});
	$("#circles").yoxview({
			backgroundColor: '#000000',
			playDelay: 5000
	});

	// ================================================================================================
	// Activate TABS if there are any
	// Simple Tab code from : http://www.sohtanaka.com/web-design/simple-tabs-w-css-jquery/
	//When page loads…
	$(".tab_content").hide(); //Hide all content
	$("ul.tabs li:first").addClass("active").show(); //Activate first tab
	$(".tab_content:first").show(); //Show first tab content
	
	//attribute an idea to each of the top tabs so we can manipulate them later
	//it is using the href value you enter, in this case #tab1, #tab2 etc and adds _top
	$('.tabs li').each(function(i) {
		var thisId = $(this).find("a").attr("href");
		thisId = thisId.substring(1,thisId.length) + '_top';
		$(this).attr("id",thisId);
	});
	
	function changeTab(activeTab){
		$("ul.tabs li").removeClass("active"); //Remove any "active" class
		$(activeTab + '_top').addClass("active"); //Add "active" class to selected tab, using the id created at document load	
		$(".tab_content").hide(); //Hide all tab content
		$(activeTab).fadeIn(); //Fade in the active content
	}

	//check to see if a tab is called onload
	if (location.hash!=""){changeTab(location.hash);}//if you call the page and want to show a tab other than the first, for instance index.html#tab4

	//On Click Event
	$("ul.tabs li").click(function() {
		//call above function
		changeTab($(this).find("a").attr("href"));
		return false;
	});

	//if you want to open a tab from a link which is not a tab, make sure you give that link a class of external_link
	//example: Lets go to tab 4 to contact us
	//this can be within your content anywhere on the page, remember that it will not jump to the menu!
	$(".external_link").click(function() {
		//call above function
		changeTab($(this).attr("href"));
		return false;
	});
	
	// ================================================================================================
	// Get Twitter feed...
	//getSearch("JAKprint");
	
	// ================================================================================================
});

function getSearch(src)
{
	clearTimeout(timer);
	var results="";
	var showing=0;
	
	$.post("/GetTwitter.php?src="+src, {query: ""},  function(xml){																										 
			$('entry',xml).each(function(i){
			var title = $(this).find('content').text();

			var show_post = 0;

			/* only show posts referencing user name */
			var s1 = new RegExp("@<b>"+src+"</b>", 'gi');
			if (s1.test(title) == true) show_post = 1;

			/* only show posts originating from user name */
			var s2 = new RegExp(src+":", 'gi');
			if (s2.test(title) == true) show_post = 1;

			if(show_post==1 && showing<10){
				results = results + '<div class="twitter-post">'+title+'</div>';
				showing = showing + 1;
			}
		});
		$("#twitter-wrapper").html(results);
});

timer = setTimeout('getSearch()', 600000);
}
