var LGBigPicViewer = new function(){
	this.HTMLElement = document.createElement('div');
	this.image = null;
	this.IMGurl = null;
	this.IMGObject = null;
	this.loopInterval = 15;
	this.shadeOutSpeed = 5;
	this.shadeOut = false;
	this.shadeIn = false;
	this.opacity = 100;
	var _this = this;
	
	this.openImage = function (url){
		this.IMGurl = url;
		this.IMGObject = new Image();
		this.IMGObject.onload = function () { _this.show() }
		this.IMGObject.src = this.IMGurl;
	}
	
	this.HTMLCloserElement = document.createElement('div');
	this.HTMLCloserElement.style.fintFamili = "sans-serif";
	this.HTMLCloserElement.style.backgroundImage = 'url("des_imgs/closebutton.png")';
	this.HTMLCloserElement.style.cursor = "pointer";
	this.HTMLCloserElement.style.position = "absolute";
	this.HTMLElement.appendChild(this.HTMLCloserElement);
	
	this.setOpacity = function(opa){
		if (NotIE){
			this.HTMLElement.style.opacity = opa/100;
		} else {
			this.HTMLElement.style.filter = "alpha(opacity="+opa+")";
		}
		this.opacity = opa;
	}
	
	this.show = function(){
		this.HTMLElement.style.backgroundImage = 'url("'+this.IMGurl+'")';
		this.HTMLElement.style.width = this.IMGObject.width+"px";
		this.HTMLElement.style.height = this.IMGObject.height+"px";
		this.HTMLElement.style.backgroundRepeat = "no-repeat";
		this.HTMLElement.style.position = "absolute";
		this.HTMLElement.style.left = (document.body.clientWidth-this.IMGObject.width)/2+"px";
		this.HTMLElement.style.zIndex = "100000";
		this.HTMLCloserElement.style.left = (this.IMGObject.width - this.closerImage.width)+"px";
		this.setOpacity(0);
		//alert(this.HTMLCloserElement.style.left);
		this.HTMLCloserElement.style.top = "0px"
		this.HTMLElement.style.display = "block";
		document.body.appendChild(this.HTMLElement);
		this.shadeIn = true;
	}
	
	
	this.hide = function(){
		this.HTMLElement.style.display = "none";
	}
	
	this.hide(); //inicializálásnál elrejtjük
	
	this.HTMLCloserElement.onclick = function (){
		_this.shadeOut = true;
	}
	
	
	this.closerImage = new Image();
	this.closerImage.src = "des_imgs/closebutton.png";
	this.closerImage.onload = function (){
		_this.HTMLCloserElement.style.width = _this.closerImage.width+"px";
		_this.HTMLCloserElement.style.height = _this.closerImage.height+"px";
	}
	
	this.runLoop = function(){
		if (this.shadeOut){
			if ( (this.opacity - this.shadeOutSpeed) < 0){
				this.shadeOut = false;
				this.hide();
			} else {
				this.setOpacity(this.opacity - this.shadeOutSpeed);
			}
		}
		
		if (this.shadeIn){
			if ( (this.opacity + this.shadeOutSpeed) > 100){
				this.shadeIn = false;
				this.setOpacity(100);
			} else {
				this.setOpacity(this.opacity + this.shadeOutSpeed);
			}
		}
		
	}
	
	this.timer = setInterval(function() {_this.runLoop()},this.loopInterval);
	
}
