function get_page_size(){
	var xScroll, yScroll;

	if (window.innerHeight && window.scrollMaxY) {
		xScroll = window.innerWidth + window.scrollMaxX;
		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
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth;
		} else {
			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 = xScroll;
	} else {
		pageWidth = windowWidth;
	}

	return [pageWidth,pageHeight];
}

function show_clubuser_entry(){

	var popup = document.getElementById("popup_entry");
	popup.style.display = 'block';
	var page_size = get_page_size();
	
	popup.style.left = parseInt((page_size[0] - 328)/2) + 'px';

	var  shape = document.createElement('div');
	shape.style.width = page_size[0] + 'px';
	shape.style.height = page_size[1] + 'px';
	shape.id = 'shape_div';
	document.body.appendChild(shape);
	
	document.popup_form.login.focus();
	addHandler(document.body, checkbodykeypress, 'keypress');
	
}


function show_banner_entry()
{
	var banner = document.getElementById("banner_entry");
	banner.style.display = 'block';
	var shade = document.getElementById("body_shade");
	shade.style.display = 'block';
	var page_size = get_page_size();
	banner.style.left = parseInt(page_size[0]/2 - 300) + 'px';
}

function hide_banner_entry(){
	document.getElementById("banner_entry").style.display = 'none';
	document.getElementById("body_shade").style.display = 'none';

	var shape = document.getElementById('shape_div_banner');
	if(shape){
		document.body.removeChild(shape);
	}
}


function checkbodykeypress(ev){
	if(document.getElementById("popup_entry").style.display!='none'){
		var Code = (ev.keyCode || ev.which);
		if(Code==13){
		if(window.ActiveXObject){ // Если IE
					checkClubuser();
					document.popup_form.submit();
				}
		}
		if(Code==27){
			hide_clubuser_entry();
		}

		return true;
	}else{
		return false;
	}
}

function hide_clubuser_entry(){
	document.getElementById("popup_entry").style.display = 'none';

	var shape = document.getElementById('shape_div');
	if(shape){
		document.body.removeChild(shape);
	}
}

function fixed(e, pos)
{
	//pos = parseInt((screen.height - e.offsetHeight) / 2);
    if (/MSIE (5\.5|6).+Win/.test(navigator.userAgent))
    {
        e.style.position = 'absolute';
        var top = Math.max(document.body.scrollTop, document.documentElement.scrollTop);
        return (top + pos) + 'px';
    }
    else e.style.top = pos + 'px';
}

function addHandler(obj, handler, event) {
	if(obj.addEventListener) {
		obj.addEventListener (event, handler, false);
	}else if(obj.attachEvent) {
		obj.attachEvent ("on"+event, handler);
	}else{
		//obj.onclick = handler;
	}
}

