﻿function CheckProduct()
{
    //alert("CheckProduct");
    var err="";
    if($("txCantitate").value!="" && isPozIntNum($("txCantitate").value)){
        cant=$("txCantitate").value;
    }
    else{
        err+= getJSPH("Comanda_Va rugam introduceti o cantitate numar intreg pozitiv.")+"\n";
    }
//    try{
//        buget=($("txBuget").value).replace(",",".");
//    }
//    catch(ex) {buget="";}
//    if(buget!=""){
//        if (isPozNum(buget) &&  parseFloat(buget) >= parseFloat(($("spPrice").innerHTML).replace(",",".")) +10){
//            
//        }
//        else{
//            err+=getJSPH("Comanda_Va rugam introduceti o suma cu cel putin 10 EUR mai mult.")+"\n";
//        }
//    }
    locatie=0;
    try{ locatie = $("ddCity").value;} catch(ex) {}
    try{ locatie = $("ddCountry").value;} catch(ex) {}
    if(locatie ==0)
    {
        err+= getJSPH("Comanda_Va rugam introduceti o locatie pentru livrare.")+"\n";
    }
    if(err!=""){ alert(err); }
    else { $("hAction").value = "AddToChart"; $("frmMain").submit(); }
}


function AddToCart(pid, location)
{
    var err="";   var cant="";
    if($("txCantitate").value!="" && isPozIntNum($("txCantitate").value)){
      cant=$("txCantitate").value;
    }
    else{
     err=jetJSPH("Comanda_Va rugam introduceti o cantitate pozitiva.")+"\n";
    }
    
    if(err!=""){ alert(err); }
    else {add(pid,cant); }
}

function add(pid, cant, buget, location)
{
     result = Netlogiq.Web.DetaliuProdus.AddP(pid,cant);
     //document.location.href="continutcomanda.aspx";
     $("spProductsNo").innerHTML = (result.value == 1)? "1 "+getJSPH("Comanda_produs"):result.value+" "+getJSPH("Comanda_produse");
     
}

function submitOnEnterProduct(e,pid) {
	if (window.event && window.event.keyCode == 13) {
		AddToCart(pid);
	}
	else if (e.keyCode == 13) {
		AddToCart(pid);
	}

}

