var tPhotoHeight = 0;
var jPhoto = function(name,x,y) { 
	this.globInterval = null;
	this.stopInterval = true;
	this.imageName = name;
	this.x = x;
	this.y = y;
	this.ieO = 0;
	this.fO = 0;
	tPhotoHeight = y;
	this.bgImage = document.body.appendChild(document.createElement("DIV"));
	this.bgImage.id = "photoBack";
	var l = parseInt((document.body.clientWidth - x) / 2);
	var t = parseInt((document.body.clientHeight - y) / 2)+(document.body.scrollTop); 
	with(this.bgImage.style) {
		position = "absolute";
		width = document.body.clientWidth;
		height = document.body.clientHeight;
		backgroundColor = "#000000";
		top = document.body.scrollTop;
		left = "0px";
		zIndex = 400;
	}
	if (window.event) {
		this.bgImage.style.filter = "alpha(opacity=0)";
	} else {
		this.bgImage.style.MozOpacity = "0.0";
	}
	this.ghost = document.body.appendChild(document.createElement("DIV"));
	this.ghost.id = "jPhoto_";
	with(this.ghost.style) {
		zIndex = 500;
		width = "10px"; height = "10px"; top = t + "px"; left = l + "px"; position = "absolute"; backgroundColor = "#999999"; border = "1px solid #808080"; textAlign = "center";
		padding = "1px"; 
	}
	this.imageSelf = this.ghost.appendChild(document.createElement("IMG"));
	this.imageSelf.src = name;
	this.imageSelf.style.display = "none";
	this.closerSelf = this.ghost.appendChild(document.createElement("DIV"));
	this.closerSelf.innerHTML = "<div style='font:bold 11px tahoma; color:#ffffff; cursor:pointer;'>Kapat</div>";
	this.closerSelf.style.display = "none";
	var csasd = this;
	this.closerSelf.onclick = function() { csasd.close(); }
	var h = this;
	this.globInterval = setInterval(function() { h.run(); }, 5);
}

jPhoto.prototype.getHeight = function() {
	return parseInt(this.ghost.style.height);
}

jPhoto.prototype.getWidth = function() {
	return parseInt(this.ghost.style.width);
}

jPhoto.prototype.run = function() {
	var widthMul = (this.x > this.y) ? 50 : ((this.x/this.y) * 50);
	var heightMul = (this.y > this.x) ? 50 : ((this.y/this.x) * 50);
	if (this.getWidth() < this.x) {
		this.ghost.style.width = this.getWidth() + widthMul;
		this.stopInterval = false;
	} else { this.stopInterval = true; }
	if (this.getHeight() < this.y) {
		this.ghost.style.height = this.getHeight() + heightMul;
		this.stopInterval = false;
	} else { this.stopInterval = true; }
	
	if (this.ieO <70) {
		this.ieO = this.ieO + 10;
		this.fO = this.fO + 0.1;
	}
	
	this.bgImage.style.filter = "alpha(opacity="+this.ieO+")";
	
	if (this.stopInterval) {
		if (window.event) {
			this.bgImage.style.filter = "alpha(opacity=70)";
		} else {
			this.bgImage.style.MozOpacity = "0.7";
		}
		clearInterval(this.globInterval);
		this.imageSelf.style.display = "";
		this.closerSelf.style.display = "";
	}
}	

jPhoto.prototype.close = function() {
	document.body.removeChild(this.bgImage);
	document.body.removeChild(this.ghost);
}

function photoScroll() {
	try {
		document.getElementById("jPhoto_").style.top = parseInt((document.body.clientHeight - tPhotoHeight) / 2)+(document.body.scrollTop); 
		document.getElementById("photoBack").style.top = (document.body.scrollTop); 
	} catch (e) { }
}
