var xmlhttp
	/*@cc_on @*/
	/*@if (@_jscript_version >= 5)
	  try {
	  xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")
	 } catch (e) {
	  try {
	    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
	  } catch (E) {
	   xmlhttp=false
	  }
	 }
	@else
	 xmlhttp=false
	@end @*/
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	 try {
	  xmlhttp = new XMLHttpRequest();
	 } catch (e) {
	  xmlhttp=false
	 }
	}
	function myXMLHttpRequest() {
	  var xmlhttplocal;
	  try {
	    xmlhttplocal= new ActiveXObject("Msxml2.XMLHTTP")
	 } catch (e) {
	  try {
	    xmlhttplocal= new ActiveXObject("Microsoft.XMLHTTP")
	  } catch (E) {
	    xmlhttplocal=false;
	  }
	 }

	if (!xmlhttplocal && typeof XMLHttpRequest!='undefined') {
	 try {
	  var xmlhttplocal = new XMLHttpRequest();
	 } catch (e) {
	  var xmlhttplocal=false;
	  alert('XMLHTTP Objekt konnte nicht erstellt werden');
	 }
	}
	return(xmlhttplocal);
}

function sndReq(vote,id_num,spid) {
	var theUL = document.getElementById(spid);
	theUL.innerHTML = '<div class="loading"></div>';
	
	var params = 'num='+vote+'&tid='+id_num+'&sid='+spid;
	xmlhttp.open('POST', '/scripts/rate/dl_vote.php');
	xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlhttp.setRequestHeader("Content-length", params.length);
    xmlhttp.setRequestHeader("Connection", "close");
    xmlhttp.onreadystatechange = handleResponse;
    xmlhttp.send(params);
}

function handleResponse() {
  if(xmlhttp.readyState == 4){
		if (xmlhttp.status == 200){
       	
        var response = xmlhttp.responseText;
        var update = new Array();

        if(response.indexOf('||') != -1) {
            update = response.split('||');
            changeText(update[0], update[1]);
			changeRetMsg(update[0]);
        }
		}
    }
}

function changeText(div2show,text) {
    var IE = (document.all) ? 1 : 0;
    var DOM = 0; 
    if (parseInt(navigator.appVersion) >=5) {DOM=1};
    if (DOM) {
        var viewer = document.getElementById(div2show);
        viewer.innerHTML = text;
    }  else if(IE) {
        document.all[div2show].innerHTML = text;
    }
}

function v_text(obj) {
    var num = obj.innerHTML;
    var words = new Array("Schlecht", "Nicht so toll", "Naja...", "Cool", "Echt super!");
	var ul_id = obj.parentNode.parentNode.id;
	var vt_id = "t_" + ul_id;
	var find_id = obj.parentNode.parentNode.className.match(/vi(\d+)/)[1];
	if(!svmsg) {var svmsg = document.getElementById(vt_id).innerHTML; }
	document.getElementById(vt_id).innerHTML = words[num-1];
	obj.onmouseout = function () { document.getElementById(vt_id).innerHTML = svmsg; }
	obj.onclick = function () { sndReq(num,find_id,ul_id); return false; }
}

function changeRetMsg(el_id) {
    el_id = el_id.replace(/rate_/,"");
    document.getElementById("t_"+el_id).style.display = "none";
	document.getElementById("rate_message").style.display = "block";
	window.setTimeout(function() {
	    var rms = document.getElementById('rate_message');
        rms.parentNode.removeChild(rms);
		document.getElementById("t_"+el_id).style.display = "block";
    }, 5000);
}