function checkIsNumber(x, inCart)
{
	if (isNaN(eval('document.forms[0]._txtCount' + x + '.value')))
	{
		eval('document.forms[0]._txtCount' + x + '.value = "1"');
	}
	
	if (inCart && !eval('document.forms[0]._txtCount' + x + '.value == ""'))
	{
		RefreshCart();
	}
}

function DoCountPlus(x, inCart)
{
	eval('document.forms[0]._txtCount' + x + '.value = parseInt(document.forms[0]._txtCount' + x + '.value) + 1');
	
	if (inCart)
	{
		RefreshCart();
	}
}

function DoCountMinus(x, inCart)
{
	if (parseInt(eval('document.forms[0]._txtCount' + x + '.value')) > 1)
	{
		eval('document.forms[0]._txtCount' + x + '.value = parseInt(document.forms[0]._txtCount' + x + '.value) - 1');
	}
	
	if (inCart)
	{
		RefreshCart();
	}
}

function AddToCart(artid, hasAtr, txt)
{
	if (hasAtr)
	{
		var tested = true;
		
		var TextFelder = document.getElementsByTagName("input");
		for (var i = 0; i < TextFelder.length; i ++)
		{
			if (TextFelder[i].name.search('_txtAttribut') >= 0)
			{
				if (TextFelder[i].value == '')
				{
					tested = false;
				}
			}
		} 
		
		var DropFelder = document.getElementsByTagName("select");
		for (var i = 0; i < DropFelder.length; i ++)
		{
			if (DropFelder[i].name.search('_drpAttribut') >= 0)
			{
				if (DropFelder[i].value != "-1.00" && DropFelder[i].value == -1)
				{
					tested = false;
				}
			}
		}
		
		if (tested)
		{
			if (isNaN(eval('document.forms[0]._txtCount' + artid + '.value')) || eval('document.forms[0]._txtCount' + artid + '.value == \'\''))
			{
				alert (txt);
			}
			else
			{
				RedirectCart(artid);
			}
		}
		else
		{
			alert(txt);
		}
		
	}
	else
	{
		RedirectCart(artid);
	}
}
function RedirectCart(artid)
{
	var theForm = document.forms[0];
	if (!theForm) {
		theForm = document.forms['myForm'];
	}
	if (!theForm) {
		theForm = document.myForm;
	}
	
	if (! isNaN(eval('theForm._txtCount' + artid + '.value')))
	{
		theForm.method = 'POST';
		theForm.action = 'default.aspx?modul=eshop&eShopAction=AddToBasket&artid=' + artid;
		theForm.submit();
	}
}

function RefreshCart()
{
	var theForm = document.forms[0];
	if (!theForm) {
		theForm = document.forms['myForm'];
	}
	if (!theForm) {
		theForm = document.myForm;
	}
	
	theForm.method = 'POST';
	theForm.action = 'default.aspx?modul=eshop&eShopAction=RefreshBasket';
	theForm.submit();
}

function eShopLogin(redirectok, redirectfail)
{
	var theForm = document.forms[0];
	if (!theForm) {
		theForm = document.forms['myForm'];
	}
	if (!theForm) {
		theForm = document.myForm;
	}
	
	theForm.method = 'POST';
	
	if (redirectok) {
		theForm.LoginRedirect.value = redirectok;
	}
	if (redirectfail) {
		theForm.LoginFailRedirect.value = redirectfail;
	}
	
	if (theForm._txteMailBasket && theForm._txteMailBasket.value != '') {
		theForm._txteMail.value = theForm._txteMailBasket.value;
	}
	if (theForm._txtPassBasket && theForm._txtPassBasket.value != '') {
		theForm._txtPass.value = theForm._txtPassBasket.value;
	}
	
	theForm.action = 'default.aspx?modul=eshop&eShopAction=Login';
	theForm.submit();
}

function GetPassword()
{
	var theForm = document.forms[0];
	if (!theForm) {
		theForm = document.forms['myForm'];
	}
	if (!theForm) {
		theForm = document.myForm;
	}
	
	theForm.method = 'POST';
	theForm.action = 'default.aspx?modul=eshop&eShopAction=GetPassword';
	theForm.submit();
}

function RegisterUser()
{
	var theForm = document.forms[0];
	if (!theForm) {
		theForm = document.forms['myForm'];
	}
	if (!theForm) {
		theForm = document.myForm;
	}
	
	theForm.method = 'POST';
	theForm.action = 'default.aspx?modul=eshop&eShopAction=RegisterUser';
	theForm.submit();
}

function EditUser()
{
	var theForm = document.forms[0];
	if (!theForm) {
		theForm = document.forms['myForm'];
	}
	if (!theForm) {
		theForm = document.myForm;
	}
	
	theForm.method = 'POST';
	theForm.action = 'default.aspx?modul=eshop&eShopAction=UserEdit';
	theForm.submit();
}

function UpdateOrderStepOne(x)
{
	var theForm = document.forms[0];
	if (!theForm) {
		theForm = document.forms['myForm'];
	}
	if (!theForm) {
		theForm = document.myForm;
	}
	
	theForm.method = 'POST';
	theForm.PostBackData.value = 'true';
	theForm.action = 'default.aspx?modul=eshop&eShopAction=orderStep1';
	if (x)
		theForm.action += '&eShop_RedirectStep2=true';
	theForm.submit();
}

function UpdateOrderStepTwo(x)
{
	var theForm = document.forms[0];
	if (!theForm) {
		theForm = document.forms['myForm'];
	}
	if (!theForm) {
		theForm = document.myForm;
	}
	
	theForm.method = 'POST';
	theForm.PostBackData.value = 'true';
	theForm.action = 'default.aspx?modul=eshop&eShopAction=orderStep2';
	if (x)
		theForm.action += '&eShop_RedirectOrder=true';
	theForm.submit();
}