$(function() {

	/* ADMIN SECTION: ARTIST SELECTION DROPDOWN MENU */

	$('form#artist_dd .artist_choice').change(function() {
		$('form#artist_dd').submit();
	});

});


$(function() {

	/* edit  */

    $("#locale input[name='find_location']").ready(function() {
        if($("#locale input[name='find_location']:checked").val() == 'other') {
            $("span#alt_location").fadeIn('slow');
        } else {
            $("span#alt_location").fadeOut('fast');
        }
    });
    
    $("#locale input[name='find_location']").click(function() {
        if($("#locale input[name='find_location']:checked").val() == 'other') {
            $("span#alt_location").fadeIn('slow');
        } else {
            $("span#alt_location").fadeOut('fast');
        }
    });    

});

$(function() {
    $("#all_day").change(function() {
        if ($("#all_day").is(":checked")) {
            $(".timebox").hide();
            $("#date_wrap").show();
        } else {
            $(".timebox").show();
            $("#date_wrap").hide();
        }
    });
    
    $("#all_day").ready(function() {
        if ($("#all_day").is(":checked")) {
            $(".timebox").hide();
            $("#date_wrap").show();
            $("#dp_to").show();
        } else {
            $(".timebox").show();
            $("#date_wrap").hide();
            $("#dp_to").hide();         
        }
    });
});


$(function() {
	$("#show_open").change(function() {
		if ( $("#show_open").is(":checked") ) {
			$("#opening_row").show();
		} else {
			$("#opening_row").hide();
		}
	})
	
	$("#show_open").ready(function() {
		if ( $("#show_open").is(":checked") ) {
			$("#opening_row").show();
		} else {
			$("#opening_row").hide();
		}
	})	
});



$(function() {
    $("#start_date").datepicker();
    $("#end_date").datepicker();
    $("#opening_date").datepicker();
});

$(function() {
    $("input[name='default_loc']").ready(function() {
        if($("input[name='default_loc']:checked").val() == 'other') {
            $(".loc_row").show();
        } else {
            $(".loc_row").hide();
        }
    });
    
    $("input[name='default_loc']").click(function() {
        if($("input[name='default_loc']:checked").val() == 'other') {
        	$(".loc_row").show();
        } else {
            $(".loc_row").hide();
        }
    });
});

$(function() {
	$("input[name='event_type']").ready(function() {
		if($("input[name='event_type']:checked").val() == 'event') {
			$("input[name='show_open']").attr("disabled", true);
			$(".disabled").css('color', '#999');
			$(".loc_row").hide();			
		} else {
			$("input[name='show_open']").attr("disabled", false);
			$(".disabled").css('color', '#000');	
		}
	});

	$("input[name='event_type']").click(function() {
		if($("input[name='event_type']:checked").val() == 'event') {
			$("input[name='show_open']").attr("disabled", true);
			$("input[name='show_open']").attr('checked', false);
			$("#opening_row").hide();
			$(".disabled").css('color', '#999');
		} else {
			$("input[name='show_open']").attr("disabled", false);
			$(".disabled").css('color', '#000');
		}
	});	
	
});

$(function() {

	$("#event_time1, #event_time2").calendricalTimeRange();
	$("#opening_time1, #opening_time2").calendricalTimeRange();

});

$(function() {

	$("#start_date").change(function() {
		var sd = $("#start_date").val();
		var ed = $("#end_date").val();
		
		if (ed < sd) {
			$("#end_date").val(sd);
			$("#opening_date").val(sd);
		}	
		console.log(sd);
	});
});


$(function() {

	$(".port_artist").mouseenter(function() {
		$(this).slideUp();
	}).mouseout(function() {
		$(this).slideDown();
	});

});


