function add(Id)
{
    	
    var bskt=document.getElementById('ids').innerHTML;
    
    new Request.HTML ({  
    			url: '/add.php?id='+Id,
    			onSuccess: function(html) {
    				$("num").set('html','');
    				$("num").adopt(html);
    			}
    		      }).send();
    
    if(bskt.indexOf(';'+Id+';')==-1) 
	 { alert('Товар успешно добавлен в корзину'); document.getElementById('ids').innerHTML = document.getElementById('ids').innerHTML + Id + ";";} else {  alert('Товар уже находится в Вашей корзине'); }
}

function dGoods(id)
{
	/*var myRequest = new Request({method: 'get', url: '/cart_del.php'});
	myRequest.send('id=' + id);
	window.location.reload();*/
	new Request({method: 'get', url: '/cart_del.php',
			onSuccess: function(html) {window.location.reload()}}).send('id=' + id);
}

function numCheck(str)
{	
    var LastSymbol = "";
    var nameTeg = str.name;
    var valueTeg = str.value;
    var i=1;
    if(valueTeg != "" || valueTeg != " ")
    { 
        if(isNaN(valueTeg))
        {
            if(valueTeg.indexOf(" ") != '-1') { LastSymbol = valueTeg.substring(valueTeg.length - 1,valueTeg.length); i=2; }
            document.all(nameTeg).value = valueTeg.substring(0,valueTeg.length-i) + LastSymbol;
            document.all(nameTeg).focus();
        }
    }
}

function check_email(t)
{
    if(t.indexOf('@', 0) == -1) return false;
    return true;	 
}

function GenerateOrder()
{
    fio = document.orderform.fio.value;
    phone = document.orderform.tel.value;
    email = document.orderform.email.value;
    address = document.orderform.adr.value;
    
    if (trim(fio)=='' || trim(phone)=='' || trim(address)=='') {alert('необходимо указать все обязательные поля'); return false;}
    if (trim(email) !=''){if (!check_email(email)) {alert('Неверный формат e-mail'); return false;}}
    
    return true;
}



