function img_disp_obj(){
	this.pv = null;
	var obj_arr 																		= new Array();
	var img_arr																			= new Array();
	var disp_count																		= 0;
	var imgMaxW																			= 400;
	var imgMaxH																			= 800;
	var imgDif																			= 0;
	var dir = null;
	this.closing = true;
	this.creating = false;
	window.onresize = function(){
		try{
			var right = (f_clientWidth()/2) - ((this.pv.curr_img_width + 200)/2); 
			//var top = (f_clientHeight()/2) - (this.pv.curr_img_height/2);
			var top = 30;
			var s = "right: "+(right)+"px;";
			if(this.pv.fxObj.pre != null)
				this.pv.fxObj.pre.cancel();
			this.pv.fxObj.aft = new Effect.Morph(
				"disp_div_"+this.pv.disp_id, 
				{
					style: s+" top: "+top+"px;", 
					duration: 0.5, 
					transition: Effect.Transitions.sinoidal 
				}
			);
		}catch(ex){}
	}.bind(this)
	getScreenSize = function(){
		imgMaxW = f_clientWidth() * .9;
		imgMaxH	= f_clientHeight() * .9;	
	}
	this.img_disp = function(i, d, o, r){
		this.root = r;
		this.o = o;
		this.pre_thumb = "";
		this.nxt_thumb = "";
		this.imgs = d;
		this.img_no = i;
		var ai = this.get_new_id();
		obj_arr[ai] = this;
		this.current_img = new Array();
		this.current_img = [null,this.o.img_url_extra+this.imgs[this.img_no]];
		this.curr_img_width = this.o.init_w;
		this.curr_img_height = this.o.init_h;
		this.name = "disp_"+ai;
		this.disp_id = disp_count;
		this.loading = false;
		this.loaded = false;
		this.fxObj = {
				pre: null,
				aft: null,
				div_close: null,
				cover_close: null,
				div_show: null,
				cover_show: null
			}
		disp_count += 1;
		this.clean_up();
		this.get_thumb_link();
		this.show_cover();
		this.create_disp();
		return this;
	}
	this.img_disp.prototype = {
		show_cover:function(){
			if($("side_img"))
				$("side_img").style.display = "none";
			if(this.root.closing){
				this.root.closing = false;
				if(this.fxObj.cover_close != null)
					this.fxObj.cover_close.cancel();
				this.fxObj.cover_open = new Effect.Appear(
					"cover_photo", 
					{ 
						duration: 0.2, 
						from: 0.0, to: 1.0
					}
				);
			}
		},
		create_disp:function(){
			var disp_id	= this.disp_id;
			this.loading = true;
			var right = (f_clientWidth()/2) - (this.o.init_w/2); 
			//var top = (f_clientHeight()/2) - (this.o.init_h/2);
			var top = 30;
			create_element(d.body, "div", "disp_div_"+this.disp_id, "position:fixed;top:"+top+"px;right:"+right+"px;width:"+this.o.init_w+"px;height:"+this.o.init_h+"px;"+this.o.div_style+"overflow:hidden;display:none;zoom:1;zIndex:99", this.disp_id);
				create_element($("disp_div_"+this.disp_id), "div", "disp_div_shadow_"+this.disp_id, "position:absolute;top:0px;left:0px;"+this.o.style_div_style+"zoom:1;overflow:hidden;zIndex:95", this.disp_id);
				create_element($("disp_div_"+this.disp_id), "div", "disp_div_pre_thumb_"+this.disp_id, "position:absolute;top:0px;left:0px;width:100px;height:100%;"+this.o.prev_thumb_div_style+"zoom:1;overflow:hidden", this.disp_id);
				create_element($("disp_div_"+this.disp_id), "div", "disp_div_nxt_thumb_"+this.disp_id, "position:absolute;top:0px;right:0px;width:100px;height:100%;"+this.o.next_thumb_div_style+"zoom:1;overflow:hidden", this.disp_id);
			if(this.pre_thumb != ""){
					$("disp_div_pre_thumb_"+this.disp_id).innerHTML	= "<div style='position:absolute;bottom:50%;left:50%;margin-left:-35px;margin-bottom:-20px;text-align:center;'><img src='"+this.pre_thumb+"' alt='previous' style='"+this.o.prev_thumb_img_style+"' /></div>";
				}else{
					$("disp_div_pre_thumb_"+this.disp_id).innerHTML	= "<div style='position:absolute;bottom:50%;left:50%;margin-left:-10px;margin-bottom:-8px;text-align:center;'><img src='images/closeBttn.png' alt='close' /></div>";
				}
			if(this.nxt_thumb != ""){
					$("disp_div_nxt_thumb_"+this.disp_id).innerHTML	= "<div style='position:absolute;bottom:50%;right:50%;margin-right:-35px;margin-bottom:-20px;text-align:center;'><img src='"+this.nxt_thumb+"' alt='next' style='"+this.o.next_thumb_img_style+"' /></div>";
				}else{
					$("disp_div_nxt_thumb_"+this.disp_id).innerHTML	= "<div style='position:absolute;bottom:50%;right:50%;margin-right:-10px;margin-bottom:-8px;text-align:center;'><img src='images/closeBttn.png' alt='close' /></div>";
				}
			var objs = ["disp_div_pre_thumb_"+this.disp_id, "disp_div_nxt_thumb_"+this.disp_id, "cover_photo"];
			for(var i=0, len=objs.length; i<len; i++){
				if($(objs[i])){
					$(objs[i]).onmouseover = function(){
						mousePoint();
					};
					$(objs[i]).onmouseout = function(){
						mouseDefault();
					};
					var n = objs[i];
					switch(n){
						case "disp_div_pre_thumb_"+this.disp_id :
							$(objs[i]).onclick = function(){
								dir = "pre";
								if(!this.root.creating && !this.root.closing)
									this.pre_thumb != "" ? img_obj.pv = new img_obj.img_disp((this.img_no-1), this.imgs, this.o, this.root) : this.close_me();
							}.bind(this);
							break;
						case "disp_div_nxt_thumb_"+this.disp_id :
							$(objs[i]).onclick = function(){
								dir = "nxt";
								if(!this.root.creating && !this.root.closing)
									this.nxt_thumb != "" ? img_obj.pv = new img_obj.img_disp((this.img_no+1), this.imgs, this.o, this.root) : this.close_me();
							}.bind(this);
							break;
						case "cover_photo" :
							$(objs[i]).onclick = function(){
								if(!this.root.creating && !this.root.closing)
									this.close_me();
							}.bind(this);
							break;
						default :
							break;
					}
				}
			}
			objs = null;
			if(this.fxObj.div_close != null)
				this.fxObj.div_close.cancel();
			this.fxObj.div_show = new Effect.Appear(
				"disp_div_"+this.disp_id, 
				{ 
					duration: 0.3, 
					from: 0.0, to: 1.0
				}
			);
			this.get_box_ready();
		},
		get_thumb_link:function(){
			if(this.img_no > 0){
				if(this.o.thumb_url_extra != ""){
					this.pre_thumb = this.o.thumb_url_extra+this.imgs[(this.img_no-1)];
				}else{
					this.pre_thumb = this.imgs[(this.img_no-1)].replace("large", "thumbs").replace("big", "thumb");
				}
			}
			if(this.img_no < (this.imgs.length-1)){
				if(this.o.thumb_url_extra != ""){
					this.nxt_thumb = this.o.thumb_url_extra+this.imgs[(this.img_no+1)];
				}else{
					this.nxt_thumb = this.imgs[(this.img_no+1)].replace("large", "thumbs").replace("big", "thumb");
				}
			}
		},
		get_new_id:function(){
			return obj_arr.length;
		},
		close_me:function(){
			this.root.closing = true;
			if(this.fxObj.div_show != null)
				this.fxObj.div_show.cancel();
			if(this.fxObj.cover_show != null)
				this.fxObj.cover_show.cancel();
			this.fxObj.div_close = new Effect.Fade(
				"disp_div_"+this.disp_id, 
				{ 
					duration: 0.1,
					afterFinish: function(){
						if($("disp_div_"+this.disp_id))
							d.body.removeChild($("disp_div_"+this.disp_id));
						obj_arr.remove(return_i(obj_arr, this.disp_id));
					}
				}
			);
			this.fxObj.cover_close = new Effect.Fade(
				"cover_photo", 
				{ 
					duration: 0.5,
					afterFinish: function(){
						$("cover_photo").style.display = "none"
						if($("side_img"))
							$("side_img").style.display = "block";
						$("cover_photo").onclick = null;
						$("cover_photo").onmouseover = null;
						$("cover_photo").onmouseout = null;
						mouseDefault();
					}.bind(this)
				}
			);		
		},
		get_box_ready:function(){
			var right = (f_clientWidth()/2) - ((this.o.init_w+100)/2); 
			//var top = (f_clientHeight()/2) - ((this.o.init_h+40)/2);
			var top = 30;
			if(this.fxObj.aft != null)
				this.fxObj.aft.cancel();
			var s = "right: "+(right)+"px;";
			this.fxObj.pre = new Effect.Morph(
				"disp_div_"+this.disp_id, 
				{
					style: "height: "+(this.o.init_h+40)+"+px; width: "+(this.o.init_w+100)+"px; "+s+" top: "+top+"px;", 
					duration: 0.5, 
					transition: Effect.Transitions.sinoidal, 
					afterFinish:function(){
						this.load_img();
						this.root.creating = false;
					}.bind(this) 
				}
			);
		},
		picture_loaded:function(){
			var right = (f_clientWidth()/2) - ((this.curr_img_width + 200)/2); 
			//var top = (f_clientHeight()/2) - (this.curr_img_height/2); 
			var top = 30; 
			if(this.fxObj.pre != null)
				this.fxObj.pre.cancel();
			var s = "right: "+(right)+"px;";
			this.fxObj.aft = new Effect.Morph(
				"disp_div_"+this.disp_id, 
				{
					style: "height: "+this.curr_img_height+"px; width: "+(this.curr_img_width + 200)+"px; "+s+" top: "+top+"px;", 
					duration: 0.5, 
					transition: Effect.Transitions.sinoidal 
				}
			);
			$("disp_img_"+this.disp_id).src	= this.current_img[0].src;
			if(this.fxObj.div_close != null)
				this.fxObj.div_close.cancel();
			this.fxObj.div_show = new Effect.Appear(
				"disp_div_img_"+this.disp_id, 
				{ 
					duration: 0.5, 
					from: 0.0, 
					to: 1.0,
					afterFinish:function(){
						
					}.bind(this)
				}
			);
		},
		load_img:function(){
			var i = return_i(obj_arr, this.disp_id);
			img_arr[i] = new the_img(this);
		},
		clean_up:function(){
			for(var i=0; i<obj_arr.length;i++){
				if(obj_arr[i].disp_id != this.disp_id){
					var a = return_i(obj_arr, obj_arr[i].disp_id);
					Effect.Fade(
						"disp_div_"+obj_arr[a].disp_id, 
						{ 
							duration: 0.2,
							afterFinish:function(){d.body.removeChild($("disp_div_"+obj_arr[a].disp_id));obj_arr.remove(a)}.bind(this)
						}
					);					
				}
			}
		},
		init:function(){
			return;
		}
	};
	the_img = function(p){
		this.root = p;
		this.disp_id = p.disp_id;
		this.loaded = false;
		this.my_timer_l = null;
		this.create_img();
		return this;
	}
	the_img.prototype = {
		create_img:function(){
			this.root.current_img[0] = new Image();
			this.root.current_img[0].src = this.root.current_img[1];
			this.my_timer_l = setInterval( function() {
				this.check_load();
			}.bind(this),30);
		},
		check_load:function(){
			var i = return_i(obj_arr, this.disp_id);
			var img = this.root.current_img[0];
			if(img.width > 0 && img.height > 0){
				getScreenSize();
				clearInterval(this.my_timer_l);
				this.my_timer_l = null;
				if(img.width>img.height){
					if(img.width > imgMaxW){
						imgDif = img.height/img.width;
						img.width = imgMaxW;
						img.height = img.width * imgDif;
					}
				}else{
					if(img.height > imgMaxH){
						imgDif = img.width/img.height;
						img.height = imgMaxH;
						img.width = img.height * imgDif;
					}
				}
				
				this.root.curr_img_width = img.width;
				this.root.curr_img_height = img.height;
				this.root.loaded = true;
				this.root.loading = false;
				
				create_element($("disp_div_"+this.root.disp_id), "div", "disp_div_img_"+this.root.disp_id, "position:absolute;left:100px;top:0px;display:none;zoom:1;"+this.root.o.img_div_style+"zIndex:96", this.root.disp_id);
				create_element($("disp_div_img_"+this.root.disp_id), "img", "disp_img_"+this.root.disp_id, "width:"+img.width+"px;height:"+img.height+"px;zoom:1", this.root.disp_id);
				
				img = null;
				
				this.root.picture_loaded();
			}else{
				clearInterval(this.my_timer_l);
				this.my_timer_l = setInterval( function() {
					this.check_load();
				}.bind(this),30);
			}
		},
		init:function(){
			return;
		}
	}
};
