$(document).ready(function(){ 

		$("div.answer input").click(function(){
			$("div#vote p.active").removeClass ('active');
			$("div#vote div.sub").fadeIn("slow");
			$(this).parents("p").addClass('active');
		});												 

	});


var popupStatus = 0;

function loadPopup(){

	if(popupStatus==0){
		$("#backgroundPopup").css({
			"opacity": "0.8"
		});
		$("#backgroundPopup").fadeIn("slow");
		$("#popup").fadeIn("slow");
		popupStatus = 1;
		$("select").css({ visibility: "hidden" });		
	}
}

function disablePopup(){
	if(popupStatus==1){
		$("#backgroundPopup").fadeOut("slow");
		$("#popup").fadeOut("slow");
		popupStatus = 0;
		$("select").css({ visibility: "visible" });
	}
}

function centerPopup(){
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#popup").height();
	var popupWidth = $("#popup").width();
	$("#popup").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2		
	});	
	
	$("#backgroundPopup").css({
		"height": windowHeight
	});
	
}


$(document).ready(function(){
	
	$("a.authorization").click(function(){

	    $("input[id$=hfReturnUrl]")[0].value = this.rel;
	    
		centerPopup();
		loadPopup();

		$("input[id$=ctl00_lvView_tbLogin]")[0].focus();
		
		return false;
	});
				

	$("#backgroundPopup").click(function(){
		disablePopup();
	});

	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatus==1){
			disablePopup();
		}
	});

});