function WhereToBuyF(MF){
	//alert(MF.metro.options[MF.metro.selectedIndex].value);
	wwidth = 600;
	wheight = 500;
	wtop = (window.screen.height-wheight)/2;
	wleft =(window.screen.width-wwidth)/2;
	wname = "where";
	oppageurl = "/wheretobye.asp?pns="+MF.metro.options[MF.metro.selectedIndex].value;
	//oppageurl = "/popup_info.html";
	wind=window.open(oppageurl, wname, "location=no, menubar=no, scrollbars=yes, toolbar=no, status = no, resizable=no, directories=no, width="+wwidth+",left="+wleft+", height="+wheight+", top="+wtop);
	wind.focus();

	return false;
}

function WhereToBuy(pns){
	//alert(MF.metro.options[MF.metro.selectedIndex].value);
	wwidth = 300;
	wheight = 300;
	wtop = (window.screen.height-wheight)/2;
	wleft =(window.screen.width-wwidth)/2;
	wname = "where";
	oppageurl = "/wheretobye.asp?pns="+pns;
	//oppageurl = "/popup_info.html";
	wind=window.open(oppageurl, wname, "location=no, menubar=no, scrollbars=yes, toolbar=no, status = no, resizable=no, directories=no, width="+wwidth+",left="+wleft+", height="+wheight+", top="+wtop);
	wind.focus();

	return false;
}


function FlashResize(nsize){
	el = document.getElementById("flashmenu");
	//alert(el.height);
	el.height = nsize;
}

//Фильтр производителей
function ChBrand(MF, pn){
	brid = MF.brid.options[MF.brid.selectedIndex].value;
	//alert(brid + "|" + pn + "|");
	window.document.location = "?pn=" + pn + "&brid=" + brid;
	return false;
}

//проверка значения формы
function FormValidatorQuest(MF, Len100, Len1000)
	{	
	FIO = Trim(MF.FIO.value);
	Email = Trim(MF.Email.value);
	Question = Trim(MF.Question.value);
	
	if (FIO == "" || FIO.length > Len100)
		{
		alert("Поле \"Ваше имя\" не должно быть пустым. Длина поля не должна превышать " + Len100 + " символов.");
		MF.FIO.focus();
		return false;
		}
	if (checkmail(Email)!=2 || Trim(Email).length > Len100)
		{
		alert("Неправильно заполнено поле \"Ваш e-mail\".");
		MF.Email.focus();
		return false;
		}
	if (Question == "" || Question.length > Len1000){
		alert("Поле \"Ваш вопрос\" не должно быть пустым. Длина поля не должна превышать " + Len1000 + " символов.");
		MF.Question.focus();
		return false;
	}
	return true;
}

//Проверка формы аторизации
function FormValidatorLogin(MF, LenLogin, LenPass){
	login = Trim(MF.login.value);
	pass = Trim(MF.pass.value);
	if (login == "" || (login.length > LenLogin))
		{
		alert("Неправильно введен \"логин\"!\nПоле не должно быть пустым, длина поля не должна превышать " + LenLogin +" символов.");
		MF.login.focus();
		return false;
		}
	if (pass == "" || (pass.length > LenPass))
		{
		alert("Неправильно введен \"пароль\"!\nПоле не должно быть пустым, длина поля не должна превышать " + LenPass+ " символов.");
		MF.pass.focus();
		return false;
		}
	return true;
}

//проверка значения формы
function FormValidatorSendMess(MF, Len100)
	{	
	FIO = Trim(MF.FIO.value);
	Email = Trim(MF.Email.value);
	zapr = Trim(MF.zapr.value);
	
	if (FIO == "")
		{
		alert("Поле \"ФИО контактного лица\" не должно быть пустым.");
		MF.FIO.focus();
		return false;
		}
	if (checkmail(Email)!=2 || Trim(Email).length > Len100)
		{
		alert("Неправильно заполнено поле \"Электронный адрес\".");
		MF.Email.focus();
		return false;
		}
	if (zapr == "")
		{
		alert("Поле \"Вопросы, пожелания\" не должно быть пустым.");
		MF.zapr.focus();
		return false;
		}
	return true;
}

//проверка формы поиска
function FormValidatorSearch(MF)
	{
	if (Trim(MF.srch.value)=="")
		{
		alert("Введите строку для поиска.");
		MF.srch.focus();
		return false;
		}
	return true;
	}

//проверка формы поиска по каталогу
function FormValidatorSearchCat(MF)
	{
	if (Trim(MF.srctext.value)=="")
		{
		alert("Введите строку для поиска по каталогу.");
		MF.srctext.focus();
		return false;
		}
	return true;
	}

function selch(selind)
	{	
	document.forms['Srch'].istodb.value = "no";
	document.forms['Srch'].action = "/catalog.asp";
	document.forms['Srch'].submit();
	}

