var id=0;

function Get_Data(sid, mid){
	if (id != 0) {
		document.getElementById('sound_con_'+ id).style.display="none"
		document.getElementById('sound_con_'+ id).innerHTML = '';
	}
	id=mid
	http.open('get', 'index.php?show=sounds&op=load&id='+ sid +'&link='+ mid);
	http.onreadystatechange = maq_handle;
	http.send(null);
}

function maq_handle(){
	document.getElementById('sound_con_'+ id).style.display="block"
	if(http.readyState == 1){
		document.getElementById('sound_con_'+ id).innerHTML = '...';
	}
	if(http.readyState == 4){
		var response = http.responseText;
		document.getElementById('sound_con_'+ id).innerHTML = response;
	}
}

function Send_Vote(mid, score){
	id =mid;
	http.open('get', 'index.php?show=sounds&op=send_vote&id='+ mid +'&score='+ score);
	http.onreadystatechange = stars_handle;
	http.send(null);
}
function stars_handle(){
	if(http.readyState == 4){
		document.getElementById('sounds_stars_'+ id).innerHTML = http.responseText;
		id =0;
	}
}

var oldImgs = Array();
function star_over(id , num){
	var stars= document.getElementById('sounds_stars_'+ id);

	for (i=0; i<stars.childNodes.length; i++){
		if (stars.childNodes[i].nodeName=="IMG") {
			oldImgs[i] = stars.childNodes[i].src;
		}
	}
	
	for (i=0; i<stars.childNodes.length; i++){
		if (stars.childNodes[i].nodeName=="IMG") {
			stars.childNodes[i].src= imgsPath + 'images/star_over.gif';
			if (stars.childNodes[i].id=="vote_star_"+num) {
				break;
			}
		}
	}
}

function star_out(id){
	var stars= document.getElementById('sounds_stars_'+ id);
	for (i=0; i<oldImgs.length; i++){
		if (stars.childNodes[i].nodeName=="IMG") {
			stars.childNodes[i].src=oldImgs[i];
		}
	}
}
