﻿


var System = new Object();

System.EventCollection = new Array();

System.Save = function (name, value)
{
	document.cookie = name + "=" + value;
	return value;
}

System.Load = function (name)
{
	var cookies = document.cookie.split(";");
	name = String.Trim(name);
	for (var i = 0; i < cookies.length; i++)
		if (String.Trim(cookies[i].split("=")[0]) == name && String.Trim(cookies[i].split("=")[1]) != "")
			return String.Trim(cookies[i].split("=")[1]);
	return null;
}

System.CreateEvent = function (args)
{
	var handler = null;
	if (args != null)
	{
		handler = new EventHandler(args);
		if (args.Container.addEventListener)
		{
			args.Container.addEventListener(args.Action, args.EventCallBack, false);
		}
		else if (args.Container.attachEvent)
		{
			args.Container.attachEvent(args.Action, args.EventCallBack);
		}
		System.EventCollection.push(handler);
	}
}

function EventHandler(e)
{
	this.Sender = e.Container;
	this.Args = e;

	this.Invoke = function (filter)
	{
		if (filter == null)
			this.Args.EventCallBack(this.Sender, this.Args);
		else
		{
			filter = filter.split("|");
			for (var i = 0; i < filter.length; i++)
			{
				//alert(filter[i] + " " + this.Args.Action.indexOf(filter[i]));
				if (this.Args.Action.indexOf(filter[i]) > -1)
					this.Args.EventCallBack(this.Sender, this.Args);
			}
		}
	}
}

function ResizeEventArgs(container, eventCallBack)
{
	this.Action = Browser.Client == Browsers.IE ? "onresize" : "resize";
	this.EventCallBack = eventCallBack;
	this.Container = container;
}

function ClickEventArgs(container, eventCallBack)
{
	this.Action = Browser.Client == Browsers.IE ? "onclick" : "click";
	this.EventCallBack = eventCallBack;
	this.Container = container;
}

function MouseEnterEventArgs(container, eventCallBack)
{
	this.Action = Browser.Client == Browsers.IE ? "onmouseover" : "mouseover";
	this.EventCallBack = eventCallBack;
	this.Container = container;
}

function MouseLeaveEventArgs(container, eventCallBack)
{
	this.Action = Browser.Client == Browsers.IE ? "onmouseout" : "mouseout";
	this.EventCallBack = eventCallBack;
	this.Container = container;
}