function selchS(selind)
	{	
	document.forms['Srch'].istodb.value = "no";
	document.forms['Srch'].submit();
	}
	
//Картинка в отдельном окне
function ShPhoto(razd, pict, imgw, imgh)
	{
	wwidth = imgw;
	wheight = imgh;
	
	//if (parseInt(wwidth) < 200)
	//	wwidth = 200
	//if (parseInt(wheight) < 200)
	//	wheight = 200
	wtop = (window.screen.height-wheight)/2;
	wleft =(window.screen.width-wwidth)/2;
	if (wwidth < 100){
		leftM = parseInt((100 - wwidth)/2);
		rightM = parseInt((100 - wwidth)/2);
	}else{
		leftM = 0;
		rightM = 0;
	}
	if (wheight < 100){
		topM = parseInt((100 - wheight)/2);
		bottomM = parseInt((100 - wheight)/2);
	}else{
		topM = 0;
		bottomM = 0;
	}
	wname = "Pict";
	oppageurl = "/shPhoto.asp?razd="+razd+"&pict="+pict + "&leftM=" + leftM + "&rightM=" + rightM  + "&topM=" + topM + "&bottomM=" + bottomM;
	//oppageurl = "/popup_info.html";
	wind=window.open(oppageurl, wname, "location=no, menubar=no, scrollbars=no, toolbar=no, status = no, resizable=no, directories=no, width="+wwidth+",left="+wleft+", height="+wheight+", top="+wtop);
	wind.focus();
}

//Картинка в отдельном окне
function ChPhoto(pict, imgw, imgh){
	try{
		el = document.getElementById("galocolor");
		//alert(el.src);
		el.src = escape(pict);
		if (imgw!=0 && imgh!=0){
			el.width = imgw;
			el.height = imgh;
		}
		/*else{
			el.width = "";
			el.height = "";
		}*/
		
	}
	catch(e){}
}

//Картинка в отдельном окне
function ShPhotoS(razd, pict, imgw, imgh)
	{
	wwidth = imgw;
	wheight = imgh;
	//if (parseInt(wwidth) < 200)
	//	wwidth = 200
	//if (parseInt(wheight) < 200)
	//	wheight = 200
	wtop = (window.screen.height-wheight)/2;
	wleft =(window.screen.width-wwidth)/2;
	if (wwidth < 100){
		leftM = parseInt((100 - wwidth)/2);
		rightM = parseInt((100 - wwidth)/2);
	}else{
		leftM = 0;
		rightM = 0;
	}
	if (wheight < 100){
		topM = parseInt((100 - wheight)/2);
		bottomM = parseInt((100 - wheight)/2);
	}else{
		topM = 0;
		bottomM = 0;
	}
	wname = "Pict";
	oppageurl = "/shPhotoS.asp?razd="+razd+"&pict="+pict + "&leftM=" + leftM + "&rightM=" + rightM  + "&topM=" + topM + "&bottomM=" + bottomM;
	//oppageurl = "/popup_info.html";
	wind=window.open(oppageurl, wname, "location=no, menubar=no, scrollbars=no, toolbar=no, status = no, resizable=no, directories=no, width="+wwidth+",left="+wleft+", height="+wheight+", top="+wtop);
	wind.focus();
}

//Картинка в отдельном окне
function ShPhotoG(razd, pict, imgw, imgh)
	{
	wwidth = imgw;
	wheight = imgh;
	//if (parseInt(wwidth) < 200)
	//	wwidth = 200
	//if (parseInt(wheight) < 200)
	//	wheight = 200
	wtop = (window.screen.height-wheight)/2;
	wleft =(window.screen.width-wwidth)/2;
	if (wwidth < 100){
		leftM = parseInt((100 - wwidth)/2);
		rightM = parseInt((100 - wwidth)/2);
	}else{
		leftM = 0;
		rightM = 0;
	}
	if (wheight < 100){
		topM = parseInt((100 - wheight)/2);
		bottomM = parseInt((100 - wheight)/2);
	}else{
		topM = 0;
		bottomM = 0;
	}
	wname = "Pict";
	oppageurl = "/shPhotog.asp?razd="+razd+"&pict="+pict + "&leftM=" + leftM + "&rightM=" + rightM  + "&topM=" + topM + "&bottomM=" + bottomM;
	//oppageurl = "/popup_info.html";
	wind=window.open(oppageurl, wname, "location=no, menubar=no, scrollbars=no, toolbar=no, status = no, resizable=no, directories=no, width="+wwidth+",left="+wleft+", height="+wheight+", top="+wtop);
	wind.focus();
}

//обработка submit формы поиска
function actionSearch(fname, Len100)
{
	if (fname == "Search"){
		if(FormValidatorSearch(document.forms[fname])){document.forms[fname].submit();}
	}else if (fname == "SendMess"){
		if(FormValidatorSendMess(document.forms[fname], Len100)){document.forms[fname].submit();}
	}else if (fname == "SearchCat"){
		if(FormValidatorSearchCat(document.forms[fname])){document.forms[fname].submit();}
	}
}

