var IsIE = (window.navigator.appName.toLowerCase().indexOf('microsoft')!=-1)?true:false;
var IE_Ver = (window.navigator.appVersion.toLowerCase().indexOf('msie 7')!=-1)?7:6;
var RND=parseInt(Math.random()*100000);
var cat_cur_color="#CC0000";
var cat_cur_bgcolor="";
var RememberScrollTop=0;
var scroll_pgn_num = 1; // нумерация страниц для форумов

var pathID = new Array();

function keypress(event, obj)
{
	if((event.ctrlKey) && ((event.keyCode == 0xA)||(event.keyCode == 0xD)))
    {
		var str = getSelectionText();
		if (fr_bask!=null && str!='')
		{
			fr_bask.document.location="/error_send.aspx?url="+document.location+"&text="+str;
			document.getElementById("fr_bask_id").style.height="300px";
			document.getElementById("fr_bask_id").style.display="block";
		}
    }
}

function getSelectionText() {
	var str = "";
	if (document.getSelection) 
	{
		str = document.getSelection();
	} 
	else if (document.selection && document.selection.createRange) 
	{
		range = document.selection.createRange();
		str = range.text;
	} 
	return str;
}

/*
function set_radio(str,V){
var rez;
rez = str.substring(1,V);
	return rez;
	}
*/

function show_img(width,height,s_url){
	var imgnwin=window.open(s_url,"imgswin","resizable=yes,scrollbars=yes,toolbar=yes,location=no,directoties=no,status=no,menubar=no,width="+width+",height="+height);
}

function show_win(width,height,s_url){
	var p_top=(window.screen.height-height)/2, p_left=(window.screen.width-width)/2;
	var win=window.open(s_url,"imgswin","resizable=yes,scrollbars=yes,toolbar=no,location=no,directoties=no,status=no,menubar=no,width="+width+",height="+height+",top="+p_top+",left="+p_left);
	win.focus();
}

function show_winName(width,height,s_url,winname){
	var p_top=(window.screen.height-height)/2, p_left=(window.screen.width-width)/2;
	var win=window.open(s_url,winname,"resizable=yes,scrollbars=yes,toolbar=no,location=no,directoties=no,status=no,menubar=no,width="+width+",height="+height+",top="+p_top+",left="+p_left);
	win.focus();
}

var win_imggoods=null;
function show_goods_img(goods_name){
	var height=520, width=520;
	if (win_imggoods!=null) win_imggoods.close();
	if (ImgGoodsBig!='') {
		var p_top=(window.screen.height-height)/2, p_left=(window.screen.width-width)/2;	
		win_imggoods=window.open(null,"win_imggoods","resizable=yes,scrollbars=yes,toolbar=no,location=no,directoties=no,status=no,menubar=no,width="+width+",height="+height+",top="+p_top+",left="+p_left);
		win_imggoods.focus();
		win_imggoods.document.open();
		win_imggoods.document.write('<html><head><title>Изображение '+goods_name+'</title></head><body style="padding:0px;margin:0px;text-align:center;vertical-align:center;"><img src="'+ImgGoodsBig+'" width=500/></body></html>');
	}
}

function goods_img_load(obj_img){
	if (obj_img!=null && obj_img.src!=null && obj_img.src=="") 
	{
		goods_img_set(obj_img);
	}
}

function goods_img_error(obj_img){
	if (obj_img!=null) 
	{
		goods_img_set(obj_img);
	}
}

function goods_img_set(obj_img){
	var img_rubric = document.getElementById("img_rub");
	
	if (img_rubric!=null && img_rubric.src!="" && img_rubric.src.indexOf("i/0.gif")==-1) 
		obj_img.src = img_rubric.src;
	else 
		obj_img.src="/linkpics/i/null.gif";
}

var ImgGoodsBig = '';
function set_img(id_src,img_url_small,img_url_big){
	var obj = document.getElementById(id_src);
	if (obj!=null && obj.src!=null && img_url_small!='') {
		obj.src=img_url_small;
	}
	if (img_url_big!='') { ImgGoodsBig = img_url_big; }
	else ImgGoodsBig = img_url_small;
}

