﻿/* url: http://www.codeproject.com/KB/ajax/AjaxKtClass.aspx */
var ajax = function()
{
	this.xmlHttp = false;
	this.url = "";
	this.updateFun = null;

	this.Create = function(url, updateFun)
	{
		try{
			this.xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		}catch(e){
			try{
				this.xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			}catch(e2){
				this.xmlHttp = false;
			}
		}
		if(!this.xmlHttp&&typeof XMLHttpRequest != 'undefined'){
			this.xmlHttp = new XMLHttpRequest();
		}
		
		this.url = url;
		this.updateFun = updateFun;
	}

	this.Open = function()
	{
		this.xmlHttp.open("GET", this.url, true);
		this.xmlHttp.onreadystatechange = this.updateFun;
		this.xmlHttp.send(null);
	}

	this.GetData = function()
	{
		if(this.xmlHttp.readyState == 4){
			return this.xmlHttp.responseText;
		}
		return null;
	}
}

var ajaxRate = new ajax();

function rateclick(val) {
	ajaxRate.Create("/rate.php?value="+val, cb_rate);
	ajaxRate.Open();
}

function cb_rate() {
	var req = ajaxRate.GetData();
	if(req == "OK") {
		document.getElementById("idRate").innerHTML = "<span style=\"color:green;\">Danke!</span>";
	}
}



