
var x, y;
var step = 10;
var flag = 0;

var message = "Êóïè ñåáå æèðàôà!! ";
message = message.split("");
var xpos = new Array();
for (i = 0; i <= message.length - 1; i++) {
xpos[i] = -50;
}
var ypos = new Array();
for (i = 0; i <= message.length - 1; i++) {
ypos[i]= -50;
}
function handlerMM(e) {
x = (document.layers) ? e.pageX : document.body.scrollLeft + event.clientX;
y = (document.layers) ? e.pageY : document.body.scrollTop + event.clientY;
flag = 1;
}
function makesnake() {
if (flag == 1 && document.all) {
for (i = message.length - 1; i >= 1; i--) {
xpos[i] = xpos[i - 1] + step;
ypos[i] = ypos[i - 1];
}
xpos[0] = x + step;
ypos[0] = y;
for (i = 0; i < message.length - 1; i++) {
var thisspan = eval("span" + (i) + ".style");
thisspan.posLeft = xpos[i];
thisspan.posTop = ypos[i];
   }
}
else if (flag==1 && document.layers) {
for (i = message.length - 1; i >= 1; i--) {
xpos[i] = xpos[i - 1] + step;
ypos[i] = ypos[i - 1];
}
xpos[0] = x + step;
ypos[0] = y;
for (i = 0; i < message.length - 1; i++) {
var thisspan = eval("document.span" + i);
thisspan.left = xpos[i];
thisspan.top = ypos[i];
   }
}
var timer = setTimeout("makesnake()", 0);
}

function show_mid(layer)
	{
		var l = document.getElementById(layer);

		if(l.style.visibility != 'visible'){
			
			try {
				l.style.visibility = "visible";
			} catch(e){
			}
			
			try {
				l.style.display = "block";
			} catch(e){
			}
					return true;
		}else{
			try {
				l.style.display = "none";
			} catch(e){
			}
			try {
				l.style.visibility = "hidden";
			} catch(e){
			}
			return true;
			
		}	
	}


var newWindow;
function makeNewWindow(title, img_path) {
    if (!newWindow || newWindow.closed) {
        newWindow = window.open("","sub","resizable,status,height=800,width=800");
        writeToWindow(title, img_path);
    } else if (newWindow.focus) {
		newWindow.close();
		writeToWindow(title, img_path);
        newWindow.focus( );
    }
}
function writeToWindow(new_title, img_path) {
    var newContent = "<html><head><title>"+new_title+"</title></head>";
	newContent += "<LINK rel=stylesheet href=/style.css>";
    newContent += "<body><a href=\"#\" OnClick=\"window.close()\"><img src=\""+img_path+"\"</img><br>";
	newContent += "<center><a href=\"#\" OnClick=\"window.close()\">Çàêðûòü Îêíî</a></center>";
    newContent += "</body></html>";
    newWindow.document.write(newContent);
    newWindow.document.close();
}
function makeNewWindow1(title, img_path, width, height) {
    if (!newWindow || newWindow.closed) {
        newWindow = window.open("","sub","resizable,status,height="+height+",width="+width+",scrollbars=yes");
        writeToWindow1(title, img_path, width, height);
    } else if (newWindow.focus) {
		newWindow.close();
        newWindow = window.open("","sub","resizable,status,height="+height+",width="+width+",scrollbars=yes");
		writeToWindow1(title, img_path, width, height);
        newWindow.focus( );
    }
}

function writeToWindow1(new_title, img_path, width, height) {
	width = width-50;
	height = height-50;
    var newContent = "<html><head><title>"+new_title+"</title></head>";
	newContent += "<LINK rel=stylesheet href=/style.css>";
    newContent += "<body><center><a href=\"#\" OnClick=\"window.close()\"><br /><img width="+width+" heigth="+height+" src=\""+img_path+"\" border=0 alt=\"Çàêðûòü îêíî\" /><br /><br />";
	newContent += "<a href=\"#\" OnClick=\"window.close()\">Çàêðûòü Îêíî</a></center>";
    newContent += "</body></html>";
    newWindow.document.write(newContent);
    newWindow.document.close();
}

function calc() {
var sum=0;
var m1=0;
var m2=0;
var m3=0;
var rashod=1;
var izm="";
var pl=0;

m1=document.getElementById("room_dl").value;
m2=document.getElementById("room_width").value;
m3=document.getElementById("room_height").value;

dv1=document.getElementById("dveri_kolvo").value;
dv2=document.getElementById("dveri_sh").value;
dv3=document.getElementById("dveri_vis").value;

ok1=document.getElementById("okna_kolvo").value;
ok2=document.getElementById("okna_sh").value;
ok3=document.getElementById("okna_vis").value;

pl=document.getElementById("ploshad_pokraski").value;

if (document.getElementById("tipkraski").selectedIndex==0) { rashod=0.1; izm="êã. ";}
if (document.getElementById("tipkraski").selectedIndex==1) { rashod=0.1; izm="ëèò.";}
if (document.getElementById("tipkraski").selectedIndex==2) { rashod=0.1; izm="ëèò.";}
if (document.getElementById("tipkraski").selectedIndex==3) { rashod=0.12;izm="êã.";}
if (document.getElementById("tipkraski").selectedIndex==4) { rashod=0.2; izm="êã.";}
if (document.getElementById("tipkraski").selectedIndex==5) { rashod=0.1; izm="ëèò.";}
if (document.getElementById("tipkraski").selectedIndex==6) { rashod=0.09; izm="ëèò.";}
if (document.getElementById("tipkraski").selectedIndex==7) { rashod=0.09; izm="ëèò.";}
if (document.getElementById("tipkraski").selectedIndex==8) { rashod=0.1; izm="êã.";}
if (document.getElementById("tipkraski").selectedIndex==9) { rashod=0.12; izm="ëèò.";}
if (document.getElementById("tipkraski").selectedIndex==10) { rashod=0.2; izm="êã.";}
if (document.getElementById("tipkraski").selectedIndex==11) { rashod=0.15; izm="êã.";}
if (document.getElementById("tipkraski").selectedIndex==12) { rashod=0.11; izm="êã.";}
if (document.getElementById("tipkraski").selectedIndex==13) { rashod=0.1; izm="êã.";}
if (document.getElementById("tipkraski").selectedIndex==14) { rashod=0.5; izm="êã.";}
if (document.getElementById("tipkraski").selectedIndex==15) { rashod=1; izm="êã.";}
if (document.getElementById("tipkraski").selectedIndex==16) { rashod=0.3; izm="êã.";}
if (document.getElementById("tipkraski").selectedIndex==17) { rashod=0.12; izm="ëèò.";}
if (document.getElementById("tipkraski").selectedIndex==18) { rashod=0.5; izm="êã.";}
if (document.getElementById("tipkraski").selectedIndex==19) { rashod=0.5; izm="êã.";}
if (document.getElementById("tipkraski").selectedIndex==20) { rashod=0.15; izm="êã.";}
if (document.getElementById("tipkraski").selectedIndex==21) { rashod=0.15; izm="êã.";}

if (document.getElementById("rachetploshadi1").checked) 
	{ sum = ((m1*m3*2+m2*m3*2)-(dv1*dv2*dv3+ok1*ok2*ok3))*rashod; 
	document.getElementById("rachetploshadi2").checked=false;
	}

else if (document.getElementById("rachetploshadi2").checked) 
	{ sum = pl*rashod; 
	document.getElementById("rachetploshadi1").checked=false;
	}

 //document.getElementById("count1").value = parseInt(sum);

document.getElementById("count1").value = (sum);
document.getElementById("count2").value = (izm);
}
