
 function LightBoxLayer() {

     var _lightBoxLayer = {

         // constructor & deconstructor
         Init: function(show) {

             // create overlay layer element
             _lightBoxLayer.Element.CreateOverlay();

             if (typeof (status) != 'undefined' && show == true)
                 _lightBoxLayer.Show();

         },

         // element
         Element: {

             // overlay dom object
             Overlay: null,
             // content dom object
             Container: null,

             // Element create
             Create: function(tagName) {

                 return document.createElement(tagName);

             },
             // Overlay element creation
             CreateOverlay: function() {

				var _elm = document.getElementById('overlay-layer');
			 
                 if (_lightBoxLayer.Element.Overlay == null) {

                         if (_elm == null) {

                             _elm = _lightBoxLayer.Element.Create('div');
                             _elm.id = 'overlay-layer';
                             _elm.className = _elm.className == '' ? 'overlay-division' : _elm.className;
                             _elm.style.display = 'none';

                         }
                     
                         // assign to global variable
                         _lightBoxLayer.Element.Overlay = _elm;

                         // Binding layer click action
                         _lightBoxLayer.Element.Overlay.onclick = function() {

                             _lightBoxLayer.Hide();
                         }


                 } else {
							
							if (_elm == null) {	
								this.AppendChild();	
								}
							
                     return _lightBoxLayer.Element.Overlay;

                 }

                 this.AppendChild();

             },

             AppendChild: function() {

                 if (typeof (document.body) != 'undefined') {

                     document.body.appendChild(_lightBoxLayer.Element.Overlay)

                 } else {

                     this.Log('Error : document body is undefined !');

                 }
             }
         },

         // content intializer              

         Content: function(elmmentID) {

             var _content = null;

             _content = document.getElementById(elmmentID);

             if (_content != null) {

                 this.Element.Container = _content;

             } else {

                 this.Log('Error : content (container) is undefined !');

             }
         },

         // action

         Show: function() {

             if (this.Element.Overlay != null && this.Element.Container != null) {

                 this.Element.Overlay.style.display = 'block';
                 this.Element.Container.style.display = 'block';
                 this.Log('State is open !');
                 this.OnShow();
				 
				 this.Resize();

             }

         },

         Hide: function() {

             if (this.Element.Overlay != null && this.Element.Container != null) {

                 this.Element.Overlay.style.display = 'none';
                 this.Element.Container.style.display = 'none';
                 this.Log('State is hide !');
                 this.OnHide();

             }
         },

         Resize: function() {

			 var _doc = document;
			 var _hegiht =  Math.max(
									Math.max(_doc.body.scrollHeight, _doc.documentElement.scrollHeight),
									Math.max(_doc.body.offsetHeight, _doc.documentElement.offsetHeight),
									Math.max(_doc.body.clientHeight, _doc.documentElement.clientHeight)
								);
			
		
		 	 if (this.Element.Overlay != null) {
			 	
				this.Element.Overlay.style.height = _hegiht; 
			 }
		 
         },

         // events

         OnShow: function() {

         },

         OnHide: function() {

         },
         Destroy: function() {

             if (document.body != null) {

                 document.body.removeChild(_lightBoxLayer.Element.Overlay);
                 this.Log('Ready!');

             }

         },
         Log: function(str) {

             this.State = str;
             if (typeof (console) != 'undefined')
                 console.log(str)
         },
         // script state                          
         State: 'No Action'

     }

        return _lightBoxLayer;

    }


