var ajax2 = new Ajax();
var music_type = null;

function ChangeMusic(musictype) {
	music_type = musictype;
	if(music_type == '1') {
		ChangeContent('the_card','Please wait...');
	}
	else {
		ChangeContent('musicplayer','Please wait..');
	}
	doTask2();
}

var doTask2 = function() {
	start = new Date();
	start = start.getTime();
	ajax2.doGet('/music_ajax.php?start=' + start + '&music_type=' + music_type, showTask2);
}

var showTask2 = function(str) {
	var taskResult = '';
	var diff = 0;
	var end = new Date();
	if(str == 'empty') {
		taskResult = '<i>Something went wrong! Please try again.</i>';
	}
	else {
		end = end.getTime();
		diff = (end - start) / 1000;
		taskResult = str;
	}
	printResult2(taskResult);
}

function printResult2(str) {
	if(music_type == '1') {
		ChangeContent('the_card',str);
	}
	else {
		ChangeContent('musicplayer',str);
	}
}

function returnObjById(id) { // use this function to get an element's ID, even when getElementById is not available in older browsers
	var returnVar;
	if(document.getElementById) {
		returnVar = document.getElementById(id);
	}
	else if(document.all) {
		returnVar = document.all[id];
	}
	else if(document.layers) {
		returnVar = document.layers[id];
	}
	return returnVar;
}