 function TestWebFirm(form)
 {
   if ((form.web.value == "") && (form.firm.value == ""))
      {
        alert("Пожалуйста, введите строку поиска в поля 'Товар' или 'Фирма'!")
        return false
      }
   else
		{
		var s = new String(form.web.value)
		var l = s.length
		var s2 = new String(form.firm.value)
		var l2 = s2.length
		if ((l > 0) && (l <= 2) || (l2 > 0) && (l2 <= 2) )
        {
          alert("Длина строки поиска в полях 'Товар' или 'Фирма' должна быть больше 2 символов!")
          return false
        }
        else return true
		}
 }

 function mSubmit()
 {
    document.forms.F_count_pos.submit();
 }
 function f_inweb(value)
 {
   if (F_count_pos.inweb.checked)
      {form_main.inweb.value = value;
       rus.rus.value = value;
      }
      else
      {form_main.inweb.value = ""
       rus.rus.value = "";
      }
 }
 function month()
 {
 	var date = new Date()
	return date.getCalendarMonth
 }

 function f_boxclick(CurrentObject)
 {
	if (CurrentObject.checked)
		{
         CurrentObject.value = "True";
		}
	else
		{
         CurrentObject.value = "False";
		}
 }
 function f_find_in_group(CurrentObject, id_group, id_subgroup)
 {
	if (CurrentObject.checked)
		{
         CurrentObject.value = "True";
         form_main.id_group.value = id_group
         form_main.id_subgroup.value = id_subgroup
		}
	else
		{
         CurrentObject.value = "False";
         form_main.id_group.value = ''
         form_main.id_subgroup.value = ''
		}
 }

 function open_image(id_service, id_hist_image, extended, name, firm, phone, email)
 {
        image_win = window.open("", "Photo", "alwaysRaised=yes, width=660, height=660, screenX=380, screenY=50, top=50, left=400, scrollbars=yes, resizable=yes, location=no, toolbar=no, menubar=no");
        image_win.document.write('<html>');
        image_win.document.write('<head>');
        image_win.document.write('<title>'+name+'</title>');
        image_win.document.write('<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">');
        image_win.document.write('</head>');
        image_win.document.write('<body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0">');
        image_win.document.write('<div align="center">');
        image_win.document.write('<img src="'+'/find/images/'+id_service+'/'+id_service+'_'+id_hist_image+extended+'" border="0">');
        image_win.document.write('</div>');
        image_win.document.write('<div align="center">');
        image_win.document.write(name+'<br>');
        image_win.document.write(firm+"<br>тел.&nbsp;"+phone+';&nbsp;email:&nbsp;<a href="mailto:'+email+'">'+email+'</a>');
        image_win.document.write('<hr>');
        image_win.document.write('<form>');
        image_win.document.write('<input type="button" value="Закрыть окно" onclick="self.close()">&nbsp;');
        image_win.document.write('<input type="button" value="Печать" onclick="self.print()">');
        image_win.document.write('</form>');
        image_win.document.write('</div>');
        image_win.document.write('</body>');
        image_win.document.write('</html>');
        image_win.focus();
        image_win.document.close();
 }

 function open_YandMap(yandex_map_key, name_firm, geocoder_string)
 {
        YandMap_win = window.open("", "YandMap", "alwaysRaised=yes, width=660, height=670, screenX=380, screenY=50, top=50, left=400, scrollbars=yes, resizable=yes, location=no, toolbar=no, menubar=no");
        YandMap_win.document.writeln('<html>');
        YandMap_win.document.writeln('<head>');
        YandMap_win.document.writeln('<title>'+name+'</title>');
        YandMap_win.document.writeln('<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">');
        YandMap_win.document.writeln('<script src="http://api-maps.yandex.ru/1.1/index.xml?key='+yandex_map_key+'" type="text/javascript"></script>');
        YandMap_win.document.writeln('<script type="text/javascript">');
        YandMap_win.document.writeln('var map, geoResult;');
        YandMap_win.document.writeln('YMaps.jQuery( ');
        YandMap_win.document.writeln('  function () { ');
        //YandMap_win.document.writeln('  map = new YMaps.Map(document.getElementById("YMapsID"));');
        YandMap_win.document.writeln('    map = new YMaps.Map(YMaps.jQuery("#YMapsID")[0]);');
        YandMap_win.document.writeln('    map.removeOverlay(geoResult);');
        YandMap_win.document.writeln('    map.addControl(new YMaps.TypeControl());');
        YandMap_win.document.writeln('    map.addControl(new YMaps.ToolBar());');
        YandMap_win.document.writeln('    map.addControl(new YMaps.Zoom());');
        YandMap_win.document.writeln('    map.addControl(new YMaps.MiniMap());');
        YandMap_win.document.writeln('    map.addControl(new YMaps.ScaleLine());');
        YandMap_win.document.writeln('    var geocoder = new YMaps.Geocoder("'+geocoder_string+'", {results: 1, boundedBy: map.getBounds()});');
        YandMap_win.document.writeln('    YMaps.Events.observe( geocoder, geocoder.Events.Load, function () {');
        YandMap_win.document.writeln('       if (this.length()) {');
        YandMap_win.document.writeln('          geoResult = this.get(0);');
        YandMap_win.document.writeln('          map.addOverlay(geoResult);');
        YandMap_win.document.writeln('          map.setBounds(geoResult.getBounds());');
        YandMap_win.document.writeln('       }else {');
        YandMap_win.document.writeln('          alert("Ничего не найдено")');
        YandMap_win.document.writeln('       }');
        YandMap_win.document.writeln('    });');
        YandMap_win.document.writeln('  });');
        YandMap_win.document.writeln('</script>');
        YandMap_win.document.writeln('');
        YandMap_win.document.writeln('');
        YandMap_win.document.writeln('');
        YandMap_win.document.writeln('');

        YandMap_win.document.writeln('</head>');
        YandMap_win.document.writeln('<body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0">');
        YandMap_win.document.writeln('<div>фирма:&nbsp;<b>'+name_firm+'</b> адрес:&nbsp;<b>'+geocoder_string+'</b></div>');
        YandMap_win.document.writeln('<div id="YMapsID" align="center" style="width:620px;height:590px;"></div>');
        //YandMap_win.document.writeln('<hr>');
        YandMap_win.document.writeln('<form>');
        YandMap_win.document.writeln('<input type="button" value="Закрыть окно" onclick="map.destructor();self.close();">&nbsp;');
        YandMap_win.document.writeln('<input type="button" value="Печать" onclick="self.print()">');
        YandMap_win.document.writeln('</form>');
        YandMap_win.document.writeln('</div>');
        YandMap_win.document.writeln('</body>');
        YandMap_win.document.writeln('</html>');
        YandMap_win.focus();
        YandMap_win.document.close();
 }


 function f_price_gr(id_service, id_city, id_firm, id_group, id_subgroup, firm, web, keyword)
 {
    form_price_gr.id_service.value = id_service;
    form_price_gr.id_city.value = id_city;
    form_price_gr.id_firm.value = id_firm;
    form_price_gr.id_group.value = id_group;
    form_price_gr.id_subgroup.value = id_subgroup;
    form_price_gr.firm.value = firm;
    form_price_gr.web.value = web;
	 form_price_gr.keyword.value = keyword;
    form_price_gr.submit();
 }
 function f_price(id_service, id_city, id_firm, firm, web, keyword)
 {
    form_price.id_service.value = id_service;
    form_price.id_city.value = id_city;
    form_price.id_firm.value = id_firm;
    form_price.firm.value = firm;
    form_price.web.value = web;
    form_price.keyword.value = keyword;
    form_price.submit();
 }
 function HideIframe(idframe, idban)
{
	var ifr = document.getElementById(idframe);
    var doc = (ifr.contentWindow || ifr.contentDocument);
    var docu = doc.document;
    //docu.body.style.backgroundColor = 'transparent';
    if (docu.getElementById(idban).innerHTML == '')
    { document.getElementById(idframe).style.display = 'None'; }
    else { document.getElementById(idframe).style.display = ''; }
}
function WidthTDbanner(idframe, idban, id, width)
{
	var ifr = document.getElementById(idframe);
    var doc = (ifr.contentWindow || ifr.contentDocument);
    var docu = doc.document;
    if (docu.getElementById(idban).innerHTML != '')
	{ document.getElementById(id).style.width = width; }
	else { document.getElementById(id).style.width = '5'; }
}
