// JavaScript Document


$(document).ready(function()
{

	/*voting*/
	if ($(".voting").length)
	{
//		$(".votingResults").addClass("hide");
//        if ($(".votingCenter2").length != 0) $(".votingResults").addClass("hide");
		/*$(".votingCenter2").each(function()
			{
				if(!$(this).hasClass("cat_1")) $(this).hide();
			});*/

	//	$("body").append("<span id='ok'></span>");
	//	$("#ok").remove();
		//$(".votingCenter2.current").removeClass("hide");
		$(".resView a").click(function()
		{
			$(".votingResults").css("display", "");
			$(".votingQuestions").removeClass("visible").addClass("hide");
			$(".votingResults").removeClass("hide").addClass("visible");
			$(".votingTop h3").html("Результаты голосования");
			return false;
		});

		$(".voiceBack a").click(function()
		{
		    $(".votingResults").css("display", "none");
			$(".votingQuestions").removeClass("hide").addClass("visible");
			$(".votingResults").removeClass("visible").addClass("hide");
			$(".votingTop h3").html("Поделись свежими идеями!");
			return false;
		});

		$(".votingCenter1 a").click(function()
		{
			$(this).addClass("current").parent().siblings().find(" > a").removeClass("current");
			var name=$(this).parent().attr("class");
			$(".voting").find("div."+name).show().siblings().hide();
			return false;
		});


//	if ( detectNotIE6() ){		
		$(".voicetext label").hover(function(){
				var topPosition=$(this).offset().top+35;
				var leftPosition=$(this).offset().left-30;
				//alert(topPosition);
				//alert($(this).offset().left);						 
               $("#altText .altCenter").html($(this).parent().parent().find('.txt').html());
			   $("#altText").css({left:leftPosition+"px", top:topPosition+"px"}).show();
           }, function(){
              $("#altText").hide();
           })
		
		
	};

//}
});

function detectNotIE6(){
  var browser = navigator.appName;
  if (browser == "Microsoft Internet Explorer"){
    var b_version = navigator.appVersion;
    var re = /\MSIE\s+(\d\.\d\b)/;
    var res = b_version.match(re);
    if (res[1] <= 6){
      return false;
    }
  }
  return true;
}

/*function showResult() {
    var bl = $(".votingCenter2:eq(1)");
    alert(bl.length);
    alert($(".resView a", bl).length);
//     $(".dealers-tabs span:eq(1)").
    $(".resView a").trigger('click');
}*/

function feedformval(formid, cnt) {
    if (!formid || !$('#'+formid).length) return;

    $(function() {
		var form = $("#"+formid);
        var btn = $('input[type=submit]', form);
         if ( 1 && btn.length == 1) {
//             alert(cnt);
             btn.attr('disabled', 'disabled').addClass('disabled');

             var count_input = 0;

             $('input[type=radio]',form).bind('change click', function() {
				count_input = $('input[type=radio]:checked', form).length;
				if (count_input == cnt) {
				    btn.removeAttr('disabled').removeClass('disabled');
				}

			});

         }
    });
}
