String.prototype.trim = function() { return this.replace(/^\s\s*/, '').replace(/\s\s*$/, ''); };
String.prototype.isemail = function() { return this.search(/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}/) >=0;};
String.prototype.isint = function() { return this.search(/\d/) ==0;};
String.prototype.ishexa = function() { return this.search(/0x[0-9a-fA-F]+/) ==0;};
String.prototype.isfloat = function() { return this.search(/\d(\.\d)?/) ==0;};
String.prototype.isipaddr = function() { return this.search(/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/) ==0;};
String.prototype.isdate = function()
{
	ok = this.search(/\d{4}\.\d{2}\.\d{2}/) ==0;
	if (ok)
	{
		year = this.substr(0,4)*1;
		month = this.substr(5,2)*1;
		day = this.substr(8,2)*1;
		ok = ((month>=1)&&(month<=12));
	}
	if (ok)
	{
		leapday = (year%4 ==0)?((year%100 == 0)?((year%400 == 0)?1:0):1):0;
		monthdays = new Array(0,31,28+leapday,31,30,31,30,31,31,30,31,30,31);
		ok = ((day>=1)&&(day<=monthdays[month]));
	}
	return ok;
};
window.AjaxObjectHandler = Class.create(
	{
		initialize : function(HostURL)
		{
			this.HostURL = HostURL;
			this.ObjectListOrder = '';
			this.ObjectListOrderDirection = 'ASC';
			this.OperationStatus = 0;

			if (this.HelpDataElement == null)
				this.HelpDataElement = 'helpdata';
			if (this.ObjectDataElement == null)
				this.ObjectDataElement = 'objectdata';
			if (this.ObjectListElement == null)
				this.ObjectListElement = 'objectlist';
			if (this.ObjectListCountElement == null)
				this.ObjectListCountElement = 'objectlistcount';
			if (this.LoginScreenElement == null)
				this.LoginScreenElement = 'loginscreen';

			if (this.ShowHelpFunction == null)
				this.ShowHelpFunction = 'ShowHelp';
			if (this.ListFunction == null)
				this.ListFunction = 'ListObject';
			if (this.EmptyFunction == null)
				this.EmptyFunction = 'EmptyObject';
			if (this.ShowFunction == null)
				this.ShowFunction = 'ShowObject';
			if (this.IsUniqueFunction == null)
				this.IsUniqueFunction = 'IsUnqueObject';
			if (this.DeleteFunction == null)
				this.DeleteFunction = 'DeleteObject';
			if (this.UpdateFunction == null)
				this.UpdateFunction = 'UpdateObject';
			if (this.InsertFunction == null)
				this.InsertFunction = 'InsertObject';
			if (this.LoginScreenFunction == null)
				this.LoginScreenFunction = 'LoginScreen';
			if (this.LoginFunction == null)
				this.LoginFunction = 'Login';


			if (this.CantDeleteMessage == null)
				this.CantDeleteMessage = 'Cant Delete!';
			if (this.ErrorColor == null)
				this.ErrorColor = '#FF0000';
			if (this.Pager != null)
				this.Pager.ObjectHandler = this;
			if (this.ObjectIDElement == null)
				this.ObjectIDElement = 'objectid';
			if (this.DebugLevel == null)
				this.DebugLevel = 0;
		},
  		GetExtraParams : function(functionname)
		{
			return null;
		},
		CombineExtraParams : function(functionname,parameters,functionparams,extraparams)
		{
			if (!Object.isHash(parameters))
				parameters = $H(parameters);
			if (functionparams)
			{
				if (!Object.isHash(functionparams))
					functionparams = $H(functionparams);
				parameters = parameters.merge(functionparams);
			}
			if (extraparams)
			{
				if (!Object.isHash(extraparams))
					extraparams = $H(extraparams);
				parameters = parameters.merge(extraparams);
			}
			extraparams = this.GetExtraParams(functionname);
			if (extraparams)
			{
				if (!Object.isHash(extraparams))
					extraparams = $H(extraparams);
				parameters = parameters.merge(extraparams);
			}
			return parameters;
		},
		SetListOrder : function(listorder)
		{
			if (this.ObjectListOrder == listorder)
			{
				if (this.ObjectListOrderDirection == 'ASC')
					this.ObjectListOrderDirection = 'DESC';
					else this.ObjectListOrderDirection = 'ASC';
			}
			else
			{
				this.ObjectListOrder = listorder;
				this.ObjectListOrderDirection = 'ASC';
			}
			this.ObjectList();
		},
		ErrorHandler : function(transport)
		{
			errorcode = GetNodeValue(transport.responseXML,'errorcode',0);
			errormessage = GetNodeValue(transport.responseXML,'errormessage','');
			functionname = GetNodeValue(transport.responseXML,'functionname','');
			serverdebuglevel = GetNodeValue(transport.responseXML,'debuglevel',0);
			serverdebuginfo = GetNodeValue(transport.responseXML,'debuginfo','');
			alert('functionname='+functionname+', errorcode='+errorcode+' erromessage='+errormessage+' debuglevel='+serverdebuglevel+' debuginfo='+serverdebuginfo);
   			return 0;
		},
		GenericFunction : function(functionname,functionparams,extraparams,events)
		{
			parameters = this.CombineExtraParams(functionname,
   				{funct : functionname, rnd:Math.random()},
    				functionparams,extraparams);
			if ((events != null)&&(events.OnDebugParameters != null))
				events.OnDebugParameters(parameters);
			else if (this.DebugLevel > 2)
				alert(parameters.toQueryString());
			nthis = this;
			var operationstatus = 0;
			new Ajax.Request(this.HostURL,
    			{
     			asynchronous: false,
     			parameters:parameters,
     			onSuccess: function(transport)
     			{
				if (transport.responseXML != null)
				{
					code = GetNodeValue(transport.responseXML,'code',0);
					if (code == 0)
					{
						if ((events != null)&&(events.OnSuccessXML != null))
						{
							operationstatus = events.OnSuccessXML(transport);
						}
					}
					else
					{
						errorcode = GetNodeValue(transport.responseXML,'errorcode',0);
						if ((code == 1)&&(errorcode==-1))
						{
							nthis.LoginScreen();
						}
						else if ((events != null)&&(events.OnError != null))
							operationstatus = events.OnError(transport);
						else operationstatus = nthis.ErrorHandler(transport);
					}
				}
				else
				{
					if ((events != null)&&(events.OnSuccessText != null))
						operationstatus = events.OnSuccessText(transport);
					else
					{
					alert(transport.responseText);//Isnt xml. Fatal error. Why?
					operationstatus = -3;
					}
				}
     			},
    			onFailure: function()
			{
				if ((events != null)&&(events.OnFailure != null))
					operationstatus = events.OnFailure();
				else operationstatus = -1;
			},
    			onException: function()
			{
				if ((events != null)&&(events.OnException != null))
					operationstatus = events.OnException();
				else operationstatus = -2;
			}
    			});
			return operationstatus == 0;
		},
		LoginScreen : function(extraparams)
		{
			nthis = this;
			return this.GenericFunction(this.LoginScreenFunction,null,extraparams,
				{
					OnSuccessXML : function(transport)
					{
						$(nthis.LoginScreenElement).innerHTML = GetNodeValue(transport.responseXML,'content','');
						$(nthis.LoginScreenElement).show();
						$(nthis.LoginScreenElement).style.opacity=0.9;
						return 0;
					}
				});
		},
		Login : function(extraparams)
		{
			nthis = this;
			return this.GenericFunction(this.LoginFunction,null,extraparams,
				{
					OnSuccessXML : function(transport)
					{
						code = GetNodeValue(transport.responseXML,'code','0')*1;
						if (code==0)
						{
						$(nthis.LoginScreenElement).hide();
						}
						//$(nthis.LoginScreenElement).innerHTML = GetNodeValue(transport.responseXML,'content','');
						return 0;
					}
				});
		},
		ObjectList : function(extraparams,events)
		{
			nthis = this;
			return this.GenericFunction(this.ListFunction,
				{pagerposition : this.Pager == null?0:this.Pager.Position, pagerlength : this.Pager == null?0:this.Pager.Length, listorder : this.ObjectListOrder,
				listorderdirection : this.ObjectListOrderDirection},extraparams,
				{
					OnSuccessXML : function(transport)
					{
						if ((events != null)&&(events.OnBefore != null))
							events.OnBefore(transport);
						$(nthis.ObjectListElement).innerHTML = GetNodeValue(transport.responseXML,'content','');
						if (nthis.Pager != null)
							{
							objectlistcount = GetNodeValue(transport.responseXML,'objectlistcount',0);
							nthis.Pager.SetCount(objectlistcount*1);
							nthis.Pager.Evaluate();
							}
						if ((events != null)&&(events.OnAfter != null))
							events.OnAfter(transport);
						return 0;
					}
				});
		},
		EmptyObjectData : function (extraparams,events)
		{
			nthis = this;
			return this.GenericFunction(this.EmptyFunction,null,extraparams,
				{
					OnSuccessXML : function(transport)
					{
						if ((events != null)&&(events.OnBefore != null))
							events.OnBefore(transport);
						$(nthis.ObjectDataElement).innerHTML = GetNodeValue(transport.responseXML,'content','');
						$(nthis.ObjectDataElement).show();
						if ((events != null)&&(events.OnAfter != null))
							events.OnAfter(transport);
						return 0;
					},
					OnFailure : function()
					{
						nthis.HideObjectData();
						return -1;
					}
				});
		},
		ShowObjectData : function(objectid,extraparams,events)
		{
			nthis = this;
			return this.GenericFunction(this.ShowFunction,{id : objectid},extraparams,
				{
					OnSuccessXML : function(transport)
					{
						if ((events != null)&&(events.OnBefore != null))
							events.OnBefore(transport);
						$(nthis.ObjectDataElement).innerHTML = GetNodeValue(transport.responseXML,'content','');
						$(nthis.ObjectDataElement).show();
						if ((events != null)&&(events.OnAfter != null))
							events.OnAfter(transport);
						return 0;
					},
					OnFailure : function()
					{
						nthis.HideObjectData();
						return -1;
					}
				});
		},
		IsUniqueName : function(objectname,extraparams,events)
		{
			nthis = this;
			return this.GenericFunction(this.IsUniqueFunction,{name : objectname},extraparams,
				{
					OnSuccessXML : function(transport)
					{
						if ((events != null)&&(events.OnBefore != null))
							events.OnBefore(transport);
						uniquecount = GetNodeValue(transport.responseXML,'uniquecount',0)*1;
						operationstatus = (uniquecount==0)?0:1;
						if ((events != null)&&(events.OnAfter != null))
							events.OnAfter(transport);
						return operationstatus;
					}
				});
		},
		UpdateObjectData : function(extraparams,disablelisting,events)
		{
			if (disablelisting == null) disablelisting = false;
			nthis = this;
			return this.GenericFunction(this.UpdateFunction,null,extraparams,
				{
					OnSuccessXML : function(transport)
					{
						if ((events != null)&&(events.OnBefore != null))
							events.OnBefore(transport);
						if (!disablelisting)
						{
							nthis.HideObjectData();
							nthis.ObjectList();
						}
						if ((events != null)&&(events.OnAfter != null))
							events.OnAfter(transport);
						return 0;
					}
				});
		},
		InsertObjectData : function(extraparams,disablelisting,events)
		{
			if (disablelisting == null) disablelisting = false;
			nthis = this;
			return this.GenericFunction(this.InsertFunction,null,extraparams,
				{
					OnSuccessXML : function(transport)
					{
						if ((events != null)&&(events.OnBefore != null))
							events.OnBefore(transport);
						if (!disablelisting)
						{
							nthis.HideObjectData();
							nthis.ObjectList();
						}
						if ((events != null)&&(events.OnAfter != null))
							events.OnAfter(transport);
						return 0;
					}
				});
		},
		DeleteObject : function(id,extraparams,disablelisting,events)
		{
			if (disablelisting == null) disablelisting = false;
			nthis = this;
			return this.GenericFunction(this.DeleteFunction,{id : id},extraparams,
				{
					OnSuccessXML : function(transport)
					{
						if ((events != null)&&(events.OnBefore != null))
							events.OnBefore(transport);
						if (!disablelisting)
							nthis.ObjectList();
						if ((events != null)&&(events.OnAfter != null))
							events.OnAfter(transport);
						return 0;
					}
				});
		},
		ConfirmDeleteObject : function(id,objectname,extraparams)
		{
			return this.DeleteObject(id,extraparams);
		},
		ShowHelp : function(helpid)
		{
			if ($(this.HelpDataElement).style.visibility == 'hidden')
			{
			nthis = this;
			return this.GenericFunction(this.ShowHelpFunction,{name : helpid},null,
				{
					OnSuccessXML : function(transport)
					{
						$(nthis.HelpDataElement).innerHTML = GetNodeValue(transport.responseXML,'content','');
						$(nthis.HelpDataElement).show();
						return 0;
					}
				});
			}
		},
		HideHelp : function()
		{
			$(this.HelpDataElement).hide();
		},
		HideObjectData : function()
		{
			$(this.ObjectDataElement).hide();
		},
		SetErrorOnField : function(divelementname,state)
		{
			divelement = $(divelementname);
			if (this.DebugLevel>0)
				elementok = divelement != null;
				else elementok = true;
			if (elementok)
			{
				if (state)
					divelement.style.color = '';
					else divelement.style.color = this.ErrorColor;
			}
			else if (this.DebugLevel>0) alert('SetErrorOnField error (divelementname='+divelementname+')');
		},
		GetCookie : function(name)
		{
			value = '';
			nameindex = document.cookie.indexOf(escape(name) + '=');
			if (nameindex >=0 )
			{
				valueindex = nameindex + (escape(name)).length + 1;
				lastindex = document.cookie.indexOf(';', valueindex);
				if (lastindex >= 0) value = unescape(document.cookie.substring(valueindex, lastindex));
				else value = unescape(document.cookie.substring(valueindex));
			}

		return value;
		},
		SetCookie : function(name,value,expiredays)
		{
			expire=new Date();
			expire.setDate(expire.getDate()+expiredays);
			document.cookie = name+ "=" +escape(value) + ((expiredays==null) ? "" : ";expires="+expire.toGMTString());
		}
	});

