	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;
	}

	
//	 Hyperlink reference
//	function changemodel1(indexselect, carname){
//		cur = indexselect;
//		document.form1.makename.value=carname;
//		document.form1.type.value="V";
//		for (var n=document.form1.model.options.length - 1; n > -1; n--) {
//			document.form1.model.options[n] = null;
//		}
//		for (var n=0; n < main[cur].length; n++) {
//			document.form1.model.options[n] = new Option(main[cur][n], main[cur][n]);
//		}
//		document.form1.model.options[0].selected=true;
//	}
 
	// Hyperlink reference 2
	function changemodel2(type, carname){
		var zippy = document.form1.zipcode.value
		// Checks for Zip code to be entered
		//document.form2.makename.value=carname;
		document.form2.type.value=type;
		document.form2.zipcode.value = document.form1.zipcode.value;
		if (zippy == ""){
			alert("Please enter a zip/postal code for your search.");
			return document.form1.zipcode.focus();
		}else{
			if(stringValid(document.form1.zipcode,"6")){
				document.form2.submit();
			}else{
				alert("Zip/Postal Code ("+document.form1.zipcode.value+") contains invalid character(s).");
				return document.form1.zipcode.focus();
				//return false;
			}
		}
	//	if (zippy){
	//	isNum(zippy);
	//	}
	//	if (zippy != "") {
	//	document.form2.submit();
	//	}
	}
 

	// Select box reference
	function changemodel(form){
		cur = form.options[form.selectedIndex].value;
		//document.auto_search.makename.value = form.options[form.selectedIndex].text;
		for (var n = document.auto_search.model.options.length - 1; n > -1; n--) {
			document.auto_search.model.options[n] = null;
		}
		document.auto_search.model.options[0] = new Option('Все',0);
		var col = 1;
		for (var n = 0; n < main[cur].length; n++) {
			if (main[cur][n] != null){
				document.auto_search.model.options[col] = new Option(main[cur][n], [n]);
				col += 1;
			}
		}
		document.auto_search.model.options[0].selected=true;
//		document.form1.makename.value = form.options[form.selectedIndex].text;
//		for (var n = document.form1.model.options.length - 1; n > -1; n--) {
//			document.form1.model.options[n] = null;
//		}
//		for (var n = 0; n < main[cur].length; n++) {
//			document.form1.model.options[n] = new Option(main[cur][n], main[cur][n]);
//		}
//		document.form1.model.options[0].selected=true;
	}
