var xmlhttp;

	try
	{  // Firefox, Opera 8.0+, Safari  
		xmlHttp=new XMLHttpRequest();  }
	catch (e)
	{  // Internet Explorer  
		try
		{
			xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");    }
	  	catch (e)
		{    
			try
		  	{
				xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");      }
			catch (e)
		  	{
				alert("Your browser does not support AJAX!");  
			}
		}
	}
	
	  
  function submitPoll()
  {
  /*
      // Set up the request
      var xmlhttp =  new XMLHttpRequest();
      xmlhttp.open('POST', 'poll_post.asp', true);
      
      // The callback function
      xmlhttp.onreadystatechange = function() {
          if (xmlhttp.readyState == 4) {
              if (xmlhttp.status == 200) {
				  var oDiv=document.getElementById('poll_stats');
				  oDiv.style.display="block";
				  oDiv.innerHTML=xmlhttp.responseText;
				  alert(xmlhttp.responseText);
				  oDiv=document.getElementById('poll_question');
				  oDiv.style.display="none";
	     		}
          }
      }
      	
      // Send the POST request
      xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	  
//	  alert('pollOptionID=' + getCheckedValue(document.frmPoll.poll_option) +'&pollID=' +document.frmPoll.pollID.value);
	  
      xmlhttp.send('pollOptionID=' + getCheckedValue(document.frmPoll.poll_option) +'&pollID=' +document.frmPoll.pollID.value);
//      xmlhttp.send('poll:' + document.frmPoll.pollKey.value + ':' + getCheckedValue(document.frmPoll.poll_option));
	  */
		
		// Submit the form to the special URL which will get rewritten by ISAPI_rewrite:
		//document.frmPoll.action = 'poll--' + document.frmPoll.pollKey.value + '--' + getCheckedValue(document.frmPoll.pollOptionKey) +"#quickpoll";
		//document.frmPoll.action = 'poll--' + document.frmPoll.pollKey.value + '--' + getCheckedValue(document.frmPoll.poll_option);
		//alert(document.frmPoll.action);
		
		//document.frmPoll.action = 'poll';
		
		var eventID = 'event' + (Number(document.frmPoll.pollID.value)+11);
		//alert( eventID + " ) q: " + document.frmPoll.pollKey.value + " | a: " + getCheckedValue(document.frmPoll.poll_option) );
		
		//KeyLinkTrack( document.frmPoll.pollKey.value, getCheckedValue(document.frmPoll.poll_option), eventID) 
		KeyLinkTrack( document.frmPoll.pollKey.value, getCheckedValue(document.frmPoll.pollOptionKey), eventID);
		
		document.frmPoll.submit();
		
	}

	function submitRating()
	{
		// get the page from the URL:
		/*
		var currentUrl = location.href;
		var page;
		var lastSlashPos;
		var lastDotPos;
		
		if( currentUrl.indexOf( "://" ) >= 0 )
		{
			currentUrl = currentUrl.substring( currentUrl.indexOf( "://" )+3, currentUrl.length );
		}
		
		lastSlashPos = currentUrl.lastIndexOf('/');
		lastDotPos = currentUrl.lastIndexOf('.');
		
		if( lastDotPos > lastSlashPos )
		{
			page = currentUrl.substring( lastSlashPos+1, lastDotPos );
		}
		
		if( ( lastSlashPos > lastDotPos ) || ( page == "index" ) )
		{
			currentUrl = currentUrl.substring( 0, lastSlashPos );
			lastSlashPos = currentUrl.lastIndexOf('/');
			page = currentUrl.substring( lastSlashPos+1, currentUrl.length );
		}
		*/
		
		// Submit the form to the special URL which will get rewritten by ISAPI_rewrite:
		//document.frmRating.action = '?rate_' + page + '_' + getCheckedValue( document.frmRating.ratingOption );
		
		//alert( val + "  " +  getCheckedValue( document.frmRating.ratingKey ) );
		
		KeyLinkTrack('Page Rating', getCheckedValue( document.frmRating.ratingKey ).toString(),'event11');
		document.frmRating.submit();
	}
	
	function hideResults()
	{
		var oDiv=document.getElementById('poll_question');
	  	oDiv.style.display="block";
	
	  	oDiv=document.getElementById('poll_stats');
	  	oDiv.style.display="none";
	}
	
	function viewPoll(nPollID) {
      
	 
	  
      /* Set up the request */
	  if( !xmlhttp )
	  {
      xmlhttp =  new XMLHttpRequest();
	  }
      xmlhttp.open('POST', siteroot + 'inc/poll_post.asp', true);
      
      /* The callback function */
      xmlhttp.onreadystatechange = function() {
          if (xmlhttp.readyState == 4) {
              if (xmlhttp.status == 200) {
				  var oDiv=document.getElementById('poll_stats');
				  oDiv.style.display="block";
				  oDiv.innerHTML=xmlhttp.responseText;
				  oDiv=document.getElementById('poll_question');
				  oDiv.style.display="none";
	     		}
          }
      }
      
      /* Send the POST request */
      xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
      xmlhttp.send('pollID=' + nPollID );
	}

	function getCheckedValue(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 "";
	}

