function flash(link, w, h){
	document.write("<object data=\"" + link + "\" type=\"application/x-shockwave-flash\" style=\"width: " + w + "; height: " + h + "; display: block;\"><param name=\"movie\" value=\"" + link + "\" /></object>");
}
function lTrim(str)
{
	var tstr = str;
	while(tstr.length>0 && (tstr.indexOf(" ")==0 || tstr.indexOf("\t")==0)) tstr = tstr.substring(1,tstr.length);
	return tstr;
}
function rTrim(str)
{
	var tstr = str;
	while((tstr.lastIndexOf(" ")==tstr.length-1 || tstr.lastIndexOf("\t")==tstr.length-1)&& tstr.length>0) tstr = tstr.substring(0,tstr.length-1);
	return tstr;
}
function Trim(str)
{
	return lTrim(rTrim(str));
}
function checkSymbols(word, chfl)
	{
	if (chfl==1)
		{
		re = /^[a-zA-Z0-9]+$/;//проверяем на тоже, но без подчеркивания
		}
	else if(chfl==2)
		{
		re = /^[\w]+$/;//проверяем на латинские буквы, цифры и подчеркивание
		}
	result = re.test(word);
	if (result)
		{
		return (true);
		}
	else
		{
		return (false);
		}
	}
function checkNumber(word)
	{
	re = /^[0-9]{1,10}$/;//проверяем только на цифры
	result = re.test(word);
	if (result)
		{
		return (true);
		}
	else
		{
		return (false);
		}
	}	
function checkFloat(word, r, f, s)
{	
	if ( (typeof(r) != "number") || r == 0 || r > 38){r = 38}
	if ( (typeof(f) != "number") || f == 0 || f > 38){f = 38}
	if ( (typeof(s) != "number") || s == 0 || s > 38){s = 38}
	re=/ /g;
	new_word = word.replace(re,"");
	if (new_word==""){
		return (true);
	}
	else
	{
		re=/,/g;
		new_word = word.replace(re,".");
		pos = new_word.indexOf(".");
		if (pos == -1){
			//re = /^[0-9]{1,r}$/;//проверка на числа
			var re = new RegExp("^[0-9]{1," + r + "}$","ig");
			
			result = re.test(new_word);
			if (result)
			{
				return (true);
			}
			else
			{
				return (false);
			}
		}else{
			strS = new_word.substring(0,pos);
			strF = new_word.substring(pos+1,new_word.length);
			//reS = /^[0-9]{1,1}$/;//проверка на числа
			var reS = new RegExp("^[0-9]{1," + r + "}$","ig");
			//reF = /^[0-9]{1,f}$/;//проверка на числа
			var reF = new RegExp("^[0-9]{1," + f + "}$","ig");
			resultS = reS.test(strS);
			resultF = reF.test(strF);
			if (resultS && resultF && (strS.length + strF.length <= s) ){
				return (true);
			}
			else
			{
				return (false);
			}
			
		}
	}
}
function checkmail(mailString)
	{
		// Возвращает 0 - если пустое, 1 - если неправильно заполнено, 2 - если правильно
		if(mailString!="")
		{
			re = /([\.\-_@][\.\-_@])|(^[\.])|(^[\-])|(^[\@])/;
			result = re.test(mailString);
			if(!result)		
			{
				re = /^[\w\-\.]+@[\w\-\.]+\.[a-zA-Z]{2,4}$/
				result = re.test(mailString);
				if(!result)
					return  1;
				return 2;	
			}
			return 1;
		}
		return 0;
	}
	
	
