var pbg = "";
$(function(){
	$('#survey p a').click(function(){
		window.open(this.href,'survey','location=1,status=1,scrollbars=1,width=500,height=600');
		return false;
	});
	/* add home link to logo */
	$("#logo").hover(function(){
		$(this).css("cursor","pointer");
	}).click(function(){
		window.location="/";return false;
	});
	
	/* show and hide top subnav links */
	$("#about_links ul").hide();
	$("#about_links ul").mouseleave(function(){
		$(this).fadeOut();
	});
	$(".top_nav:contains('about')").click(function(){
		$("#about_links ul").toggle("slow");
	});
	
	$(".top_nav:contains('about')").hover(function(){
		$(this).css("cursor","pointer");
	}).mouseenter(function(){
		$(this).css("background-color","#B58E43");
	}).mouseleave(function(){
		$(this).css("background-color","#695D46");
	});
	
	$("#contact_links ul").hide();
	$("#contact_links ul").mouseleave(function(){
		$(this).fadeOut();
	});
	$(".top_nav:contains('contact')").click(function(){
		$("#contact_links ul").toggle("slow");
	});
	
	$(".top_nav:contains('contact')").hover(function(){
		$(this).css("cursor","pointer");
	}).mouseenter(function(){
		$(this).css("background-color","#B58E43");
	}).mouseleave(function(){
		$(this).css("background-color","#695D46");
	});
	
	/* give top subnav links hover bg color */
	$("#about_links li").mouseenter(function(){
		$(this).css("background-color","#FFF6C5");
	}).mouseleave(function(){
		$(this).css("background-color","#fff");
	});
	
	$("#contact_links li").mouseenter(function(){
		$(this).css("background-color","#FFF6C5");
	}).mouseleave(function(){
		$(this).css("background-color","#fff");
	});
	
	/* fade in flickr photo on load */
	$("#flickr").fadeIn(5000);
	
	/* give hover colors to left nav */
	$("#lft_nav li").hover(function(){
		$(this).css("cursor","pointer");
	}).click(function(){
		window.location=$(this).find("a").attr("href");return false;
	});
	$("#lft_nav li").mouseenter(function(){
		$(this).css("background-color","#B58E43");
	}).mouseleave(function(){
		$(this).css("background-color","#695D46");
	});
	
	/* show latest flickr photo */
	$.getJSON("http://www.flickr.com/services/rest/?method=flickr.photos.search&user_id=81085559@N00&per_page=1&format=json&api_key=594fb249392c0301ff092bb17a325a16&jsoncallback=?",
		function(data){
			$.each(data.photos.photo, function(i,p){
				pbg = "<a href='http://www.flickr.com/photos/goodseaweed/' target='_blank'><img src='http://farm"+p.farm+".static.flickr.com/"+p.server+"/"+p.id+"_"+p.secret+".jpg' width='300' alt='"+p.title+"' title='"+p.title+"'></a><br /><p>&quot;"+p.title+"&quot;</p>";
				$("#flickr").append(pbg);
			});
		}
	);
	/* show latest tweets */
	$.getJSON("http://twitter.com/statuses/user_timeline.json?screen_name=logginglife&callback=?",
		function(data){
			$.each(data, function(i,t){
				if(i<1){$("#twitter1").append(t.text);}
			});
		}
	);
	$.getJSON("http://twitter.com/statuses/user_timeline.json?screen_name=intrinsi&callback=?",
		function(data){
			$.each(data, function(i,t){
				if(i<1){$("#twitter2").append(t.text);}
			});
		}
	);
});