// --------------------------------------------------------------------------------------
function SetRadioNoAlert(Nazwa)
{
	RadioObject = document.getElementsByName(Nazwa);
	a = RadioObject.length;	
	for (i=0;i<a;i++)
	{
		if(RadioObject[i].type == 'radio')
			RadioObject[i].className = "radio";
	}
}
// -------------------------------------------------------------------------
function GetAppMenu(Zdarzenie)
{
	Obj = document.getElementById("AppMenu");
	if (Obj.className == "ukryte")
	{
		if (ie)
		{
			X = Zdarzenie.clientX + document.documentElement.scrollLeft;
			//X = X - (CalDivObj.offsetWidth /2 );
			Y = Zdarzenie.clientY + document.documentElement.scrollTop;
			Obj.style.top = Y+5;
			Obj.style.left = X+5;
		}
		else
		{
			Y = Zdarzenie.pageY+5;	
			X = Zdarzenie.pageX+5 ;
			Obj.setAttribute("style","position:absolute;top:"+Y+"px;left:"+X+"px;");
		}	
		Pokaz("AppMenu");
	}
	else
	{
		Ukryj("AppMenu");
	}
}
//-------------------------------------------------------------------------
function CzyNull(Obiekt,StyleOK,StyleAlert)
{
	napis = Obiekt.value;
	//alert (napis);
	if (napis == "")
	{
		Obiekt.focus();
		Obiekt.className = StyleAlert;
	}	
	else
	{
		Obiekt.className = StyleOK;
	}	
}
//-------------------------------------------------------------------------
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;
	
	if (liczba < -9999999999999)
		liczba = -9999999999999;
	
	liczba = Math.round(liczba*100);
	liczba = liczba /100;
	return liczba;
}
//-------------------------------------------------------------------------
function ToInt (liczba)
{

	if (liczba > 9999999999999)
		liczba = 9999999999999;
	
	liczba = Math.floor(liczba);
	return liczba;
}
//-------------------------------------------------------------------------
function SprawdzCombo(ComboObject)
{
	if (ComboObject.value == 0)
		ComboObject.className = "combo_alert";
	else
		ComboObject.className = "combo";
	
	return true;
}
//-------------------------------------------------------------------------
function BeforeSubmit(FormObject)
{
	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');
				return false;
			}
		} 
	}
	return true;
}
//-------------------------------------------------------------------------
function Pokaz(IdObject)
{
	Obj = document.getElementById(IdObject)
	Obj.className = "widoczne";
	//alert("widoczne");
}
//-------------------------------------------------------------------------
function Zmien(IdToHide,IdToDsp)
{
	Ukryj(IdToHide);
	Pokaz(IdToDsp);
}
//-------------------------------------------------------------------------
function Ukryj(IdObject)
{
	Obj = document.getElementById(IdObject)
	Obj.className = "ukryte";
	//alert("ukryte");
}
//-------------------------------------------------------------------------
