<!--

function prodAvail(dv1, dv2, p)
{
	this.color = 0;
	this.size = 0;
	this.dv1Name = dv1;
	this.dv2Name = dv2;
	
	this.param = {pid:0, aid:0};
	
	for(var a in p)
	{
		this.param[a] = p[a];
	}
	
	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	
	this.setColor = function(x)
	{
		this.color = (parseInt(x) > 0)? parseInt(x) : 0 ;
		this.tryCheck();
	}
	
	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	
	this.setSize = function(x)
	{
		this.size = (parseInt(x) > 0)? parseInt(x) : 0 ;
		this.tryCheck();
	}
	
	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	
	this.tryCheck = function()
	{
		if((this.param.pid > 0 && this.size > 0 && this.color > 0) || this.param.aid > 0)
		//if(this.size > 0 && this.color > 0)
		{
			$(this.dv1Name).innerHTML = '<img src="_img/loader.gif" alt="">';
			$(this.dv2Name).innerHTML = '<img src="_img/loader.gif" alt="">';
			
			var req = mint.Request();
			var that = this;
    
			req.OnSuccess = function()
			{
	        	$(that.dv1Name).innerHTML = (parseInt(this.responseText) > 0)? "tak" : "na zamówienie" ;
				$(that.dv2Name).innerHTML = (parseInt(this.responseText) > 0)? "0 dni" : "5 dni" ;
				document.forms['productForm'].dostepny.value = parseInt(this.responseText);
    		}
			
			//alert("index.php?a=product_is_dost&pid="+useProductId+"&c="+this.color+"&r="+this.size);
			if(this.param.pid > 0)
			    req.Send("index.php?a=product_is_dost&pid="+this.param.pid+"&c="+this.color+"&r="+this.size);
			else if(this.param.aid > 0)
				req.Send("index.php?a=product_is_dost&aid="+this.param.aid);
		}
		else
		{
			$(this.dv1Name).innerHTML = 'wybierz rozmiar i kolor';
			$(this.dv2Name).innerHTML = 'j.w.';
		}
	}
}

//-->