window.AjaxObjectPager = Class.create(
	{
		initialize : function(varname)
		{
			this.VarName = varname;
			if (this.LengthElement == null)
				this.LengthElement = 'pagerlength';
			if ($(this.LengthElement))
				$(this.LengthElement).onchange = function () {eval(varname+'.LengthChange()');};

			if (this.FirstIconElement == null)
				this.FirstIconElement = 'pagerfirsticon';
			if (this.PrevIconElement == null)
				this.PrevIconElement = 'pagerprevicon';
			if (this.NextIconElement == null)
				this.NextIconElement = 'pagernexticon';
			if (this.LastIconElement == null)
				this.LastIconElement = 'pagerlasticon';
			if (this.PageCountElement == null)
				this.PageCountElement = 'pagerpagecount';
			if (this.ActualPageElement == null)
				this.ActualPageElement = 'pageractualpage';
			if (this.PageRowElement == null)
				this.PageRowElement = 'pagerrow';
			if (this.PagerElement == null)
				this.PagerElement = 'pager';

			if (this.FirstIconLinkClass == null)
				this.FirstIconLinkClass = '';
			if (this.PrevIconLinkClass == null)
				this.PrevIconLinkClass = '';
			if (this.NextIconLinkClass == null)
				this.NextIconLinkClass = '';
			if (this.LastIconLinkClass == null)
				this.LastIconLinkClass = '';
			if (this.PageRowIconLinkClass == null)
				this.PageRowIconLinkClass = '';
			if (this.PageRowIconActiveLinkClass == null)
				this.PageRowIconActiveLinkClass = 'class="active"';

			if (this.FirstIconTitle == null)
				this.FirstIconTitle = 'First';
			if (this.PrevIconTitle == null)
				this.PrevIconTitle = 'Prev';
			if (this.NextIconTitle == null)
				this.NextIconTitle = 'Next';
			if (this.LastIconTitle == null)
				this.LastIconTitle = 'Last';

			if (this.Length == null)
				this.Length = 20;
			this.Position = 0;
			this.Count = 0;
		},
		Next : function()
		{
			if (this.Position < this.Count-1)
			{
				if (this.Position + this.Length > this.Count)
					this.Last();
				else
				{
					this.Position = this.Position + this.Length;
					this.ObjectHandler.ObjectList();
				}
			}
		},
		Prev : function()
		{
			if (this.Position > 0)
				{
				if (this.Position - this.Length < 0)
					this.Position = 0;
				else this.Position = this.Position - this.Length;
				this.ObjectHandler.ObjectList();
				}
		},
		First : function()
		{
			this.Position = 0;
			this.ObjectHandler.ObjectList();
		},
		Last : function()
		{
			if (this.Position < this.Count - this.Length)
				{
				if (this.Count % this.Length == 0)
					this.Position = this.Count - this.Length;
				else this.Position = this.Count - this.Count % this.Length;
				this.ObjectHandler.ObjectList();
				}
		},
		Jump : function(page)
		{
			if (this.Count>0)
				pagecount = (this.Count / this.Length)+1;
			else pagecount = 0;
			if ((page<=pagecount)&&(page>0))
			{
				this.Position = (page-1)*this.Length;
				this.ObjectHandler.ObjectList();
			}
		},
		LengthChange : function()
		{
			this.Position = 0;
			this.Length = $F(this.LengthElement)*1;
			this.ObjectHandler.ObjectList();
		},
		SetCount : function(count)
		{
			this.Count = count;
		},
		Show : function(count)
		{
			if (this.PagerElement.length>0)
			{
				if ($(this.PagerElement))
					$(this.PagerElement).show();
			}
		},
		Hide : function(count)
		{
			if (this.PagerElement.length>0)
			{
				if ($(this.PagerElement))
					$(this.PagerElement).hide();
			}
		},
		Evaluate : function()
		{
			if (this.FirstIconElement.length>0)
			{
				if ($(this.FirstIconElement)) this.SetFirstIconContent();
			}
			if (this.PrevIconElement.length>0)
			{
				if ($(this.PrevIconElement)) this.SetPrevIconContent();
			}
			if (this.NextIconElement.length>0)
			{
				if ($(this.NextIconElement)) this.SetNextIconContent();
			}
			if (this.LastIconElement.length>0)
			{
				if ($(this.LastIconElement)) this.SetLastIconContent();
			}
			if (this.PageCountElement.length>0)
			{
				if ($(this.PageCountElement)) this.SetPageCountContent();
			}
			if (this.ActualPageElement.length>0)
			{
				if ($(this.ActualPageElement)) this.SetActualPageContent();
			}
			if (this.PageRowElement.length>0)
			{
				if ($(this.PageRowElement)) this.SetPageRowContent();
			}
		},
		SetFirstIconContent : function()
		{
			if (this.Position > 0)
				$(this.FirstIconElement).innerHTML = '<a href="javascript:void(0);" OnClick="'+this.VarName+'.First();" '+this.FirstIconLinkClass+'>'+this.FirstIconTitle+'</a>';
				else $(this.FirstIconElement).innerHTML = this.FirstIconTitle;
		},
		SetPrevIconContent : function()
		{
			if (this.Position > 0)
				$(this.PrevIconElement).innerHTML = '<a href="javascript:void(0);" OnClick="'+this.VarName+'.Prev();" '+this.PrevIconLinkClass+'>'+this.PrevIconTitle+'</a>';
				else $(this.PrevIconElement).innerHTML = this.PrevIconTitle;
		},
		SetNextIconContent : function()
		{
			if ((this.Position+this.Length < this.Count)&&(this.Length > 0)&&(this.Count > 0))
				$(this.NextIconElement).innerHTML = '<a href="javascript:void(0);" OnClick="'+this.VarName+'.Next();" '+this.NextIconLinkClass+'>'+this.NextIconTitle+'</a>';
				else $(this.NextIconElement).innerHTML = this.NextIconTitle;
		},
		SetLastIconContent : function()
		{
			if ((this.Position+this.Length < this.Count)&&(this.Length > 0)&&(this.Count > 0))
				$(this.LastIconElement).innerHTML = '<a href="javascript:void(0);" OnClick="'+this.VarName+'.Last();" '+this.LastIconLinkClass+'>'+this.LastIconTitle+'</a>';
				else $(this.LastIconElement).innerHTML = this.LastIconTitle;
		},
		SetActualPageContent : function()
		{
			if (this.Count>0)
			{
				if (this.Length>0)
					$(this.ActualPageElement).innerHTML = Math.ceil(this.Position / this.Length)+1;
					else $(this.ActualPageElement).innerHTML = 1;
			}
			else $(this.ActualPageElement).innerHTML = 0;
		},
		SetPageCountContent : function()
		{
			if (this.Count>0)
			{
				if (this.Length>0)
					$(this.PageCountElement).innerHTML = Math.ceil(this.Count / this.Length);
					else $(this.PageCountElement).innerHTML = 1;
			}
			else $(this.PageCountElement).innerHTML = 0;
		},
		SetPageRowContent : function()
		{
			actualpage = Math.ceil(this.Position / this.Length)+1;
			if (this.Count>0)
				pagecount = Math.ceil(this.Count / this.Length);
			else pagecount = 0;
			s = '';
			for (i=1;i<=pagecount;i++)
			{
				if (actualpage != i)
					s+='<a href="javascript:void(0);" OnClick="'+this.VarName+'.Jump('+i+');" '+this.PageRowIconLinkClass+'>'+i+'</a>';
				else s+='<a href="javascript:void(0);" '+this.PageRowIconActiveLinkClass+' OnClick="'+this.VarName+'.Jump('+i+');">'+i+'</a>';
			}
			$(this.PageRowElement).innerHTML = s;
		}
	});
