// JavaScript Document
function ajax(){
	var xmlHttp;
	var divid;

	var createXMLHttp = function(){
		if (window.XMLHttpRequest){
			xmlHttp = new XMLHttpRequest();
		}else if (window.ActiveXObject){
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}

	var createQueryString = function(num){
		return "num=" + num;
	}

	this.top_listCase = function(num,url){
		createXMLHttp();
		xmlHttp.onreadystatechange = function(){
			if (xmlHttp.readyState == 4){
				if (xmlHttp.status == 200){
					//document.getElementById(divid).innerHTML = xmlHttp.responseText;
					setSoundTo(xmlHttp.responseText);
				}
			}
		};
		xmlHttp.open("POST", url);
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlHttp.send(createQueryString(num));
	};
}

function setSoundTo(soundNum){
	//alert(document.getElementById("bgs2").src = "./images/" + soundNum.substring(1, 2) + ".wav");
    setTimeout('play1("' + soundNum + '")', 500);
    setTimeout('play2("' + soundNum + '")', 1000);
    setTimeout('play3("' + soundNum + '")', 1500);
    setTimeout('play4("' + soundNum + '")', 2000);
    setTimeout('play5("' + soundNum + '")', 2500);
}

function play1(soundNum){
    document.getElementById("bgs1").src = "/images/" + soundNum.substring(0, 1) + ".wav";
}

function play2(soundNum){

    document.getElementById("bgs2").src = "/images/" + soundNum.substring(1, 2) + ".wav";
}

function play3(soundNum){
    document.getElementById("bgs3").src = "/images/" + soundNum.substring(2, 3) + ".wav";
}

function play4(soundNum){
    document.getElementById("bgs4").src = "/images/" + soundNum.substring(3, 4) + ".wav";
}

function play5(soundNum){
    document.getElementById("bgs5").src = "/images/" + soundNum.substring(4, 5) + ".wav";
}