month_numbDay=new Array(); month_numbDay[1]=31;month_numbDay[2]=28;month_numbDay[3]=31;month_numbDay[4]=30;month_numbDay[5]=31; month_numbDay[6]=30;month_numbDay[7]=31;month_numbDay[8]=31;month_numbDay[9]=30;month_numbDay[10]=31;month_numbDay[11]=30;
month_numbDay[12]=31;
function DayToMonth(dayn, monthn, yearn, fname)
	{
    flag1=true;
    flag2=true;
    day = eval ("document.forms['" + fname + "']."+dayn);
    month = eval ("document.forms['" + fname + "']."+monthn);
	year = eval ("document.forms['" + fname + "']."+yearn);
	year=parseInt(year.options[year.selectedIndex].value);
	if (year % 400==0)
		{
		month_numbDay[2]=29;
		}
	else if ((year % 4==0) && (year % 100!=0))
		{
		month_numbDay[2]=29;
		}
	else
		{
		month_numbDay[2]=28;
		}
    while(flag1)
		{
        if(day.options[day.options.length-1].value<month_numbDay[month.options[month.selectedIndex].value])
			{
            op=new Option();
            op.text=parseInt(day.options[day.options.length-1].value)+1;
            op.value=op.text;
            day.options[day.options.length]=op;
        	}
		else
			{
            flag1=false;
        	}
    	}
    while(flag2)
		{
        if(day.options[day.options.length-1].value>month_numbDay[month.options[month.selectedIndex].value])
			{
            if (day.selectedIndex==day.options.length-1)
				{
                day.selectedIndex=day.options.length-2;
            	}
            day.options[day.options.length-1]=null;
        	}
		else
			{
            flag2=false;
        	}
    	}
	}//преобразование месца сделали
function NumField()
	{
	var key =event.keyCode;
	var obj = event.srcElement;//поле формы
	//key=45-тире
	//key=46-точка
	//key=44-запятая
	//цифры-48-57
	//запятую заменяем на точку
	if(obj.value.length==0 && key==45);//типа проверяем на минус в начале
	else if((!(key>47 && key<58)) && key!=46 && key!=44 && key!=13)//проверяем на циферки
	{
		event.cancelBubble=true;
		event.returnValue = false;
		alert("Некорректный символ.");
	}
	//нужно проверить на точку(и ее единственность)
	else if ((key==46 || key==44) && obj.value.indexOf(".")>-1)
		{
		event.cancelBubble=true;
		event.returnValue = false;
		alert("Некорректный символ.Точка должна присутствовать один раз");
		}
	else if (key==44)
		{
		event.cancelBubble=false;
		event.keyCode=46
		event.returnValue = true;
		}
	}
function PasteToNumField()
	{
	var obj = event.srcElement;//данные в поле формы
	event.returnValue = false;//отменяем действие
	var oTR = document.selection.createRange();
	var str = window.clipboardData.getData("Text");
	var oldv = obj.value;
	//заменим запятую на точку
	while(str.indexOf(",")>-1)
		{
		str=str.substring(0,str.indexOf(","))+"." + str.substring(str.indexOf(",")+1, str.length);
		}
	if(!isNaN(str))
		{
		oTR.text = str;//вставляем текст в поле
		//теперь нужно проверить, чтобы в полях не появилось несколько точек
		newv=obj.value;//новое значение
		if (newv.indexOf(".")!=newv.lastIndexOf("."))
			{
			alert("Некорректное значение!");
			obj.value=oldv;
			}
		}
	else
		{
		alert("Некорректное значение!");
		}
	}
function BeforePasteToNumField()
	{
	event.returnValue = false;
	}

function loadfileW(pict)
	{
	window.document.location = "/testLinkForm.asp?loadfile=1&sourcelf="+pict
	}	

//Картинка в отдельном окне
function showim(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 = "/showim.asp?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 showimPage(group, imgw, imgh)
	{
	wwidth = imgw;
	wheight = imgh;
	//wheight = parseInt(wheight) + 50;
	//alert(wheight);
	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 = 5;
		rightM = 5;
	}
	if (wheight < 100){
		topM = parseInt((100 - wheight)/2);
		bottomM = parseInt((100 - wheight)/2);
	}else{
		topM = 5;
		bottomM = 5;
	}
	wwidth = parseInt(wwidth)+100;
	wheight = parseInt(wheight) + 100;
	
	wname = "GroupPict";
	oppageurl = "/showimpage.asp?gr="+group + "&leftM=" + leftM + "&rightM=" + rightM  + "&topM=" + topM + "&bottomM=" + bottomM;
	wind=window.open(oppageurl, wname, "location=no, menubar=no, scrollbars=no, toolbar=no, status = no, resizable=yes, directories=no, width="+wwidth+",left="+wleft+", height="+wheight+", top="+wtop);
	wind.focus();
	}

//открытие в новом окне укрупненного изображения товара
function ShPhoto(img, imgw, imgh)
	{
	wwidth = imgw;
	wheight = imgh;
	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;
	}
	//alert(topM);
	wname = "shp_"+imgh+"_"+imgw;
	oppageurl = "/shpict.asp?img=" + img + "&imgw=" + imgw + "&imgh=" + imgh + "&leftM=" + leftM + "&rightM=" + rightM  + "&topM=" + topM + "&bottomM=" + bottomM;
	wind=window.open(oppageurl, wname, "location=no, menubar=no, scrollbars=no, toolbar=no, status = no, directories=no, width="+wwidth+",left="+wleft+", height="+wheight+", top="+wtop);
	wind.focus();
	}
	
