
var Modules_TMP = Array();
Modules_TMP["file_name"] = "main.js";

Loaded_Modules["main"] = Modules_TMP;

var NAVIGATOR_TYPE_INTERNET_EXPLORER = 1;
var NAVIGATOR_TYPE_NETSCAPE = 2;
var NAVIGATOR_TYPE_FIREFOX = 3;
var NAVIGATOR_TYPE_INNA = 100;

var NAVIGATOR_NAME_INTERNET_EXPLORER = new String("Internet Explorer");
var NAVIGATOR_NAME_NETSCAPE = new String("Netscape");
var NAVIGATOR_NAME_FIREFOX = new String("Firefox");

function GetValueBy(pBy, pValue_True, pValue_False)
{
	if (pBy)
	{
		return(pValue_True);
	}
	else
	{
		return(pValue_False);
	}
}

function LTrim(pText, pOnlySpaces)
{
	var vResult = new String(pText);
	
	var vOnlySpaces = pOnlySpaces;
	if (vOnlySpaces == null)
	{
		vOnlySpaces = false;
	}
	
	while (vResult != "")
	{
		if (
				(
					vOnlySpaces &&
					(vResult.charAt(0) == " ")
				) ||
				(
					(!vOnlySpaces) &&
					(
						(vResult.charAt(0) == " ") ||
						(vResult.charAt(0) == "\t") ||
						(vResult.charAt(0) == "\n") ||
						(vResult.charAt(0) == "\r")
					)
				)
			)
		{
			vResult = vResult.substr(1);
		}
		else
		{
			break;
		}
	}
	
	return(vResult);
}

function RTrim(pText, pOnlySpaces)
{
	var vResult = new String(pText);
	
	var vOnlySpaces = pOnlySpaces;
	if (vOnlySpaces == null)
	{
		vOnlySpaces = false;
	}
	
	var vLastIndex = vResult.length-1;
	
	while (vResult != "")
	{
		vLastIndex = vResult.length-1;
		
		if (
				(
					vOnlySpaces &&
					(vResult.charAt(vLastIndex) == " ")
				) ||
				(
					(!vOnlySpaces) &&
					(
						(vResult.charAt(vLastIndex) == " ") ||
						(vResult.charAt(vLastIndex) == "\t") ||
						(vResult.charAt(vLastIndex) == "\n") ||
						(vResult.charAt(vLastIndex) == "\r")
					)
				)
			)
		{
			vResult = vResult.substr(0, vLastIndex);
		}
		else
		{
			break;
		}
	}
	
	return(vResult);
}

function Trim(pText, pOnlySpaces)
{
	var vResult = pText;
	
	vResult = LTrim(vResult, pOnlySpaces);
	vResult = RTrim(vResult, pOnlySpaces);
	
	return(vResult);
}

function GetClientType()
{
	var vResult = NAVIGATOR_TYPE_INNA;
	
	var vNavigator_Name = new String(navigator.appName);
	var vName_TMP = new String("");
	
	vNavigator_Name.toUpperCase();
	
	vName_TMP = new String(NAVIGATOR_NAME_INTERNET_EXPLORER);
	vName_TMP.toUpperCase();
	if (vNavigator_Name.indexOf(vName_TMP) >= 0)
	{
		vResult = NAVIGATOR_TYPE_INTERNET_EXPLORER;
	}
	else
	{
		vName_TMP = new String(NAVIGATOR_NAME_NETSCAPE);
		vName_TMP.toUpperCase();
		if (vNavigator_Name.indexOf(vName_TMP) >= 0)
		{
			vResult = NAVIGATOR_TYPE_NETSCAPE;
		}
		else
		{
			vName_TMP = new String(NAVIGATOR_NAME_FIREFOX);
			vName_TMP.toUpperCase();
			if (vNavigator_Name.indexOf(vName_TMP) >= 0)
			{
				vResult = NAVIGATOR_TYPE_FIREFOX;
			}
			else
			{
				vResult = NAVIGATOR_TYPE_INNA;
			}
		}
	}
	
	return(vResult);
}

function SetStyle_Display(pObject, pVisible)
{
	if (pObject != null)
	{
		pObject.style.display = GetValueBy(pVisible, "block", "none");
	}
}

function SetInnerHTML_By(pObject, pBy, pValue_True, pValue_False)
{
	if (pObject != null)
	{
		pObject.innerHTML = GetValueBy(pBy, pValue_True, pValue_False);
	}
}

function SetSrc_By(pObject, pBy, pValue_True, pValue_False)
{
	if (pObject != null)
	{
		pObject.src = GetValueBy(pBy, pValue_True, pValue_False);
	}
}

function GetLength_EnterAsChar(pText)
{
	var vResult = 0;
	
	var vText = new String(pText);
	
	vText = vText.replace(/\r/g, "");
	vText = vText.replace(/\n/g, " ");
	
	vResult = vText.length;
	
	return(vResult);
}

function CheckLength_EnterAsChar(pText, pMaxLength)
{
	var vResult = false;
	
	vResult = (GetLength_EnterAsChar(pText) < pMaxLength);
	
	return(vResult);
}

function CheckLength_EnterAsChar_Event(pText, pMaxLength, pEvent)
{
	var vResult = true;
	
	var vNavigatorType = GetClientType();
	
	var vCharCode = 0;
	
	var vEvent_Name =  new String("");
	
	if (pEvent != null)
	{
		vEvent_Name = (new String(pEvent.type)).toLowerCase();
		vCharCode = pEvent.keyCode;
		
		if (vEvent_Name == "keypress")
		{
			switch (vNavigatorType)
			{
				case NAVIGATOR_TYPE_INTERNET_EXPLORER:
				{
					vCharCode = pEvent.keyCode;
					
					break;
				}
				case NAVIGATOR_TYPE_NETSCAPE:
				{
				}
				case NAVIGATOR_TYPE_FIREFOX:
				{
					vCharCode = pEvent.charCode;
					
					break;
				}
				case NAVIGATOR_TYPE_INNA:
				{
					vCharCode = pEvent.keyCode;
					
					break;
				}
				default:
				{
					vCharCode = pEvent.keyCode;
				}
			}
		}
	}
	
	if (
			(vCharCode >= 32) ||
			(vCharCode == 13)
		)
	{
		vResult = CheckLength_EnterAsChar(pText, pMaxLength);
	}
	
	return(vResult);
}

function randomize_()
{
	today = new Date();
	num = today.getTime();
	
	return(num);
}

function openW(strona,width_,height_)
{
	new_window = window.open(strona,randomize_(),'width='+width_+',height='+height_+',toolbars=no,resizeble="no",scrollbars=no');
}

function openS(strona,width_,height_)
{
	new_window = window.open(strona,randomize_(),'width='+width_+',height='+height_+',toolbars=no,resizeble="no",scrollbars=yes');
}

function openA(strona,width_,height_)
{
	new_window = OpenWindowAuto(strona, randomize_(), width_, height_);
}

function foto(plik,width_,height_)
{
	new_window = window.open('foto.php?ID='+plik,randomize_(),'width=400,height=400,toolbars=no,resizeble="no",scrollbars=no');
}

