var gOverride = {
	urlBase: 'http://gridder.andreehansson.se/releases/latest/',
	gColumns: 12,
	gOpacity: 0.35,
	gWidth: 10,
	pColor: '#C0C0C0',
	pHeight: 24,
	pOffset: 0,
	pOpacity: 0.55,
	center: true,
	gEnabled: true,
	pEnabled: true,
	setupEnabled: true,
	fixFlash: true,
	size: 960
};

var showRSS = false;

function clearDefaultValue(element) {
    if (element.value == element.defaultValue) element.value = '';
}

function showDefaultValue(element) {
    if (element.value == '') element.value = element.defaultValue;
}

$(window).load(function(){
	$("a.nav-logo").removeClass("loader");
});

$(document).ready(function(){
	$("#tweet-loader").append('<div style="text-align: center"><img src="/images/core/ajax-loader.gif" /></div>');
	
	$("#podcast-loader").append('<div style="text-align: center"><img src="/images/core/ajax-loader.gif" /></div>');
	
	$("a[href=#header]").click(function(){
		$("html, body").animate({scrollTop:0}, {duration: 500, easing: "easeInOutQuart"});
		return false;
	});
	
	if ($.browser.webkit) {
		$("#rss-panel").removeClass("hide");
		$('input[name="q"]').focus(function() {  
			$(".search").addClass("focused").removeClass("unfocused");
		});
		
		$('input[name="q"]').blur(function() {  
			$(".search").removeClass("focused").addClass("unfocused");
		});
		$(".nav-rss").click(function(event){
			$("#rss-panel").removeClass("closed");
			return false;
		});
		$("#rss-footer-toggle").click(function(event){
			$("#rss-panel").removeClass("closed");
			return false;
		});
	
		$("#rss-panel-close").click(function(event){
			$("#rss-panel").addClass("closed");
			return false;
		});
	}
	
	$("a[href=#archive]").click(function(){
		$("html, body").animate({scrollTop: $("#archive").offset().top}, {duration: 500, easing: "easeInOutQuart"});
		return false;
	});
	
	$("a[href=#2010apr]").click(function(){
		$("html, body").animate({scrollTop: $("#2010apr").offset().top}, {duration: 500, easing: "easeInOutQuart"});
		return false;
	});
	
	$("a[href=#2010jun]").click(function(){
		$("html, body").animate({scrollTop: $("#2010jun").offset().top}, {duration: 500, easing: "easeInOutQuart"});
		return false;
	});
	
	$("a[href=#2010mar]").click(function(){
		$("html, body").animate({scrollTop: $("#2010mar").offset().top}, {duration: 500, easing: "easeInOutQuart"});
		return false;
	});
	
	$("a[href=#2010feb]").click(function(){
		$("html, body").animate({scrollTop: $("#2010feb").offset().top}, {duration: 500, easing: "easeInOutQuart"});
		return false;
	});

	$("a[href=#2010jan]").click(function(){
		$("html, body").animate({scrollTop: $("#2010jan").offset().top}, {duration: 500, easing: "easeInOutQuart"});
		return false;
	});

	$("a[href=#2009dec]").click(function(){
		$("html, body").animate({scrollTop: $("#2009dec").offset().top}, {duration: 500, easing: "easeInOutQuart"});
		return false;
	});

	$("a[href=#2009nov]").click(function(){
		$("html, body").animate({scrollTop: $("#2009nov").offset().top}, {duration: 500, easing: "easeInOutQuart"});
		return false;
	});

	$.getFeed({
		url: '/includes/proxy.php?url=http://www.wyctim.com/feeds/vegetative.xml',
		success: function(feed) {	        
			var html = '';
			for(var i = 0; i < feed.items.length && i < 4; i++) {
				var item = feed.items[i];
				html += '<li><a href="/podcast/">' + item.title + '</a></li>';
			}
			$('#result').append(html);
			$("#podcast-loader").hide();
		}
	});

	$.getJSON("http://twitter.com/statuses/user_timeline/wyctim.json?count=1&callback=?",
		function(data){
			$("#tweet-link").append((data[0].text));
			$("#tweet-loader").hide();
		}
	);
});