var gAutoPrint = true; // Flag for whether or not to automatically call the print function

function printSpecial()
{
	if (document.getElementById != null)
	{
		var html = '<html>\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1251\" />\n<link href=\"print_style.css\" rel=\"stylesheet\" type=\"text/css\">\n</head>\n<body>';
		html += '<p class=\"head\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Софийски градски съд<hr width=\"630px\" color=\"black\" align="left"/></p>';
		html += '<p class=\"subhead\">Търговско отделение, Фирмени състави - Входящ регистър</p>';
		
		html += '<div id=\"main\">\n'
		
		var printReadyElem = document.getElementById("firm_register_results");
		
		if (printReadyElem != null)
		{
				html += printReadyElem.innerHTML;
		}
		else
		{
			alert("Could not find the printReady section in the HTML");
			return;
		}
			
		html += '</div>\n'
		
		var printWin = window.open("","printSpecial");
		printWin.document.open();
		printWin.document.write(html);
		printWin.document.close();
		if (gAutoPrint)
			printWin.print();
	}
	else
	{
		alert("Съжаляваме, автоматичното отпечатване на страницата е възможност само в по-новите браузъри.\rЗа да отпечатате страницата използвайте стандартният начин за отпечатване (менюто File->Print).");
	}
}


function printSpecialShort()
{
	if (document.getElementById != null)
	{
		var html = '<html>\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1251\" />\n<link href=\"print_style.css\" rel=\"stylesheet\" type=\"text/css\">\n</head>\n<body>';
		html += '<p class=\"head\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Софийски градски съд<hr width=\"630px\" color=\"black\" align="left"/></p>';
		html += '<p class=\"subhead\">Търговско отделение, Фирмени състави - Входящ регистър</p>';
		
		html += '<div id=\"main\">\n'
		
		var printReadyElem = document.getElementById("firm_register_short_results");
		
		if (printReadyElem != null)
		{
				html += printReadyElem.innerHTML;
		}
		else
		{
			alert("Could not find the printReady section in the HTML");
			return;
		}
			
		html += '</div>\n'
		
		var printWin = window.open("","printSpecial");
		printWin.document.open();
		printWin.document.write(html);
		printWin.document.close();
		if (gAutoPrint)
			printWin.print();
	}
	else
	{
		alert("Съжаляваме, автоматичното отпечатване на страницата е възможност само в по-новите браузъри.\rЗа да отпечатате страницата използвайте стандартният начин за отпечатване (менюто File->Print).");
	}
}

function formcheck ()
{ 
 function CheckField(fieldvalue) 
 {
		var checkOK = "0123456789";
		var checkStr = fieldvalue;
		var allValid = true;
		
 for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      {
        if (ch == checkOK.charAt(j))
        break
      }  
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
 return allValid;
}

if (document.search.find_txt.value == "") 
{
alert("Въведете критерии за търсене!")
			document.search.find_txt.focus()
			return (false)	
}

if (document.search.find_txt.value != "")
   {
 		if (!CheckField(document.search.find_txt.value))
 		 {
 			alert("Въведени са непозволени символи !\n В полето за търсене могат да се въвеждат само цифри.");
			document.search.find_txt.focus();
			return (false);
 		 }
 			
 	 }
 
 return (true);
}

