window.onload = function() {
	addTB();
}

function reVal(el){
  if(trim(el.value)!='')el.style.backgroundImage='none';
}

function isMail(mail){
  var mailre=/^[_a-zA-Z0-9\.\-]+@[_a-zA-Z0-9\.\-]+\.[a-zA-Z]{2,4}$/;
  return mailre.test(mail);
}

function incNumber(num){
  var numre=/^.*[0-9].*$/;
  return numre.test(num);
}

function checkFrm(f){
	var emptys=new Array();
	var invalids=new Array();
    var alrt="";
    
	if(trim(f.f_75.value)=='')emptys[emptys.length]=new Array(f.f_75,'Název společnosti');
	if(trim(f.f_76.value)=='')emptys[emptys.length]=new Array(f.f_76,'IČO');
	if(trim(f.f_77.value)=='')emptys[emptys.length]=new Array(f.f_77,'Předmět podnikání');
	if(trim(f.f_78.value)=='')emptys[emptys.length]=new Array(f.f_78,'Ulice');
	if(trim(f.f_79.value)=='')emptys[emptys.length]=new Array(f.f_79,'Město');
	if(trim(f.f_80.value)=='')emptys[emptys.length]=new Array(f.f_80,'PSČ');
  
	  if(emptys.length>0 || invalids.length>0){
            if(emptys.length>0){
                alrt+="Následující položky nebyly vyplněny:\n\n";
                for(var i=0;i<emptys.length;i++){
                    alrt+=emptys[i][1]+"\n";
                    if(typeof(emptys[i][0].style) != 'undefined') {
                        emptys[i][0].style.backgroundImage="url('images/layout/crumbs/exclamation-mark.gif')";
                        emptys[0][0].focus();
                    }
                }
            }

            if(invalids.length>0){
                alrt+=(emptys.length>0?"\n\n":"")+"Nasledujici položky nebyly správně vyplněny:\n\n";
                for(var i=0;i<invalids.length;i++){
                    alrt+=invalids[i][1]+"\n";
                    invalids[i][0].style.backgroundImage="url('images/layout/crumbs/exclamation-mark.gif')";
                    if(emptys.length==0)invalids[0][0].focus();
                }
            }
            alert(alrt);
            return false;
    } else {
        return true;
    }
}
