if(!self.addLoadEvent) {
	// appending the addLoadEvent method, if it hasn't been defined already
	// function written by Simon Willison (simon.incutio.com)
	function addLoadEvent(func) {
		var oldonload = window.onload;
		if (typeof(window.onload) != 'function') {
			window.onload = func;
		} else {
			window.onload = function() {
				oldonload();
				func();
			}
		}
	}
}

function poll_form_init() {
	var form=document.getElementById('POLL_FORM');
	
	if(!form) return;
	
	form.action="";
	form.onsubmit=do_ajax;
}

function show_quick_results(xhtml) {
	var div=document.getElementById("quick-poll-container");
	var bg=document.getElementById("quick-poll-background");
	var flash=document.getElementById("flash");
	var form=document.getElementById('POLL_FORM');
	var bodyElm=document.getElementsByTagName('body')[0];
	
	//alert(xhtml);
	
	if(div==null) {
		bg=document.createElement('div');
		bg.id="quick-poll-background";
		
		div=document.createElement('div');
		div.id="quick-poll-container";
		
		bodyElm.appendChild(bg);
		bodyElm.appendChild(div);
		flash.style.visibility="hidden";
	}
	
	bg.onclick=hide_quick_results;
	
	div.onclick=hide_quick_results;
	div.innerHTML=xhtml;
	
	bg.style.display="block";
	div.style.display="block";
	
  prepareIE('100%','hidden');
	
	flash.style.visibility="hidden";
	
	form.submit.disabled=true;
		
	bodyElm.focus();
}

function hide_quick_results() {
	var div = document.getElementById("quick-poll-container");
	var bg=document.getElementById("quick-poll-background");
	var flash=document.getElementById("flash");
	
	
  prepareIE('auto','auto');
	
	div.style.display="none";
	bg.style.display="none";
	flash.style.visibility="visible";
	
	//window.location=window.location;
}

function prepareIE(height, overflow){
    bod = document.getElementsByTagName('body')[0];
    bod.style.height = height;
    bod.style.overflow = overflow;

    htm = document.getElementsByTagName('html')[0];
    htm.style.height = height;
    htm.style.overflow = overflow; 
}

function do_ajax() {
	var form=document.getElementById("POLL_FORM");
	
	if(form!=null)		
		dAjaxSubmitForm(form,'../application/poll/quick-results.php',show_quick_results);
		
	return false;
}