window.onload=init;

function init() {
	startList();
}


function startList() {
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("menu_fall");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" over";
				}
				node.onmouseout=function() {
					this.className=this.className.replace(" over", "");
				}
			}
		}
	}
}


function doDiv(id) {
	var obj, oimg;

	if (!(obj = document.getElementById('his_div_'+id))) return;
	if (!(oimg = document.getElementById('i_'+id))) return;
	
	if (!obj) {
		oimg.src = gc_path+"../images/minus.gif";
		return;
	}
	
	if (obj.style.display == 'block') {
		obj.style.display = 'none';
		oimg.src = gc_path+"../images/plus.gif";
	} else {
		obj.style.display = 'block';
		oimg.src = gc_path+"../images/minus.gif";
	}
}



function checkSearchField(obj) {
	var elem;
	if (obj.value == 'num') {
		if ((elem = document.getElementById('num_search'))) elem.style.display='block';
		if ((elem = document.getElementById('reg_search'))) elem.style.display='none';
		if ((elem = document.getElementById('search_query'))) elem.value='';
	} else {
		if ((elem = document.getElementById('num_search'))) elem.style.display='none';
		if ((elem = document.getElementById('reg_search'))) elem.style.display='block';
		if ((elem = document.getElementById('search_from'))) elem.value='';
		if ((elem = document.getElementById('search_to'))) elem.value='';
	}
}


function openNew(obj, width, height, titul) {
	var newwin = window.open('../images/spacer.gif', 'Information', 'toolbar=0,status=0,menubar=0,scrollbars=0,resizable=1,width=' + width + ',height=' + height);
	newwin.document.open();
	newwin.document.write('<html><head><title>'+ titul + '</title></head>');
 	newwin.document.write('<body style="margin-left:0; margin-right:0; margin-top:0; margin-bottom:0;padding-top:0; padding-left:0; padding-right:0; padding-bottom:0;"><a href="javascript:void(0)" onClick="window.close()"><img src="' + obj + '" border="0" alt="Скрыть"/></a></body></html>');
 	newwin.document.close();
	newwin.focus();
}

function eCheckFloat(sn){		
    var regexp = eval("/" + "," + "/gi");
    sn.value = sn.value.replace(regexp, ".");    
    s = sn.value;    
    for (var i = 0; i < s.length; i++) {
        ch = s.substring(i, i + 1)

        if (!((ch >= "0" && ch <= "9") || ch=="." || ch=="-"))
             return false;
        }
   tmp = parseFloat(s);
   if (tmp > 0)
   return true;
   else return false;		
} 

function getResult()
{
	var Qn = new Array("160", "150", "150", "130", "130");
	var Q;
	var Sh;
	var Gl;
	var Tm;
	var Result;

	if (!eCheckFloat(document.getElementById("SH")))
	{
		alert("Неверно указана ширина помещения или указана ширина 0!");
		return false;
	}
	if (!eCheckFloat(document.getElementById("GL")))
	{
		alert("Неверно указана глубина помещения или указана глубина 0!");
		return false;
	}
	Sh = parseFloat(document.getElementById("SH").value);
	Gl = parseFloat(document.getElementById("GL").value);	
	v_x1 = parseFloat(document.getElementById("x1").value);
	v_x2 = parseFloat(document.getElementById("x2").value);
	v_x3 = parseFloat(document.getElementById("x3").value);
	v_x4 = parseFloat(document.getElementById("x4").value);
	v_x5 = parseFloat(document.getElementById("x5").value);
	v_x6 = parseFloat(document.getElementById("x6").value);
	v_x7 = parseFloat(document.getElementById("x7").value);
	Tm = v_x1*v_x2*v_x3*v_x4*v_x5*v_x6*v_x7*Sh*Gl*100;
	document.getElementById("NUM_SKR").value = Math.round(Tm);
	for (i = 0; i < Qn.length; i++)
	{
	Result = Tm / Qn[i]	;
	NumSec = Math.round(Result);
	if (NumSec < 1) NumSec = 1;
	document.getElementById("NUM_S"+i).value = NumSec;
	}
	
}