function show_print(s_url){
	var height=520, width=520;
	if (win_imggoods!=null) win_imggoods.close();
	var p_top=(window.screen.height-height)/2, p_left=(window.screen.width-width)/2;	
	win_imggoods=window.open(s_url,"win_imggoods","resizable=yes,scrollbars=yes,toolbar=yes,location=no,directoties=no,status=no,menubar=no,width="+width+",height="+height+",top="+p_top+",left="+p_left);
	win_imggoods.focus();
}


function active_win(surl){
	window.opener.document.location=surl;
}

function add_bask_img(idcat,idgoods,url){
	str_url="";
	if (url!=null) str_url=url;
	document.write("<a href='javascript:void(0);' onclick='fr_bask.document.location=\""+str_url+"/basket_add.aspx?idc="+idcat+"&idg="+idgoods+"&c=addbask&ctype=showbask&r="+RND+"\";document.getElementById(\"fr_bask_id\").style.display=\"block\";'><img src='/i/basket.gif' width=21 height=17 border=0 alt='в корзину' align='absmiddle' class='g_bask_img'></a>");
}

function add_bask_img2(idcat,idgoods,url){
	str_url="";
	if (url!=null) str_url=url;
	document.write("<a href='javascript:void(0);' onclick='fr_bask.document.location=\""+str_url+"/basket_add.aspx?idc="+idcat+"&idg="+idgoods+"&c=addbask&ctype=showbask&r="+RND+"\";document.getElementById(\"fr_bask_id\").style.display=\"block\";'><img src='/i/buy.gif' width=146 height=48 border=0 alt='в корзину' align='absmiddle' class='g_bask_img'></a>");
}

function add_bask_img_text(idcat,idgoods,url){
	document.write("<a href='javascript:void(0);' onclick='fr_bask.document.location=\"/basket_add.aspx?idc="+idcat+"&idg="+idgoods+"&c=addbask&ctype=showbask&r="+RND+"\";document.getElementById(\"fr_bask_id\").style.display=\"block\";' class=bask_img_text><img src='/i/bask_goods.gif' width=21 height=17 border=0 alt='в корзину' align='absmiddle' class='g_bask_img'> в корзину</a>");
}

function add_bask_text(iddir,idcat,idgoods){
	document.write("&raquo; <a href='javascript:void(0);' onclick='fr_bask.document.location=\"/basket_add.aspx?idd="+iddir+"idc="+idcat+"&idg="+idgoods+"&c=addbask&ctype=showbask&r="+RND+"\";document.getElementById(\"fr_bask_id\").style.display=\"block\";' class=bask_img_text>в корзину</a>");
}

function Add2Basket(iddir,idcat,idgoods){
    var url = "/basket_add.aspx?idd="+iddir+"idc="+idcat+"&idg="+idgoods+"&quan"+idgoods+"=" + document.getElementById("quan"+idgoods).value + "&c=addbask&ctype=showbask&r="+RND;
//alert(url);
    fr_bask.document.location = url;
    document.getElementById("fr_bask_id").style.display="block";
}

function add_bask_text2(idcat,idgoods,url){
	document.write("<a href='javascript:void(0);' onclick='fr_bask.document.location=\""+str_url+"/basket_add.aspx?idc="+idcat+"&idg="+idgoods+"&c=addbask&ctype=showbask&r="+RND+"\";document.getElementById(\"fr_bask_id\").style.display=\"block\";' class=bask_img_text>");
}


function set_selected(p,v){
	for (i=0; i < p.options.length; i++) {
		if (p.options[i].value==v) { p.options[i].selected=true; break; }
	}
}

function set_radio(p,v){
	for (i=0; i < p.length; i++) {
		if (p[i].value==v) { p[i].checked=true; break; }
	}
}

function set_checked(p,v){
	if (p.value==v) p.checked=true; 
}

