function ChangeQnty (f, id, sign) {
	if (eval("document."+ f +".cougood" + id + ".value") >= '0')
	{
		Qnty = parseInt(eval("document." + f +".cougood" + id + ".value"));
		Qnty = Qnty + parseInt(sign);
		
		if (Qnty <= 1) Qnty = "1";
		eval("document."+ f +".cougood" + id + ".value=" + Qnty);
	}
	if ((eval("document."+ f +".cougood" + id + ".value") == "") && (sign == 1)) 
	{	
		Qnty = 1;
		eval("document."+ f +".cougood" + id + ".value=" + Qnty);
	}
	return;
}

function add2basket(id)
	{
		document.getElementById('basketFrame').src = "/basket/basket_small.php?action=add&id="+id+"&count=1";
	}

function validate_reg_form()
{

	if (document.reg_form.login.value=="")
		{
			alert("Вы забыли указать логин!");
			document.reg_form.login.focus();
			return false;
		}

	if (document.reg_form.password.value=="")
		{
			alert("Вы забыли указать пароль!");
			document.reg_form.password.focus();
			return false;
		}

	if (document.reg_form.password2.value=="")
		{
			alert("Вы забыли повторить пароль!");
			document.reg_form.password2.focus();
			return false;
		}

	if (document.reg_form.password2.value!=document.reg_form.password.value)
		{
			alert("Введенные пароли не совпадают!");
			document.reg_form.password.value = "";
			document.reg_form.password2.value = "";
			document.reg_form.password.focus();
			return false;
		}

	if (document.reg_form.name_user.value=="")
		{
			alert("Вы забыли указать ФИО!");
			document.reg_form.name_user.focus();
			return false;
		}

	if (document.reg_form.email.value!="")
		{
			obj = document.reg_form.email;
    		if (
    			obj.value.indexOf('@') < 1 ||
				obj.value.indexOf('@') == obj.value.length - 1 ||
      			obj.value.lastIndexOf('@') != obj.value.indexOf('@') ||
				obj.value.indexOf('.') < 1 ||
				obj.value.indexOf('.') == obj.value.length - 1 ||
      			obj.value.lastIndexOf('.') < obj.value.indexOf('@')
      			) 
				{
      				alert("Проверьте правильность написания e-mail.");
      				obj.focus();
      				return false;
    			}
    	}
    else
    	{
			alert("Вы забыли указать e-mail!");
			document.reg_form.email.focus();
			return false;
		}


		if (document.reg_form.tel_kont.value=="")
			{
				alert("Вы забыли указать телефон!");
				document.reg_form.tel_kont.focus();
				return false;
			}
		else
			{
				obj = document.reg_form.tel_kont;
    			n = obj.value.length;
				str= obj.value;
    			for (i = 0; i < n; i ++)
    				{
    					if ((str.charAt(i)=='0') || (str.charAt(i)=='1') || (str.charAt(i)=='2') || (str.charAt(i)=='3') || (str.charAt(i)=='4') || (str.charAt(i)=='5') ||
        					(str.charAt(i)=='6') || (str.charAt(i)=='7') || (str.charAt(i)=='8') || (str.charAt(i)=='9') || (str.charAt(i)=='(') || (str.charAt(i)==')') ||
        					(str.charAt(i)==' ') || (str.charAt(i)=='-'))
        					{}
    					else
    						{
    							alert("Проверьте правильность написания контактного телефона.");
      							obj.focus();
      							return false;
    						}
    				}
			}

	if (document.reg_form.tel_mob.value!="")
		{
			obj = document.reg_form.tel_kont;
    		n = obj.value.length;
			str= obj.value;
    		for (i = 0; i < n; i ++)
    			{
    				if ((str.charAt(i)=='0') || (str.charAt(i)=='1') || (str.charAt(i)=='2') || (str.charAt(i)=='3') || (str.charAt(i)=='4') || (str.charAt(i)=='5') ||
        				(str.charAt(i)=='6') || (str.charAt(i)=='7') || (str.charAt(i)=='8') || (str.charAt(i)=='9') || (str.charAt(i)=='(') || (str.charAt(i)==')') ||
        				(str.charAt(i)==' ') || (str.charAt(i)=='-'))
        				{}
    				else
    					{
    						alert("Проверьте правильность написания мобильного телефона.");
      						obj.focus();
      						return false;
    					}
    			}
		}

	if (document.reg_form.address_delivery.value=="")
		{
			alert("Вы забыли указать адрес доставки!");
			document.reg_form.address_delivery.focus();
			return false;
		}


	if (document.reg_form.data_dost.value=="")
		{
			alert("Вы забыли указать желаемую дату доставки!");
			document.reg_form.data_dost.focus();
			return false;
		}

	return true;
}

function show_photo(path) {
	popupWin = window.open('/show_photo.php?photo=' + path, "Photo","directories=no,height=240,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no,width=320, top=250, left=300");
	popupWin.focus();
	return false;
}