//-------------------------------------------------------------------------------------------------
// Константы

	__FORUM_BUTTON_ID_SUBMIT__		= "createqfrm";
//-------------------------------------------------------------------------------------------------
	__CONTENT_MODE_INDEX__  =  0; // Первая страница
	__CONTENT_MODE_CMS__		=  1; // Контент из Си-Лейк

//-------------------------------------------------------------------------------------------------
	__LANG_RUSSIAN__				= 'ru'; // Русский язык

//-------------------------------------------------------------------------------------------------
// Обработчики событий
handlers = [];
//-------------------------------------------------------------------------------------------------
// Форум: создание вопроса
handlers[__FORUM_BUTTON_ID_SUBMIT__] = function(e) {
	var submit = true;
	//$Q.DEBUG(params);

			submit = ( $Q.chFormat("ФИО",'fio', true, false, $Q.TYPE_TEXT_MAXLENGTH, false, ' ФИО*:') &&
							   $Q.chFormat("E-mail",'email', false, false, $Q.TYPE_EMAIL_MAXLENGTH, $Q.TYPE_EMAIL_REGEXP,' E-mail:*') &&
							   $Q.chFormat("Тел",'tel', true, false, $Q.TYPE_TEXT_MAXLENGTH, false, ' Тел*:') &&
							   $Q.chFormat("Вопрос", 'comment', true, false, $Q.TYPE_COMMENT_MAXLENGTH, false,' Сообщение:') &&
							   $Q.chFormat("Введите код", 'kcap', true, $Q.TYPE_CAPTCHA_LENGTH, $Q.TYPE_CAPTCHA_LENGTH, false,false)
							     );

		return submit;
}
//-------------------------------------------------------------------------------------------------
// Поддержка Ajax
	is_supported_ajax = function() {
		return (typeof XMLHttpRequest != "undefined" || typeof window.ActiveXObject != "undefined");
	}


//-------------------------------------------------------------------------------------------------
// Ajax-Обработчики
function set_ajax_handlers() {
 	$("#menu > a").click(handlers[__LINK_ITEM_CLICK__]);
 	$("#pagebar > a").click(handlers[__LINK_ITEM_CLICK__]);
}

