var xmlhttp; function onVoteBand() { var f = document.getElementById( "poll_form" ); var a = f.answer; var sel = -2; for ( var i = 0; i < a.length; i++ ) { if ( a[i].checked) { sel = a[i].value; } } if ( sel > 0 ) { getVoteForBand( sel ); } else { getVoteForBand( -2 ); } return false; } function onViewVoteBandResult() { getVoteForBand( -2 ); return false; } function onBackButtonClicked() { getVoteForBand( -1 ); return false; } function getVoteForBand( int ) { xmlhttp=GetXmlHttpObject(); if ( xmlhttp == null ) { alert ("Browser does not support HTTP Request"); return; } //alert ("currentPageURL = "); //var urlForVotes = "http://jackazz.co.za/tigbase/js/poll/poll.php"; var urlForVotes = "tigbase/js/poll/poll.php"; urlForVotes = urlForVotes + "?vote=" + int; urlForVotes = urlForVotes + "&sid=" + Math.random(); xmlhttp.onreadystatechange = stateChanged; xmlhttp.open( "GET", urlForVotes, true ); xmlhttp.send( null ); } function stateChanged() { if ( xmlhttp.readyState == 4 ) { document.getElementById( "poll" ).innerHTML = xmlhttp.responseText; var max_idx = 4; for( var i = 1; i <= max_idx; i++ ) { var bar = $( '#poll_bar_' + i ); var w = bar.css( 'width' ); bar.css( 'width', 0 ); bar.show(); bar.animate({ width: w }, 1000 ); } } } function GetXmlHttpObject() { var objXMLHttp=null; if ( window.XMLHttpRequest ) { objXMLHttp = new XMLHttpRequest(); } else if ( window.ActiveXObject ) { objXMLHttp = new ActiveXObject( "Microsoft.XMLHTTP" ); } return objXMLHttp; } $(document).ready( function() { getVoteForBand( -1 ); });