
		//VOTE POLL -------------------------------------
		function makeVote(url, parameters) {
		  http_request = false;
		  if (window.XMLHttpRequest) { // Mozilla, Safari,...
			 http_request = new XMLHttpRequest();
			 if (http_request.overrideMimeType) {
				// set type accordingly to anticipated content type
				//http_request.overrideMimeType('text/xml');
				http_request.overrideMimeType('text/html');
			 }
		  } else if (window.ActiveXObject) { // IE
			 try {
				http_request = new ActiveXObject("Msxml2.XMLHTTP");
			 } catch (e) {
				try {
				   http_request = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) {}
			 }
		  } else return false;
		  if (!http_request) {
			 alert('Cannot create XMLHTTP instance');
			 return false;
		  }
		  
		  http_request.onreadystatechange = alertVote;
		  http_request.open('POST', url, true);
		  http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		  http_request.setRequestHeader("Content-length", parameters.length);
		  http_request.setRequestHeader("Connection", "close");
		  http_request.send(parameters);
		}

	   function alertVote() {
		  if (http_request.readyState == 4) {
			 if (http_request.status == 200) {
				//alert(http_request.responseText);
				var id = $("#poll_id").val()
				$.get("result.php?poll_id="+id, function(data) {
									$("#vote_msg").html(data);
							})            
			 } else {
				alert('There was a problem with the request.');
			 }
		  }
		}
	   
	 
	   function submit_vote(obj) {
		  var vote_value = selected_poll_value;
		  var poststr = "poll_id=" + encodeURI( document.getElementById("poll_id").value ) +
						"&voteid=" + encodeURI( vote_value);				
		  makeVote('vote.php', poststr);
	   }

	function getxmlhttp(){
		var page_request = false;
		if (window.XMLHttpRequest){
			return xmlhttp = new XMLHttpRequest();
		}else if (window.ActiveXObject){
			try {
				return xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
			}catch (e){
				try{
					return xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
				}catch (e){}
			}
		}else{
			return false
		}
		}
		
		function getpage(url, container){
			xmlhttp = getxmlhttp();
			xmlhttp.open('GET', url);
			xmlhttp.onreadystatechange = function(){
				if(xmlhttp.readyState == 4 && xmlhttp.status == 200){
					document.getElementById(container).innerHTML = xmlhttp.responseText;
					tinyMCE.execCommand("mceAddControl",false,'content');
				}else{
				document.getElementById(container).innerHTML = "<h3>Loading.....</h3>";
					//document.getElementById(container).innerHTML = '<div style="text-align:center;"><img src="images/ajax-loader.gif" /></div>';
				}			
				//alert(xmlhttp.status);
				//document.getElementById(container).innerHTML = xmlhttp.responseText;
			}
			xmlhttp.send(null);
		}
	
		$(function() {
			
			var lis = $("#poll-options li");
			lis.each(function() {
				$(this).click(function() {
					lis.css("color", "");
					$(this).css("color", "red");
					selected_poll_value = this.id.substring(3)
				})
			})
			
			$('#modal_submit').click(function() {
				// Make sure all fields are filled in
				if ($("#name").val() == "" || $("#name").val() == "Name" || $("#email").val() == "") {
					$("#modal_error").text("All fields are required.")
					return false;
				} else {
					// Make sure email address appears valid (has an @, and a . in position -3 or -4)
					var checkEmail = $("#email").val();
					if ((checkEmail.indexOf('@') < 0) || ((checkEmail.charAt(checkEmail.length-4) != '.') && (checkEmail.charAt(checkEmail.length-3) != '.'))) {
						$("#modal_error").text("Please enter a valid email address.")
						return false;
					} else {
						// All good
						return true;
					}
				}
			})
		})
