
$(document).ready(function() {

	// Scrollable
	$("#scrolling").scrollable({circular: true}).navigator().autoscroll(/*{interval: 6000}*/);	

	// Menu popdown
	$("ul#site li").hover(
		function(){ $(this).addClass("hover"); },
		function(){ $(this).removeClass("hover"); }
	);
	
	$('ul#site li').hover(
		function() {
			$(this).children('a').addClass("hover");
		},
		function() {
			$(this).children('a.hover').removeClass("hover");
	});
	
	// Page Scroller
    $('a[href=#site_layout]').click(function(){
        $('html, body').animate({scrollTop:0}, 'slow');
        return false;
    });	
	
});

function equalHeight(group) {
	var tallest = 0;
	group.each(function() {
		var thisHeight = $(this).height();
		if(thisHeight > tallest) {
			tallest = thisHeight;
		}
	});
	group.height(tallest);
}

$(document).ready(function() {
	equalHeight($("#sub_categories li"));
	equalHeight($("#sub_categories li a"));
	//equalHeight($("#products li"));
	//equalHeight($("#products li a"));
	equalHeight($("#categories li"));
	equalHeight($("#categories li a"));
});

// Namespace function
function namespace(ns) {
    ns = ns.split('.');
    var cur = window, i;
    while ( i = ns.shift() ) {
        if ( !cur[i] ) cur[i] = {};
        cur = cur[i];
    }
}

namespace("website");

$(document).ready(function(){
		
	// Hide Labels from particular fieldsets
	$("form.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 = '';
		}
	}
	
};


