$(document).ready(function(){
	$('.hide').hide();
	
	$(".datepicker").datepicker({ beforeShowDay: $.datepicker.noWeekends });
	
	$('#navigation ul.menu li.children ul').hide();
	
	// Disable submit button on contest form until terms agreed
	$("#submit_agree").attr("disabled", "disabled");

    $("#agree").click(function() {
        var checked_status = this.checked;
        if (checked_status == true) {
            $("#submit_agree").removeAttr("disabled");
        }
        else {
            $("#submit_agree").attr("disabled", "disabled");
        }
    });

	// Position menu arrow under active li
	if($('li.active a').length != 0) { //Check if actice li exists, otherwise js will error
		var active_pos = $('li.active a').position();
		var li_width = $('li.active a').width();
		$('.arrow').css('left',active_pos.left + li_width/2 + 10);
		$('.arrow').css('display','block');
	}
	
	var parent_pos = 0;
	// Position the dropdown menu below it's corresponding li
	$('#navigation ul.menu li.children ul').css('left',function() {
		parent_pos = 0;
		parent_pos = $(this).prev('a').position();
		return parent_pos.left;
	});
	
	$('#navigation ul.menu li.children').hover(
		function() {
			$(this).children('ul').show();
		},
		function() {
			$(this).children('ul').hide();
		}
	);
	
	// Carousel
	$('#carousel').cycle({ 
	    fx: 'scrollLeft',
	    timeout:  6000,
		prev:    '#prev',
        next:    '#next',
        pager:  '.carousel_nav',
		cleartype:  true,
	    cleartypeNoBg:  true
	});
	$('.pause').click(function() {
		$('#carousel').cycle('toggle');
	});
	
	/*
$('#navigation ul.menu li.children ul').each(function() {
		var index = 0;
		
		$(this).children('li').each(function() {
			index++;
			//alert(index);
			//$(this).addClass('index'+index);
			
			if(index == 10) {
				$(this).add($(this).prevAll('li')).wrapAll('<ul class="col1" />');
			
				$(this).add($(this).nextAll('li')).wrapAll('<ul class="col2" />');
				
				return false;
			}
			
		});
		
	});
*/

});
