<!--
// new window
function OpenWindow(strURL,width,height,sroll){
	var objWnd = window.open(strURL,"Detail","scrollbars=" + sroll + ",resizable=yes,height=" + height + ",width=" + width + ",left=0,top=0");
	objWnd.focus();
}

// otevreni noveho okna
function NewWindow(strURL){
	var objWnd = window.open(strURL);
	objWnd.focus();
}

// otevreni noveho okna
function NewWindow2(url){
	document.write('<a onclick="window.open(this.href,\'_blank\');return false;" href="' + url + '" title="Stránka se otevře v novém okně."><img src="http://www.cajovykramek.cz/images/basic/new-win.gif" width="16" height="13" title="Stránka se otevře v novém okně." alt="Stránka se otevře v novém okně." class="icon" /></a>');
}

// menu

var timer, menuId;
var activeMenuId = '';

function SetVisibility(element,newVisibility){ 
	document.getElementById(element).style.display = newVisibility;
}

function MenuShow(idMenu){
	if(activeMenuId != '' && activeMenuId != idMenu) SetVisibility(activeMenuId, 'none');
	clearTimeout(timer);
	SetVisibility(idMenu, 'block');
	activeMenuId = idMenu;
}

function MenuHide(idMenu){
	menuId = idMenu;
    timer = setTimeout("SetVisibility(menuId, 'none')",50);
}

function MenuDontHide(idMenu){
	clearTimeout(timer);
}

// oriznuti mezer
function Trim(s){
	while(s.substring(0,1) == ' '){
		s = s.substring(1,s.length);
	}
	while(s.substring(s.length-1,s.length) == ' '){
		s = s.substring(0,s.length-1);
	}
	return s;
}

//testovani regularnich vyrazu
function RegExpTest(test,reg){
	return test.search(reg) == 0;
}

// kontrola prazdne hodnoty pole
function CheckEmptyField(sField){

	var sMsg = '';
	var oLabel = document.getElementById('lb' + sField);

	if(Trim(document.getElementById(sField).value) == ""){
		document.getElementById(sField).focus();

		if(oLabel){
			sMsg = oLabel.firstChild.data;
			oLabel.style.color = '#AA0813';
		}
		else sMsg = '';

		alert("Musíte vyplnit poloku: " + sMsg + ".");
		return false;
	}
	else{
		if(oLabel) oLabel.style.color = '';
		return true;
	}
}

// kontrola spravnosti emailove adresy
function CheckEmail(sField){

	var sMsg = '';
	var oLabel = document.getElementById('lb' + sField);
	var sEmail = Trim(document.getElementById(sField).value);
	var sRe  = "^[^.]+(\.[^.]+)*@([^.]+[.])+[a-z]{2,3}$";

	if(sEmail != ""){
		if(!RegExpTest(sEmail,sRe)){
			document.getElementById(sField).focus();
			if(oLabel){
				sMsg = oLabel.firstChild.data;
				oLabel.style.color = '#AA0813';
			}
			else sMsg = '';
			alert("patný formát: " + sMsg + ".");
			return false;	
		}
		else{
			if(oLabel) oLabel.style.color = '';
			return true;			
		}
	}
	else return true;
}

// validace formulare
function ValidateEmailForm(){

	if(!CheckEmptyField('message')) return false;
	if(!CheckEmptyField('email')) return false;
	if(!CheckEmail('email')) return false;

	return true;
}
//-->