
function setAvatar(postData){		
	var currentDate = new Date();

	http.open('post', 'set_avatar.php?PHPSESSID=' + sid + '&time='+currentDate.valueOf(), true);
	http.onreadystatechange = setAvatarHandle;
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http.setRequestHeader("Content-length", postData.length);
	http.setRequestHeader("Connection", "close");
	http.send(postData);
}

function setAvatarHandle(){
	if(http.readyState == 1) void(0);
	if(http.readyState == 2) void(0);
	if(http.readyState == 4){
		if(http.status == 200){
			var response = http.responseText;
			if(response!="ok"){
				ggoto("profile");
			}else{
				ggoto("profile");
			}
		}else{
			ggoto("profile");
		}
	}
}

/* games */


function game(game, postData){		
	var currentDate = new Date();

	http.open('post', 'set_game.php?PHPSESSID=' + sid + '&game=' + game + '&time='+currentDate.valueOf(), true);
	http.onreadystatechange = gameHandle;
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http.setRequestHeader("Content-length", postData.length);
	http.setRequestHeader("Connection", "close");
	http.send(postData);
}

function gameHandle(){
	if(http.readyState == 1) void(0);
	if(http.readyState == 2) void(0);
	if(http.readyState == 4){
		if(http.status == 200){
			var response = http.responseText;
			// skryvacky
			if(response == 5 || response == 6 || response == 7 || response == 8 || response == 11 || response == 10 || response == 13 || response == 12 || response == 1 || response ==2){
			    // zustane  na profilu
				// ggoto("profile");
			}else{
				ggoto("profile");			
			}
		}else{			
			ggoto("profile");
		}
	}
}


function placeOrder(postData){		
	var currentDate = new Date();

	http.open('post', 'set_shop_order.php?PHPSESSID=' + sid + '&time='+currentDate.valueOf(), true);
	http.onreadystatechange = placeOrderHandle;
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http.setRequestHeader("Content-length", postData.length);
	http.setRequestHeader("Connection", "close");
	http.send(postData);
}

function placeOrderHandle(){
	if(http.readyState == 1) void(0);
	if(http.readyState == 2) void(0);
	if(http.readyState == 4){
		if(http.status == 200){
			var response = http.responseText;
			if(response!="ok"){
				// ggoto("profile");
			}else{
				// ggoto("profile");						
			}
		}else{			
			// ggoto("profile");
		}
	}
}

