$(document).ready(function(){
	
	if(window.loadedIE7Fix != true && $.browser.msie && $.browser.version == "7.0"){
		
		$("head").append("<style type='text/css'>"+
							"#divLeftMenu .rtable {width:100% !important;}"+
							"#divLeftMenu .rmenu {overflow-y:auto;}"+
							"select#Currency {min-width:130px;}"+
							"#MainMenu .rtabel .rtab {height: 46px !important;padding-top:3px !important;}"+
							".rwintable_ie, .rwininfotable_ie, .tblHistResults_ie, .tblLimits_ie, .tblCardInfoAccts_ie, .tblCMS_ie,.tblOperHistResults_ie,.tblLimits_ie,.tblAccountInfoCards_ie{	width:100% !important;}"+
							".divLogonLang{	float:right !important;}"+
							".divLogonDL{display:block !important;}"+
							".divLogonRU{	float:left !important;}"+
							".divLogonEN{	margin-left:45px !important;}"+
							".pipka{	margin-top:10px !important;	top:145px !important;} "+
							".btn-format {    display: inline !important;}"+
							".btn-widget {    display: inline !important;}"+
							".btnMakeHistory{  margin-bottom:0px !important;}"+
							
						"</style>  ");
		
		window.loadedIE7Fix = true;
	}
	
});