//ссылка на печатную версию
function prpage(parthref, cid, sbtid, arch, cpg)
	{
	wwidth = 775;
	wheight = 600;
	wtop = (window.screen.height-wheight)/2;
	wleft = (window.screen.width-wwidth)/2;
	wname = "prpage"+cid+"_"+sbtid;
	oppageurl = parthref + "?pn=" + cid +"&page=" + cpg + "&pns=" + sbtid + "&pr=1" + "&arch=" + arch;
	wind=window.open(oppageurl, wname, "scrollbars=yes, location=no, menubar=no, toolbar=no, status=no, resizable=yes, directories=no, width="+wwidth+",left="+wleft+", height="+wheight+", top="+wtop);
	wind.focus();
	}	

//ссылка на печатную версию
function prpage_cat(parthref, cid, gid, brid, arch)
	{
	wwidth = 775;
	wheight = 600;
	wtop = (window.screen.height-wheight)/2;
	wleft = (window.screen.width-wwidth)/2;
	wname = "prpage"+cid+"_"+brid;
	oppageurl = parthref + "?cid=" + cid + "&gid=" + gid + "&pr=1" + "&brid=" + brid + "&arch=" + arch;
	wind=window.open(oppageurl, wname, "scrollbars=yes, location=no, menubar=no, toolbar=no, status=no, resizable=no, directories=no, width="+wwidth+",left="+wleft+", height="+wheight+", top="+wtop);
	wind.focus();
	}

//функция сворачивания/разворачивания дерева
function clickMenu(id, Sid)
{
	TgtName = "submenuitems-" + id;
	if (document.getElementById) { 
		Target = document.getElementById(TgtName);
		if (Target == null) return;
		if (Sid == 1)
		{
			if (Target.style.display == "none")
			{
				Target.style.display = "";
			} 
			else 
			{
				Target.style.display = "none";
			}
		}
		else
		{
			Target.style.display = "";
		}
	}
}

	<!--
//функция сворачивания/разворачивания дерева
function clickMenu1(){
	sTarget = document.getElementById("ttt");
	if (sTarget == null){
	 	return;
	}
	//sTarget.style.display = 'none';
	if (sTarget.style.display == "none"){
		sTarget.style.display = "";
	}else{
		sTarget.style.display = "none";
	}
	alert(sTarget.style.display);
}

function ShPage(pn)
	{
	wwidth = 500;
	wheight = 400;
	wtop = (window.screen.height-wheight)/2;
	wleft = (window.screen.width-wwidth)/2;
	wname = "shp_pages";
	oppageurl = "/hpages.asp?pn=" + pn;
	wind=window.open(oppageurl, wname, "location=no, menubar=no, scrollbars=yes, toolbar=no, status = no, resizable=yes, directories=no, width="+wwidth+",left="+wleft+", height="+wheight+", top="+wtop);
	wind.focus();
        }

function SendInfo(pn, pns)
	{
	wwidth = 850;
	wheight = 530;
	wtop = (window.screen.height-wheight)/2;
	wleft = (window.screen.width-wwidth)/2;
	wname = "sendinfo"+pn+"_"+pns;
	oppageurl = "/sendinfo.asp?pn=" + pn + "&pns=" + pns;
	wind=window.open(oppageurl, wname, "location=no, menubar=no, scrollbars=yes, toolbar=no, resizable=yes, directories=no, width="+wwidth+",left="+wleft+", height="+wheight+", top="+wtop);
	wind.focus();
	}

function Subscr(pn, pns)
	{
	wwidth = 850;
	wheight = 530;
	wtop = (window.screen.height-wheight)/2;
	wleft = (window.screen.width-wwidth)/2;
	wname = "subscr"+pn+"_"+pns;
	oppageurl = "/subscr.asp?pn=" + pn + "&pns=" + pns;
	wind=window.open(oppageurl, wname, "location=no, menubar=no, scrollbars=yes, toolbar=no, resizable=yes, directories=no, width="+wwidth+",left="+wleft+", height="+wheight+", top="+wtop);
	wind.focus();
	}

//-->