<!--

var page = {
	
	addLoader : function(dvName, txt)
	{
		$(dvName).innerHTML = '<img src="images/loader.gif" style="vertical-align:middle;"> '+(txt || 'zaczekaj...');
	},
	
	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

	clearLoader : function(dvName, txt)
	{
		$(dvName).innerHTML = txt||"";
	},	
	
	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	
	msg : function(str)
	{
		$("msgDV").innerHTML = str;
		setTimeout('$("msgDV").innerHTML="&nbsp;";', 3000);
	},
	
	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	
	sendForm : function(fname, funct, param)
	{
		var req = mint.Request();
		req.retryNum = 1;
		req.timeout = 30 * 1000;
		var obj = null;

    	req.OnSuccess = function()
		{
			if(funct)
			{
				if (typeof funct != 'string')
				{
					alert('sendForm: bad func !!!');
					return;
				}

				if(funct.indexOf(".") != -1)
				{
					obj = eval(funct.substr(0, funct.indexOf(".")));
					funct.substr(funct.indexOf(".")+1);
				}

				//eval(funct+"('"+this.responseText+"', "+param+")");	

				if(param != undefined)
					eval(funct).apply(obj, [param, this.responseText]);
				else
					eval(funct).apply(obj, [this.responseText]);
			}
			else if(param)
			{
				if(typeof param == "string")
					$(param).innerHTML = this.responseText;
				else if(param.href)
					location.href = param.href;
			}
			else
				location.reload();
    	}
		
		req.OnError = function()
		{
			alert("Błąd wysłania formularza !");
		}
		
		req.OnTimeout = function()
		{
			alert("Błąd - minął czas oczekiwania serwera !");
		}		
		
		if(document.forms[fname].onsubmit && document.forms[fname].onsubmit.length > 0)
		{
			if(eval(document.forms[fname].onsubmit).apply())
				req.SendForm(fname);
		}
		else
			req.SendForm(fname);
	},
	
	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	
	sendQuery : function(query, funct, param)
	{
		var req = mint.Request();
		req.retryNum = 1;
		req.timeout = 30 * 1000;
		req.evalScripts = true;
		var obj = null;

    	req.OnSuccess = function()
		{
			if(funct)
			{
				if (typeof funct != 'string')
				{
					alert('sendForm: bad func !!!');
					return;
				}

				if(funct.indexOf(".") != -1)
				{
					obj = eval(funct.substr(0, funct.indexOf(".")));
					funct.substr(funct.indexOf(".")+1);
				}

				//eval(funct+"('"+this.responseText+"', "+param+")");	
	
				if(param != undefined)
					eval(funct).apply(obj, [param, this.responseText]);
				else
					eval(funct).apply(obj, [this.responseText]);
			}
			else if(param)
			{
				if(typeof param == "string")
					$(param).innerHTML = this.responseText;
				else if(param.href)
					location.href = param.href;
			}
			else
				location.reload();
    	}
		
		req.OnError = function(s)
		{
			if(s != -1)
				alert("Błąd wysłania zapytania !");
		}
		
		req.OnTimeout = function()
		{
			alert("Błąd - minął czas oczekiwania serwera !");
		}

	    req.Send(query);
	},
	
	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	
	checkRado : function(formName, fldName)
	{
		var fld = document.forms[formName].elements[fldName];
		if(!fld)
			return false;
		
		var ile = fld.length || 1;
	
		if(ile == 1)
		{
			if(fld.checked)
				return true;
		}
		else
		{
			for(var i=0; i<ile; i++)
			{
				if(fld[i].checked)
					return true;
			}
		}
	
		return false;
	},
	
	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	
	sellCheckboxes : function(f1, f2)
	{
		var f = document.forms[f1].elements[f2];
		var count = f.length;
		var ile = 0;
		
		if(count)
		{
			for(i=0; i<count; i++)
			{
				if(f[i].checked)
					ile++;
			}
		
			var z = (ile < count/2);
		
			for(i=0; i<count; i++)
				f[i].checked = z;
		}
		else
		{
			f.checked = !f.checked;
		}
	},
	
	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	
	versionCompare : function(v1, v2)
	{
		var v1 = {a:parseInt(v1[0]), b:parseInt(v1[1]), c:parseInt(v1[2])}
		var v2 = {a:parseInt(v2[0]), b:parseInt(v2[1]), c:parseInt(v2[2])}
	
		if(v1.a > v2.a)
			return true;
		else if(v1.a == v2.a)
		{
			if(v1.b > v2.b)
				return true;
			else if(v1.b == v2.b)
			{
				if(v1.c >= v2.c)
					return true;
				else
					return false;
			}
			else
				return false;
		}
		else
			return false;
		
		return false;
	}
	
	
	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	//private function
	

	
}

//-->
