var sound_Title = new Array();
var sound_Artist = new Array();
var request_ItemCode = getQueryParameter('ItemCode').toUpperCase();

function getSoundList() {
	if (check_music_category() && sound_Title.length>0) {
		
		if (sound_Artist.length>0) {
			//For Normal Music Album
			document.write('<table>');
			document.write(' <tr>');
			document.write('  <td colspan="2">&nbsp;</td>');
			document.write('  <th>' + header1 + '</th>');
			document.write('  <th>' + header2 + '</th>');
			document.write(' </tr>');
			for (sound_count=1;sound_count<sound_Title.length;sound_count++) {
				document.write(' <tr>');
				document.write('  <td><a href="javascript:call_player(\'' + sound_Title[sound_count].replace('\'','\\\'') + '\',\'' + request_ItemCode + '_' + sound_count + '\')">');
				document.write('<img src="/images/btn_play2.jpg" border="0"></a></td>');
				document.write('  <td>' + sound_count + '.</td>');
				document.write('  <td>' + sound_Title[sound_count] + '</td>');
				document.write('  <td>' + sound_Artist[sound_count] + '</td>');
				document.write(' </tr>');
			}
			document.write(' <tr>');
			document.write('  <td></td>');
			document.write('  <td colspan="2"><span>' + footer1 + '</span></td>');
			document.write('  <td><span>' + footer2 + '</span></td>');
			document.write(' </tr>');			
			document.write('</table>');
		} else {
			//For Special Case Music Album
			sound_count_half = (sound_Title.length - 1) / 2;
			
			document.write('<table>');
			document.write(' <tr>');
			document.write('  <td colspan="2">&nbsp;</td>');
			document.write('  <th>' + header1 + '</th>');
			document.write('  <td colspan="2">&nbsp;</td>');
			document.write('  <th>' + header2 + '</th>');
			document.write(' </tr>');
			for (sound_count=1;sound_count<=sound_count_half;sound_count++) {
				var left_side_count = sound_count;
				var right_side_count = sound_count + sound_count_half;
				
				//Left Side
				document.write(' <tr>');
				document.write('  <td><a href="javascript:call_player(\'' + sound_Title[left_side_count].replace('\'','\\\'') + '\',\'' + request_ItemCode + '_' + left_side_count + '\')">');
				document.write('<img src="/images/btn_play2.jpg" border="0"></a></td>');
				document.write('  <td>' + left_side_count + '.</td>');
				document.write('  <td>' + sound_Title[left_side_count] + '</td>');
				
				//Right Side
				document.write('  <td><a href="javascript:call_player(\'' + sound_Title[right_side_count].replace('\'','\\\'') + '\',\'' + request_ItemCode + '_' + right_side_count + '\')">');
				document.write('<img src="/images/btn_play2.jpg" border="0"></a></td>');
				document.write('  <td>' + right_side_count + '.</td>');
				document.write('  <td>' + sound_Title[left_side_count] + '</td>');
				document.write(' </tr>');
			}
			document.write(' <tr>');
			document.write('  <td></td>');
			document.write('  <td colspan="2"><span>' + footer1 + '</span></td>');
			document.write('  <td>&nbsp;</td>');
			document.write('  <td colspan="2"><span>' + footer2 + '</span></td>');
			document.write(' </tr>');			
			document.write('</table>');
		}
	}	
}

function check_music_category() {
	if (request_ItemCode.substring(0,1).toUpperCase()=='G') {
		return true;
	} else {
		return false;
	}
}

function load_song_db() {
	if (check_music_category()) {
		require('/products/' + request_ItemCode +'.js');
	}
}

function call_player(sname, fname) {
	MM_showHideLayers('player','','hide');
	document.getElementById('player').innerHTML  = '<table border="0" cellspacing="0" cellpadding="2"><tr><td><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="150" height="70"><param name="movie" value="/player_01.swf?myname='+sname+'&myfile='+fname+'"><param name="wmode" value="opaque"><param name="quality" value="high"><embed src="player_01.swf?myname='+sname+'&myfile='+fname+'" wmode="opaque" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="150" height="70"></embed></object></td></tr></table>';
	doSomething('player','305');
}

function load_song_db_byCode(ProductCode) {
	sound_Title = new Array();
	sound_Artist = new Array();
	require('/products/' + ProductCode +'.js');
}

function load_product_detail(ProductCode,Desc) {
	if (check_music_category()) {
		// Album
		document.write('<h2>' + Desc + ' <span>(' + ProductCode + ')</span></h2>');
	} else {
		// Product
		document.write('<p>' + ProductCode + '</p>')
	}
}

load_song_db();