function getxmlhttpobject()
{
	var xmlhttp=null;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlhttp=new XMLHttpRequest();
	}
	catch (e)
	{
		//Internet Explorer
		try
		{
			xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlhttp;
}

function poll2()
{


	xmlhttp=getxmlhttpobject();

	for(i=0;i<document.polling.length;i++)
	{
		if (document.polling.poll[i].checked == true)
			var data=document.polling.poll[i].value;
	}
    if(data>0) {
		document.getElementById("ajaxrep").innerHTML='<img scr="images/ajax-loader-green.gif"/>';
		var query="val="+data;
         //alert(query);
			xmlhttp.onreadystatechange=function()
			{
				if (xmlhttp.readyState==4)
				{
                $(document).ready( function() {


					jAlert(xmlhttp.responseText, 'Confirmation Dialog',

				    function(r) {


					if(r==true)
					{
					    $("#pollcontent").fadeOut(300);
					}



					});

			  });

                  	//document.getElementById("ajaxrep").innerHTML=xmlhttp.responseText;
				}
			}
	xmlhttp.open("GET","index.php?action=poll&block=added&"+query,true);
	xmlhttp.send(null);}
    else {

         $(document).ready( function() {


					jAlert('<span style="color:red" class="error">Please select atleast one option</span>', '',

				    function(r) {


					if(r==true)
					{
					    $("#pollcontent").fadeOut(300);
					}



					});

			})
      	//document.getElementById("ajaxrep").innerHTML="<span style='color:red' class='error'>Please select atleast one option</span>";
    }
}
function getpage(url){
  url='result.php?poll_id='+url;

		xmlhttp = getxmlhttpobject();
		xmlhttp.open('GET', url);
		xmlhttp.onreadystatechange = function(){
			if(xmlhttp.readyState == 4 && xmlhttp.status == 200){
				document.getElementById('pollarea').innerHTML = xmlhttp.responseText;
				tinyMCE.execCommand("mceAddControl",false,'content');
			}else{
		  //	document.getElementById('pollarea').innerHTML = "<h3>Loading.....</h3>";
				//document.getElementById('pollarea').innerHTML = '<div style="text-align:center;"><img src="images/ajax-loader.gif" /></div>';
			}
			//alert(xmlhttp.status);
			//document.getElementById('pollarea').innerHTML = xmlhttp.responseText;
		}
		xmlhttp.send(null);
}

function counter(){
     xmlhttp=getxmlhttpobject();
	 xmlhttp.onreadystatechange=function(){
	 if (xmlhttp.readyState==4){
                    // alert(xmlhttp.responseText)
                  	//document.getElementById("ajaxrep").innerHTML=xmlhttp.responseText;
				}
			}
	xmlhttp.open("GET","counter.php",true);
	xmlhttp.send(null);
}

