
///////////////////////////////////////////////////////////////////////////////
//  e4system v 0.3.2
//  (c) 2002, Michal Kouïa , e4you spol. s r.o., michal.kouda@e4you.cz
///////////////////////////////////////////////////////////////////////////////
//  JavaScript function library
///////////////////////////////////////////////////////////////////////////////

// definice konstant browseru
var UNKNOWN   ='UNKNOWN';
var MOZILLA   ='MOZILLA';
var NETSCAPE  ='NETSCAPE';
var IE4       ='IE4';
var IE5       ='IE5';
var IE6       ='IE6';
var KONQUEROR ='KONQUEROR';

// funkce identifikujici typy browseru
function getBrowser() {
  if(navigator.userAgent.indexOf('MSIE 6')!=-1) return IE6;
  if(navigator.userAgent.indexOf('MSIE 5')!=-1) return IE5;
  if(navigator.userAgent.indexOf('Gecko')!=-1) return MOZILLA;
  if(navigator.userAgent.indexOf('Konqueror')!=-1) return KONQUEROR;
  if((navigator.userAgent.indexOf('Mozilla/4')!=-1)&&navigator.appName=='Netscape') return NETSCAPE;
  return UNKNOWN;
}

// do promenne browser priradime typ browseru
browser=getBrowser()

function isLayerVisible(LID) {
  switch(browser) {
    case 'KONQUEROR':
    case 'IE5':
    case 'IE6':
      l=eval('document.all.'+LID);
      return (l.style.visibility=='')||(l.style.visibility=='visible');
      break;
    case 'MOZILLA':
      l=document.getElementById(LID);
      return (l.style.visibility=='')||(l.style.visibility=='visible');
      break;
    case 'NETSCAPE':
      l=eval('document.layers.'+LID);
      return (l.visibility=='')||(l.visibility=='show');
      break;
  }
  return false;
};

// funkce skryje vrstvu se jmenem LID
function hideLayer(LID) {
  switch(browser) {
    case 'KONQUEROR':
    case 'IE5':
    case 'IE6':
      l=eval('document.all.'+LID);
      l.style.visibility = "hidden";
      return true;
      break;
    case 'MOZILLA':
      l=document.getElementById(LID);
      l.style.visibility = "hidden";
      return true;
      break;
    case 'NETSCAPE':
      l=eval('document.layers.'+LID);
      l.visibility = "hide";
      return true;
      break;
  }
  return false;
};

// funkce zobrazí vrstvu se jmenem LID
function showLayer(LID) {
  switch(browser) {
    case 'KONQUEROR':
    case 'IE5':
    case 'IE6':
      l=eval('document.all.'+LID);
      l.style.visibility = "visible";
      return true;
      break;
    case 'MOZILLA':
      l=document.getElementById(LID);
      l.style.visibility = "visible";
      return true;
      break;
    case 'NETSCAPE':
      l=eval('document.layers.'+LID);
      l.visibility = "show";
      return true;
      break;
  }
  return false;
};

// funkce nastavujici objektu tridu
function setClass(obj,cls) {
	obj.className=cls;
	return true;
};
  
function validEmail(email) {
	if(email=='') return false;
	reEmail = new RegExp("^[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+[.][a-zA-Z]{2,7}$");
	return reEmail.test(email);
};

function validUsername(username) {
	if(username=='') return false;
	reLogin = new RegExp("^[a-zA-Z0-9_-]{5,20}$");
	return reLogin.test(username);
};

function validPasswd(passwd) {
	if(passwd == '') return false;
	if(passwd.length < 6) return false;
	reAZ = new RegExp('[0-9]+');
	if(!reAZ.test(passwd)) return false;
	re09 = new RegExp('[a-z]+');
	if(!re09.test(passwd)) return false;
	return true;
};

function validUserPasswdPair(username,passwd) {
	if(!validUsername(username)) return false;
	if(!validPasswd(passwd)) return false;
	if(passwd.toUpperCase()==username.toUpperCase()) return false;
	if(passwd.search(username)!=-1) return false;
	revuname = '';
	for(i=0;i<username.length;i++) {
		revuname = username.charAt(i) + revuname;
	}
	if (revuname.toUpperCase()==passwd.toUpperCase()) return false;
	return true;
}

function validICO(ico) {
	if(ico=='') return true;
	reICO = new RegExp("^[0-9]{8}$");
	return reICO.test(ico);
};

function validDIC(dic) {
	if(dic=='') return true;
	reDIC = new RegExp("^[0-9]{3}-+[0-9]{8,10}$");
	return reDIC.test(dic);
};


function openLink(url) {
	previewWin=window.open(url,'linx','');
}


PicWinOpened = false;
function previewImg(src,w,h,description) {
	if(PicWinOpened) {
		PicWin.close();
	}
	winw = w + 30;
	winh = h + 30;
	PicWin = window.open('','picturedetail','width='+winw+',height='+winh+',resizable=no,location=no,status=no,scrollbars=no');
	with(PicWin) {
		document.write('<head><title>'+description+'</title></head>');
		document.write('<html><body style="margin: 10px 0 0 0; padding: 0px; background-color: black; text-align:center; font-family: verdana,sans-serif; font-size: 11px;">');
		document.write('<a href="javascript: window.close();" title="Zavøít okno"><img src="'+src+'" alt="Zavøít okno" width="'+w+'" height="'+h+'" border="0" /></a>');
		//document.write('<a href="javascript: window.close();" title="Zavøít okno"><img src="'+src+'" alt="'+name+'" border="0" onLoad="window.resizeTo(this.width+20,this.height+20); window.innerWidth=this.width+6; window.innerHeight=this.height+6; return true;"/></a>');
		document.write('<div style="color: white">'+description+'</div>');
		document.write('</body></html>');
		focus();
		PicWinOpened = true;
	};
};