//-------------------------------------------------------------------------------------------------
// Разбор строки url и формирования хеша параметров
function get_content_params() {
	var params = new Object();
	var href = document.location.href.replace(/#.*$/, '');
	if (href.indexOf("?") != -1) {
		var vars = href.substring(href.indexOf("?") + 1,href.length).split(/\?|&/);
		for (var v in vars) {
				var p = vars[v].split('=');
				params[p[0]] = p[1];
		}
	}
	return params;
}

//-------------------------------------------------------------------------------------------------
// Обработчик после загрузки страницы
function event_body_onload() {
  // Параметры контента в одном массиве
	set_html_handlers();
	var param_lang = get_content_params();
	 if (param_lang['lang'] == 'en')
	 {
	 	Date.fullYearStart = '20';
	 	Date.dayNames = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
		Date.abbrDayNames = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
		Date.monthNames = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
		Date.abbrMonthNames = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
		Date.firstDayOfWeek = 1;
		Date.format = 'dd.mm.yyyy';
	 }
	$(".datepicker").datePicker({});
	$(".datepicker").dpSetStartDate('01/01/1991');
	$(".datepicker").dpSetEndDate('01/01/2110');
  }
//-------------------------------------------------------------------------------------------------
// Обычные обработчики


//-------------------------------------------------------------------------------------------------
// Обычные обработчики
function set_html_handlers() {

$(".datepicker").change( function() { $("form")[1].submit(); } );
//$("#eml").attr("href", "mailto:myland@united.net.ua");
var maxH;


//установим ширину блоков подменю
$("#ulmenu li ul").each(function(i){
if ($(this).parent().width()>90)
	{$(this).width($(this).parent().width()) ; }
else //первый пункт по требованию дизайнера фикс ширины!
	{$(this).width(90) ;}
});



/* выкатывание подменю  при выделениии п.меню не активного*/
$("#ulmenu .munsel, #ulmenu .msel").parent().hover(function(){

		$(this).find('ul:first').css({visibility: "visible",display: "none"}).show(400);
		},function(){
		 	$(this).find('ul:first').css({visibility: "hidden"});
		});

/*изменение стилей основоного меню при наведении */
$("#ulmenu .munsel").parent().hover(function(){
		$(this).attr("class","limsel");
		$(this).children(".munsel").attr("class","msel");
		},function(){
		$(this).attr("class","limunsel");
		$(this).children(".msel").attr("class","munsel");
		});

/*изменение стилей под меню при наведении
 */
$("#ulmenu .lisub_unsel").hover(function(){
		$(this).attr("class","lisub_sel");

		},function(){
		$(this).attr("class","lisub_unsel");

		});

fixHeightColumns();


}

function fixHeightColumns() {
var maxHeight;
switch (params.mode) {
	
	case 0 : //index.php
		 maxHeight = Math.max($("#anal").height(), $("#zakon").height(), 350)+30;
		$("#anal").height(maxHeight);
		 $("#zakon").height(maxHeight);
		 
		 maxHeight = Math.max($("#about").height(), $("#bib").height(), 350)+60;
		 $("#about").height(maxHeight);
		 $("#bib").height(maxHeight);
		 
		// $("#banners").height($("#mid").height()-$("#news").height()-54);
		break;	
	

	case 1   : 
		 maxHeight = Math.max($("#zmist").height(), $("#sublist").height(), 300)+20;
		$("#zmist").height(maxHeight+7);
		 $("#sublist").height(maxHeight);
		break;	
		
	case 2   :
		 maxHeight = Math.max($("#zmist").height(), $("#sublist").height(), 300)+20;
		$("#zmist").height(maxHeight+7);
		$("#sublist").height(maxHeight);
		break;	
		
		
	case 3   : // Новини
		 maxHeight = Math.max($("#news").height(), $("#sublist").height(), 430)+20;
		$("#news").height(maxHeight+7);
		$("#sublist").height(maxHeight);
		break;		
		
		case 4   :
		 maxHeight = Math.max($("#zmist").height(), $("#sublist").height(), 300)+20;
		$("#zmist").height(maxHeight+7);
		$("#sublist").height(maxHeight);
		break;	
		
		case 5   :
		 maxHeight = Math.max($("#zmist").height(), $("#sublist").height(), 300)+20;
		$("#zmist").height(maxHeight+7);
		$("#sublist").height(maxHeight);
		break;	
			case 6   :
		 maxHeight = Math.max($("#zmist").height(), $("#sublist").height(), 300)+20;
		$("#zmist").height(maxHeight+7);
		$("#sublist").height(maxHeight);
		break;	
		
		case 7   :
		 maxHeight = Math.max($("#zmist").height(), $("#sublist").height(), 300)+20;
		$("#zmist").height(maxHeight+7);
		$("#sublist").height(maxHeight);
		break;	
		case 8   :
		 maxHeight = Math.max($("#zmist").height(), $("#sublist").height(), 300)+20;
		$("#zmist").height(maxHeight+7);
		$("#sublist").height(maxHeight);
		break;	
		
		case 10   ://
		 maxHeight = Math.max($("#news").height()+$("#banners").height(), $("#sublist").height(), 300)+18;
		$("#sublist").height(maxHeight);
		if ($("#news").height()+$("#banners").height()< $("#sublist").height())
	{}//	{$("#banners").height(maxHeight-18-$("#news").height());}
		break;		
		
		
}


}

function maillink(mailprefix, maildomain, mailsuffix, mailname)
			{
			  if (mailname == null) { mailname = "e-mail"; }
			  document.write('<a href="mailto:' + mailprefix + '@' + maildomain + '.' + mailsuffix + '"><img  src="img/ico_mail.png"/></a>');
			}



