
var col_tov = 0;

function clickbuy(id)
{
	document.all["buy"+id].innerHTML = "<table cellspacing='0' cellpadding='3' border='0'><tr><td colspan='3' class='a10blue' align='center'><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;В корзину</b></td></tr><tr><td><b>Кол-во</b></td><td align='center'><input id='buy_col"+id+"' class='buy_col' type='text' value=''></td><td><b>шт.</b></td></tr><tr><td colspan='3' align='center' onclick='clickbuyadd("+id+");'><img src='img/add.jpg' style='cursor:hand;'></td></tr></table>";
}

function clickbuyadd(id)
{
	if(Number(document.all["buy_col"+id].value))
	{
		document.getElementsByTagName('iframe')[0].contentWindow.add_prod(id, document.all["buyname"+id].value, document.all["buy_col"+id].value, document.all["zena"+id].value);
	}
	document.all["buy"+id].innerHTML = "<img src='img/buy.jpg' border='0' style='cursor:hand;' onclick='clickbuy("+id+");'><br>";
}

function colvo_change()
{
	var vsego = 0;
	for(i=1; i<=col_tov; i++)
	{
		if(Number(document.all["inp"+i].value))
		{
			inp = parseFloat(document.all["inp"+i].value); 
			zenaa = parseFloat(document.all["zena"+i].value);
		}
		else
		{
			document.all["inp"+i].value = document.all["stoimost"+i].value/document.all["zena"+i].value;
			inp = parseFloat(document.all["inp"+i].value); 
			zenaa = parseFloat(document.all["zena"+i].value);
		}
			stoimost = inp*zenaa;
			vsego = vsego + stoimost;
			document.all["stoimost"+i].value = stoimost;
			document.all["a_stoimost"+i].innerHTML = stoimost;
			document.all["vsego"].innerHTML = vsego;
	}
	document.all["buttt"].value = "Сохранить";
	document.all["buttt"].name = "save_korz";
}

function menu_but(but, fl)
{
	if(fl == 1)
	{
		document.all[but].style.background = '#F8EC38';
	}
	else if(fl == 0)
	{
		document.all[but].style.background = '#F9F4AA';
	}
}

function click_bot(url)
{
	location.href = url;
}

function ch_color(but, fl)
{
	if(fl == 1)
	{
		document.all[but].style.background = "#b76262";
	}
	else if(fl == 0)
	{
		document.all[but].style.background = "#666666";
	}
}

function chbg(div, col)
{
	document.all[div].style.background = col;
}

//************************************************************************************************************************************************************************

function getCookie_n(name)
{
	name += '=';
	with(document)
	{
		var beg = cookie.indexOf(name);
		if(beg == -1) return false;
		else beg += name.length;
		var end = cookie.indexOf(';', beg);
		if(end == -1) end = cookie.length;
		return unescape(cookie.substring(beg, end));
	}
}
var stc1 = getCookie_n('Components');

var stc2 = getCookie_n('Otrib');

function name_cookie(fl, zak)
{
	if(fl == "add")
	{
		if(fizliz == "ok")
		{
			document.cookie="Otrib=or=fa="+document.all['famil'].value+"na="+document.all['name'].value+"ot="+document.all['otchest'].value+"go="+document.all['gorod'].value+"ad="+document.all['adres'].value+"co="+document.all['conttelef'].value+"fak="+document.all['faks'].value+"em="+document.all['email'].value+"|; path=/; expires=Mon, 01-Jan-2012 00:00:00 GMT";
		}
		else
		{
			document.cookie="Otrib=or="+document.all['organiz'].value+"fa="+document.all['famil'].value+"na="+document.all['name'].value+"ot="+document.all['otchest'].value+"go="+document.all['gorod'].value+"ad="+document.all['adres'].value+"co="+document.all['conttelef'].value+"fak="+document.all['faks'].value+"em="+document.all['email'].value+"|; path=/; expires=Mon, 01-Jan-2012 00:00:00 GMT";
		}
	}
	else if(fl == "get")
	{
		var prov = "" + stc2;
		if(prov != "false")
		{
			if(zak == "ul")
			{
				document.all['organiz'].value = stc2.substring (stc2.indexOf("or=")+3, stc2.indexOf("fa="));
			}
			document.all['famil'].value = stc2.substring (stc2.indexOf("fa=")+3, stc2.indexOf("na="));
			document.all['name'].value = stc2.substring (stc2.indexOf("na=")+3, stc2.indexOf("ot="));
			document.all['otchest'].value = stc2.substring (stc2.indexOf("ot=")+3, stc2.indexOf("go="));
			document.all['gorod'].value = stc2.substring (stc2.indexOf("go=")+3, stc2.indexOf("ad="));
			document.all['adres'].value = stc2.substring (stc2.indexOf("ad=")+3, stc2.indexOf("co="));
			document.all['conttelef'].value = stc2.substring (stc2.indexOf("co=")+3, stc2.indexOf("fak="));
			document.all['faks'].value = stc2.substring (stc2.indexOf("fak=")+4, stc2.indexOf("em="));
			document.all['email'].value = stc2.substring (stc2.indexOf("em=")+3, stc2.indexOf("|"));
		}
	}
}

