// -------------------------------------------------------------------------
function ZmienIlosc(ItemId,Model)
{
	val = document.getElementById("Count"+ItemId+"_"+Model).value;
	location.href="?action=ChgIlo&arg1="+ItemId+"&arg2="+Model+"&arg3="+val;
	//alert("?action=ChgIlo&arg1="+ItemId+"&arg2="+Model+"&arg3="+val);
}
// -------------------------------------------------------------------------
function ChangeStatus(Id)
{
	status = document.getElementById("StatusID").value;	
	location.href="?action=ChgSts&arg1="+Id+"&arg2="+status;
}
// -------------------------------------------------------------------------
function Goooo(FormObject)
{
	// puźniej będzie tu dorobiona obliczanie ostatecznej ceny jeszcze 
	FormObject.submit();
}
// -------------------------------------------------------------------------
function DodajDoKoszyka(ItemId,Ilosc,Model)
{
	location.href="?action=AddToBasket&arg1="+ItemId+"&arg2="+Ilosc+"&arg3="+Model;
	
}
// -------------------------------------------------------------------------
function ReloadCalendar(Action,ObiectString)
{
	YearObject = document.getElementById("year");
	MonthObject = document.getElementById("month");	
	param = "?action="+Action+"&arg1="+YearObject.value+"-"+MonthObject.value+"-01&arg2="+ObiectString;
	location.href=param;
}
// -------------------------------------------------------------------------
function Pokaz(IdObject)
{
	Object = document.getElementById(IdObject)
	Object.className = "widoczne";
	//alert("widoczne");
}
// -------------------------------------------------------------------------
function Ukryj(IdObject)
{
	Object = document.getElementById(IdObject)
	Object.className = "ukryte";
	//alert("ukryte");
}
// -------------------------------------------------------------------------
function ToInt (liczba)
{

	if (liczba > 9999999999999)
		liczba = 9999999999999;
	
	liczba = Math.floor(liczba);
	return liczba;
}
// -------------------------------------------------------------------------
function CzyInt(Obiekt,StyleOK,StyleAlert,OldValue)
{
	napis = Obiekt.value;
	napis = ComaToPoint(napis);
	if (isNaN(napis))
	{
		Obiekt.value = OldValue;
		Obiekt.focus();
		Obiekt.className = StyleAlert;
	}	
	else
	{
		if (napis < 0)
		{		
			Obiekt.value = OldValue;
			Obiekt.focus();
			Obiekt.className = StyleAlert;
		}
		else
		{
			Obiekt.className = StyleOK;
			Obiekt.value = ToInt(napis);
		}
	}	
}
// -------------------------------------------------------------------------
function CzyReal(Obiekt,StyleOK,StyleAlert,OldValue)
{
	napis = Obiekt.value;
	napis = ComaToPoint(napis);
	if (isNaN(napis))
	{
		Obiekt.value = OldValue;
		Obiekt.focus();
		Obiekt.className = StyleAlert;
	}	
	else
	{
		if (napis < 0)
		{		
			Obiekt.value = OldValue;
			Obiekt.focus();
			Obiekt.className = StyleAlert;
		}
		else
		{
			Obiekt.className = StyleOK;
			Obiekt.value = ToCurr(napis);
		}
	}	
}
// -------------------------------------------------------------------------
function ComaToPoint (text)
{
	napis = "";
	for (i=0;i<text.length;i++)
	{		
		a=text.substring(i,i+1);
		if (a==',')
			a="."
		napis += a;
	}
	return napis;
}
// -------------------------------------------------------------------------
function ToCurr (liczba)
{

	if (liczba > 9999999999999)
		liczba = 9999999999999;
	
	liczba = Math.floor(liczba*100);	
	liczba = liczba /100;
	return liczba;
}
// -------------------------------------------------------------------------
function CzyNull(Obiekt,StyleOK,StyleAlert)
{
	napis = Obiekt.value;
	//alert (napis);
	if (napis == "")
	{
		Obiekt.focus();
		Obiekt.className = StyleAlert;
	}	
	else
	{
		Obiekt.className = StyleOK;
	}	
}
// -------------------------------------------------------------------------
function BeforeSubmit(FormObject,Komunikat)
{
	a=FormObject.length;
	//window.status = "a: "+a;
	for (i=0;i<a;i++)
	{
		test = FormObject.elements[i].className;
		//alert(test);
		if (test.length >=6)
		{
			dl = test.length;			
			alerttest = test.substring(dl-6,dl);
			//alert('test: '+test + ' alerttest: '+ alerttest +' dl: '+ dl);
			if (alerttest == "_alert")
			{
				//alert('Nie wszystkie wymagane pola (wyróżnione) zostały wypełnione');
				alert(Komunikat);
				return false;
			}
		} 
	}
	return true;
}
// -------------------------------------------------------------------------