function show_parent_div(div_par){
    var IDParentElement="", NextParentElement="";
		var obj=null; 
		var obj1=null;
    if (document.getElementById(div_par)!=null)
    {
			obj1=document.getElementById(div_par);
			for(var i=0; i<10; i++) {
				obj=obj1;
				if (obj!=null) {
					if (obj.id!="" && obj.style.display!="block") {
						obj.style.display="block";
					}
				}
				else break;
				obj1=eval("obj.parentElement");
			}
		}
}

function ShowAsDeleted(div_par)
{
    MakeBgColor4TagName("TR", div_par, "#AAAAAA");
    var obj=document.getElementById(div_par);
    var col=null;
    if (obj!=null)
    {  
		if (IsIE) col=obj.children;
		else col = obj.childNodes;
		for(var i=0; i<col.length; i++)
		{
    		if (col[i].tagName=="A")
    		{
                changeText(col[i], "Отображать на сайте");
                break;
    		}
		}
    }
}

function MakeBgColor4TagName(TagName, div_par, bgcl)
{
    var i=0;
	var obj=null;
    var obj1=document.getElementById(div_par);
    while (obj1!=null && i<10)
    {
		obj=obj1;
		//alert("1="+obj.tagName);
		obj.style.backgroundColor=bgcl;
		if (obj.tagName==TagName)
		{
			break;
		}
	    i++;
		if (IsIE) obj1=eval("obj.parentElement");
		else obj1=eval("obj.parentNode");
	}
}


function show_div(id_cur){
	var div_set=null;
	div_set=document.getElementById(id_cur);
	if (div_set!=null) {
		if (div_set.style.display=="block") div_set.style.display="none";
		else div_set.style.display="block";
	}
}

function show_divMODE(id_cur, mode){
	var div_set=null;
	div_set=document.getElementById(id_cur);
	if (div_set!=null)
		div_set.style.display=mode;
}


function show_cat(id_cur){
	var div_set = document.getElementById(id_cur);
	var obj_link = document.getElementById(id_cur+"_a");
	var obj_ico = document.getElementById(id_cur+"_ico");
	if (div_set!=null) {
		if (div_set.style.display=="block") {
			div_set.style.display="none";
			/*
			if ( obj_link!=null )
			{
				obj_link.setAttribute("className","cat0_off");
				obj_link.className = "cat0_off";
			}
			*/
			if (obj_ico!=null && obj_ico.src!=null)
			{
				obj_ico.src = "/i/ic_plus.gif"
			}
		}
		else {	
			div_set.style.display="block";
			/*
			if ( obj_link!=null )
			{
				obj_link.setAttribute("className","cat0_on");
				obj_link.className = "cat0_on";
			}
			*/
			if (obj_ico!=null && obj_ico.src!=null)
			{
				obj_ico.src = "/i/ic_minus.gif"
			}
		}
	}
	return false;
}


function show_parent_div(div_par){
    var IDParentElement="", NextParentElement="";
		var obj=null; 
		var obj1=document.getElementById(div_par);


		if (obj1 != null)
    {
			for(var i=0; i<10; i++) {
				obj=obj1;

				if (obj!=null) {
					if (obj.id!="" && obj.style.display!="block") {
						obj.style.display="block";
					}
					//if ( obj.id.indexOf('cat')!=-1 && cat_cur_bgcolor!="" ) obj.style.backgroundColor = cat_cur_bgcolor;
					if ( cat_cur_color!="" && document.getElementById(obj.id+'_a')!=null ) 
						document.getElementById(obj.id+'_a').style.color = cat_cur_color;
					obj_ico = null;
					if ( (obj_ico=document.getElementById(obj.id+'_ico'))!=null && obj_ico.src!=null ) 
						obj_ico.src = "/i/ic_minus.gif";

				}
				else break;
				if (IsIE) obj1=eval("obj.parentElement");
				else obj1=eval("obj.parentNode");
				//parentNode 
			}// end for
		}
		else {
			obj1=document.getElementById(div_par+'_a');
			if ( cat_cur_color!="" && obj1!=null ) obj1.style.color = cat_cur_color;
		}
}

CurCurse='1.0';


