$(document).ready(
function(){

	//	jQuery.browser.version = jQuery.browser.msie &&
	//    parseInt(jQuery.browser.version) >= 6 &&
	//    window["XMLHttpRequest"] ? "7.0" : jQuery.browser.version;

//	jQuery.browser.msie6 = jQuery.browser.msie && parseInt(jQuery.browser.version) == 6 && !window["XMLHttpRequest"];



	var userAgent = navigator.userAgent.toLowerCase();
	var ie_version = -1;
	if (navigator.appName == 'Microsoft Internet Explorer') {
		var re = new RegExp("msie ([0-9]{1,}[\.0-9]{0,})");
		if (re.exec(userAgent) != null)
		ie_version = parseFloat(RegExp.$1);
	}
	$.browser = {
		version: (ie_version>-1)?ie_version:(userAgent.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [0,'0'])[1],
		safari: /webkit/.test( userAgent ),
		opera: /opera/.test( userAgent ),
		msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ),
		mozilla: /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent )
	};




//	if (jQuery.browser.msie6 == false) {
	if (!$.browser.msie || ($.browser.msie && $.browser.version >= 7)) {

		$("#blackColLeft").css({background: "url(assets/templates/first/images/blackColBgBig-trans.png) no-repeat"});
		$("#blackColRight").css({background: "url(assets/templates/first/images/blackColBgBig-trans.png) no-repeat"});
	}

	function setMaxColumnHeight() {


		/*
		дано: высота блока с текстом + общая высота вержнего и нижнего блока
		что надо: проверить - является ли высота окна браузера больше чем сумма верхнего+нижнег+блока с текстом?
		если Да: то установить высоту обертывающего блока равной высоте окна + установить высоту контента равной разнице между высотой браузера и верхнего и нижнего блока
		если Нет: установить высоту обертывающего блока равной высоте окна + уменьшить видимую часть контента до высоты равной высоте окна минус верхний и нижний блок
		*/

		w1 = parseInt(document.getElementById("header").offsetHeight);
		w2 = parseInt(document.getElementById("footer").offsetHeight);
		w3 = parseInt(document.getElementById("content").offsetHeight);
				w4 = $("div.jScrollPaneContainer").height();
				w5 = parseInt(document.getElementById("blackColRight").offsetHeight);
				w6 = parseInt(document.getElementById("leftCol").offsetHeight);
				w7 = parseInt(document.getElementById("rightCol").offsetHeight);
		//		alert(w4)



		if($(window).height() > w1 + w2 + w3 ) {
			$("#content").height( $(window).height() - w1 - w2 );
			$("#wrapper").height( $(window).height() );
//						$("div.jScrollPaneContainer").height( $(window).height() - w1 - w2 );
		} else {
			var sum = w1 + w2;
			if (sum > $(window).height()) {
				$("#wrapper").height( sum );
				$("#content").height( 0 );
//								$("div.jScrollPaneContainer").height( 0 );
			} else {
				$("#wrapper").height( $(window).height() );
				var a =  $(window).height() - sum;
				$("#content").height(a);
//								$("div.jScrollPaneContainer").height(a);
			}
		}
//		$("#content").jScrollPane({showArrows:true, scrollbarWidth:18});

//document.title =$(window).height()+ " " + w1 + " " +w2 + " " +w3+" "+w4;
	}


	setMaxColumnHeight();

	//resizing
	$(window).resize( function() {
//		$("#content").jScrollPane({showArrows:true, scrollbarWidth:18});
		setMaxColumnHeight();
	});

});
