var media_player;
   
function LoadSong(song_file, song_name, song_info) {
	media_player = window.open('/media_player.php?song_file=' + song_file + "&song_name=" + song_name + "&song_info=" + song_info, 'MediaPlayer', 'height=450, width=400, location=false, scrollbars=auto, resizable=yes');
	media_player.resizeTo(400,280);
	media_player.focus();
}

function LaunchPlayer() {
	media_player = window.open('/media_player.php', 'MediaPlayer', 'height=450, width=400, location=false, scrollbars=auto, resizable=yes');
	media_player.resizeTo(400,550);
	media_player.focus();
}

function LoadVideo(video, video_title) {
	media_player = window.open('/media_player.php?video=' + video + "&video_title=" + video_title, 'MediaPlayer', 'height=450, width=550, location=false, scrollbars=auto, resizable=yes');
	media_player.resizeTo(580,550);
	media_player.focus();
}

function CalculateTotal(the_CD) {
		
		var form_name = "cd_form_" + the_CD;
		var the_form = document.forms[form_name];
		var price_total = 0;
		var shipping_total = 0;

		// first make sure they haven't selected a bad shipping method from the select box
		if (the_form.shipping.selectedIndex == 1 || the_form.shipping.selectedIndex == 2) {
			the_form.shipping.selectedIndex = 0;
		}
		
		if (the_form.shipping.selectedIndex == 4) {
			the_form.shipping.selectedIndex = 3;
		}
		
		the_form.shipping_meth.value=the_form.shipping.options[the_form.shipping.selectedIndex].value;
		
		// how many CDs?
		how_many = (the_form.quantity.value * 1);
		
		if(the_form.shipping_meth.value == "int") {
			var shipping_total = how_many * the_form.ship_rate.value;
			var ship_per_cd = (the_form.ship_rate.value *1);
		}
		else {
			var shipping_total = 0;
			var ship_per_cd = 0;
		}
		
		price_total = (how_many * the_form.cd_price.value) + shipping_total;
		price_total_format = price_total.toFixed(2);
		
		document.getElementById('price_total_' + the_CD).innerHTML = "$ " + price_total_format;
		the_form.amount.value = (the_form.cd_price.value * 1) + ship_per_cd;
		
}

function Purchase(the_CD) {

	var form_name = "cd_form_" + the_CD;
	var the_form = document.forms[form_name];
	
	if (the_form.quantity.value == 0) {
		alert("You have not selected any articles for purchase. Please indicate how many copies of each album you would like to purchase and select your shipping method.");
		return false;
	}
	
	the_form.submit();
}