function GetXmlHttpObject(){
	var xmlHttp=null;
	try{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	} catch (e){
		// Internet Explorer
		try{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e){
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}
			
function pollRequest() { 
	if (xmlHttp.readyState==1){				
		document.getElementById("content_inquiry").innerHTML="<div style=\"width:150px; text-align: center;margin: 50px 0 0 0px;\"><img src=\"./images/loading.gif\" /><br /> Loading ...</div>";		
	}
	if (xmlHttp.readyState==4){				
		document.getElementById("content_inquiry").innerHTML=xmlHttp.responseText;		
	}		
}
			
function vote(answer_id,poll_id){
		
	
	xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null){
			alert ("Your browser does not support AJAX!");
			return;
	}
	
	var url="poll.php";
	url=url+"?answer="+answer_id + "&poll_id="+poll_id;
	xmlHttp.onreadystatechange=pollRequest;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function votePoll() {
	var radioButtons = document.pollForm.elements['myvote'];
	var radioLength = radioButtons.length;
	
	if(radioLength == undefined) {
		if(radioButtons.checked) {
			return radioButtons.value;		
		}
	}
	
	for(var i = 0; i < radioLength; i++) {
		if(radioButtons[i].checked) {
			vote(radioButtons[i].value,document.pollForm.poll_id.value);
		}
	}	
}

function showResPoll() {
	vote("",document.pollForm.poll_id.value)
}

var status = true;
var ids = new Array('content','transparent','text-left','text-right');

function showLastNews() {
	
	if(status) {
		var visiblity	= 'hidden';
		var display		= 'none';
		status = false;
	} else {
		var visiblity	= 'visible';
		var display		= 'block';	
		status = true;
	}
	
	for(i = 0; i < ids.length; i++) {
		try {
			document.getElementById(ids[i]).style.visiblity = visiblity;
			document.getElementById(ids[i]).style.display	= display;
		} catch(e) {
		}		
	}
	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null) {
	  alert ("Your browser does not support AJAX!");
	  return;
	} 

	var url="last_news.php";
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);	
}

function stateChanged() { 
	if (xmlHttp.readyState == 1) { 
		document.getElementById("content_hidden").innerHTML="<div style=\"background: #fff; width: 100px; height: 100px; margin: 150px 0 0 250px;*margin: 150px 0 0 130px;float: left;\"><img src=\"./images/loading.gif\" style=\"margin: 32px 0 0 32px\"></div>";
	}
	
	if (xmlHttp.readyState == 4) { 
		document.getElementById("content_hidden").innerHTML=xmlHttp.responseText;
	}
}