$(document).ready(function() {

	$(".music-lyrics").click(function(){
		var $url = '/music/_lyrics/' + $(this).attr('rel');
		//alert($url);
		
		$("#lyric-content").load($url, function(){
			$("#lyric-sheet, #overlay").fadeIn();
		});
		return false;
		
	});

	$("#overlay, #lyric-close").click(function(){
		$("#overlay, .modal").fadeOut();
	});

	$("#billing input").change(function(){
		if ( $("#same-info-check input:checked").val() !== undefined ){
			var $shipsel = '#shipping_' + $(this).attr('id');
			//alert("same info");
			$($shipsel).val( $(this).val() );
			$($shipsel + " option:selected").val( $(this + " option:selected").val() );
		}
	});
	
	$("#same-info-check input").change(function(){
		if ( $("#same-info-check input:checked").val() !== undefined ){
			$("#billing input").each(function(index){
				var $shipsel = '#shipping_' + $(this).attr('id');
				$($shipsel).val( $(this).val() );
			});
		}
	});
	
	$("#checkout_button").click(function(){
		$("#return_url").val("store/checkout"); 
		$("#update_cart_form").submit(); 
		return false; 
	}); 
	$("#update_button").click(function(){
		$("#return_url").val("store/cart"); 
		$("#update_cart_form").submit(); 
		return false;
	});
	
	
	$("#register_member_form").submit(function(){
		var $email = $("#reg-user").val();
		$("#reg-sn").val( $email );
		$("#reg-email").val( $email );
		//alert($email);
		return true;
	});

	
});


function slideSwitch() {
    var $active = $('.feature-slide.active');

    if ( $active.length == 0 ) $active = $('.feature-slide:first');

    var $next =  $active.next().length ? $active.next()
        : $('.feature-slide:first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
         .addClass('active')
         .animate({opacity: 1.0}, 3000, function() {
         	$active.removeClass('active last-active');
        });
}
// Delay for home page slideshow
$(function() {
    setInterval( "slideSwitch()", 9000 );
});
