/*
// PHOTO_VIEW.JS 
// EXPANDS DIV AND PLACES FLASH THUMBNAIL WIEWER
// COPYRIGHT 2010 - JUSTIN ENOS - robotcoupdetat@gmail.com
//		receives parameters from provided object
// 		closes any already opened ones to limit memory usage by flash
//		utilizes scriptaculous.js, prototype.js and document_functions.js
// FREE TO USE, JUST KEEP THIS HEADER IN THE FILE
*/
function photo_view_obj() {
	this.pv	= null;
	var obj_arr = new Array();
	var n = true;
	var mult = 1;
	this.photo_view = function(d, a, o){
		this.div_id = d;
		var dup = this.check_dup();
		if(dup != null){
			n = false;
			mult = 1;
			obj_arr[dup].open ? obj_arr[dup].clean_up() : obj_arr[dup].open_pv();
			return obj_arr[dup];
		}else{
			this.fxObj = {
				open: null,
				close: null
			}
			this.a = a;
			this.ops = o;
			this.open = false;
			this.ai = obj_arr.length;
			obj_arr[this.ai] = this;
			n = true;
			mult = 1;
			this.clean_up();
			this.init();
			this.open_pv();
			return this;
		}
	}
	this.photo_view.prototype = {
		pv_ops:function(o){
			try{
				for (var i=0, len = o.length; i<len; i++)
				{
					var x = o[i];
					x.to.is != null ? x.obj[x.ch][x.to.is] = x.to.what : x.obj[x.ch] = x.to.what;
				}
			}catch(ex){}
		},
		open_pv:function(){
			this.open = true;
			$(this.div_id).style.display = "block";
			this.pv_ops(this.ops.prior_fx.open.items.ops);
			if(this.fxObj.close != null)
				this.fxObj.close.cancel();
			this.fxObj.open = new Effect.Morph(
				this.div_id, 
				{
					style: "height: " + this.ops.height + "px;", 
					duration: 0.5, 
					transition: Effect.Transitions.sinoidal, 
					afterFinish:function(){
						this.pv_ops(this.ops.after_fx.open.items.ops);
						var so = new SWFObject(this.ops.flash.swf, this.ops.flash.name, this.ops.flash.width, this.ops.flash.height, this.ops.flash.ver, this.ops.flash.bg, this.ops.flash.menu, this.ops.flash.wmode);
						so.write(this.div_id);
						this.fxObj.open = null;
					}.bind(this) 
				}
			);
			Effect.ScrollTo(this.div_id, { duration:'0.6', offset:-1*(this.ops.height+(this.ops.height*mult)) });
		},
		close_pv:function(){
			this.open = false;
			this.pv_ops(this.ops.prior_fx.close.items.ops);
			$(this.div_id).innerHTML = "";
			if(this.fxObj.open != null)
				this.fxObj.open.cancel();
			this.fxObj.close = new Effect.Morph(
				this.div_id, 
				{
					style: "height: 0px;", 
					duration: 0.5, 
					transition: Effect.Transitions.sinoidal, 
					afterFinish:function(){
						this.pv_ops(this.ops.after_fx.close.items.ops);
						$(this.div_id).style.display = "none";
						this.fxObj.close = null;
						obj_arr.remove(return_i(obj_arr, this.disp_id));
					}.bind(this) 
				}
			);
		},
		check_dup:function(){
			for(var i=0, len = obj_arr.length; i<len; i++){
				if(obj_arr[i].div_id == this.div_id)
					return i;
			}
			return null;
		},
		clean_up:function(){
			try{
				for(var i=0, len = obj_arr.length; i<len; i++){
					if(obj_arr[i].open){
						mult++;
						obj_arr[i].close_pv();
					}
				}
			}catch(ex){alert(ex)}
		},
		init:function(){
			return;
		}
	}
}
