$(document).ready(function(){
//table processing	
	$('.fucking-table tr').each(function(i){
		if (i<3){
			$(this).children('td:last').css('border-right','none');
		}else{
			$(this).children('td:last').css('border-right','2px solid #e9e9e9');
			$(this).children('td:first').css('border-left','2px solid #e9e9e9');
		}
	}); 
	
	$('.fucking-table tr:first').addClass('empt-row')
		.next().addClass('head-row')
		.next().addClass('empt-row').removeClass('odd-row').css('height','8px')
	;
		
	$('#form-check').width($('.fucking-table td:last').width()+16);
	
//login form validation

	$("#loginform").validate({
		rules: {
			login: "required",
			lpass: "required"
		},
		messages: {
			login: "",
			lpass: ""
		}
	});
});

function element(id)
{

	return document.getElementById ? document.getElementById(id) : document.all[id];
}

function showMesInfo(msg)
{
	getBg(); // get background
    element('error-popup-description').innerHTML    = msg;
    element('info-popup').style.display            = '';
    setPosition('info-popup');
    return true;
	return false;
}

function getBg()
{
    var ps                                          = getPageSize();
    element('error-bg').style.width=(ps[0] - 16 )+'px';
    element('error-bg').style.height=ps[1]+'px';
    element('error-bg').style.display               = '';
}


function closeEroWin()
{
    element('info-popup').style.display            = 'none';
    element('error-popup-description').innerHTML    = "";
    element('error-bg').style.display               = 'none';
    return true;
}

function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}


function setPosition(obj) 
{
    var arrayPageSize = getPageSize();
    var arrayScrollXY = getScrollXY();
    var wnd = window.document;
    var pTop = arrayScrollXY[1];
    var pLeft = arrayScrollXY[0];
    var minTop = pTop;

    pTop += ((arrayPageSize[3] - element(obj).clientHeight) / 2);
    pLeft += ((arrayPageSize[2] - element(obj).clientWidth)/2);

    pTop = Math.max(pTop, minTop);
    element(obj).style.position='absolute';
    element(obj).style.top=pTop+'px';
    element(obj).style.left=pLeft+'px';   
}

function getPageSize()
{
	var xScroll, yScroll;

	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}

	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	

	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function showmenu(id)
{
	element(id).style.display = '';
}
/*
function showbg(id)
{
	element('topmenu1_').src = src='../img/topmenu1_u.gif';
	element('topmenu2_').src = src='../img/topmenu2_u.gif';
	
	element(id).src = src='../img/'+id+'a.gif';
}

function unshowbg(id)
{
	element(id).src = src='../img/'+id+'u.gif';
}

function unshowbg2(id)
{
	if(element('sub_'+id).style.display != '')
	{
		element(id).src = src='../img/'+id+'u.gif';
	}
}

function unshowbg3()
{
	element('topmenu1_').src = src='../img/topmenu1_u.gif';
	element('topmenu2_').src = src='../img/topmenu2_u.gif';
}*/

