SNSLightbox = Class.create({
    initialize: function(container, contentcontainer, loader, options){
		this.container = $(container);
		this.content = $(contentcontainer);
		this.loader = $(loader);
		this.currentClass = '';
		this.options = {};
		Object.extend(this.options, options || {});
	},
	
	isIE: function(){
		var IE6 = false /*@cc_on || @_jscript_version <= 5.7 @*/;;
		return  IE6;
	},
	
	show:function(){
		var documentHeight = Math.max(
	        Math.max(document.body.scrollHeight, document.documentElement.scrollHeight),
	        Math.max(document.body.offsetHeight, document.documentElement.offsetHeight),
	        Math.max(document.body.clientHeight, document.documentElement.clientHeight),
	        
	        Math.max(document.body.scrollHeight, document.documentElement.scrollHeight),
	        Math.max(document.body.offsetHeight, document.documentElement.offsetHeight),
	        Math.max(document.body.clientHeight, document.documentElement.clientHeight)
        );  
		this.container.setStyle({
			height: documentHeight + "px"
		});
		this.container.show();
		
		javascript:scroll(0,0);
		if(this.isIE()){
			selects = document.getElementsByTagName("select");
	        for (i = 0; i != selects.length; i++) {
	            selects[i].style.visibility = "hidden";
	        } 
		}
		document.observe('keypress', function(event){
		    if(event.keyCode == Event.KEY_ESC){this.hide();}
		}.bind(this));

	},
	
	showErrorMessage:function (errorwrap, classname){
        var errorHTML = $(errorwrap).innerHTML;
        this.addClass(classname);
        this.setContent(errorHTML);
        this.show();
    },
	
	hide:function(){
		this.container.hide();
		if (this.isIE()) {
			selects = document.getElementsByTagName("select");
			for (i = 0; i != selects.length; i++) {
				selects[i].style.visibility = "visible";
			}
		}
	},
	
	setContent:function(content){
		this.content.update(content);
	},
	
	showLoader:function(){
//		console.log(this.loader.innerHTML);
		this.content.update(this.loader.innerHTML);
		this.addClass('loader');
		this.show();
	},
	
	hideLoader:function(){
		this.container.removeClassName('loader');
		this.hide();
	},
	
	addClass:function(styleclass){
		if(this.currentClass != ''){
			this.container.removeClassName(this.currentClass);
		}		
		this.container.addClassName(styleclass);
		this.currentClass = styleclass;
	},
    
    openLightboxTab: function(url, tabId){
        var params = {};
        if (typeof ASSOC_PRODUCT != "undefined" && ASSOC_PRODUCT != '') {
            params = {
                'assocproductid': ASSOC_PRODUCT
            };
        }
        new Ajax.Request(url, {
            method: 'post',
            parameters: params,
            
            onLoading: function(){
                snslightbox.showLoader();
            },
            onSuccess: function(response){
                snslightbox.hideLoader();
                var html = response.responseText;
                snslightbox.setContent(html);
                snslightbox.addClass('product-lightbox');
                productLigtboxtabs = new Control.Tabs('product-lightbox-tab', {
                    linkSelector: 'td a',
                    setClassOnContainer: true
                });
                productLigtboxtabs.setActiveTab(tabId);
                snslightbox.show();
            }
        });
        
    } 
		
});

