//funkce pro kontrolu zadaneho cisla

function CheckNumEdit(Edit)
{
	//prevod vstupu na cislo
	var S = Edit.value - 0;
	//kontrola zda se jedna o cislo
	if ((parseInt (S) == NaN) || (parseInt (S)+'' != S)) 
	{
		Edit.value = '1';
		Edit.focus();
		Edit.select();
	}
	else
	{
		if (S == 0) S = 1;
		Edit.value = parseInt (S);
	}
}

function numbersOnly(field, event)
{
	var key, keychar;
	
	if (window.event)
		key = window.event.keyCode;
	else if (event)
		key = event.which;
	else return true;
	
	keychar = String.fromCharCode(key);
	
	if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27))
	{
		window.status = "";
		return true;
	}
	else if ((("0123456789").indexOf(keychar) > -1))
	{
		window.status = "";
		return true;
	}
	else
	{
		window.status = "v poli lze uvádět pouze číselné hodnoty";
		return false;
	}
}
		
function SetPostovne(postovne,cenacelkem)
{
	document.pokladna.postovne.value = postovne;
	document.pokladna.cenacelkem.value = parseInt(document.pokladna.dobirkovne.value) + cenacelkem + postovne;
}

function SetDobirkovne(dobirkovne,cenacelkem)
{
	document.pokladna.dobirkovne.value = dobirkovne;
	document.pokladna.cenacelkem.value = parseInt(document.pokladna.postovne.value) + cenacelkem + dobirkovne;
}

function dorucadres(){
	if (document.forms[3].cust_is_doruc.checked == false)
		{
			document.forms[3].doruc_street.disabled = false;
			document.forms[3].doruc_city.disabled = false;
			document.forms[3].doruc_psc.disabled = false;
			document.forms[3].doruc_street.style.backgroundColor = "white";
			document.forms[3].doruc_city.style.backgroundColor = "white";	
			document.forms[3].doruc_psc.style.backgroundColor = "white";	
		}
		else
		{
			document.forms[3].doruc_street.disabled = true;	
			document.forms[3].doruc_city.disabled = true;
			document.forms[3].doruc_psc.disabled = true;
			document.forms[3].doruc_street.style.backgroundColor = "lavender";	
			document.forms[3].doruc_city.style.backgroundColor = "lavender";	
			document.forms[3].doruc_psc.style.backgroundColor = "lavender";
			document.forms[3].doruc_street.value = document.forms[3].cust_street.value;	
			document.forms[3].doruc_city.value = document.forms[3].cust_city.value;	
			document.forms[3].doruc_psc.value = document.forms[3].cust_psc.value;	
		}
}

function organiz(){
	if (document.forms[3].organizace.checked == true)
		{
			//document.forms[3].organizace_name.disabled = false;
			document.forms[3].organizace_ico.disabled = false;
			document.forms[3].organizace_dic.disabled = false;
			//document.forms[3].organizace_name.style.backgroundColor = "white";
			document.forms[3].organizace_ico.style.backgroundColor = "white";	
			document.forms[3].organizace_dic.style.backgroundColor = "white";	
		}
		else
		{
			//document.forms[3].organizace_name.disabled = true;	
			document.forms[3].organizace_ico.disabled = true;
			document.forms[3].organizace_dic.disabled = true;
			//document.forms[3].organizace_name.style.backgroundColor = "lavender";	
			document.forms[3].organizace_ico.style.backgroundColor = "lavender";	
			document.forms[3].organizace_dic.style.backgroundColor = "lavender";	
		}
}

function dorucadres2(){
	if (document.forms[2].cust_is_doruc.checked == false)
		{
			document.forms[2].doruc_street.disabled = false;
			document.forms[2].doruc_city.disabled = false;
			document.forms[2].doruc_psc.disabled = false;
			document.forms[2].doruc_street.style.backgroundColor = "white";
			document.forms[2].doruc_city.style.backgroundColor = "white";	
			document.forms[2].doruc_psc.style.backgroundColor = "white";	
			document.forms[2].doruc_street.value = document.forms[2].cust_street.value;	
			document.forms[2].doruc_city.value = document.forms[2].cust_city.value;	
			document.forms[2].doruc_psc.value = document.forms[2].cust_psc.value;	
		}
		else
		{
			document.forms[2].doruc_street.disabled = true;	
			document.forms[2].doruc_city.disabled = true;
			document.forms[2].doruc_psc.disabled = true;
			document.forms[2].doruc_street.style.backgroundColor = "lavender";	
			document.forms[2].doruc_city.style.backgroundColor = "lavender";	
			document.forms[2].doruc_psc.style.backgroundColor = "lavender";	
		}
}

function organiz2(){
	if (document.forms[2].organizace.checked == true)
		{
			//document.forms[2].organizace_name.disabled = false;
			document.forms[2].organizace_ico.disabled = false;
			document.forms[2].organizace_dic.disabled = false;
			//document.forms[2].organizace_name.style.backgroundColor = "white";
			document.forms[2].organizace_ico.style.backgroundColor = "white";	
			document.forms[2].organizace_dic.style.backgroundColor = "white";	
		}
		else
		{
			//document.forms[2].organizace_name.disabled = true;	
			document.forms[2].organizace_ico.disabled = true;
			document.forms[2].organizace_dic.disabled = true;
			//document.forms[2].organizace_name.style.backgroundColor = "lavender";	
			document.forms[2].organizace_ico.style.backgroundColor = "lavender";	
			document.forms[2].organizace_dic.style.backgroundColor = "lavender";	
		}
}