window.AjaxBreadCrumbs = Class.create(
	{
		initialize : function(varname)
		{
			this.VarName = varname;
			this.LastCrumb = null;
			if (this.Root == null)
				this.Root = {title:'index',url:'/',script:''};
			if (this.BreadCrumbsElement == null)
				this.BreadCrumbsElement = 'breadcrumbs';

			this.Sections = new Hash({});
			this.CallBacks = new Hash({});
			this.AddSection(0,new Array(this.Root));
			Event.observe(window, 'load', function(){eval(varname+'.Refresh()');});
		},
		Subscribe : function(sectionid,callback,object)
		{
			if (callback)
				this.CallBacks.set(sectionid,{callback:callback,object:object});
				else this.CallBacks.unset(sectionid);
		},
		AddSection : function(sectionid,sectioncontent,callback,object)
		{
			this.Sections.set(sectionid,sectioncontent);
		},
		Refresh : function()
		{
			this.CallBacks.each(function(element,index)
				{
					element[1].callback(this,element[1].object);
				},this);
			temp = this.Sections.sortBy(function(element,index){return element[0]*1;});
			this.LastCrumb = null;
			content = '';
			for (i=0;i<temp.length;i++)
			{
				for (j=0;j<temp[i][1].length;j++)
				{
					content+= this.SetCrumbContent(temp[i][1][j])
					this.LastCrumb = temp[i][1][j];
				}
			}
			if ($(this.BreadCrumbsElement))
				$(this.BreadCrumbsElement).innerHTML = content;
		},
		Back : function()
		{
			if (this.LastCrumb)
			{
				if (this.LastCrumb.script.length>0)
					eval(this.LastCrumb.script);
					else window.location = this.LastCrumb.url;
			}
		},
		SetCrumbContent : function(crumb)
		{
			onclick = '';
			href= crumb.url;
			if (crumb.script.length>0)
			{
				onclick = 'OnClick="'+crumb.script+'"';
				href = 'javascript:void(0);'
			}
			return '<span><a href="'+href+'" '+onclick+'>'+crumb.title+'</a></span>';;
		}
	});
