<!--//--><![CDATA[//><!--
	jsHover = function() {
		var hEls = document.getElementById("menu1").getElementsByTagName("LI");
		for (var i=0, len=hEls.length; i<len; i++) {
			hEls[i].onmouseover=function() { this.className+=" over"; }
			hEls[i].onmouseout=function() { this.className=this.className.replace(" over", ""); }
		}
		var hEls1 = document.getElementById("menu2").getElementsByTagName("LI");
		for (i=0, len=hEls1.length; i<len; i++) {
			hEls1[i].onmouseover=function() { this.className+=" over"; }
			hEls1[i].onmouseout=function() { this.className=this.className.replace(" over", ""); }
		}
	}
	if (window.attachEvent && navigator.userAgent.indexOf("Opera")==-1) window.attachEvent("onload", jsHover);
//--><!]]>


function count() {

	s = window.document.calc.area.value; //площадь
	p = window.document.calc.parea.value; //периметр

	if ((p%2.5) > 0) { for_baget = p - (p%2.5) + 2.5; } else { for_baget = p; }
	if ((p%3) > 0) { for_lenta_color = p - (p%3) + 3; } else { for_lenta_color = p; }

	//alert('2.5 = ' + (p%2.5) + '\n 3 = ' + (p%3) + '\n baget=' + for_baget + '\n lenta=' + for_lenta_color);
	//alert('Багет=' + for_baget);

	// Расчет дополнительных услуг
	d = 0;
	d += window.document.calc.item_1.value*310; //Количество труб
	d += window.document.calc.item_2.value*310; //Люстра на крючке
	d += window.document.calc.item_3.value*630; //Люстра потолочного крепления
	d += window.document.calc.item_4.value*450; //Встроенный светильник
	d += window.document.calc.circle.value*347; //Криволинейный участок
	d += for_baget*80; //Багет

	////////////////////////////////////////////////////////////////////////////
	// фактура
	var facturecost = new Array();
	facturecost[0] = 0;
	facturecost[10] = Array(1294,843,566,531); // Матовый шелк белый
	facturecost[11] = Array(1363,912,774,669); // Матовый шелк цветной
	facturecost[12] = Array(1397,982,704,635); // Матовый гранулированный белый
	facturecost[13] = Array(1536,1051,808,774); // Матовый гранулированный цветной
	facturecost[14] = Array(1363,946,774,738); // Сатиновый белый
	facturecost[15] = Array(1536,1051,912,843); // Сатиновый цветной
	facturecost[16] = Array(1918,1189,1051,949); // Глянцевый белый
	facturecost[17] = Array(2021,1328,1085,982); // Глянцевый цветной
	facturecost[18] = Array(2236,1543,1300,1197); // Глянцевый премиум
	facturecost[19] = Array(2196,1847,1467,1328); // Металлик
	facturecost[20] = Array(2196,1847,1467,1328); // Имитационный

	num = 0;
	if(s < 5) num = 0;
	if(s >=  5 && s < 10) num = 1;
	if(s >=  10 && s < 20) num = 2;
	if(s >= 20) num = 3;
	f = facturecost[window.document.calc.type.value][num];

	////////////////////////////////////////////////////////////////////////////
	// Декоративная лента
	var lentacost = new Array();
	lentacost[0] = 0;
	lentacost[1] = p*80;
	lentacost[2] = for_lenta_color*400;
	n = lentacost[window.document.calc.lenta.value];

	////////////////////////////////////////////////////////////////////////////
	//кол-во углов
	var anglecost = new Array();
	anglecost[0] = 0;
	anglecost[0] = Array(0, 4, 95);
	anglecost[1] = Array(5, 15, 150);
	anglecost[2] = Array(16, 100, 220);
	for(i=0; i<anglecost.length; i++) {
		if(window.document.calc.angle.value >= anglecost[i][0] && window.document.calc.angle.value <= anglecost[i][1])
			a = window.document.calc.angle.value*anglecost[i][2];
	}

	//срок изготовления потолка
	t = window.document.calc.srok.value;

	//подсчет суммы
	//alert("S="+s+" * \n Фактура="+f+" + \n Лента="+n+" + \n Углы="+a+" + \n Другое="+d);
	//alert("Фактура="+(s*f)+"\n Лента="+n+"\n Углы="+a+"\n Другое="+d);
	puresumm = (s * f + n + a + d);
	timesumm = puresumm*(t/100);

	//вывод результата
	window.document.calc.result.value = (puresumm + timesumm);
}
function CheckField(val, def) {
	window.document.calc[val].value = window.document.calc[val].value.replace(/,/, '.');
	if(!(/^[.0-9]+$/.test(window.document.calc[val].value))) window.document.calc[val].value = def;
}
function CheckCalc() {
	var error_log = '';

	if (window.document.calc.contact.value == '')
		error_log += '- Не заполнено контактное лицо \n';
	if (window.document.calc.phone.value == '')
		error_log += '- Не заполнен телефон \n';
	if (window.document.calc.email.value == '')
		error_log += '- Не заполнен E-mail \n';
	if (!isValidEmail(window.document.calc.email.value))
		error_log += '- Неправильный формат E-mail \n';

	if (error_log != '') {
		alert(error_log);
		return false;
	} else
		return true;
}
function isValidEmail(emailAddress) {
    var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;  //"
    return re.test(emailAddress);
}

////////////////////////////////////////////////////////////////////////////////
// Animation
////////////////////////////////////////////////////////////////////////////////
var images = new Array();
var fl_int = new Array();
fl_int[1] = 100;
fl_int[2] = 100;
fl_int[3] = 100;
fl_int[4] = 100;
var images_stop = new Array();
images_stop[1] = false;
images_stop[2] = false;
images_stop[3] = false;
images_stop[4] = false;
var imgInt = 0;
var fl_stp = 5;
var timeId = null;
var timeLt = 50;
var timePause = 10000;

function CreateAnim(id) {
	var timeout = timeLt;

	if (fl_int[id] == 100) {
		timeout = timePause * Math.random();
		if (timeout < 2000) timeout = 2500;
	}
	document.getElementById('top_image_' + id).style.opacity = fl_int[id]/100;
	document.getElementById('top_image_' + id).style.filter = 'alpha(opacity=' + fl_int[id] + ')';

	if (fl_int[id] <= 0) {
		fl_int[id] = 100;
		if(imgInt > images.length-2 ){
			imgInt = 0;
		}else{
			imgInt++;
		}
		document.getElementById('top_image_' + id).src = images[imgInt][1];
		document.getElementById('top_ahref_' + id).href = images[imgInt][0];
	} else {
		fl_int[id] -= fl_stp;
	}

	if (!images_stop[id]) timeId = setTimeout("CreateAnim(" + id + ")", timeout);
}
function anim_onMouseOver(id) {
	images_stop[id] = true;
	fl_int[id] = 100;
	document.getElementById('top_image_' + id).style.opacity = fl_int[id]/100;
	document.getElementById('top_image_' + id).style.filter = 'alpha(opacity=' + fl_int[id] + ')';
}
function anim_onMouseOut(id) {
	images_stop[id] = false;
	CreateAnim(id);
}
function CreateAnimation() {

	setTimeout("CreateAnim(1)", 7000);
	setTimeout("CreateAnim(2)", 5000);
	setTimeout("CreateAnim(3)", 3000);
	setTimeout("CreateAnim(4)", 9000);

}
