/**
 * Last Edit
 * By	:	Jason
 * When	:	23 May 08
 * What	:	Initial setup
 */
 
(function($) {

	$(document).ready(function(){
		$("ul.nav").superfish();
		$(".widget:even").addClass("even");
		$(".post:even").addClass("even");
		$("tr:even").addClass("even");
		
		// Payment - Shipping address hide/show
		
		if ($('#use_billing_address').attr('checked')) {
			$("#book_shipping_address").hide();
		} else {
			$("#book_shipping_address").show();
		}
		
		//anination on checking so make the user aware of change :)
	
		$("#use_billing_address").change(function(){
			if ($(this).attr('checked')) {
				$("#book_shipping_address").slideUp();
			} else {
				$("#book_shipping_address").slideDown();
			}
		});
			if ($(this).attr('checked')) {
				$("#other_sport").slideDown();
			} else {
				$("#other_sport").slideUp();
			}		
		$(".sports_select input[value='Other']").click(function() {
			if ($(this).attr('checked')) {
				$("#other_sport").slideDown();
			} else {
				$("#other_sport").slideUp();
			}
		});
		
		if ($("#user_hearabouts option:selected").val() == 'Other') {
			$("#other_hearabouts").show();
		} else {
			$("#other_hearabouts").hide();
		}
		$("#user_hearabouts").change(function() {
			if ($("#user_hearabouts option:selected").val() == 'Other') {
				$("#other_hearabouts").slideDown();
			} else {
				$("#other_hearabouts").slideUp();
			}
		});
		
		$("#secondary_sidebar .execphpwidget ul>li>ul").hide(function() {
			$(this).parent("li").addClass("hidden");
			$(this).parent("li").addClass("itsgotchildren");
			$("#secondary_sidebar").addClass("hidden");
		});
		$("#secondary_sidebar .execphpwidget>div>ul").find("li.current_page_ancestor>ul").show(function() {
			$(this).parent("li").removeClass("hidden");
		});
		$("#secondary_sidebar .execphpwidget ul").find("li.current_page_parent ul").show();
		
		$("#secondary_sidebar .execphpwidget>div>ul>li>a, #secondary_sidebar .execphpwidget>div>ul>li>ul>li>a").click( function(){
			if ($(this).parent().children("ul").length == 0) {
				return true;
				
			} else if($(this).parent('li').hasClass("hidden")) {
				$(this).parent("li").removeClass("hidden");
				$(this).parent().children('ul').slideDown("slow");
				return false;
			} else if (!$(this).parent('li').hasClass("hidden")) {
				$(this).parent().children('ul').slideUp("slow", function(){
					$(this).parent("li").addClass("hidden");
				});
				return false;
			}
		});
	});
})(jQuery)