// we will add our javascript code here

var requestLatestPolls = function(){
	new do_update_header_latest_polls(AJAX_SITE_REQUEST_POLL_URL+'pollautoloadpage.php', 'header_latest_polls');
	setInterval(function(){new do_update_header_latest_polls(AJAX_SITE_REQUEST_POLL_URL+'pollautoloadpage.php?t=' + new Date().getTime(), 'header_latest_polls');}, 10000);
}
if (window.addEventListener)
	window.addEventListener('load', requestLatestPolls, false);
else if (window.attachEvent)
	window.attachEvent('onload', requestLatestPolls);

function do_update_header_latest_polls(which_url,container_id){
	divRefreshButton();
	bi_preLoadImage('../images/leftbuttonlight.jpg');
	bi_preLoadImage('../images/rightbuttonlight.jpg');
	current_polls_limit = parseInt(document.getElementById("header_current_latest_polls_limit").innerHTML);

	querystring = "limit="+current_polls_limit;
	$.ajax({ 	method	: "get",
				url		:	which_url,
				data	: querystring,
				beforeSend: function(){	}, 
				complete: function(){	}, 
				success: function(html)	{ $("#"+container_id).html(html);}
	});
}
function do_next_header_latest_polls(){
	current_polls_limit = parseInt(document.getElementById("header_current_latest_polls_limit").innerHTML);
	current_polls_limit++;
	do_update_header_latest_polls(AJAX_SITE_REQUEST_POLL_URL+'pollautoloadpage.php',"header_latest_polls");
}
function do_prev_header_latest_polls(){
	cgl = parseInt(document.getElementById("header_current_latest_polls_limit").innerHTML);
	cgl--;
	cgl--;
	if(cgl<0){ cgl=0;}
	document.getElementById("header_current_latest_polls_limit").innerHTML = cgl;
	do_update_header_latest_polls(AJAX_SITE_REQUEST_POLL_URL+'pollautoloadpage.php',"header_latest_polls");
	
}
function bi_preLoadImage() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=bi_preLoadImage.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function divRefreshButton(){
	$(document).ready(function(){
		$("div.preImageCSS").mouseover(function(){$(this).addClass("preLightImageCSS"); });
		$("div.preImageCSS").mouseout(function(){ $(this).removeClass("preLightImageCSS"); });
			<!--- --->
		$("div.nextImageCSS").mouseover(function(){$(this).addClass("nextLightImageCSS"); });
		$("div.nextImageCSS").mouseout(function(){ $(this).removeClass("nextLightImageCSS");});
	});
}
