// JavaScript Document
var slideDlay = 100;
$(document).ready(function() {
	$('.sideNav ul li ul').hide(0);
	$('.sideNav ul li > .menuLink.topMenu').hover(function() {
		$(this).css('text-decoration','none');
		$(this).parent().css({
			'text-decoration': 'none'
		});
	}, function() {
		$(this).css('text-decoration','underline');
		$(this).parent().css({
			'text-decoration': 'underline'
		})
	})
	.click(function() {
		if ($(this).parent().children('ul').is(':visible')) {
			$(this).parent().find('ul').slideUp(slideDlay);
		}
		else {
			$('.menuLink.topMenu').parent().find('ul').slideUp(slideDlay);
			$(this).parent().find('ul').slideDown(slideDlay);
		}
	});
	$('.tabs li').hover(function() {
		var child = $(this).attr("rel");
		if (!$("#" + child).is(":visible")) {
			$(this).css({
				'background-color': '#ffffff',
				'color': '#000000'
			});
		}
	}, function() {
		var child = $(this).attr("rel");
		if (!$("#" + child).is(":visible")) {
			$(this).css({
				'background-color': 'transparent',
				'color': '#ffffff'
			});
		}
	}).click(function() {
		var elem = $(this).attr('rel');
		if (!$('#' + elem).is(':visible')) {
			$('.subPanel').hide(0);
			$('#' + elem).show(0);
			$('.tabs li').css({
				'background-color': 'transparent',
				'color': '#ffffff',
				'text-decoration': 'none'
			});
			$(this).css({
				'background-color': '#ffffff',
				'color': '#000000',
				'text-decoration': 'underline'
			});
		}			
	});
	$('.sideNav .menuLink').parent().hover(function() {
		$(this).css({
			'list-style': 'square'
		});
    }, function() {
		$(this).css({
			'list-style': 'none'
		});
	});
	setPage();
});

function setPage() {
	var params = getParams();
	if (params != null && params.p != null && params.p != '') {
		if ($('#' + params.p + 'Tab').length > 0) {
			$('#' + params.p + 'Tab').click();
		}
		else {
			$('.defaultTab').click();
		}
	}
	else {
		$('.defaultTab').click();
	}
}
function getParams() {
	var query = top.location.search.substring(1);
	var keyVal = query.split('&');
	var params = new Object;
	if (keyVal.length > 0 && keyVal[0] != '') {
		for (k in keyVal) {
			var pair = keyVal[k].split('=');
			params[pair[0]] = pair[1];
		}
	}
	else { params = null; }
	return params;
}
