/*------------------------------------POLL JAVASCRIPT CODE--------------------------------------------------------------*/
var Poll = 
{	
	upPoll: function(idop,idpoll)
	{		
		ajax = new ITDAJAX.AJAX();
		
		ajax.onError = Poll.error;
		
		var param		=	'action=uppoll&idop=' + idop + '&idpoll=' + idpoll;	
		
		ajax.callPage("poll.php",param,Poll.resultUpPoll);		
	},
	error: function(err)
	{
		alert(err);
	},	
	resultUpPoll: function(response)
	{		
		if(response !=''){ 
			Poll.getPoll(response);		
		}
	},	
	getPoll: function(idpoll)
	{
		ajax = new ITDAJAX.AJAX();
		
		ajax.onError = Poll.error;
		
		var param		=	'action=getpoll&idpoll=' + idpoll;	
		
		ajax.callPage("poll.php", param, Poll.resultGetPoll);
	},
	resultGetPoll: function(response)
	{		
		if(response !=''){
			document.getElementById('bodyPoll').innerHTML = response;
			
			return true;
		}
		
		return false;
		//document.getElementById('bodyPoll').style.height= '220px';
	},	
	makePoll: function(idpoll)
	{
		ajax = new ITDAJAX.AJAX();
		
		ajax.onError = Poll.error;
		
		var param		=	'action=makepoll&idpoll=' + idpoll;	
		
		ajax.callPage("poll.php",param,Poll.resultMakePoll);
	},	
	resultMakePoll: function(response)
	{
		if(response !='') document.getElementById('bodyPoll').innerHTML = response;
		
		document.getElementById('bodyPoll').style.height= '150px';
	},
	makepoll_new:function(pollid)
	{
		var optionid 	=	Poll.getCheckedValue(document.getElementsByName('checkoption'));
		
		if(optionid==null || optionid=="") return false;
		
		ajax = new ITDAJAX.AJAX();
		
		ajax.onError = Poll.error;
		
		var param		=	'action=uppoll&idop=' + optionid + '&idpoll=' + pollid;	
		
		ajax.callPage("poll.php",param,Poll.resultmakepoll_new);	
		
		return false;
	},
	resultmakepoll_new: function(response)
	{		
		if(response !=''){ 
			Poll.getPoll(response);		
		}
	},
	getCheckedValue:function(radioObj) {		
		if(!radioObj){
			return "";
		}
		var radioLength = radioObj.length;		
		if(radioLength == undefined){			
			if(radioObj.checked){
				return radioObj.value;
			}
			else{				
				return "";				
			}
		}
		for(var i = 0; i < radioLength; i++) {
			if(radioObj[i].checked) {
				return radioObj[i].value;
			}
		}
		return "";
	},
	backtoPoll:function(){
		ajax = new ITDAJAX.AJAX();
		
		ajax.onError = Poll.error;
		
		var param		=	'action=backtoPoll';	
		
		ajax.callPage("poll.php",param,Poll.resultbacktoPoll);			
	},
	resultbacktoPoll:function(response){		
		if(response != ''){
			$('bodyPoll').innerHTML	=	response;
			
			return true;
		}
		
		return false;
	}
}