function normalize(price)
{	var pr, str;
	pr=parseInt(Math.round(price*100));
	str = new String(pr);
	pr="";
	if (str.length>2)
		pr += str.substring(0, str.length-2);
	else
		pr += "0";
	pr += ".";
	if (str.length>2)
		pr += str.substring(str.length-2, str.length);
	else
	{	if (str.length==1)
			pr += "0";
		pr += str;
	}
	return pr;
}

function price_alt(in_price,in_usd,in_rur){
	if (in_price=='' || (in_usd=='' && in_rur=='')) return;
	var normal_price=parseFloat("0"+in_price);
	if (in_usd!='') { document.write( normalize(normal_price*CurCurse)+" руб." ); return; } // если цена товара в USD, то пересчитаем в рублях и отобразим альтернативную цену
	if (in_rur!='') { document.write( normalize(normal_price/CurCurse)+" $" ); return; } // если цена товара в USD, то пересчитаем в рублях и отобразим альтернативную цену
}

function price_alt2(in_price){
CurValuteFlag='2'; // 0 - не установлен, 1-доллары, 2-рубли.
	var normal_price=parseFloat("0"+in_price);
	if (CurValuteFlag=='1') { document.write( normalize(normal_price*CurCurse)+" руб." ); return; } // если цена товара в USD, то пересчитаем в рублях и отобразим альтернативную цену
	if (CurValuteFlag=='2') { document.write( normalize(normal_price/CurCurse)+" $" ); return; } // если цена товара в USD, то пересчитаем в рублях и отобразим альтернативную цену
}

function ico_img(graph)
{
	if (graph == '/i/null.gif') document.write('<img src="/i/ico_noimg.gif" width=30 height=30 border=0 alt="Изображение отсутствует">');
	else if (graph == '/i/noimage.gif') document.write('<img src="/i/ico_noimg.gif" width=30 height=30 border=0 alt="Изображение отсутствует">');
	else document.write('<img src="/i/ico_img.gif" width=30 height=30 border=0 alt="Описание с изображением">')
}

function CreateCookie(name,value,ex_date){
	var today=new Date();
	today.setDate(today.getDate()+ex_date);
	document.cookie=name+"="+value+"; expires="+today.toGMTString()+"; path=/;";
}

function CreateTmpCookie(name,value){
	document.cookie=name+"="+value+"; path=/;";
}

function RemoveCookie(name){
	CreateCookie(name,"",-1);
}

function ViewCompare(idcat, idgoods){
	document.write("<a href='javascript:void(0);' onclick='retval=SetCompare("+idcat+","+idgoods+"); fr_bask.document.location=\"/compare_set.aspx?idc="+idcat+"&idg="+idgoods+"&r="+RND+"\"; if (retval) document.getElementById(\"fr_bask_id\").style.display=\"block\";'>К сравнению</a>");
}

function ViewCompare2(idcat, idgoods){
	document.write("<a href='javascript:void(0);' onclick='retval=SetCompare("+idcat+","+idgoods+"); fr_bask.document.location=\"/compare_set.aspx?idc="+idcat+"&idg="+idgoods+"&r="+RND+"\"; if (retval) document.getElementById(\"fr_bask_id\").style.display=\"block\";'>");
}

function ViewCompareCheck(idcat,idgoods, IsChecked){
	document.write("<input id='compare"+idgoods+"' name='compare"+idgoods+"' type='checkbox' "+IsChecked+" onclick='fr_bask.document.location=\"/compare_set.aspx?idc="+idcat+"&idg="+idgoods+"&r="+RND+"\"; if (this.checked) document.getElementById(\"fr_bask_id\").style.display=\"block\";'/>");
}




function SetCompare(idc, idg){
	obj_check = document.getElementById("compare"+idg);
	retVal = false;
	if (obj_check != null)
	{
		if (!obj_check.checked) obj_check.checked = true;
		else obj_check.checked = false;
		retVal = obj_check.checked;
	}
	return retVal;
}

function ClearCompare(idg){
	obj_check = document.getElementById("compare"+idg);
	if (obj_check != null) obj_check.checked = false;
}

