/* LOADING FUNCTION */
jQuery(document).ready(function() {

	jQuery.getJSON("http://twitter.com/statuses/user_timeline/ivanprobst.json?callback=?", function(data) {
		var tweet = data[0].text;
		
	//var tweet = "at tadpolsky.com -  pour Mario http://goo.gl/fb/Sbmy Quelques tenues inédites http://goo.gl/fb/Sbmy Quelques tenues";
		if(tweet.indexOf("http") > -1) {
			var tmpTweet = tweet.substr(tweet.indexOf("http"));

			var prevLink = tweet.substring(0, tweet.indexOf("http"));
			var afterLink = "";
			var url = "";
			if(tmpTweet.indexOf(" ") > -1) {
				url = tmpTweet.substring(0, tmpTweet.indexOf(" "));
				afterLink = tmpTweet.substr(tmpTweet.indexOf(" "));
			}
			else
				url = tmpTweet.substring(0, tmpTweet.length);
		
			tweet = prevLink+"<a href=\""+url+"\">"+url+"</a>"+afterLink;
		}
		
		jQuery("#actual-tweet").html(tweet);
	});
	
	

	

	/* Follow Overlay settings */
	jQuery('#nav-follow-link').overlay({
		expose: { 
			color: '#333',
			opacity: 0.5 
		}, 
		closeOnClick: true 
	});
	/* Share settings */
	jQuery('.share-post-link a').overlay({
		expose: { 
			color: '#333',
			opacity: 0.5 
		}, 
		closeOnClick: true 
	});
	
	/* Search error message */
	jQuery('#search-button').click(function() {
		if(jQuery('#s').val() == "") {
			jQuery('#search-error-message').show();
			return false;
		}else
			return true;
	});
	
	/* Archive and tags drop down box */
	jQuery("#month-search").change(function(){
		document.location.href=this.options[this.selectedIndex].value;
	});
	jQuery("#type-search").change(function(){
		document.location.href=this.options[this.selectedIndex].value;
	});
});