//Первый параметр в пассиве - название материала, второй его цена
// ['Материал-1','10'],
function form(){

var a=[['Выберите','0'],
       ['Белая матовая','1'],
       ['Цветная матовая','2'],
       ['Сатиновая','3'],
       ['Лаковая LACKFOLIE','4'],
       ['Облака, металлик, звёзды, иллюзия воды','5'],
       ['DESCOR бесшовное полотно','6'],
       ['CLIPSO бесшовное полотно','8'],
       ['Художественная (Фотопечать) DESCOR','7']];  
// Прайс работ за штуку или кв.м:
var s='1'; //Площадь
var f='2'; //Фактура
var sv='430'; //Светильники
var l='350'; //Люстры
var v='430'; //Вентеляционные 
var t='200'; //Трубы


//   

var str='<div class="calc_div" > <form name="calcul" ><table border="0"><tr><td><b>Площадь:</b></td><td><input class="calcform" id="square" size="2"> (м. кв.)</td>';
str+='<tr><td><b>Фактура</b></td><td><select id="material" class="calcform">';
var temp='';
for (var i=0; i<a.length; i++){
    temp=a[i];str+='<option value="'+temp[1]+'">'+temp[0]+'</option>';
}
str+='</select></td></tr>';
str+='<tr><td><b>Кол-во углов</b></td><td><input class="calcform" id="ugli" size="2" value="4"> (шт.)</td></tr>'; 
str+='<tr><td><b>Светильники:</b></td><td><input class="calcform" id="lamp" size="2"> (шт.)</td></tr>';  
str+='<tr><td><b>Люстры:</b></td><td><input class="calcform" id="chandeliers" size="2"> (шт.)</td></tr>';
str+='<tr><td><b>Вентеляционные отверстия в потолке:</b></td><td><input class="calcform" id="ventilation" size="2"> (шт.)</td></tr>';
str+='<tr><td><b>Трубы</b></td><td><input class="calcform" id="pipe" size="2"> (шт.)</td></tr>'; 

str+='<tr><td valign="top" align="left"><input class="calcform" type="button" value="Подсчитать" onclick="calk('+s+','+f+','+sv+','+l+','+v+','+t+');"></td><td valign="top" align="left"><input class="calcform" type="button" value="Сброс" onclick="javascript:window.document.calcul.reset()"></td></tr></table></form><h3>Цена натяжного потолка в руб.: <span id="result"></h3></div>';  

str+='<div class="calc_div"><form name="send" action="send.php" method="post"><table border="0"><tr><td><b>ФИО:</b></td><td><input class="calcform" name="fio" size="30"></td></tr><tr><td><b>E-mail:</b></td><td><input class="calcform" name="mail" size="30"></td></tr><tr><td><b>Телефон:</b></td><td><input class="calcform" name="tel" size="30"></td></tr><tr><td><b>Комментарий:</b></td><td><textarea class="calcform" name="comment" rows="5" cols="30"></textarea><input type="hidden" id="zakaz" name="zakaz"></textarea></td></tr>';
str+='<tr><td valign="top" align="left"><input class="calcform" type="submit" value="Заказать потолок"></td><td valign="top" align="left"><input class="calcform" type="button" value="Сброс" onclick="javascript:window.document.send.reset()"></td></tr></table></form>';    
document.write(str); 
}
function calk(s,f,sv,l,v,t){//debugger;       

var square=document.getElementById('square').value;
var material=document.getElementById('material');
var ugli=document.getElementById('ugli');
var lamp=document.getElementById('lamp').value;
var chandeliers=document.getElementById('chandeliers').value;
var ventilation=document.getElementById('ventilation').value;
var pipe=document.getElementById('pipe').value;
//var price=parseInt(square * s)+parseInt(material.value*f)+parseInt(lamp*l)+parseInt(chandeliers*sv)+parseInt(ventilation*v)+parseInt(pipe*t);

var totalSquarePrice = 0; //итоговая цена за квадратуру - набирается с площади

if (material.value == '1'){
    if (square >=1) totalSquarePrice = 700 * square; 
    if (square >=5) totalSquarePrice = 630 * square;
    if (square >=11) totalSquarePrice = 580 * square;
    if (square >=16) totalSquarePrice = 540 * square;
    if (square >=21) totalSquarePrice = 480 * square;
    if (square >=31) totalSquarePrice = 430 * square;
    if (square >=51) totalSquarePrice = 380 * square;
}
else if (material.value == '2'){
    if (square >=1) totalSquarePrice = 700 * square; 
    if (square >=5) totalSquarePrice = 630 * square;
    if (square >=11) totalSquarePrice = 580 * square;
    if (square >=16) totalSquarePrice = 540 * square;
    if (square >=21) totalSquarePrice = 480 * square;
    if (square >=31) totalSquarePrice = 430 * square;
    if (square >=51) totalSquarePrice = 380 * square;
}
else if (material.value == '3'){
    if (square >=1) totalSquarePrice = 860 * square; 
    if (square >=5) totalSquarePrice = 810 * square;
    if (square >=11) totalSquarePrice = 780 * square;
    if (square >=16) totalSquarePrice = 740 * square;
    if (square >=21) totalSquarePrice = 700 * square;
    if (square >=31) totalSquarePrice = 660 * square;
    if (square >=51) totalSquarePrice = 600 * square;
}
else if (material.value == '4'){
    if (square >=1) totalSquarePrice = 950 * square; 
    if (square >=5) totalSquarePrice = 910 * square;
    if (square >=11) totalSquarePrice = 850 * square;
    if (square >=16) totalSquarePrice = 780 * square;
    if (square >=21) totalSquarePrice = 740 * square;
    if (square >=31) totalSquarePrice = 700 * square;
    if (square >=51) totalSquarePrice = 650* square;
}
else if (material.value == '5'){
    if (square >=1) totalSquarePrice = 1239 * square; 
    if (square >=5) totalSquarePrice = 1211 * square;
    if (square >=11) totalSquarePrice = 1182 * square;
    if (square >=16) totalSquarePrice = 1154 * square;
    if (square >=21) totalSquarePrice = 1125 * square;
    if (square >=31) totalSquarePrice = 1097 * square;
    if (square >=51) totalSquarePrice = 820 * square;
}
else if (material.value == '6'){  
    if (square >=1) totalSquarePrice = 1200 * square; 
    if (square >=5) totalSquarePrice = 1150 * square;
    if (square >=11) totalSquarePrice = 1050 * square;
    if (square >=16) totalSquarePrice = 1000 * square;
    if (square >=26) totalSquarePrice = 950 * square;
    if (square >=51) totalSquarePrice = 900 * square;
    if (square >=101) totalSquarePrice = 850 * square;
}
else if (material.value == '7'){
    if (square >=1) totalSquarePrice = 3100 * square; 
    if (square >=5) totalSquarePrice = 2850 * square;
    if (square >=11) totalSquarePrice = 2650 * square;
    if (square >=16) totalSquarePrice = 2550 * square;
    if (square >=26) totalSquarePrice = 2400 * square;
    if (square >=51) totalSquarePrice = 2350 * square;
    if (square >=101) totalSquarePrice = 2250 * square;
}
else if (material.value == '8'){
    if (square >=1) totalSquarePrice = 1600 * square; 
    if (square >=5) totalSquarePrice = 1570 * square;
    if (square >=11) totalSquarePrice = 1540 * square;
    if (square >=16) totalSquarePrice = 1510 * square;
    if (square >=26) totalSquarePrice = 1400 * square;
    if (square >=51) totalSquarePrice = 1350 * square;
    if (square >=101) totalSquarePrice = 1100 * square;
}
var ugliPrice = 0;
if (ugli.value > 4) ugliPrice = (ugli.value - 4) * 85;
var price = totalSquarePrice +
            parseInt(ugliPrice) +
            parseInt(lamp*l) + 
            parseInt(chandeliers*sv) + 
            parseInt(ventilation*v) + 
            parseInt(pipe*t);
document.getElementById('result').innerHTML=price;  
document.getElementById('zakaz').value='Площа: '+square+'\n\rФактура: '+material.options[material.selectedIndex].text+'<br>Светильники: '+lamp+'<br>Люстры: '+chandeliers+'<br>Вентеляционные отверстия: '+ventilation+'<br>Трубы: '+pipe+'<br>Предварительная стоимость работ='+price; 
var dd=1;//document.getElementById('result').innerHTML=document.forms.innerHTM;

//document.write(document.getElementById('calc').innerHTM);  
}        