function SpellCompare(obj){
	var str="";
	var start_IDG=0;
	var end_IDG=-1;
	var break_point=0;
	var flag;
	while (start_IDG!=-1){
		start_IDG=document.cookie.indexOf("idg",start_IDG);
		end_IDG=document.cookie.indexOf("=",start_IDG);
		if (start_IDG==-1 || end_IDG==-1) break;
		idg=unescape(document.cookie.substring(start_IDG+3,end_IDG));
		start_IDG=end_IDG;
		flag=false;
		//alert("idg="+idg+" , obj.idg.length="+obj.idg.length);
		if (isNaN(obj.idg.length)) { 
			if (obj.idg.value==idg) { obj.idg.checked=true; flag=true; }
		}
		else {
			for (i=0;i<obj.idg.length;i++) {
				if (obj.idg[i].value==idg) { obj.idg[i].checked=true; flag=true; break; }
			}
		}
		//alert("flag="+flag);
		if (!flag) { 
			//alert("!!! idg="+idg);
			str+="<input type=hidden name=idg value="+idg+">"
		}
		break_point++; if (break_point>10) break;
	}
	return str;
}

function SearchScroll(FileAction,pgsize,numpage,stype,str_url){
	var s1=new RegExp("pgsize=.&|pgsize=..&|pgsize=...&", "gi");
	var s2=new RegExp("page=.&|page=..&|page=...&", "gi");
	var s3=new RegExp("stype=.&|stype=..&|stype=...&", "gi");
	str_url=str_url.replace(s1,''); str_url=str_url.replace(s2,''); str_url=str_url.replace(s3,'');
	document.location = FileAction + '?c=search&pgsize='+pgsize + '&page='+numpage +'&stype='+stype + '&'+str_url;
}

function logoff(file_templ,idc,stype,page,idr,idt,idn){
	RemoveCookie("login");
	RemoveCookie("pass");
	RemoveCookie("userid");
	document.location='/'+ file_templ +'?idc='+idc +'&stype='+stype +'&page='+page +'&idr='+idr +'&idt='+idt +'&idn='+idn +'&r='+RND;
	//location.reload();
}

function set_url(str_url){
    if (str_url.indexOf("?")>0)
        parent.document.location=str_url+'&r='+RND;
	else
	    parent.document.location=str_url+'?r='+RND;
}

function GetMianForm() {
	var theForm = document.forms['aspnetForm'];
	if (!theForm) {
			theForm = document.aspnetForm;
	}
	if (!theForm.onsubmit || (theForm.onsubmit() != false)) return theForm;
	else return null;
}


function PostBack(command, command_type) {
	var theForm = GetMianForm();
	if (theForm != null) {
			if (theForm.c!=null) theForm.c.value = command;
			if (theForm.ctype!=null) theForm.ctype.value = command_type;
			if (theForm.IsPostForm!=null) theForm.IsPostForm.value = 1;
			theForm.submit();
	}
	return false;
}


function g_sort(s_name_sort){
	var theForm = GetMianForm();
	if (theForm != null) {
			if (theForm.GoodsSort!=null) theForm.GoodsSort.value = s_name_sort;
			if (theForm.IsPostForm!=null) theForm.IsPostForm.value = 1;
			theForm.submit();
	}
	return false;
}

function g_scroll(pgn,IsPostForm){
	var theForm = GetMianForm();
	if (theForm != null) {
			if (theForm.pgn!=null) theForm.pgn.value = pgn;
			theForm.submit();
	}
	return (IsPostForm=="1")?false:true;
}

function changeText(el,text) {
	//alert(el.firstChild.nodeValue);
  //if (IsIE && IE_Ver<7) el.innerText=text;
	//else {
		if (el.firstChild) el.firstChild.nodeValue=text;
		else el.appendChild(document.createTextNode(text));
	//}
}

