function newWindow(elm, sirka, vyska)
{ 
	vlastnosti = "width="+sirka+", height="+vyska+", left=10, top=10, resizable=yes";

	if (window.open(elm.href, elm.target, vlastnosti))
	{ 
		return true; 
	}
	
	return false; 
}

function checkEmail(address)
{
	re = /^[^.]+(\.[^.]+)*@([^.]+[.])+[a-z]{2,3}$/;
	return address.search(re) == 0;
}

function checkOrder()
{
	var bOrder = true;
	
	document.getElementById('Subject').style.backgroundColor = "#ffffff";
	document.getElementById('Name1').style.backgroundColor = "#ffffff";
	document.getElementById('Address1').style.backgroundColor = "#ffffff";
	document.getElementById('City1').style.backgroundColor = "#ffffff";
	document.getElementById('Zip1').style.backgroundColor = "#ffffff";
	document.getElementById('Phone').style.backgroundColor = "#ffffff";
	document.getElementById('Email').style.backgroundColor = "#ffffff";
	document.getElementById('Bussines1').style.backgroundColor = "#ffffff";
	document.getElementById('Bussines2').style.backgroundColor = "#ffffff";
	
	if(document.getElementById('Payment').value=="0")
	{
		window.alert("Před odesláním formuláře musíte vybrat způsob platby!");
		document.getElementById('Payment').style.backgroundColor = "#ffb0b0";
		document.getElementById('Payment').focus();
		bOrder = false;
	}
	else if(document.getElementById('Delivery').value=="0")
	{
		window.alert("Před odesláním formuláře musíte vybrat způsob dodání!");
		document.getElementById('Delivery').style.backgroundColor = "#ffb0b0";
		document.getElementById('Delivery').focus();
		document.getElementById('Payment').style.backgroundColor = "#ffffff";
		bOrder = false;
	}
	else if(document.getElementById('Subject').value=="0")
	{
		window.alert("Před odesláním formuláře musíte vybrat subjekt!");
		document.getElementById('Subject').style.backgroundColor = "#ffb0b0";
		document.getElementById('Subject').focus();
		bOrder = false;
	}
	else if(document.getElementById('Name1').value=="")
	{
		window.alert("Před odesláním formuláře musíte vyplnit název společnosti!");
		document.getElementById('Name1').style.backgroundColor = "#ffb0b0";
		document.getElementById('Name1').focus();
		bOrder = false;
	}
	else if(document.getElementById('Address1').value=="")
	{
		window.alert("Před odesláním formuláře musíte vyplnit adresu!");
		document.getElementById('Address1').style.backgroundColor = "#ffb0b0";
		document.getElementById('Address1').focus();
		bOrder = false;
	}
	else if(document.getElementById('City1').value=="")
	{
		window.alert("Před odesláním formuláře musíte vyplnit město!");
		document.getElementById('City1').style.backgroundColor = "#ffb0b0";
		document.getElementById('City1').focus();
		bOrder = false;
	}
	else if(document.getElementById('Zip1').value=="")
	{
		window.alert("Před odesláním formuláře musíte vyplnit PSČ!");
		document.getElementById('Zip1').style.backgroundColor = "#ffb0b0";
		document.getElementById('Zip1').focus();
		bOrder = false;
	}
	else if(document.getElementById('Phone').value=="")
	{
		window.alert("Před odesláním formuláře musíte vyplnit telefon!");
		document.getElementById('Phone').style.backgroundColor = "#ffb0b0";
		document.getElementById('Phone').focus();
		bOrder = false;
	}
	else if(!checkEmail(document.getElementById('Email').value))
	{
		window.alert("Před odesláním formuláře musíte vyplnit email!");
		document.getElementById('Email').style.backgroundColor = "#ffb0b0";
		document.getElementById('Email').focus();
		bOrder = false;
	}
	else if(document.getElementById('Subject').value=="Firma" && document.getElementById('Bussines1').value=="")
	{
		window.alert("Před odesláním formuláře musíte vyplnit IČO!");
		document.getElementById('Bussines1').style.backgroundColor = "#ffb0b0";
		document.getElementById('Bussines1').focus();
		bOrder = false;
	}
	else if(document.getElementById('Subject').value=="Firma" && document.getElementById('Bussines2').value=="")
	{
		window.alert("Před odesláním formuláře musíte vyplnit DIČ!");
		document.getElementById('Bussines2').style.backgroundColor = "#ffb0b0";
		document.getElementById('Bussines2').focus();
		bOrder = false;
	}
	else if(!document.getElementById('Agree').checked)
	{
		window.alert("Před odesláním formuláře musíte souhlasit s obchodními podmínkami!");
		bOrder = false;
	}
	
	return bOrder;
}

function changePrice()
{
	var FinalPrice = document.getElementById('PriceVatTemp').value;

	var dot = FinalPrice.indexOf(".");
	var DecimalPlaces = '.00';
	
	if (dot > -1)
	{
		DecimalPlaces = FinalPrice.substring(dot, FinalPrice.length);	
	}

	FinalPrice = parseInt(FinalPrice);
	
	var PaymentMethod = document.getElementById('Payment').value;
	var DeliveryMethod = document.getElementById('Delivery').value;
	
	if (FinalPrice < 5000)
	{	
		if (PaymentMethod == 'Dobírkou - při převzetí zboží od přepravce TEX (50,- Kč)')
		{
			FinalPrice = FinalPrice + 50;
			document.getElementById('paymentRow').style.display = "block";
		}
		else
		{
			document.getElementById('paymentRow').style.display = "none";
		}
		
		if (DeliveryMethod == 'Dodání zboží přepravcem TEX (90,- Kč)')
		{
			FinalPrice = FinalPrice + 90;
			document.getElementById('deliveryRow').style.display = "block";
		}
		else
		{
			document.getElementById('deliveryRow').style.display = "none";
		}
	
		document.getElementById('PriceVat').value = parseFloat(FinalPrice + DecimalPlaces).toFixed(2);
	}
	else
	{
		if (PaymentMethod == 'Dobírkou - při převzetí zboží od přepravce TEX (50,- Kč)')
		{
			document.getElementById('paymentRowFree').style.display = "block";
		}
		else
		{
			document.getElementById('paymentRowFree').style.display = "none";
		}
		
		if (DeliveryMethod == 'Dodání zboží přepravcem TEX (90,- Kč)')
		{
			document.getElementById('deliveryRowFree').style.display = "block";
		}
		else
		{
			document.getElementById('deliveryRowFree').style.display = "none";
		}
	}
}



