﻿function calendarGoToLastMonth()
{
    //alert("will redirect with paramms year = " + calendarYear +" month = " + calendarMonth);
    window.location.href = calendarBaseURL  + "?y="+calendarYear + "&m=" + calendarMonth;
}


function standartRounder()
	{
		$(".date3").corner("round , 3px");	
		$(".lizapartiibls").corner("tr bevel , 5px");
		$(".greylofj").corner("round , 3px");
		$(".optsbuttons").corner("round , 3px");
		$(".bannerrounder").corner("round , 4px");
		$(".pageCenter").corner("round, 2px");
		$(".pageCenterActive").corner("round, 2px");
		$(".NewscommentRow").corner("round, 5px");
		$(".NewscommentRow2").corner("round, 5px");
		$(".blogcatsblocklistbl").corner("right , 5px");
	}
	
function plOpen(id)
{
	$('#pl_open'+id).hide();
	$('#pl_answer'+id).show();
	$('#pl_close'+id).show();

}

function plClose(id)
{
	$('#pl_close'+id).hide();
	$('#pl_answer'+id).hide();
	$('#pl_open'+id).show();

	
}

function clearRightBorder()
{
	$("#center").css({"border":"none"});	
}
	
function NewsListCalendar(year)
{
	var l_all_years = ".newslistmonthblocks";
	var l_id_prefix = "#newslistyearid";
	
	//$(l_all_years).hide();
	$(l_id_prefix + year).show(200);

}

function personeInfoUndo()
{
	

}

function getClientWidth()
{
	//return $("body").html();
  return $("body").width();
//  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
}

function getClientHeight()
{
	return $("#center").height();
 // return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;
}



function personeInfo(id,objId)
{

//alert(getClientWidth());	
//alert(getClientHeight());	
	var deputatContent = $('#'+ id).html();
	var newWindowPosition = $("#" + objId).offset();
	//alert(newWindowPosition.left + " / " + newWindowPosition.top);
	var zatemnenie = "\".zatemnenie\"";
	deputatContentOk = "<div class='jsWindowDeputat static_content' onclick='$(this).remove(); $(" + zatemnenie + ").remove(); personeInfoUndo(); ' style='display:none; width:450px; background-color:White; position:absolute; left:"+ newWindowPosition.left +"px; top:"+ newWindowPosition.top+"px; z-index:99; '>" + deputatContent + "</div>";
	$("body").css({"position" : "relative" , "z-index" : "50"});
	$(".jsWindowDeputat").remove();
	$("body").prepend(deputatContentOk);
	$(".jsWindowDeputat").corner("round, 5px");
	$(".jsWindowDeputat").show(200);
	//
	$("body").append("<div class='zatemnenie' style='opacity: 0.6; filter:progid:DXImageTransform.Microsoft.Alpha(opacity=50); height: "+ getClientHeight() +"px; width: "+ getClientWidth() +"px; visibility: visible; background: black; z-index:70; position:absolute;'></div>");
	//alert(deputatContentOk);
	//alert("#" + id);

}

$(document).ready(function()
{


	$("#findthis").focus(function(e){
			$("#findthis").css({'background':'White','color':'#0A2736'});
	});
	
	$("#findthis").focusout(function(e){
			$("#findthis").css({'background':'#14485C','color':'#5B8599'});
	});
	
	$("#authform input").focus(function(e){
			$("#authform input").css({'background':'White','color':'#0A2736'});
	});
	
	$("#authform input").focusout(function(e){
			$("#authform input").css({'background':'#14485C','color':'#5B8599'});
	});
	

	/*$(document).click(function(e){

		if(e)
		{
			$('.menusubul').hide();
		}
		
	});
	*/
	$('.menusubul').mouseleave(function(){
		$('.menusubul').hide();
	});
	
	$('#menubl').mouseleave(function(){
		$('.menusubul').hide();
	});
	
	
			standartRounder();
			
	$('textarea[maxlength]').keyup(function(){
	        var max = parseInt($(this).attr('maxlength'));
	        if($(this).val().length > max){
	            $(this).val($(this).val().substr(0, $(this).attr('maxlength')));
	      }
		  });
		  
	$("#voteBjq").click(function(e){
			
			check_const = 3;
			countregions = $(".region_deputat_list").length;
			countdistricts = $(".district_deputat_list").length;
			
			if(countregions > check_const)
				countregions = check_const;
				
			if(countdistricts > check_const)
				countdistricts = check_const;
				
			
			if($(".region_deputat_list:checked").length == countregions && $(".district_deputat_list:checked").length == countdistricts)
			{
				document.getElementById("submittedval").value = "1";
				$("#callbackform").submit();
			}
			else
			{
				if(g_lang == 'ru')
					alert("Вы не выбрали нужное количество депутатов");
				else
					alert("Ви не вибрали необхiдну кiлькiсть депутатiв");
			
			}
	});
	
	// new events
	
	$("#authform input[name='username']").focus(function(e){

	var pos =  $(e.target).offset();
	var str = "";
	str+= "<div class=\"jsinfosearch\" style=\" width:205px; text-align:left; position:absolute; top: "+ (pos.top + 30) +"px; line-height:17px; background-color: White;  border:1px solid Silver; z-index:1000; color: #4079A6; left:" + pos.left + "px; \"><p style='padding:0; margin:0 auto; width:190px;'>";

	if(g_lang == 'ua')
		str+= "Якщо ви заходите в перший раз, введіть номер партквитка і переходьте в поле «пароль»";
	else
		str+= "Если вы заходите  первый раз, введите номер парт билета и переходите в поле «пароль»";
		str+= "</p></div>";
		$("#title").append(str);
	});
	
	
	
	$("#authform input[name='password']").focus(function(e){

	var pos =  $(e.target).offset();
	var str = "";
	str+= "<div class=\"jsinfosearch\" style=\" width:205px; text-align:left; position:absolute; top: "+ (pos.top + 30) +"px; line-height:17px; background-color: White;  border:1px solid Silver; z-index:1000; color: #4079A6; left:" + pos.left + "px; \"><p style='padding:0; margin:0 auto; width:190px;'>";

	if(g_lang == 'ua')
		str+= "Введіть Ідентифікаційний номер і натисніть клавішу «Enter»";
	else
		str+= "Введите Идентификационный номер и нажмите клавишу «Enter»";
		str+= "</p></div>";
		$("#title").append(str);
	});
	
	
	
	$("#authform input").blur(function(){
		$('.jsinfosearch').hide();
	});
	
	
	//
	
});