function search_action(){
	var theForm = GetMianForm();
	if (theForm != null && theForm.s_Word!=null && theForm.s_Word.value!='') {
			if (theForm.c!=null) theForm.c.value = "search";
			if (theForm.IsPostForm!=null) theForm.IsPostForm.value = 1;
			if (theForm.__VIEWSTATE!=null) theForm.__VIEWSTATE.value = '';
			theForm.action='/search.aspx';
			theForm.submit();
	}
	return false;
}

function set_message(id_div,text){
	var obj = document.getElementById(id_div);
	if (obj!=null) changeText(obj,text);
}

function CheckPayCondition(obj_Paymode, BasketSummUSD, BasketSumRUR){
	var PayConditionCreditPersonal = document.getElementById("PayConditionCreditPersonal");
	var PayConditionCreditOrg = document.getElementById("PayConditionCreditOrg");

	if (obj_Paymode!=null && PayConditionCreditPersonal!=null && PayConditionCreditOrg!=null) {
		PayConditionCreditOrg.style.display="none";
		PayConditionCreditPersonal.style.display="none";
		if (obj_Paymode.value==300 && BasketSummRUR<3000){
			PayConditionCreditPersonal.style.display="block";
		}
		else if (obj_Paymode.value==400 && BasketSummUSD<5000){
			PayConditionCreditOrg.style.display="block";
		}
	}
}

function mySelect(fileName, ObjectID2Paste, winName){
	var obj = document.getElementById(ObjectID2Paste);
	if (obj==null)
    {   
        alert("Не удается найти объект " + ObjectID2Paste);
        return false;
    }
    show_winName(800, 600, fileName + "?id=" + ObjectID2Paste, winName);
}

// функция для просмотра картинки в отдельном окне
function viewimageJS(myfile, mydirect, mypath)
{	var tmp, i;
	myfile = new String(myfile);
	if (myfile!="")
	{	if ((myfile.substring(0,7)!="http://") && (mydirect==0)) // относительная адресация
		{	tmp = new String(mypath);
			i = tmp.lastIndexOf("/");
			if (i>-1)
				tmp = tmp.substring(0, i-1);
			else
				tmp = "";
			if (tmp.substring(0, 1)=="/")
				myfile = "http://" + tmp.substring(0, tmp.lastIndexOf("/")-1) + myfile;
			else
				myfile = "http://" + tmp.substring(0, tmp.lastIndexOf("/")) + myfile;
		}
		alert(myfile);
		var iwin = window.open(myfile, "iwin", "resizable=yes,scrollbars=yes,toolbar=no,location=no,directoties=no,status=no,menubar=no,width=400,height=400");
		if (iwin!=null)
			iwin.focus();
	}
}


var cols=1;
//var TRClosing="";
function s_cols_1(num_cols){//start
//alert("cols = " + cols + " num_cols="+num_cols);
	if (cols > num_cols) cols=1;
	if (cols==1) { document.write("<tr valign=top>"); } 
}
function s_cols_2(num_cols){//end
//alert("cols = " + cols + " num_cols="+num_cols);
	if ( cols==num_cols ) { document.write("</tr>"); } 
	cols++;
}
function s_cols_final(num_cols){//end
	if (cols<=num_cols) {
		for (i=cols; i<=num_cols; i++) {
			document.write("<td width="+(100/num_cols)+"%>&nbsp;</td>");
		}// end for
    	document.write("</tr>");
	}// end if
	cols=1;
}

// показываем конкретный товар
function Show_GoodsItem(DirectionID, RubricID, GoodsID)
{
    //alert("GoodsID = " + GoodsID);
    var rl = document.getElementById("RubricsList");
    var gl = document.getElementById("GoodsList");
    var gi = document.getElementById("GoodsItem");
    var vs = document.getElementById("VertScroll");
    if (gl==null || gi==null || vs==null)
    {
        alert("Ошибка Show_GoodsItem: отсутствует GoodsList и/или GoodsItem и/или VertScroll");
        return false;
    }
    RememberScrollTop = vs.scrollTop;   // запомним как было прокручено окно со списком товаров
    if (rl!=null) rl.style.display = "none";
    gl.style.display = "none";
    // установим свойства карточки товара
    document.getElementById("GI_Image").src = document.getElementById("g" + GoodsID + "_img").src;
    document.getElementById("GI_Image").alt = document.getElementById("g" + GoodsID + "_name").innerHTML;
    document.getElementById("GI_Text").innerHTML = document.getElementById("g" + GoodsID + "_txt").innerHTML;
    // покажем карточку товара
    gi.style.display = "block";
    vs.scrollTop=0; // конкретный товар надо всегда показывать "c начала"
    //return true;
}

