var uagent    = navigator.userAgent.toLowerCase();

function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) 
field.value = field.value.substring(0, maxlimit);
else 
countfield.value = maxlimit - field.value.length;
}

function mfrDevs()
{
cur_mfr=document.forms.form.mfr.value;
dev=document.forms.form.dev;
dev.length=dev_cnt;
dev.options[0].value='0';
dev.options[0].text='Укажите модель';
ii=1;
for(i=0;i<dev_cnt;i++)
if(dev_mfrs[i]==cur_mfr)
{
dev.options[ii].value=dev_ids[i];
dev.options[ii].text=dev_names[i];
ii++;
}dev.length=ii;
}
function setPrevParams(pmfr,pdev)
{
  mfr=document.forms.form.mfr;
for(i=0;i<mfr.options.length;i++)
{
if(mfr.options[i].value==pmfr)
{
mfr.selectedIndex=i;
break;
};
} mfr.onchange();
    dev=document.forms.form.dev;
for(i=0;i<dev.options.length;i++)
{
if(dev.options[i].value==pdev)
{
dev.selectedIndex=i;
break;
};
}}

function ShowHide(id1, id2)
{
	if (id1 != '') toggleview(id1);
	if (id2 != '') toggleview(id2);
}
	
function change_cell_color( id, cl )
{
	itm = my_getbyid(id);
	
	if ( itm )
	{
		itm.className = cl;
	}
}

function my_getbyid(id)
{
	itm = null;
	
	if (document.getElementById)
	{
		itm = document.getElementById(id);
	}
	else if (document.all)
	{
		itm = document.all[id];
	}
	else if (document.layers)
	{
		itm = document.layers[id];
	}
	
	return itm;
}


function my_hide_div(itm)
{
	if ( ! itm ) return;
	
	itm.style.display = "none";
}


function my_show_div(itm)
{
	if ( ! itm ) return;
	
	itm.style.display = "";
}


function togglemenucategory( fid, add )
{

	//-----------------------------------
	// Add?
	//-----------------------------------

	if ( add )
	{

		my_show_div( my_getbyid( 'fo_'+fid  ) );
		my_hide_div( my_getbyid( 'fc_'+fid  ) );
	}
	else
	{
		my_show_div( my_getbyid( 'fc_'+fid  ) );
		my_hide_div( my_getbyid( 'fo_'+fid  ) );
	}
}

function openWin(model,photo1,photo2){
myWin= open("","photoWindow","width=400,height=370,status=no,toolbar=no,menubar=no,resizable=yes");
myWin.document.write("<html><head><title>"+model+"</title>");
myWin.document.write("<META http-equiv=Content-Type content='text/html; charset=windows-1251'>");
myWin.document.write("</head><body><table width=400px><tr><td width=50% align=center>"); myWin.document.write("<img src='./goods_photos/"+photo1+"' border=0></td><td>");
if (photo2!=""){
   myWin.document.write("<img src='./goods_photos/"+photo2+"' border=0></td>");
   } else {
     myWin.document.write("&nbsp;</td>");
    }
myWin.document.write("</tr></table><br><div align=center><input type=button value='Закрыть окно' onClick='window.close()'></div>");
myWin.document.write("</body></html>");
myWin.document.close();
}
function change_image(img_name){
     document.big_image.src=img_name;
}

