/***************************************************************************************************/

//Namespace 2112
//Create Object Node if not already done.
window.NS2112 = window.NS2112 || {};
//SNAPIN Constants / Flags

/*The global array for the YUI get utility*/

NS2112.syncArray = null ;

//encapsulation of the YUI Event - needs to be replaced by an own class to someday
//finally get rid of the YUI stuff.
NS2112.CustomEvent = function( type , oScope , silent , signature ) 
{  //this is just an encapsulation and in the future the YAHOO CE should be eradicated.
   this.ce = new YAHOO.util.CustomEvent(type, oScope, silent, signature);

   this.subscribe = function( fn , obj , override ){
      this.ce.subscribe( fn , obj , override ) ;
   } 

   this.unsubscribe = function( fn , obj  ){
      this.ce.unsubscribe( fn , obj ) ;
   } 

   this.fire = function( arguments ) {
      this.ce.fire(arguments) ;
   }

   return this.ce ;
}

//encapsulation of the YUI Methods
NS2112.scrollOffsetX = function(baseElement) //optional
{   
   return YAHOO.util.Dom.getDocumentScrollLeft(baseElement) ;
}

NS2112.scrollOffsetY = function(baseElement) //optional
{   
   return YAHOO.util.Dom.getDocumentScrollTop(baseElement) ;
}


//Taken from http://www.dustindiaz.com/javascript-curry/
NS2112.curry = function(fn, scope) {
    var scope = scope || window;
    var args = [];
    for (var i=2, len = arguments.length; i < len; ++i) {
        args.push(arguments[i]);
    };
    return function() {
	    fn.apply(scope, args);
    };
}



  

NS2112.clone = function(myObj)
{
	if(typeof(myObj) != 'object') return myObj;
	if(myObj == null) return myObj;
	var myNewObj = new Object();
	for(var i in myObj)
		myNewObj[i] = NS2112.clone(myObj[i]);
	return myNewObj;
}


NS2112.include = function (file) {
  var script  = document.createElement('script');
  script.src  = file;
  script.type = 'text/javascript';

  document.getElementsByTagName('head').item(0).appendChild(script);
}


//Now we can use the NS2112.
//This namespace will be used later for declaring Classes within it.

NS2112.namespace = function(ns) {

    if (!ns || !ns.length) {
        return null;
    }

    var levels = ns.split(".");
    var nsobj = NS2112;

    // NS2112 is implied, so it is ignored if it is included
    // Creating sublevels if not already done so.
    for (var i=(levels[0] == "NS2112") ? 1 : 0; i<levels.length; ++i) {
        nsobj[levels[i]] = nsobj[levels[i]] || {};  //create empty object if necessary
        nsobj = nsobj[levels[i]];
    }

    return nsobj;
};

//Extending by prototypal inheritance using this function.
NS2112.extend = function(subclass, superclass) {
    var f = function() {};
    f.prototype = superclass.prototype;
    subclass.prototype = new f();
    subclass.prototype.constructor = subclass;
    subclass.superclass = superclass.prototype;
    if (superclass.prototype.constructor == Object.prototype.constructor) {
        superclass.prototype.constructor = superclass;
    }
};

NS2112.namespace("NS2112");
NS2112.namespace("windowStyle");
NS2112.namespace("WIDGET");

NS2112.namespace("LoadControl"); // for constants 



NS2112.windowStyle.WS_SHOWTITLE      =  0x1  ;
NS2112.windowStyle.WS_CANCLOSE       =  0x2  ;
NS2112.windowStyle.WS_CANGROW        =  0x4  ;
NS2112.windowStyle.WS_MAXIMIZE       =  0x8  ;


NS2112.windowStyle.WS_DROPDOWN       =  0x10 ;   
NS2112.windowStyle.WS_BORDERS        =  0x20 ;
NS2112.windowStyle.WS_FREEFLOAT      =  0x40 ;
NS2112.windowStyle.WS_MANAGEHEIGHT   =  0x80 ;
NS2112.windowStyle.WS_FITTOHOST      =  0x100 ;
NS2112.windowStyle.WS_CANRELOAD      =  0x200 ;
NS2112.windowStyle.WS_CANNAVIGATE    =  0x400 ; //Back/Forth Navigation with buttons
NS2112.windowStyle.WS_CANUNDOCK      =  0x800 ;
NS2112.windowStyle.WS_MANAGECONTENT  =  0x1000 ; //Manage the inner size of content
NS2112.windowStyle.WS_RESIZE         =  0x2000 ; //has a resize handle
NS2112.windowStyle.WS_CHILD          =  0x4000 ; //a childwindow without any controls (footer, header...)

NS2112.windowStyle.WS_VANILLA      =  NS2112.windowStyle.WS_SHOWTITLE 
                                    | NS2112.windowStyle.WS_CANCLOSE
                                    | NS2112.windowStyle.WS_BORDERS 
                                    | NS2112.windowStyle.WS_RESIZE;


//Some Standard values
NS2112.WINDOWSPACING_X = 7 ;
NS2112.WINDOWSPACING_Y = 7 ;

NS2112.WIDGET.SNAP = 'snap' ;
NS2112.WIDGET.UWA  = 'uwa'  ;
NS2112.WIDGET.CONTENT = 'content' ;
//Containers - 
NS2112.WIDGET.HOSTSINGLE = 0 ;
NS2112.WIDGET.HOSTMULTIPLE = 1 ;