// показываем список товаров
function Show_GoodsList()
{
    var rl = document.getElementById("RubricsList");
    var gl = document.getElementById("GoodsList");
    var gi = document.getElementById("GoodsItem");
    var vs = document.getElementById("VertScroll");
    if (gl==null || gi==null || vs==null)
    {
        alert("Ошибка Show_GoodsItem: отсутствует GoodsList и/или GoodsItem и/или VertScroll");
        return false;
    }
    gi.style.display = "none";
    if (rl!=null) rl.style.display = "block";
    gl.style.display = "block";
    vs.scrollTop=RememberScrollTop; // восстановим запомненную прокрутку для списка товаров
}

// раскрываем направление слева по идентификатору
function openLeftDir(id)
{   var obj = null;
    obj = document.getElementById("dir_t"+id);
    if (obj!= null) obj.className = obj.className + "_act";
    obj = document.getElementById("leftdir"+id);
    if (obj!= null) obj.className = obj.className + "_act";
    obj = document.getElementById("dir_u"+id);
    if (obj!= null) obj.className = obj.className + "_act";
    obj = document.getElementById("dircat"+id);
    if (obj!= null) obj.className = obj.className + "_act";
}

// раскрываем рубрику слева по идентификатору
function openLeftRub(id)
{   var obj = null;
    obj = document.getElementById(id);
    if (obj!= null) obj.className = obj.className + "_act";
}

// активируем пункт меню - просто меняем ему стиль
function MakeMenuActive(id)
{   var obj = null;
    obj = document.getElementById(id);
    if (obj!= null) obj.className = obj.className + "_inv";
}

// делает разбаение на строки при выводе типов новостной
var sepNews = "</tr></table><table width=100% border=0 cellspacing=0 cellpadding=0 class=news0><tr valign=top>";
function NewsMakeTR(num_cols)
{
    if ((cols % num_cols) == 0)
        document.write(sepNews);
    cols++;
}
function NewsMakeSep()
{
    if (cols>0)
        document.write(sepNews);
    cols++;
}

// проверка формы для отправки письма
function CheckMailForm()
{
    if (document.getElementById("firm")==null || document.getElementById("city")==null || document.getElementById("fio")==null || document.getElementById("phone")==null || document.getElementById("email")==null || document.getElementById("dir")==null || document.getElementById("sf")==null)
    {
        alert("Ошибка CheckMailForm: Не все поля форма найдены");
        return false;
    }
    if (document.getElementById("firm").value=="")
    {
        alert("Поле 'Фирма' не заполнено");
        return false;
    }
    if (document.getElementById("city").value=="")
    {
        alert("Поле 'Город' не заполнено");
        return false;
    }
    if (document.getElementById("fio").value=="")
    {
        alert("Поле 'Контактное лицо' не заполнено");
        return false;
    }
    if (document.getElementById("phone").value=="")
    {
        alert("Поле 'Телефон (с кодом)' не заполнено");
        return false;
    }
    if (document.getElementById("email").value=="")
    {
        alert("Поле 'E-mail' не заполнено");
        return false;
    }
    if (document.getElementById("dir").value=="")
    {
        alert("Поле 'Направление деятельности фирмы' не заполнено");
        return false;
    }
    document.getElementById('sf').value=1;
    document.getElementById('aspnetForm').submit();
    return true;
}

function HideObjIfStrIsEmpty(ObjID, Str)
{
	var ob=document.getElementById(ObjID);
	if (ob!=null && (Str=="" || Str=="&nbsp;"))
	{
		ob.style.display="none";
	}
}

function scroll_pgn() {
    document.write(scroll_pgn_num++);
}

