/**
 * @author zgr3d
 */

function $( x ) {
	return document.getElementById( x );
}

function toggle( x ) {
	if( x.style.display == 'none' )
		x.style.display = 'block';
	else
		x.style.display = 'none';
}

function setFooter() {
	if( $('div_left').offsetHeight > $('div_right').offsetHeight )
		var moveFromTop = $('div_left').offsetHeight;
	else
		var moveFromTop = $('div_right').offsetHeight;
	
	if( $('div_main').offsetHeight > moveFromTop )
		moveFromTop = $('div_main').offsetHeight;
	
	if (moveFromTop + 18 > window.innerHeight || (!window.innerHeight && moveFromTop + 18 > $('body').offsetHeight)) 
		$('div_footer').style.top = ( moveFromTop + 35 ) + 'px';
	else {
		$('div_footer').style.top = '';
		$('div_footer').style.bottom = '0px';
	}
}

function menu_el( x , y ) {
	var div = x.previousSibling;
	var div2 = div.previousSibling;
	var width;
	if (div.style.display == 'block') {
		div.style.display = 'none';
		div2.style.display = 'none';
		x.style.background = '#fff';
		x.style.overflow = 'hidden';
		width = '100%';
	} else {
		div.style.display = 'block';
		div2.style.display = 'block';
		x.style.background = 'transparent';
		x.style.overflow = 'visible';
		width = x.firstChild.offsetWidth + y;
		if( width > x.parentNode.offsetWidth )
			width += 'px';
		else
			width = '100%';
	}
	x.style.width = width;
	div.style.width = width;
	div2.style.width = width;
}

function windowOpen( w , h , url , name ) {
	return window.open( url , name , 'status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,scrollbars=0,height=' + h + ',width=' + w )
}

