var Supra = {

	/* load all required functions */
	load: function() {
		this.updateExternalLinks();
		this.updateSearchField();
		this.addPostToolsTabs();
	
	
		// showcase
		if( this.isIE6() ) {
			this.prepareIE6();
		}
	},
	
	/* make all rel=external links open in a new window */
	updateExternalLinks: function(){
		$('a[rel=external]').click(function(){
			window.open(this.href);
			return false;
			});
		},

	/* clear/revert search field value */
	updateSearchField: function() {

		searchInput = $("input[name=s]");	
		searchQuery = searchInput.val();
		
		searchInput.focus(function(){
			searchQuery = searchInput.val();
			searchInput.attr('value','');
			});

		searchInput.blur(function(){
			if(searchInput.val().length==0){
				searchInput.attr('value',searchQuery);	
				}
			});

		},

	
	// add tabs to blog post
	addPostToolsTabs: function(){
	

			addComment=$("#add-comment");
			shareThis=$("#share-this");

			$("#add-comment, #share-this").wrapAll("<ul class=\"tabs\"></ul>");
			$("#add-comment, #share-this").wrap("<li></li>");

			/* preparing tabs */
			if(addComment.height()>shareThis.height()) {
				maxPanelHeight = addComment.height();
				} else {
				maxPanelHeight = shareThis.height();
				}
				
			$('.tabs').height(maxPanelHeight+'px');
			$('.tabs h2').next().addClass("panel");
			$('.tabs>li:first').addClass('active');

			$('.tabs h2').click(function(){
				$('.tabs li').removeClass('active');
				$(this).parents(1).addClass('active');
			});

			$('#share-this h2').css('left',$("#add-comment h2").width()+40+'px');
	},


	// check if is IE6
	isIE6: function() {
	
		if( ( jQuery.browser.msie )&&( parseInt(jQuery.browser.version)<7 ) ) {
			return true;
		} else {
			return false;
		}

	
	},


	/* prepare for IE6 */		
	prepareIE6: function(){
		$("#projects-showcase-preview > div").before( "<span class=\"preview-browser\"></span>" );
	}
}


