function SendKalkulacia()
{
	if (document.form.kod.value.length>5)
	{
		if (!CheckSubory())
		{
			if (document.form.otvor_a.value.length<1)
			{
				alert("Zadaj otvor A!!!");
				return;
			}
			if (document.form.otvor_b.value.length<1)
			{
				alert("Zadaj otvor B!!!");
				return;
			}
			if (document.form.otvor_c.value.length<1)
			{
				alert("Zadaj otvor C!!!");
				return;
			}
			if (document.form.otvor_d.value.length<1)
			{
				alert("Zadaj otvor D!!!");
				return;
			}		
			if (document.form.otvor_e.value.length<1)
			{
				alert("Zadaj otvor E!!!");
				return;
			}
			if (document.form.otvor_f.value.length<1)
			{
				alert("Zadaj otvor F!!!");
				return;
			}
			if (document.form.otvor_g.value.length<1)
			{
				alert("Zadaj otvor G!!!");
				return;
			}
			if (getCheckedValue(document.form.tvar)=="")
			{
				alert("Zadaj tvar schodiska!!!");
				return;
			}
			if (getCheckedValue(document.form.typ)<1)
			{
				alert("Zadaj typ schodiska!!!");
				return;
			}
			if (document.form.parenyAgat.checked==false && document.form.buk.checked==false && document.form.dub.checked==false && document.form.jasen.checked==false)
			{
				alert("Zadaj material!!!");
				return;
			}
		}	
		if (document.form.meno.value.length<5)
		{
			alert("Zadaj meno/názov firmy!!!");
			return;
		}
		if (document.form.miesto.value.length<5)
		{
			alert("Zadaj miesto realizácie!!!");
			return;
		}
		if (!CheckEmail(document.form.email.value))
			return;
		if (document.form.telefon.value.length<7)
		{
			alert("Zadaj telefon!!!");
			return;
		}	
		
		if (!(SendKalkulacia.arguments[0]==undefined))
		{
			if (SendKalkulacia.arguments[0]==1)
				document.form.odoslat.value='a';
			else
				document.form.odoslat2.value='a';
			
			document.form.submit();
		}
	}
	else
	{
		alert("Nezadali ste overovací kód!!!");
	}
}
	
	function CheckEmail(S) 
	{  
		var stav=true;
		var LastChar = S.length - 1;
	  var CharPos = S.indexOf("@");
	  if ((CharPos < 1) || (CharPos == LastChar)) stav=false;
	  var CharPos = S.indexOf(".");
	  if (CharPos < 1) stav=false;
	  var CharPos = S.lastIndexOf(".");
	  if (CharPos == LastChar) stav=false;
		
		if (!stav)
		{
			alert ("Zle vyplnený e-mail !!!");
			return false;
		}
		else
		  return true;
}

function CheckSubory()
{
	if(document.form.subor_1.value.length>0)return true;
	if(document.form.subor_2.value.length>0)return true;
	if(document.form.subor_3.value.length>0)return true;
	if(document.form.subor_4.value.length>0)return true;
	if(document.form.subor_5.value.length>0)return true;
	return false;
}

function getCheckedValue(radioObj) 
{
	if(!radioObj)	return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) 
	{
		if(radioObj[i].checked) 
		{
			return radioObj[i].value;
		}
	}
	return "";
}


