$(function() { 
	
	// Tabs
	$("#videos").tabs("#videos .pane", {tabs: 'ul.tabs li a', effect: 'default', initialIndex: null, current: 'active'});
	
});

$(document).ready(function() {	

	$("#home.accordion div.pane:not(:first)").hide();

	$("#home.accordion h2").click(function(){
		$(this).next("#home.accordion div.pane").slideToggle("fast");
	});
	
	
	$("a.tooltip").append("<em></em>");
	$("a.tooltip").hover(function() {
		$(this).find("em").animate({opacity: "show"});
		var hoverText = $(this).attr("title");
	    $(this).find("em").text(hoverText);
	}, function() {
		$(this).find("em").animate({opacity: "hide"});
	});	 
	
	// Login
    $("a.login").click(function(){
        if ($("#login_form").is(":hidden")){
            $("#login_form").slideDown();
    		$("a.login").text("Close");
        }
        else{
            $("#login_form").slideUp();
    		$("a.login").text("Log in");
        }
    });
	$("#login_form").hide();
	
	// Hide Labels from particular fieldsets
	$(".hide_labels").each(website.hide_labels);
	
});


website = {	
	// Hide labels, set text to targets value
	hide_labels: function() {
		$(this).find("label").each(function() {
			$('#' + this.htmlFor).val(this.innerHTML);
			$(this).hide();
			$('#' + this.htmlFor).click(website.clearbox);
		})
	},
	// Clear default text in an input box
	clearbox: function() {
           if (!this.default_value) this.default_value = this.value;

           if (this.value == '') {
           	this.value = this.default_value;
           	this.select();
           } else if (this.value == this.default_value) {
           	this.value = '';
           }
	}
};



