var msgCache = {'0':['']};

function msg(msgID){
  var msg = msgCache[msgID];
  if(msg){
    return msg[0];
  }else{
    return '';
  }
}


//Vrati referenci na document ve frame podle nazvu Frame
function getObj(objName){
	try
	{
		return document.getElementById(objName);
	}catch(e){}
	return null;
}
function getObjName(objName){
	try
	{
		var eBTN = document.getElementsByTagName('input');
		for(i=0;i<eBTN.length;i++)
		{
			if(eBTN[i].name==objName) return eBTN[i];
		}
		return document.getElementById(objName);
	}catch(e){}
	return null;
}

//Zjisti jestli je objek nasetovan
function isObj(obj){
	try{if(obj!=null && obj!='undefined') return true;}catch(e){}
	return false;
}

//Enabluje Objekt
function enableObject(objName)
{
	try
	{
		getObj(objName).disabled = false;
	}catch(e){}
}
//Disabluje Objekt
function disableObject(objName)
{
	try
	{
		getObj(objName).disabled = true;
	}catch(e){}
}
function ValidForm(mForm)
{
	//Reference na form
	if(mForm!=null) return true;
	return false;
}	

//Konverze
function toInt(strValue)
{
	strValue = strValue.toString();
	var i = 0;
	try
	{
		i = parseInt(strValue);
	}catch(e){}
	return i;
}

//Nastavi focus na prvek a pokud se preda isValidErr tak i obarvi
function setFocus(elemName,isValidErr)
{
	try{
		var mObj = getObj(elemName);
		if(isObj(mObj))
		{
			if(isObj(isValidErr))
			{
				//Nastavi pozadi zpet
				var mObjTmp = document.getElementsByTagName('input');
				if(isObj(mObjTmp))
				{
					for(i=mObjTmp.length-1;i>=0;i--) if(isObj(mObjTmp[i].bbc)) mObjTmp[i].style.backgroundColor=mObjTmp[i].bbc;
				}
				//Obarvi pozadi
				if(mObj.type=='text' || mObj.type=='password' || mObj.type=='button')
				{	
					if(!isObj(mObj.bbc)) mObj.bbc=mObj.style.backgroundColor;
					mObj.style.backgroundColor='#FFCFCF';
				}
			}
			//Nastavi focus
			mObj.focus();
		}
	}catch(e){}
}

function hideElements(tagName,prefix,len)
{
	var oTmp = getObj('oDivPage').getElementsByTagName(tagName);
	for(i=oTmp.length-1;i>=0;i--)
	{
		if(isObj(oTmp[i].id))
		{
			if(oTmp[i].id.substring(0,len)==prefix)
			{
				oTmp[i].innerHtml='';
				oTmp[i].style.display='none';
				oTmp[i].style.visibility='hidden';
			}
		}
	}
}

function keyDown()
{
	if(event.keyCode==27)
	{
		CloseLayerWindow();
		hideLayerBox();
	}
}

function pageWidth() {return window.innerWidth != null? window.innerWidth: document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth:document.body != null? document.body.clientWidth:null;}
function pageHeight() {return (window.innerHeight != null? window.innerHeight: document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight:document.body != null? document.body.clientHeight:null);}
function posLeft() {return typeof window.pageXOffset != 'undefined' ? window.pageXOffset:document.documentElement && document.documentElement.scrollLeft? document.documentElement.scrollLeft:document.body.scrollLeft? document.body.scrollLeft:0;}
function posTop() {return typeof window.pageYOffset != 'undefined' ? window.pageYOffset:document.documentElement && document.documentElement.scrollTop? document.documentElement.scrollTop: document.body.scrollTop?document.body.scrollTop:0;}

//projde vsechny checkboxy a zaskrne nebo odskrtne
function checkbox_Process(checkboxPrefix,checked)
{
	
	var allChbx = document.getElementsByTagName('input');
	for(i=0;i<allChbx.length;i++)
	{
		if(allChbx[i].id.substring(0,checkboxPrefix.length)==checkboxPrefix) allChbx[i].checked = checked;
	}
}
function VlozitSmajlika(title)
{
	getObj("message").value += ' (~'+title+'~) ';
	getObj("message").focus();
}

