var GiftgirlLightbox = new Class({
        
        options: {
            type: ''
        },
        
        initialize: function(){

            this.remove();
           this.count = 0; 

            multiBox = new MultiBox('lightbox-open', {
                useOverlay: true,
                openFromLink: false,
                descClassName: null,
                showControls: false,
                fixedTop: false,
                relativeToWindow: true,
                whenComplete: this.afterOpen.bind(this),
                close: this.afterClose.bind(this)
            });
            
            // Move the Multibox Content w/ the multibox
			window.addEvent('resize', this.position.bind($('MultiBoxContainer')) );
        },
        
        
        /*
         * el - Clickable Element 
         * type - 'product-detail' or 'new-profile'
         */
        open: function(el,type){
          if( true || this.count == 0 ){
            // alert("inside open function of giftgirl lightbox");
            this.type = type;
            this.clearBodyClass();
            
            if( type == 'product-detail' ){
                multiBox.options.movieWidth = 800;
                document.body.addClass('lightbox-detail');
            }
            else if ( type == 'go-get-it' ){
                multiBox.options.movieWidth = 500;
                multiBox.options.movieHeight = 500;
                document.body.addClass('lightbox-go-get-it');
            }
            else {
                multiBox.options.movieWidth = 500;
                multiBox.options.movieHeight = 500;
                //document.body.addClass('lightbox-default');
            }
            multiBox.open(el);
            this.count++;
          }
        },
        
        remove: function(){
            if( $('OverlayContainer') )
                $('OverlayContainer').remove();
            
            if( $('MultiBoxContainer') )
                $('MultiBoxContainer').remove();
        },
        
        afterOpen: function(){
            /*
            var gglightbox = new Element('div', { "id": "gg-lightbox"} );
            gglightbox.injectInside( $E('.MultiBoxContent') );
            $('MultiBoxContentContainer').injectInside(gglightbox);
            */
            
            if( this.type == 'product-detail' )
                productList.initAddToWishlistDetailPage();
            
            if( this.type == 'new-profile' )
                init_multibox_form_elements();
       		
			// User Dashboard types 
   			if ('dashboard-edit-profile' == this.type) {
				// alert("inside dashboard-edit-profile conditional");
				init_profile_multibox_form_elements();
			}
			if ('dashboard-edit-guest' == this.type) {
				// alert("inside dashboard-edit-guest conditional");
				init_guest_multibox_form_elements();
            }
			if( $('list-content') ){ 
				$("table-wrap").setStyle('overflow','hidden');
			}
			$ES('.mif-tree-wrapper').setStyle('overflow','hidden'); 
			if( $('wishlist-content') ){
				if( $("table-wrap") ) {
				  $("table-wrap").setStyle('overflow','hidden'); 
				}
				if( $("received-div") ) {
				  $("received-div").setStyle('overflow','hidden'); 
				}
			}
        },
        
		close: function() {
		  multiBox.close();
                  this.count = 0;
		},
		
        afterClose: function(){
            if( this.type == 'new-profile' )
                cancel_create_profile();

			if( $('list-content') ){
				$("table-wrap").setStyle('overflow','auto');
			}
			if( $ES('.mif-tree-wrapper') ) {
			  $ES('.mif-tree-wrapper').setStyle('overflow','auto'); 
			}
			if( $('wishlist-content') ){
				if( $("table-wrap") ) {
				$("table-wrap").setStyle('overflow','auto'); 
				}
				if( $("received-div") ) {
				$("received-div").setStyle('overflow','auto'); 
				}
			}

        },
        
        clearBodyClass: function(){
            document.body.removeClass('lightbox-small');
            document.body.removeClass('lightbox-detail');
            document.body.removeClass('lightbox-default');            
            document.body.removeClass('lightbox-go-get-it');
        }, 
        
        position: function(){
            var myCoords = this.getCoordinates();
            var h = window.getSize().y;
            var h = h/2 - 200;
            
            this.setStyles({
                top: h+'px', 
                height: myCoords.height+'px', 
                left: myCoords.left+'px', 
                width: myCoords.width+'px'
            }); 
        }
        
});
GiftgirlLightbox.implement(new Options);
