$(document).ready(function(){

	if(location.href.indexOf('#') != -1){
		l = location.href.split('#');
		gotoTab(l[1]);
	}

	// Check for params, in particular the status one
	if(location.href.indexOf('?') != -1){
		l = location.href.split('?');
		// Check for status param
		//alert("l = "+l);
		//alert("l[1] length = "+l[1].length);
		if(l[1].length > 0) {
			//p = l[1].split('=');
			//if(p[0] == "status") gotoTab('help');
			p = l[1].split('&');
			//alert("p = "+p);
			if(p.length == 2) {
				// status param
				s = p[0].split('=');
				//alert("s = "+s);
			    if(s[0] == "status") {
			    	gotoTab('help');
			    	// tab param
					//t = p[1].split('=');
					//alert("t = "+t);
				    //if(t[0] == "app") gotoTab(t[1]);

			    }
			}
		}
	}
	
	$('#slider .nav li a').click(function(){

		tabSize(this);
		return false;

	});

});

function gotoTab(anchor){
		a = $('#menuitem-' + anchor + ' a');
		showDiv('#' + anchor, a);
}

function tabSize(a){
	if($(a).hasClass('selected') || $(a).hasClass('loading')) return;
	target = '#' + a.href.split("#")[1];
	showDiv(target, a);
}

function showDiv(target, a){
	// mostrar target
	$(target).fadeIn(400).siblings('div').not('.control').hide();
	// cambiar clases en link
	$(a).removeClass('loading').parent().addClass('selected').siblings().removeClass('selected').parent('.submenu').removeClass('loading'); // el loading es en caso de que tuviera

}
