/* Отображение всплывающего блока на главной */
var changeIE6 = false;
/* Если ИЕ6, то после загрузки страницы нужно изменить высоту блока */
window.onload = function() {
	if(changeIE6) {
		var docHeight = getPageHeight();
		//document.getElementById("forMainOverlay").style.height = docHeight + 'px';
	} 
}

function iecompattest() {
	return (document.compatMode && document.compatMode != "BackCompat") ? document.documentElement : document.body;
}

/* Отображение блока */
function showForMain(height, width) {
	var text = "";
	width += 4;
	notify = document.getElementById("divForMain");
	if(notify != null) {
		var YOffset = document.all ? iecompattest().scrollTop : pageYOffset;
		sw = Math.floor(iecompattest().clientWidth/2) - Math.floor(width/2);
		//document.getElementById("forMain").id = "forMainOverlay";
		if(detectIE6()) {
			//var divOver = document.getElementById("forMainOverlay");
			//divOver.style.position = 'absolute';
			changeIE6 = true;
		}
		notify.className = "";
		notify.style.left = sw + "px";
		notify.style.height = height + "px";
		notify.style.width = width + "px";
		notify.style.display = "block";
		sh = Math.floor(iecompattest().clientHeight/2) - Math.floor(height/2) + YOffset;
		notify.style.top = sh + "px";
	}
}
/* Закрывание блока */
function closeForMain() {
	document.getElementById("divForMain").style.display = "none";
//	document.getElementById("forMainOverlay").id = "forMain";
}
/* Определение высоты страницы */
function  getPageHeight(){
	var yScroll;

	if (window.innerHeight && window.scrollMaxY) {
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		yScroll = document.body.scrollHeight;
	} else if (document.documentElement && document.documentElement.scrollHeight > document.documentElement.offsetHeight){ // Explorer 6 strict mode
		yScroll = document.documentElement.scrollHeight;
	} else { // Explorer Mac...would also work in Mozilla and Safari
		yScroll = document.body.offsetHeight;
	}

	var windowWidth, windowHeight;
	if (self.innerHeight) { // all except Explorer
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowHeight = document.body.clientHeight;
	}

	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else {
		pageHeight = yScroll;
	}

	return pageHeight;
}

function detectIE6(){
	var browser = navigator.appName;
	var b_version = navigator.appVersion;
	var version = parseFloat(b_version);
	if ((browser == "Microsoft Internet Explorer") && (version <= 6)){
		return true;
	}else{
		return false;
	}
}
// Дерево разделов и товаров - скрытие и раскрытие
function changeTreeVisible(id, hide, switcher, prefix) {
	var block = document.getElementById(id) || false;
	if (!block) return;
	if (!block.style.display) block.style.display = (hide == 1) ? "block" : "none";
	if("none" == block.style.display) {
		block.style.display = "block";
		switcher.innerHTML = "<img src=\""+prefix+"img/minus.gif\" width=\"9\" height=\"9\" alt=\"\"/>";
	} else {
		block.style.display = "none";
		switcher.innerHTML = "<img src=\""+prefix+"img/plus.gif\" width=\"9\" height=\"9\" alt=\"\"/>";
	}
}