function mresize() {
	if (sessionLastActivityTime != null) {
		sessionLastActivityTime = (new Date()).getTime();
	}
	if ($('.mayPrint', '#body').length == 0
			&& $('.mayPrint', '#fadeDiv').length == 0) {
		clearPrintDiv();
	}
	// console.log('=======================================================================');
	// $('#divRightWrapFixedTop
	// div').each(function(){console.log('id='+$(this).attr('id')+';class='+$(this).attr('class'));});
	if ($('#fadeDiv').css('visibility') == 'visible') {
		var maxh = $('#fadeDiv').height();
		var maxw = $('#fadeDiv').width();
		$('#fadeDiv #fadeContent').css('left',
				(maxw - $('#fadeDiv #fadeContent').width()) / 2);
		if ($('#fadeDiv #actionContentDivWrap').length) {
			var toppadding = $('#fadeDiv #actionContentDivWrap').attr(
					'toppadding') ? $('#fadeDiv #actionContentDivWrap').attr(
					'toppadding') : 0.25;
			$('#fadeDiv #fadeContent').css('top', (maxh * toppadding));
			var ch = 0;
			if ($('#fadeDiv #confirm_block').css('display') != 'none') {
				ch = $('#fadeDiv #confirm_block').height();
			}
			var nmax = maxh - 10 - maxh * toppadding - 12 - ch
					- $('#fadeDiv #winheader').height();
			if ($('#fadeDiv #actionContentDiv').height() >= nmax) {

				$('#fadeDiv #actionContentDivWrap').height(nmax);
			} else {
				$('#fadeDiv #actionContentDivWrap').css('height', 'auto');
			}
		} else {
			$('#fadeDiv #fadeContent').css('top',
					(maxh - $('#fadeDiv #fadeContent').height()) * 0.35);
		}
	}

	if ($('#divKeyboardWrap').length > 0 && $('#Password').length > 0) {
		px = $('#Password').offset().left;
		py = $('#Password').offset().top + 20;
		$('#divKeyboardWrap').css({
			left : px + "px",
			top : py + "px"
		});
	}

  if ($('.logonWrapRegistration').length>0) {
    var logonWrap = $('.logonWrapRegistration');
    var logonReg = $('.logonRegistration');
    if ((logonReg.height() + logonReg.offset().top) > logonWrap.height()){
      logonWrap.height(logonReg.height()+logonReg.offset().top+15)
      $('#body').css('overflow','auto');
    }
  }

	if (!$('#MainContent').length) {
		return;
	}
	var topp = $('#MainContent').offset().top;
	var bott = $('#divFooter').offset().top;
	var tabh = 1;
	if ($('#divMain #ulRightWrap').length > 0
			&& $('#divMain #ulRightWrap').attr('hght')
			&& $('#divMain #ulRightWrap').attr('hght') != "") {
		tabh = $('#divMain #ulRightWrap').attr('hght');
	}
	var maxH = bott - topp - 7 - 21 - 10 - Number(tabh) - 2;// $(this).parent().attr('hght',tallestcolumn+4);
	$('#pipka').css('top', topp + 'px');
	$('#pipka').height(bott - topp);
	$('#divMain').height(bott - topp);

	if ($('#divLeftMenu').css('display') == 'none') {
		$('#divMain').width($('#pipka').width());
	} else {
		$('#divMain')
				.width($('#pipka').width() - $('#divLeftMenu').width() - 7);// -5
		$('.rmenulist').css('max-height', bott - topp - 15);
		$('#divMenu').height($('.rmenulist').height() + 20);
		var hgtRmenu = $('.rmenulist .menuheader').height();
		var amtRmenu = $('.rmenulist .menuheader').length;
		var maxHgtRmenu = (bott - topp - 20) - (hgtRmenu + 25) * amtRmenu;//+16
		//$('.menubody').css('max-height', maxHgtRmenu);
		$(".menubody").each(function(){
			var buttonsDiv = $(this).find("div[class*='Buttons']");
			if(buttonsDiv.length > 0 ){
				buttonsDiv.siblings("div[id*='_Tbl']").css({"max-height": maxHgtRmenu, "overflow-y" : "auto"});
			}else{
				$(this).css({"max-height": maxHgtRmenu, "overflow-y" : "auto"});
			}
		});
		
		if ($.browser.msie
				&& ($.browser.version == 6 || $.browser.version == 7)) {
			if ($('#divMenu').height() < $('#divMenu > .rmenulist').height()) {
				$('#divMenu > .rmenulist .rtable').each(function() {
					$(this).width(400 - 8 - 10 - 18);
					/* $('#divMenu').width()=392 */
				});
			} else {
				$('#divMenu > .rmenulist .rtable').each(function() {
					$(this).width(400 - 8 - 10);
				});
			}
		}
		if ($.browser.msie && $.browser.version > 7) {
			if ($('#divMenu').height() < $('#divMenu > .rmenulist').height()) {
				$('#divMenu').css('width', 'auto');
			} else {
				// $('#divMenu').width(392);
			}
		}
	}

	if ($('#divMain #divRightWrapScrlMiddleWrap').length > 0
			&& $('#divMain #divRightWrapScrlMiddleWrap').css('display') != 'none') {
		var mH = maxH;
		if ($('#divMain #divRightWrapFixedTop').css('display') != 'none') {
			// console.log($('#divMain #divRightWrapScrlMiddle').offset().top);
			mH -= $('#divMain #divRightWrapFixedTop').height();// console.log('-top='+$('#divMain
																// #divRightWrapFixedTop').height());
		}
		if ($('#divMain #divRightWrapFixedBottom').css('display') != 'none') {
			mH -= $('#divMain #divRightWrapFixedBottom').height();// console.log('-bot='+$('#divMain
																	// #divRightWrapFixedBottom').height());
			if ($('#divMain #divHelp').css('display') != 'none') {
				mH += $('#divMain #divHelp').height();
			}
		}
		if (mH < 80) {
			mH = 80;
		}
		if ($('#divMain #divRightWrapScrlMiddle').height() > mH) {
			$('#divMain #divRightWrapScrlMiddleWrap').height(mH - 23);
			if ($('#div-switch').length > 0 && $('#div-switch').is(':visible')) {
				$('#divMain #divRightWrapScrlMiddleWrap').height(
						mH - $('#div-switch').height());
			}
		} else {
			$('#divMain #divRightWrapScrlMiddleWrap').height(
					$('#divMain #divRightWrapScrlMiddle').height());
		}
	}

	if ($('#divMain #divRightWrapContent').length > 0) {
		if ($('#divMain #divRightWrapContent').height() < 80) {
			$('#divMain #divRightWrapContentWrap').height(80);
		} else {
			if ($('#divMain #divRightWrapContent').height() > maxH) {
				maxH -= 20;
				$('#divMain #divRightWrapContentWrap').css('height', maxH);
			} else {
				$('#divMain #divRightWrapContentWrap').css('height', 'auto');
			}
		}
	}

	if ($('#tblHome').length > 0) {
		if ($('#tblHome').height() > $('#divMain').height() - 5) {
			$('#tblHome').width($('#pipka').width() - 18 - 5);
		} else {
			$('#tblHome').width($('#pipka').width() - 5);
		}
	}
	
	tabHideBottomBorder();
		
	$(".icolistTitle").eq(0).each(function(){
		
		if($.trim($(this).html()).length){
			$(this).addClass("withLineAndMarker");
		}
		
	});
	
}

function tabHideBottomBorder(){
	$('#ulRightWrap .rtabel .rtab b.top, .logonRegistration .rtabel .rtab b.top').css({"width":"inherit"});
}
