function SimpleLightBox() {
	this.diff=200;
	this.originalWidth=0;
	this.originalHeight=0;
	this.bgColor = '#CCCCCC';
	this.border  = '3px solid #4C6A75';
	
	this.toggleSelects = function(state){
		$('select').each(function(){
			$(this).css("visibility",(state=='hide'?'hidden':'visible'));
		});
	}
	
	this.toggleFlash = function(state){
		
		$('object').each(function(){
			$(this).css("visibility",(state=='hide'?'hidden':'visible'));
		});
		$('embed').each(function(){
			$(this).css("visibility",(state=='hide'?'hidden':'visible'));
		});
	}
	
	this.getWindowSize=function() {
	  	 
	  var myWidth = 0, myHeight = 0;
	  if( typeof( window.innerWidth ) == 'number' ) {
	    //Non-IE
	    myWidth = window.innerWidth;
	    myHeight = window.innerHeight;
	  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
	    //IE 6+ in 'standards compliant mode'
	    myWidth = document.documentElement.clientWidth;
	    myHeight = document.documentElement.clientHeight;
	  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
	    //IE 4 compatible
	    myWidth = document.body.clientWidth;
	    myHeight = document.body.clientHeight;
	  }
	  return {width:myWidth,height:myHeight};
	}
	this.loadFile = function(file){
	   var _this = this;
	   jQuery.ajax({
		   async: true,
		   type: "GET",
		   url: file,
		   success: function(data){
				_this.loadHTML(data);			
		   }
		});
	}
	
	this.loadHTML = function(html){
		var self=this;
		var size = self.getWindowSize();
		$(window).resize(function(){
			size = self.getWindowSize();
			try{
				$('#lboxContent').style.left=(((size.width-(parseInt(self.originalWidth)))/2))+'px';
			}
			catch(ex){
			}
		});

		var boxBgOpacityPercent = 60;
  		var boxBg = document.createElement("DIV");
  		var boxContent = document.createElement("DIV");
  		if($('#lbox').attr("id")=='lbox'){
			//$('#lbox').remove();
  		}
  		if($('#lboxContent').attr("id")=='lboxContent'){
  			$('#lboxContent').remove();
  		}
  		
  		$('body').css('overflow','hidden');
  		this.toggleSelects('hide');
  		if($('#lbox').attr("id")!='lbox'){
  			
	  		$(boxBg).css('position','absolute');
	  		$(boxBg).css('margin','0px');
	  		$(boxBg).css('padding','0px');
	  		$(boxBg).css('zIndex','99998');
	  		$(boxBg).css('backgroundColor',this.bgColor);
	  		$(boxBg).css('height',($(document).height() - (jQuery.browser.msie && jQuery.browser.version <= 6?4:0) )+"px");
	  		$(boxBg).css('width',(screen.width-(document.all || ($(document).width() > screen.width) || ($(document).height() > screen.height) ? 20:0 ))+"px");
	  		$(boxBg).css('top','0px');
	  		$(boxBg).css('left','0px');
	  		$(boxBg).css('opacity' , (boxBgOpacityPercent/100));
	  		$(boxBg).css('filter ', 'alpha(opacity =' + boxBgOpacityPercent + ')');
	  		$(boxBg).attr('id' , 'lbox');
	  		$('body').append(boxBg);
	  		$('body').css("overflow","hidden");
  		}
  		
  		
  		$(boxContent).css('width','auto');
  		$(boxContent).css('height','auto');
  		$(boxContent).attr('id','lboxContent');
  		$(boxContent).css('position','absolute');
  		$(boxContent).css('zIndex','99999');
  		$(boxContent).css('padding','0px');
  		$(boxContent).css('marging','0px');
  		$(boxContent).css('border',this.border);
  		$(boxContent).css('opacity',(1/100));
  		$(boxContent).css('filter','alpha(opacity =' + 1 + ')');
  		$(boxContent).html(html);
  		$(boxContent).css('opacity', (100/100) );
  		$(boxContent).css('filter','alpha(opacity =' + 100 + ')');
  		$(boxContent).css('backgroundColor','#FFF');
  		$('body').append(boxContent);
  		
  		
  		
  		
  		this.originalHeight = parseInt(document.getElementById("lboxContent").offsetHeight-(parseInt(this.border)*2));
  	    this.originalWidth  = parseInt(document.getElementById("lboxContent").offsetWidth-(parseInt(this.border)*2));
		
		
  		$(boxContent).css('opacity',(100/100));
  		$(boxContent).css('filter','alpha(opacity =' + 100 + ')');
  		$(boxContent).css('width', this.originalWidth>this.diff?((this.originalWidth-this.diff)+"px"):"1px");
  		$(boxContent).css('height',(this.originalHeight<=this.diff?0:this.originalHeight-this.diff)+"px");
		$(boxContent).css('top',parseInt(this.originalHeight)<size.height?(((size.height-(parseInt(this.originalHeight)))/2)+$(document).scrollTop())+'px':'50px');
  		$(boxContent).css('left',(((size.width-(parseInt(this.originalWidth)))/2))+'px');
  		$(boxContent).css('padding','0px');
  		$(boxContent).css('margin','0px');
  		this.animate();
	
	}	
	this.close = function(){
			
		try{
			$("body").css("overflow","visible");
			this.toggleSelects('show');
			this.toggleFlash('show');
			if($('#lbox')){
  				$('#lbox').remove();
	  		}
	  		if($('#lboxContent')){
	  			$('#lboxContent').remove();
	  		}
		}
		catch(ex){
		}
	}
	this.animate=function(){
		$('#lboxContent').animate({width:'+='+(this.originalWidth<=this.diff?this.originalWidth:this.diff)},500);
  		$('#lboxContent').animate({height:'+='+(this.originalHeight<=this.diff?this.originalHeight:this.diff)},500);
	}

}
var MySimpleLightBox = new SimpleLightBox();