function CheckLogin(f)
{	if (f.customer_email.value=="")
	{	alert('Zadejte emailovou adresu ...');
		f.customer_email.focus();
		return false;
	}
	if (f.customer_password.value=="" || f.customer_password.value=="heslo")
	{	alert('Zadejte heslo ...');
		f.customer_password.focus();
		return false;
	}
	return true;
}

function CheckSearch(f)
{	if (f.search_string.value=="")
	{	alert('Zadejte slovo pro vyhledávání ...');
		f.search_string.focus();
		return false;
	}
	return true;
}

function cislaplus(myfield, e, plus)
{	var key; var keychar;
	if (window.event) key = window.event.keyCode;
	else if (e) key = e.which; else return true;
	keychar = String.fromCharCode(key);
	if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27) ) return true;
	else if ((("0123456789"+plus).indexOf(keychar) > -1)) return true; else return false;
}

function checkMail(email)
{	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	return filter.test(email);
}

isDate = function(y, m, d)
{	if (typeof y == "string" && m instanceof RegExp && d)
	{	if(!m.test(y)) return 1;
		y = RegExp["$" + d.y], m = RegExp["$" + d.m], d = RegExp["$" + d.d];
	}
	d = Math.abs(d) || 0, m = Math.abs(m) || 0, y = Math.abs(y) || 0;
	return arguments.length != 3 ? 1 : d < 1 || d > 31 ? 2 : m < 1 || m > 12 ? 3 : /4|6|9|11/.test(m) && d == 31 ? 4        : m == 2 && (d > ((y = !(y % 4) && (y % 1e2) || !(y % 4e2)) ? 29 : 28)) ? 5 + !!y : 0;
};

function numberformat(n,DECIMAL_POINT,THOUSANDS_SEP)
{	n += '';
	x = n.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? DECIMAL_POINT + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + THOUSANDS_SEP + '$2');
	}
	return x1 + x2;
}

function IntoBasket(product_id, option_set_id)
{	product_quantity=Number(document.forms.frm_amount.product_quantity.value);
	if (product_quantity<=0) product_quantity=1;
	window.location.href='/scripts/intobasket.php?product_id='+product_id+'&option_set_id='+option_set_id+'&product_quantity='+product_quantity;
}

function BasketAction(A)
{	switch (A)
	{	case "CASHDESK":
			document.forms.frm_basket.action.value='CASHDESK'
			document.forms.frm_basket.submit();
		break;
		case "RECOUNT":
			document.forms.frm_basket.action.value='RECOUNT'
			document.forms.frm_basket.submit();
		break;
		case "EMPTY":
			if (confirm('Opravdu si přejete vyprázdnit nákupní košík ?')) window.location.href='/scripts/clear_basket.php';
		break;
	}
}

function RemoveItem(product_id, option_set_id)
{	window.location.href='scripts/recount_basket.php?product_id='+product_id+'&option_set_id='+option_set_id;
}

function PutRating(product_id, product_rating_nr)
{	window.location.href='/scripts/put_rating.php?product_id='+product_id+'&product_rating_nr='+product_rating_nr;
}

function SbmtManForm(manufacturer_name_url, f)
{	f.action="/vyrobce/"+manufacturer_name_url;
	f.submit();
}