
////////////////////////////////////////////////////////////
//
function getElement(id) 
{
	// IE x Netscape
	return document.all ? document.all(id) 
					    : document.getElementById ? document.getElementById(id) 
												  : document.layers ? document.layers[id] 
												                    : null;
}

///////////////////////////////////////////////////////////////////////
//
function ConvertToBool(val)
{
	if(typeof(val) == "string")
		return val == "True";
	
	return val > 0;
}

///////////////////////////////////////////////////////////////////////
// Otestovani vstupu pro edity, do kterych se smeji vkladat hodnoty typu int
function TestIntValue()
{
	// Test pri vstupu dat z clipboardu
	if(event.type == "paste")
	{
		var s = new String;
		var i;
	
		s = window.clipboardData.getData("Text");
	
		event.returnValue = true;
	
		for(i = 0; i < s.length; i++)
		{
			var a = s.charCodeAt(i);
			if(a < 48 || a > 48 + 10)
			{
				event.returnValue = false;
				break;
			}
		}
	}
	else
		// Test pri vstupu dat z klavesnice
	{
		if(event.keyCode >= 48 && event.keyCode <= 48 + 10)
			event.returnValue = true;
		else
			event.returnValue = false;
	}
}

///////////////////////////////////////////////////////////////////////
// Otestovani vstupu pro edity, do kterych se smeji vkladat hodnoty typu double
function TestDoubleValue()
{
	// Test pri vstupu dat z clipboardu
	if(event.type == "paste")
	{
		var s = new String;
		var i;
	
		s = window.clipboardData.getData("Text");
	
		event.returnValue = true;
	
		for(i = 0; i < s.length; i++)
		{
			var a = s.charCodeAt(i);
			if((a < 48 || a > 48 + 10) && a != ',' && a != '.')
			{
				event.returnValue = false;
				break;
			}
		}
	}
	else
		// Test pri vstupu dat z klavesnice
	{
		if ((event.keyCode >= 48 && event.keyCode <= 48 + 10) ||
			event.keyCode == 44 || event.keyCode == 46)
			event.returnValue = true;
		else
			event.returnValue = false;
	}
}

//////////////////////////////////////////////////////////////////////
// Otestovani vstupu pro edity, do kterych se smeji vkladat hodnoty typu date
function TestDateValue()
{
	// Test pri vstupu dat z clipboardu
	if(event.type == "paste")
	{
		var s = new String;
		var i;
	
		s = window.clipboardData.getData("Text");
	
		event.returnValue = true;
	
		for(i = 0; i < s.length; i++)
		{
			var a = s.charCodeAt(i);
			if((a < 48 || a > 48 + 10) && a != '.' && a != '/' && a != '-')
			{
				event.returnValue = false;
				break;
			}
		}
	}
	else
		// Test pri vstupu dat z klavesnice
	{
		if ((event.keyCode >= 48 && event.keyCode <= 48 + 10) ||
			event.keyCode == 46 || event.keyCode == 47 || event.keyCode == 45)
			event.returnValue = true;
		else
			event.returnValue = false;
	}
}

///////////////////////////////////////////////////////////////////////
//
function OnChangeMandatoryTextBox(edit)
{
	if(edit.value != "")
	{
		if(typeof(edit.oldclass) != "undefined")
			edit.className = edit.oldclass;
	}
	else
	{
		if(typeof(edit.oldclass) == "undefined")
			edit.oldclass  = edit.className;
			
		edit.className = edit.MandatoryClass;
	}	
}

//////////////////////////////////////////////////////////////////////
// Funkce je volana pri stisku tlacitka ButtonEx
function ButtonEx_OnClick(button, causesValidation, message)
{
	if(button.isDisabled) 
		return false
	
	if(causesValidation)
	{
		if(typeof(Page_ClientValidate) == "function") 
		{
			if(!Page_ClientValidate())
				return false;
		}
	}
		
	if(message != "")
	{
		if(confirm(message) != true)
			return false;								
	}	
}

//////////////////////////////////////////////////
// Pridani scriptu na zobrazeni zprav po nacteni stranky
// Do stranky se MUSI do elementu body pridat onload="ShowLoadMessage();"
var strLoadMessages = new Array;

function ShowLoadMessage()
{
	for(var i = 0; i < strLoadMessages.length; i++)
	{
		window.alert(strLoadMessages[i]);
	}
}

////////////////////////////////////////
// Send string to server	
function SendStringToServer(value, name)
{
	var input = window.document.createElement('INPUT');                            
	input.value = value;
	input.name = name;
	input.type = 'hidden';
	
	document.forms[0].appendChild(input);
}
