var xmlHttp;

function updateSupportCount(mad_uid){	
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 	
	
	var url=domainName+"/includes/ajax/updateSupportCount.php"; 	
	url=url+"?sid="+Math.random();
	url=url+"&mad_uid="+mad_uid;	
	url=url+"&tmstmp="+new Date().getTime();	
	xmlHttp.onreadystatechange=stateChangedToSupport
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null);
	//setTimeout('xmlHttp.send(null);',5000);
} 


function stateChangedToSupport() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
		if(xmlHttp.responseText != ''){
			var response = xmlHttp.responseText.split('=X=');
			
			if(response[1] == 'DONE'){
				window.location.reload();
			}else if(response[1] == 'ALREADY'){
				var drawer = $("#drawer");
				drawer.slideDown(function()  {
					// colored flash effect
					document.getElementById('drawer').innerHTML = "You are already supporting this MAD LTD.";
					drawer.css("backgroundColor", "#ffffff");			
					setTimeout(function() { drawer.slideUp(); }, 5000);			
				});
				//alert('You are already supporting this');
			}else if(response[1] == 'LOGIN'){
				window.location.href = "index.php#login";
			}
			
		}
	} 
} 
