﻿/// <reference path="~/Scripts/ByteStorm/_BSC_Interface.js" />
(function(){
	BSC.UI.Ws = function()
    { 
        // Hold the open windows
		var guidlist = {};
		// Hold the open windows
		var list = {};
		// Genrel UI Properties
		// The window ID in focus
		var activeId = null;
		// The window currently being dragged
		var activeDrag = null;
		var activeUIDrag = null;
		var activeUIDragShadow = null;
		var RenderMethods = {};
		var DataMethods = {};
		var EventBindingMethods = {};
		var DisposeMethods = {};
		var OnBlurMethods = {};
		var OnFocusMethods = {};
		// Start ZIndex, will be increment
		var ZIndex = 1001;
		
		return {
			Prop:
			{
				ContentHeight:13,
				ContentHeightTabs:40,
				ContentHeightNoTabs:21
			},
			GetNextZIndex:function()
			{
				/// <summary>Get the next z-index</summary>
				/// <return>Return Next Z-Index</return>
				return ZIndex++;
			},
			AddOnFocusMethod:function(key,func)
			{
				OnFocusMethods[key] = func;
			},
			GetOnFocusMethod:function(key)
			{
				return OnFocusMethods[key];
			},
			AddOnBlurMethod:function(key,func)
			{
				OnBlurMethods[key] = func;
			},
			GetOnBlurMethod:function(key)
			{
				return OnBlurMethods[key];
			},
			AddDataMethod:function(key,func)
			{
				DataMethods[key] = func;
			},
			GetDataMethod:function(key)
			{
				return DataMethods[key];
			},
			AddEventBindingMethod:function(key,func)
			{
				EventBindingMethods[key] = func;
			},
			GetEventBindingMethod:function(key)
			{
				return EventBindingMethods[key];
			},
			AddDisposeMethod:function(key,func)
			{
				DisposeMethods[key] = func;
			},
			GetDisposeMethod:function(key)
			{
				return DisposeMethods[key];
			},
			AddRenderMethod:function(key,func)
			{
				RenderMethods[key] = func;
			},
			GetRenderMethod:function(key)
			{
				return RenderMethods[key];
			},
			AddWIDGuid:function(guid)
			{
				guidlist[guid] = true;
			},
			GetWIDGuid:function(guid)
			{
				return guidlist[guid];
			},
			GetWIDGuidList: function(guid)
			{
				return guidlist;
			},			
			Add:function(guid,w)
			{
				list[guid] = w;
			},
			Get:function(guid)
			{
				return list[guid];
			},
			GetByWGUID:function(wguid)
			{
			    var l = list.length;
			    for(j in list)
			    {
			        if(list[j].wguid==wguid)
        				return list[j];
			    }
			    return null;
			},
			GetList:function()
			{
				return list;
			},
			GetGuidList:function()
			{
				return guidlist;
			},
			Remove:function(guid,wiguid)
			{
			    delete guidlist[wiguid];
				delete list[guid];
			},
			SetActiveId:function(guid)
			{
				activeId = guid;
			},
			GetActive:function()
			{
				return list[activeId];
			},
			GetActiveId:function()
			{
				return activeId;
			},
			ActiveId:activeId,			
			ActiveDrag:activeDrag,
			ActiveUIDrag:activeUIDrag,
			ActiveUIDragShadow:activeUIDragShadow
		};
    }();
})();
    