function tdscol(td, fl)
{
	if(fl == 1)
	{
		document.all[td + 'td1'].style.background = '#FF0000';
		document.all[td + 'td2'].style.background = '#FF0000';
		document.all[td + 'td3'].style.background = '#FF0000';
		document.all[td + 'td4'].style.background = '#FF0000';
		document.all['f' + td].style.color = '#000000';
	}
	else if(fl == 0)
	{
		document.all[td + 'td1'].style.background = '#66BB66';
		document.all[td + 'td2'].style.background = '#66BB66';
		document.all[td + 'td3'].style.background = '#66BB66';
		document.all[td + 'td4'].style.background = '#66BB66';
		document.all['f' + td].style.color = '#555555';
	}	
}

var flhid=0;
var light;
var lightpm;
var Inflsh;
var browser_name = navigator.appName;
var br = navigator.appVersion;
var browser_version = br.substr(br.indexOf('MSIE')+5, br.lastIndexOf(';')-br.indexOf('MSIE')-5);

function divshow(d)
{
	if(flhid == 2 || flhid == 3)
	{
		clearInterval(Inflsh);
	}
	else
	{
		flhid=1;
		object=d;
		clearInterval(light);
		document.all[object].style.visibility="visible";
		if (browser_name == "Microsoft Internet Explorer" && browser_version > 5.01)
		{
			//document.all[object].filters.alpha.opacity=0;
			document.all[object].filters.alpha.opacity=90;
			//light = setInterval("light_stat(object);",3);
		}
	}
}
function divsh()
{
	flhid=1;	
	clearInterval(Inflsh);
}
function shpm(d)
{
	divsh();
	divpm = "m1p" + d;
	document.all[divpm].style.visibility="visible";
}
function showpm(d)
{
	divpm = "m1p" + d;
	clearInterval(lightpm);
	document.all[divpm].style.visibility="visible";
	if (browser_name == "Microsoft Internet Explorer" && browser_version > 5.01)
	{
		//document.all[divpm].filters.alpha.opacity=0;
		document.all[divpm].filters.alpha.opacity=90;
		//lightpm = setInterval("lightpm_stat(divpm);",3);
	}
}
function divhide(d)
{
	flhid=2;
	which2 = d;
	clearInterval(Inflsh);
	Inflsh=setInterval("hide(which2);", 500);
}
function divhi(d)
{
	flhid = 3;
	which2 = d;
	clearInterval(Inflsh);
	Inflsh=setInterval("divhide(which2);", 500);
}
function hide(d)
{
	if(flhid == 2 || flhid == 3)
	{
		flhid = 0;
		theobject=d;
		clearInterval(Inflsh);
		document.all[theobject].style.visibility="hidden";
		menu_but('b4', '0');
	}
}
function hidepm(d)
{
	theobject="m1p" + d;
	document.all[theobject].style.visibility="hidden";
	divhi('m1');
}
function light_stat(cur2)
{
	if (document.all[cur2].filters.alpha.opacity<90)
	{
		document.all[cur2].filters.alpha.opacity+=3;
	}
	else if (window.light_stat)
	{
		clearInterval(light);
	}
}
function lightpm_stat(cur2)
{
	if (document.all[cur2].filters.alpha.opacity<90)
	{
		document.all[cur2].filters.alpha.opacity+=3;
	}
	else if (window.lightpm_stat)
	{
		clearInterval(lightpm);
	}
}
function count(f, count)
{
	if (browser_name == "Microsoft Internet Explorer" && browser_version > 5.01)
	{
		if(f == 1)
		{
			document.all[count].filters.alpha.opacity=100;
		}
		else if(f == 0)
		{
			document.all[count].filters.alpha.opacity=20;
		}
		else if(f == "all")
		{
			for(i=1; i<count+1; i++)
			{
				coun = "img" + i;
				document.all[coun].filters.alpha.opacity=20;
			}
		}
	}
}

function chdivimg (d, div)
{
	if (d == 1)
	{
		document.all[div].style.background = "#FFCC99";
	}
	else if (d == 0)
	{
		document.all[div].style.background = "";
	}
}

function sendmail ()
{
	window.open('mail.php', 'pic500xx500','width=503,height=330,copyhistory=0,directories=0,menubar=0,location=0,status=0,scrollbars=0,toolbar=0,borderstyle=0');
}

function sendmail_tochip ()
{
	window.open('mailto_chip.php', 'pic500xx500','width=503,height=330,copyhistory=0,directories=0,menubar=0,location=0,status=0,scrollbars=0,toolbar=0,borderstyle=0');
}

function zapros ()
{
	window.open('zapros.php', 'pic500xx500','width=503,height=360,copyhistory=0,directories=0,menubar=0,location=0,status=0,scrollbars=0,toolbar=0,borderstyle=0');
}
