function showonline(siteurl){
goPopWindow = window.open(siteurl,'showonline','width=800,height=600,left=150,top=150,screenX=50,screenY=150,resizable=yes,scrollbars=yes');
}
$(function(){
	$("#all-news .list ul a:not(:first)").each(function(){
		$(this).find("img").animate({opacity: 0.5}, "fast");
	});

	$("#all-news .news:not(:first)").each(function(){
		$(this).animate({opacity: 0.7}, "fast");
	});

	$("#all-news .list ul a").hover(
	function(){
		//if(!$(this).is(".selected"))
			$(this).find("img").animate({opacity: 1}, "slow");

			if(!$(this).hasClass("selected")){
			$("#all-news .list a.selected").each(function(){
				$(this).removeClass("selected");
				$(this).find("img").animate({opacity: 0.5}, "slow");
			});
			}
			$(this).addClass("selected");

			_className_ = '.news.'+$(this).attr("rel");

			if($(_className_).attr("id") != "news_active"){
//				$("#news_active").attr("id","").css("display:none;");
//				$(_className_).attr("id","news_active").css("display:block;");

				$("#news_active").attr("id","").animate({opacity: 0.5}, "fast");
				$(_className_).attr("id","news_active").animate({opacity: 1}, "slow");
			}
	},
	function(){
		if(!$(this).hasClass("selected"))
			$(this).find("img").animate({opacity: 0.5}, "slow");
	});

	var options = {
		target: "#output",
		beforeSubmit: showRequest,
		success: showResponse,
		timeout: 3000
	};

	$("#poll").submit(function() {
		var inputRadio = $("#poll input:radio");
		var radioLength = inputRadio.length;
		var check 		= 0;

		for(var i = 0; i < radioLength; i++) {
			if(inputRadio[i].checked) {
				$(this).ajaxSubmit(options);
				check = 1;
			}
		}
		if (!check) {
			alert('Пожалуйста, сделайте свой выбор.');
		}

		return false;
	});

	function showRequest(formData, jqForm, options) {
  		$('#btn_result').click(function(){
  			return false;
  		});
		return true;
	}

 function showResponse(responseText, statusText){
        $("#poll").empty();
	}

	$("#btn_result").click(function(){
		var qString = $("#poll").formSerialize();
		var task = "&amp;task=result";
		var quryString = qString+task;

		$.post("index3.php?option=com_poll", quryString, function(data){
			$("#poll").empty();
			$("#output").append(data);
		});

		return false;
	});
});

