﻿//Modify from http://yui.yahooapis.com/2.7.0/build/yahoo/yahoo-min.js
//declare global namespace Object HUYMINH;
//It unique on every page
//if not exits: declare it
//if exits declare to overwrite it
if (typeof HUYMINH == "undefined" || !HUYMINH)
    var HUYMINH = {};
    
HUYMINH.Namespace = function(){
    this.checkExistsNamspace = function(_NameOfNamespace){
        eval("var NE = false; try{if(" + _NameOfNamespace + "){NE = true;}else{NE = false;}}catch(err){NE=false;}"); 
        return NE;
    };
    this.registerNamespace = function(_NameOfNamespace){
        var chkExits = false;
        var cob = "";
        var spc = _NameOfNamespace.split(".");
        for(var i = 0; i<spc.length; i++)
        {
            if(cob!=""){cob+=".";}
            cob+=spc[i];
            chkExits = this.checkExistsNamspace(cob);
            if(!chkExits){
                this.createMethodForNamespace(cob);
            }
        }
        if(chkExits){
            throw "Namespace: " + _NameOfNamespace + " is already defined.";
        }
    };
    this.createMethodForNamespace = function(_NameOfMethod){
        eval("window." + _NameOfMethod + " = new Object();");
    }
}