var IE = (typeof document.all == 'object') ?  true : false;
var DOM = (typeof document.getElementByID == 'object') ?  true : false;

function getElmByID(ID){
	if( IE ){
		elm =  document.all[ID];
	} else {
		elm = document.getElementById(ID);
	}
	
	if( typeof elm == 'object' ){
		return elm;
	} else {
		return false;
	}
} // getElmByID();


function ReSizeWindow(){
	var main = getElmByID('main');
	var BoxLayer = getElmByID('menuBoxLayer');
	var WH = IE ? document.body.offsetHeight-10 : window.innerHeight;

	if( main != false ){
		if( idWZ = getElmByID('idWorkZone') )
			idWZ.style.display = 'block';
			if( idCR = getElmByID('idCopyRight') )
				idCR.style.display = 'block';
		if( BoxLayer ) {
			BoxLayer.style.top = Math.round(WH/2)-127;
		}
//		alert(WH);
		main.style.height = WH;
		return true;
	} else {
		return false;
	}
} // ReSizeWindow();

function UpLayer(node, z, h){
	if( h ){
		node.style.zIndex = z;
		getElmByID('aphorism_'+z).style.display = 'none';
		getElmByID('default').style.display = 'block';
	} else {
		getElmByID('aphorism_'+z).style.display = 'block';
		getElmByID('default').style.display = 'none';
		node.style.zIndex = 1000;
	}
} // UpLayer();

function OpenSection(url){
	document.location.href = url;
} // OpenSection();

function SH_imgSection(arImg, def, ignor){
	for(var i = 0; i < arImg.length; i++){
		getElmByID(arImg[i]).style.display = i == ignor ? 'block' : 'none';
	}
	if( def ){
		getElmByID(arImg[def-1]).style.display = 'block';
	}
} // SH_imgSection();

function ShowZavitok(node){
	node.parentNode.className = "ZSmall";
//	alert(node);
} // ShowZavitok();

var t = 0;

function DivScroll(d){
	var x = getElmByID('DContent');
	if( x ){
		t = setInterval("getElmByID('DContent').scrollTop += "+d+";", 4);
	}
} // DivScroll();

function DivScrollStop(){
	clearInterval(t);
} // DivScrollStop();

function CheckScrolling(){
//	alert(getElmByID('DContent').scrollHeight);

	if( getElmByID('DContent') && getElmByID('DContent').scrollHeight >  255 ){
		getElmByID('ScrollUp').style.display = 'block';
		getElmByID('ScrollDown').style.display = 'block';
	}
} // CheckScrolling();

function SelPage(index){
	getElmByID('BPage'+index).src = '/html/decor/page-sel.gif';
} // SelPage();

function UnSelPage(index, sel){
	getElmByID('BPage'+index).src = sel ? '/html/decor/page-press.gif' : '/html/decor/page.gif';
} // SelPage();

function SelArrow(der){
	getElmByID('arrow'+der).src = '/html/decor/arrow-'+der+'-sel.gif';
} // SelArrow();

function UnSelArrow(der){
	getElmByID('arrow'+der).src = '/html/decor/arrow-'+der+'.gif';
} // UnSelArrow();

var timeTitle = -1;

function SelLogo(node){
	var tID = node.id.substr(1);
	
	clearTimeout(timeTitle);
	getElmByID('SectionTitle').innerHTML = '<img src="'+arTitles[tID].src+'" width="'+arTitles[tID].w+'" height="'+arTitles[tID].h+'" alt="'+arTitles[tID].alt+'"/>';
	
	node.src = node.src.replace('.gif', '-sel.gif');
} // SelLogo();

function UnSelLogo(node){
	tID = -1;
	timeTitle = setTimeout('getElmByID(\'SectionTitle\').innerHTML = \'<img src="'+arTitles[tID].src+'" width="'+arTitles[tID].w+'" height="'+arTitles[tID].h+'" alt="'+arTitles[tID].alt+'"/>\'', 200);
	node.src = node.src.replace('-sel.gif', '.gif');
} // SelLogo();