//добавление товаров в корзину пользователя
function AddToBasket(cid, sbtid)
	{
	window.location = "/content.asp?cid=" + cid + "&sbtid=" + sbtid + "&gnum=1&red=1&basket";
	//eval("numg = document.getElementById(\"numg" + sbtid + "\").value");
	//wwidth = 775;
	//wheight = 600;
	//wtop = (window.screen.height-wheight)/2;
	//wleft = (window.screen.width-wwidth)/2;
	//wname = "addtob";//+sbtid;
	//oppageurl = "/addtobasket.asp?cid=" + cid + "&sbtid=" + sbtid + "&gnum=" + numg;
	//wind=window.open(oppageurl, wname, "location=no, menubar=no, scrollbars=yes, toolbar=no, directories=no, width="+wwidth+",left="+wleft+", height="+wheight+", top="+wtop);
	//window.document.location.reload();
	//wind.focus();
	}

//проверка значения формы
function FormValidatorSendBasket(MF, Len100)
	{	
	FIO = Trim(MF.FIO.value);
	Email = Trim(MF.Email.value);
	phone = Trim(MF.phone.value);
	org = Trim(MF.org.value);
	//zapr = Trim(MF.zapr.value);
	
	if (FIO == "")
		{
		alert("Поле \"Контактное лицо\" не должно быть пустым.");
		MF.FIO.focus();
		return false;
		}
	if (org == "")
		{
		alert("Поле \"Организация\" не должно быть пустым.");
		MF.org.focus();
		return false;
		}
	if (phone == "")
		{
		alert("Поле \"Контактный телефон\" не должно быть пустым.");
		MF.phone.focus();
		return false;
		}
	if (checkmail(Email)!=2 || Trim(Email).length > Len100)
		{
		alert("Неправильно заполнено поле \"Email\".");
		MF.Email.focus();
		return false;
		}
	/*if (zapr == "")
		{
		alert("Поле \"Вопросы, пожелания\" не должно быть пустым.");
		MF.zapr.focus();
		return false;
		}*/
	MF.FIO.disabled=false;
	return true;
}
	
//пересчет в корзине
function relcook()
	{
	document.forms['price'].action='basket.asp';
	document.forms['price'].submit();
	}

//проверка формы в корзине
function FormValidatorBasket(MainForm,hide)
	{
	totsff=document.forms['price'].TotalSum;
	tots=parseInt(totsff.value);
	totsn=0;
	for (i=0; i<MainForm.elements.length;i++)
		{
		if ((MainForm.elements[i].type=="text" || MainForm.elements[i].type=="hidden") && MainForm.elements[i].name.indexOf("cost")>-1)
			{
			begp = MainForm.elements[i].name.indexOf("price")+5;
			endp = MainForm.elements[i].name.length;
			numbstr = MainForm.elements[i].name.substring(begp, endp);
			chvalue('numg'+numbstr);
			eval("newp = document.forms['price'].cost"+numbstr+".value*document.forms['price'].numg"+numbstr+".value;");
			totsn = totsn + newp;
			}
		}
	totsff.value=totsn;
	if (!hide) document.all.sumT.innerText=totsn;

	if (parseInt(MainForm.TotalSum.value)==0)
		{
		alert("Выберите хотя бы один товар.");
		return false;
		}
	}

//изменение значения в поле количество в корзине
function chvalue(ffname, url, hide)
	{
	eval("ff=document.forms['price']."+ffname);
	pr = Trim(ff.value);
	if (isNaN(pr) || pr=="" || pr!=parseInt(pr))
		{
		alert("Количество - целый параметр!");
		ff.value = document.getElementById("prev"+ffname).value;
		return;
		}

	totsff=document.forms['price'].TotalSum;
	tots=parseInt(totsff.value);
	totsn=0;
	for (i=0; i<document.forms['price'].elements.length;i++)
		{
		if ((document.forms['price'].elements[i].type=="text" || document.forms['price'].elements[i].type=="hidden") && document.forms['price'].elements[i].name.indexOf("cost")>-1)
			{
			begp = document.forms['price'].elements[i].name.indexOf("price")+5;
			endp = document.forms['price'].elements[i].name.length;
			numbstr = document.forms['price'].elements[i].name.substring(begp, endp);
			eval("newp = document.forms['price'].cost"+numbstr+".value*document.forms['price'].numg"+numbstr+".value;");
			if (!hide) eval("document.all.sum"+numbstr+".innerText=newp + ' руб.';");
			totsn = totsn + newp;
			}
		}
	totsff.value=totsn;
	//eval("document.all.sumT.innerText=totsn" + " 'руб.';");
	if (!hide) document.all.sumT.innerText=totsn;
	document.forms['price'].action=url;
	document.forms['price'].submit();
	//document.all.totsum.innerText = totsn + ' руб.';
	}