
$("#document").ready(function(){
//alert("ds");
	$("#_surveysClick input").click(function(){
		//alert("ds");
		var title_id = $("#voteBlock").attr("name");
		var checkedNum = 0;
		if($("#answerOne").attr("checked")){
			
			checkedNum = 1;
			
			//alert(checkedNum);
			
		}else if( $("#answerTwo").attr("checked")){
			checkedNum = 2;
		}else{
		
			//alert("checked first!");
			checkedNum = 0;
		
		}
		
		if(checkedNum != 0) {
			
			var roundNum = parseInt(Math.random()*10000+1);
			
			$.get("/report.php?pitch_on="+checkedNum+"&poll_id="+title_id+"&rondom="+roundNum,null,
			
											function(response){
												
											
												//$("#elva_response").html(response);
												
												//$("#elva_response").dialog({width:450,height: 230});
												
												//alert($("#elva_response").html());
												
												var layer;
												var div;
												
												var de=document.compatMode=="CSS1Compat"?document.documentElement:document.body;
											
								        if($("#layer1").size()>0) {
								        		$('._response').html(response);
								            $("#layer1").css("display","block");
								             //alert(response);
								        } else {
								            div=document.createElement("div");
								            div.id="layer1";
								            div.style.cssText="position:absolute;z-index:999;top:0;left:0;opacity:0.9;filter:alpha(opacity=90);background:#999999";
								            div.style.width=Math.max(de.offsetWidth,de.scrollWidth)+"px";
								            div.style.height=Math.max(de.offsetHeight,de.scrollHeight)+"px";
								            //document.title=de.offsetHeight+"|"+de.scrollHeight;
								            
								            layer=document.createElement("div");
								            
								            //alert(response);
								            layer.style.cssText="position:fixed;_position:absolute;z-index:1000;top:50px;width:450px;height:240px;background:#FFFFFF;border:solid 1px #09c;";
								            layer.innerHTML="<p><span style='float:right;cursor:pointer;margin:5px 7px;'><img src='/static/images/close_icon.gif'/></span><p>" +
								            								"<div class='_response' style='margin-top:5px;margin-left:20px;color:#666666;font-family:Arial,NSimSun;font-size:13px;margin:20px;'>"+response+"</div>";      
								            div.appendChild(layer); 
								            document.body.appendChild(div);
								            
								            layer.style.left=(de.clientWidth-layer.clientWidth)/2 +'px';
								            layer.style.top=(de.clientHeight-layer.clientHeight)/2 +'px'
								            
								            $("span",layer).click(function() {
								                $("#layer1").css("display","none");
								            });
								        }        
							        

											
											
								});
			
			
			
		}else{
			
			
		}
		
		
	
	});
	
});

