jQuery.noConflict();  


jQuery(function(){
	// makes search box 'watermark text' work using jquery.searchField.js
	jQuery('input').searchField();
	jQuery('textarea').searchField();
});

var tabState = "closed";

// show or hide footer contact tab
function contactTab() {
	if (tabState == "closed") {
		// open contact tab
		//jQuery('#footer_tab_wrapper').css("overflow", "auto");
		jQuery('#footer_tab_wrapper').css("height", ( jQuery('#footer_tab_content').height() + 20 ) + "px");
		jQuery('#footer_tab_wrapper').animate({"top": "-=" + ( jQuery('#footer_tab_wrapper').height() - 20 ) + "px"}, "fast");
		tabState = "open";
	} else {
		// close contact tab
		//jQuery('#footer_tab_wrapper').css("overflow", "hidden");
		jQuery('#footer_tab_wrapper').animate({"top": "+=" + ( jQuery('#footer_tab_wrapper').height() - 20) + "px"}, "fast");
		jQuery('#footer_tab_wrapper').animate({"height": "20px"}, "fast");
		// jQuery('#footer_tab_wrapper').css("height", "20px");
		tabState = "closed";
	}
};


// keep footer & contact tab placed correctly if browser is resizedq
jQuery(window).resize(function() {
	jQuery('#footer').css("top", ( jQuery(window).height() - jQuery('#footer').height() ) + "px");
	jQuery('#footer_tab_wrapper').css("top", ( jQuery(window).height() - jQuery('#footer').height() - jQuery('#footer_tab_wrapper').height() ) + "px");
});


jQuery(document).ready(function() {

	// move footer to the bottom, then show it
	jQuery('#footer').css("top", ( jQuery(window).height() - jQuery('#footer').height() ) + "px");
	jQuery('#footer').show();

	// position contact tab
	jQuery('#footer_tab_wrapper').css("top", ( jQuery(window).height() - jQuery('#footer_tab_wrapper').height() ) + "px");
	jQuery('#footer_tab_wrapper').show();
	jQuery('#footer_tab_wrapper').animate({"top": "-=" + jQuery('#footer').height() + "px"}, "slow");
	jQuery('#footer_tab_wrapper').css("position", "fixed");


	jQuery('#footer_tab_wrapper #footer_contact_tab_wrapper #footer_contact_tab a').click(function() {
		contactTab();
		return false;
	});
	jQuery('a.showContactTab').click(function() {
		contactTab();
		return false;
	});




	// prevent tab key from jumping cursor into the closed footer
	jQuery(document).unbind().bind('keypress', function(event) { 
		if(tabState == "closed") {
		    if(event.which == 0) {
		    	return false;
			} 
		}
	}); 




	// show/hide sidebar blog section 
	jQuery('.aside .widget_categories h3').click(function() {
		if (jQuery(".aside .widget_categories ul").is(":hidden")) {
			jQuery('.aside .widget_categories h3').addClass('arrowselected');
			jQuery('.aside .widget_categories ul').slideDown();
		} else {
			jQuery('.aside .widget_categories h3').removeClass('arrowselected');
			jQuery('.aside .widget_categories ul').slideUp();
		}
		return false;
	});

	jQuery('.aside .widget_archive h3').click(function() {
		if (jQuery(".aside .widget_archive ul").is(":hidden")) {
			jQuery('.aside .widget_archive ul').slideDown();
		} else {
			jQuery('.aside .widget_archive ul').slideUp();
		}
		return false;
	});



});




