function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function showmenu(obj_id) {
  if (document.getElementById(obj_id).className == "hidden") {
  document.getElementById(obj_id).className = "shown";
  } else {
  document.getElementById(obj_id).className = "hidden";
    }

  
}
var timer = null;
function hidemenu() {
  timer = window.setTimeout(hidemenu2, 100);
}
function hidemenu2() {

  document.getElementById('menu1').className = "hidden";
    } 
  


function menu2_over(obj){
	try {
		document.getElementById(obj.id+"_img").src = "img/"+obj.id+"a.gif";
		
	} catch(E) {
	 //alert(E.message||E.description);
  }
  //obj.className = "menu2over";
   window.clearTimeout(timer);
}
function menu2_out(obj){
  //obj.className = "";
  try {
  	document.getElementById(obj.id+"_img").src = "img/"+obj.id+".gif";
  } catch(E) {
	}

}

var CeilingPrice = new Array();
LustrePrice = new Array();
var cornerPrice, tubePrice, lightPrice;

function clearCeiling() {
  document.getElementById('ceiling_plenka').selectedIndex = 0;
  document.getElementById('ceiling_area').value = "";
  document.getElementById('ceiling_corners').value = "";
  document.getElementById('ceiling_lustreq').value = "";
  document.getElementById('ceiling_lustretype').selectedIndex = 0;
  document.getElementById('ceiling_tubes').value = "";
  document.getElementById('ceiling_lignts').value = "";
  document.getElementById('ceiling_result').innerHTML = "&nbsp;";
  
}
function calcCeiling() {
	plenka = parseInt(document.getElementById('ceiling_plenka').value);
	if (isNaN(plenka) || (plenka <0) || (plenka > CeilingPrice.length)) {
    alert("Не задан тип пленки");
    return false;
  }
  area = parseFloat(document.getElementById('ceiling_area').value);
	if (isNaN(area) || (area <0)) {
    alert("Пожалуйста, укажите площадь помещений");
    return false;
  }
  if (area < 10) {
    result = CeilingPrice[plenka].price1*area;
  } else {
    result = CeilingPrice[plenka].price2*area;
  }
 
  corners = parseInt(document.getElementById('ceiling_corners').value);
  if (!isNaN(corners) && (corners > 0)) {
    result += corners*cornerPrice;
  }
  lustres = parseInt(document.getElementById('ceiling_lustreq').value);
  lustrestype = parseInt(document.getElementById('ceiling_lustretype').value);
  
  if (!isNaN(lustres) && (lustres > 0)) {
    if (isNaN(lustrestype) || (lustrestype <0) || (lustrestype > LustrePrice.length)) {
      alert("Не задан тип люстры. Расчет произведен без учета стоимости люстр.")
    } else {
      result += lustres*LustrePrice[lustrestype];
    }
  }
  tubes = parseInt(document.getElementById('ceiling_tubes').value);
  if (!isNaN(tubes) && (tubes > 0)) {
    result += tubes*tubePrice;
  }
  lignts = parseInt(document.getElementById('ceiling_lignts').value);
  if (!isNaN(lignts) && (lignts > 0)) {
    result += lignts*lightPrice;
  }
  if (!isNaN (result)) {
  //  alert(result);
    document.getElementById('ceiling_result').innerHTML = "Стоимость= "+result+" р.";
  } else {
    alert("При расчете стоимости произошла ошибка. Введите корректные данные.");

  }

}