/*Node.prototype.setWrapper = function (wrapper) {
	this.imageWrapper = wrapper;
}
Node.prototype.getWrapper = function () {
	return this.imageWrapper;
}*/
var OneImage = function(galleryPath, imageName, myCount) {
	this.src = "";
	this.image = new Image();
	this.node = document.createElement("img");
	this.node.setAttribute(isIE7 ? "className" : "class", "thumb");
	this.imageWidth = 0;
	this.imageHeight = 0;
	this.myCount = myCount;
	
	this.showHuge = function () {
		dusk();
		var imageWrapper = document.getElementById("realImageWrapper");
		if(imageWrapper == null)
			imageWrapper = document.getElementById("imgWrapper").cloneNode(true);
		imageWrapper.style.display="block";
		imageWrapper.setAttribute("id", "realImageWrapper");
		var tMess = calculateMessures (this.imageWidth, this.imageHeight, FINAL_IMAGE_WIDTH);
		var node = document.createElement("img");
		node.setAttribute(isIE7 ? "className" : "class", "image");
		node.setAttribute("src", this.src);
		node.setAttribute("width", "" + tMess[0]);
		node.setAttribute("height", "" + tMess[1]);
		var left = (FINAL_IMAGE_SPACE -tMess[0])/2;
		
		var top = (FINAL_IMAGE_SPACE -tMess[1])/2;
		node.setAttribute("style", "border:0px;left:" + left +"px;top:" + top + "px;");
		if(isIE7) {
			node.style.cssText="border:0px;left:" + left +"px;top:" + top + "px;";
		}
		var old = imageWrapper.getElementsByTagName("img");
		for (var i = 0; i < old.length; i++) {
			imageWrapper.removeChild(old[i]);
		}
		imageWrapper.appendChild(node);
		getElementsByClassAttribute("div", "container")[0].appendChild(imageWrapper);
	}
	this.placeImage = function() {
		this.node.setAttribute("src", this.src);
		var mC = this.myCount;
		var tMess = calculateMessures (this.imageWidth, this.imageHeight, FINAL_THUMB_WIDTH);
		this.node.setAttribute("width", "" + tMess[0]);
		this.node.setAttribute("height", "" + tMess[1]);
		var left = (FINAL_THUMB_SPACE -tMess[0])/2;
		var top = (FINAL_THUMB_SPACE -tMess[1])/2;
		this.node.setAttribute("style", "border:0px;left:" + left +"px;top:" + top + "px;");
		if(isIE7) {
			this.node.style.cssText="border:0px;left:" + left +"px;top:" + top + "px;";
		}
		this.node.onclick=function () {
			showHuge(mC);
		}
		this.node.onmouseover = function () {
			document.body.style.cursor = "pointer";
			if(this.animator == null) {
				this.animator = new ThumbAnimator(this);
			}
			this.animator.animate();
		}
		this.node.onmouseout = function() {
			document.body.style.cursor = "default";
			this.animator.stopAnimation();
		}
		thumbBoard.appendChild(createDivWrapper(this.node));
	}
	this.checkImageLoaded = function () {;
		if(this.image.complete && this.image.width != 0 && this.image.height !=0) {
			this.imageWidth = this.image.width;
			this.imageHeight = this.image.height;
			//this.ta = new ThumbAnimator(this);
			return true;
		}
		return false;
	}
	this.init = function(galleryPath, imageName, myCount) {
		this.myCount = myCount;
		this.src = galleryPath + imageName;
		this.image.src = this.src;
	}
	this.toString = function () {
		return "oneImage " + this.myCount;
	}
	this.ta;
	
	this.init(galleryPath, imageName, myCount);
	//this.node.setWrapper(this);
}