window.AjaxPasswordTester = Class.create(
	{
		initialize : function()
		{
			this.pwd_lowercase = "abcdefghijklmnopqrstuvwxyzáéíóőúű";
			this.pwd_uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZÁÉÍÓÚŰ";
			this.pwd_numbers = "0123456789";
			if (this.pwd_others == null)
				this.pwd_others = "!?<>[]@#$%^&*()_+-.,;:{}|";
			if (this.UnusableTitle == null)
				this.UnusableTitle = 'unusable';
			if (this.VeryWeakTitle == null)
				this.VeryWeakTitle = 'very weak';
			if (this.WeakTitle == null)
				this.WeakTitle = 'weak';
			if (this.AcceptableTitle == null)
				this.AcceptableTitle = 'acceptable';
			if (this.StringTitle == null)
				this.StrongTitle = 'strong';
			if (this.VeryStrongTitle == null)
				this.VeryStrongTitle = 'very strong';
		},
		PasswordContains : function(password, validChars)
		{
			i = 0;
			found = 0;
			while ((i<password.length)&& (found==0))
			{
				if (validChars.indexOf(password.charAt(i)) > -1)
					found = 1;
				else i++
			}
			return found;
		},
		PasswordLetters : function(password)
		{
			letters = "";
			for (i=0;i<password.length;i++)
				if (letters.indexOf(password.charAt(i)) == -1)
			letters+=password.charAt(i);
		return letters.length;
		},
		TestPassword : function(password)
		{
			range = this.PasswordContains(password,this.pwd_lowercase)*this.pwd_lowercase.length;
			range += this.PasswordContains(password,this.pwd_uppercase)*this.pwd_uppercase.length;
			range += this.PasswordContains(password,this.pwd_numbers)*this.pwd_numbers.length;
			range += this.PasswordContains(password,this.pwd_others)*this.pwd_others.length;
			letters = this.PasswordLetters(password);
			return Math.pow(range,letters)/(86400*200);
		},
		TestPasswordOnDiv : function(password,elementid)
		{
			value = this.TestPassword(password);
			if (value < 10)
				$(elementid).innerHTML = this.UnusableTitle;
			else if (value < 200)
				$(elementid).innerHTML = this.VeryWeakTitle;
			else if (value < 4000)
				$(elementid).innerHTML = this.WeakTitle;
			else if (value < 80000)
				$(elementid).innerHTML = this.AcceptableTitle;
			else if (value < 160000)
				$(elementid).innerHTML = this.StrongTitle;
			else $(elementid).innerHTML = this.VeryStrongTitle;
		}
});
function GetNodeValue(xml,nodename,defaultvalue)
{
	tag = xml.getElementsByTagName(nodename);
	if (tag.length > 0)
	{
		node = tag[0];
		if (node.childNodes.length >0)
		{
			result ='';
			for (i=0;i<node.childNodes.length;i++)
				result += node.childNodes[i].nodeValue;
		}
			else result = defaultvalue;
	}
	else result = defaultvalue;

	return result;

}
function GetJSONValue(xml,nodename)
{
	node = GetNodeValue(xml,nodename,null);
	if (node!=null)
		return eval(node);
}
function CheckKeys(key)
{
	validkeys = '0123456789abcdefghijklmnopqrstuvwxyzáéíóőúűöü ';
	found = false;
	i = 0;
	len = validkeys.length;
	while (!found && i<len)
	{
		found = validkeys.charAt(i) == key;
		i++;
	}

	return found;
}
function ChangeSearchToken(e)
{
	if(window.event) // IE
	{
		keynum = e.keyCode;
	}
	else if(e.which) // Netscape/Firefox/Opera
	{
		keynum = e.which;
	}
	key = String.fromCharCode(keynum).toLowerCase();
	searchtoken = document.getElementById('searchtoken').value;
	refresh = false;
	if (keynum == 8 )
	{
		searchtoken = searchtoken.substr(0,searchtoken.length-1);
		refresh = (searchtoken.length>3)||(searchtoken.length==0);
	}
	else if (CheckKeys(key))
	{
		searchtoken += key;
		refresh = (searchtoken.length>2)||(searchtoken.length==0);
	}
	if (refresh)
	{
		PagerPosition = 0;
		ListObject(searchtoken);
	}
	return true;
}

