// Declaring required variables
var digits = "0123456789";
// non-digit characters whiAch are allowed in ico numbers
var icoNumberDelimiters = "()- ";
// characters which are allowed in international ico numbers
// (a leading + is OK)
var validWorldIcoChars = icoNumberDelimiters + "+";
// Minimum no of digits in an international ico no.
var minDigitsInIIcoNumber = 8;

function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function checkInternationalIco(strIco){
s=stripCharsInBag(strIco,validWorldIcoChars);
return (isInteger(s) && s.length == minDigitsInIIcoNumber);
}

function checkICO(){
	var Ico=document.formular.ico
	
	if ((Ico.value==null)||(Ico.value=="")){
		alert("Vložte IČO")
		Ico.focus()
		return false
	}
	if (checkInternationalIco(Ico.value)==false){
		alert("Vložte správné IČO/KÓD!\nIČO/KÓD musí obsahovat 8 číslic 0-9")
		Ico.value=""
		Ico.focus()
		return false
	}
	return true
 }
function visi(nr)
{
if (document.layers)
 {
 vista = (document.layers[nr].visibility == 'hide') ? 'show' : 'hide'
 document.layers[nr].visibility = vista;
 }
 else if (document.all)
 {
 vista = (document.all[nr].style.visibility == 'hidden') ? 'visible' : 'hidden';
 document.all[nr].style.visibility = vista;
 }
 else if (document.getElementById)
 {
 vista = (document.getElementById(nr).style.visibility == 'hidden') ? 'visible' : 'hidden';
 document.getElementById(nr).style.visibility = vista;

 }
}

function blocking(nr)
{
 if (document.layers)
 {
 current = (document.layers[nr].display == 'none') ? 'block' : 'none';
 document.layers[nr].display = current;
 }
 else if (document.all)
 {
 current = (document.all[nr].style.display == 'none') ? 'block' : 'none';
 document.all[nr].style.display = current;
 }
 else if (document.getElementById)
 {
 vista = (document.getElementById(nr).style.display == 'none') ? 'block' : 'none';
 document.getElementById(nr).style.display = vista;
 }
}

