var slide_win_array 																= new Array();
var slide_disp_count 																= 0;
var slide_obj																		= null;
function slide_window(sw, sh, page, id){
	if(slide_win_array.length == 0){
		if(pv != null){
			var dup 																= pv.check_dup();
			$(photo_vw_array[dup].name).innerHTML 									= "";
			pv.close_me();
		}
		this.size_h																	= sh;
		this.size_w																	= sw;
		this.page																	= page;
		this.page_id																= id;
		var array_i																	= this.get_new_id();
		slide_win_array[array_i]													= this;
		this.my_timers																= new Array();
		this.curr_img_width															= 10;
		this.curr_img_height														= 10;
		this.name																	= "disp_"+array_i;
		this.disp_id 																= slide_disp_count;
		this.my_timer_a																= null;
		this.my_timer_h 															= null;
		this.mc_h 																	= 2;
		this.my_timer_w 															= null;
		this.mc_w 																	= 0;
		this.my_timer_b																= null;
		this.my_timer_i																= null;
		this.my_timer_b																= null;
		this.my_timer_c																= null;
		this.my_timers																= [this.my_timer_h, this.my_timer_w, this.my_timer_b, this.my_timer_i, this.my_timer_a, this.my_timer_c];
		this.box_fadeout_speed														= 50;
		this.bg_fadeout_speed														= 50;
		this.bg_fadein_speed														= 50;
		this.scale_speed															= 40;
		this.img_fadein_speed														= 4;
		slide_disp_count += 1;
		this.my_timer_b 															= setInterval( function() {
			this.fade_in_bg();
		}.bind(this),0);
		this.init();
		this.clean_up();
		this.create_disp();
		slide_obj 																	= this;
		return this;
	}else{
		if(slide_obj.page_id != id){
			slide_obj 																= slide_win_array[0];
			slide_obj.size_h														= sh;
			slide_obj.size_w														= sw;
			slide_obj.page															= page;
			slide_obj.page_id														= id;
			slide_obj.update_disp();
			return slide_win_array[0];
		}
	}
}
slide_window.prototype 																= {
	create_disp:function(){
		var i 																		= return_i(slide_win_array, this.disp_id);
		var disp_id																	= this.disp_id;
		create_element(d.body, "div", "disp_div_"+this.disp_id, "backgroundColor:#f3f3f3;position:fixed;bottom:50%;right:50%;width:30px;height:10px;marginRight:-15px;marginBottom:-5px;border:20px #5B5B5B solid;padding:0;opacity:0;filter:alpha(opacity=0);overflow:hidden;zoom:1;zIndex:9", this.disp_id);
		this.my_timer_a 															= setInterval( function() {
			this.fade_in();
		}.bind(this),0);
		this.grow_disp_w();
		new Ajax.Updater("disp_div_"+this.disp_id, this.page, {
			method: 'get',
			parameters: {req: "true"},
			evalScripts:true,
			onCreate:function(){
				$("disp_div_"+this.disp_id).innerHTML								= "<div style='margin:25% auto;height:36px;width:36px;'><img src='images/loading.gif'></div>";
			}.bind(this),
			onComplete:function(){
				//6LcJzLkSAAAAAP-Q45rzmSeij_OaZHFkCcky2QVF
				Recaptcha.create("6LdkCboSAAAAAPVE9wT_dee_-jpp5cdgHr-EOT-O",
					"recaptcha_div", {
					theme: "white"
				});
				clearInterval(this.my_timer_c);
				this.my_timer_c 													= setInterval( function() {
					this.check_captcha();
				}.bind(this),0);
			}.bind(this)
		});
	},
	update_disp:function(){
		for(var i=0; i<slide_win_array.length;i++){
			if(slide_win_array[i].disp_id != this.disp_id){
				for(var z=0; z<slide_win_array[i].my_timers.length; z++){
					clearInterval(slide_win_array[i].my_timers[z]);
				}
			}
		}
		var obj 																	= $("disp_div_"+this.disp_id);
		obj.style.width 															= "10px";
		obj.style.marginRight														= "-" + (nopx(obj.style.width)/2) + "px";
		obj.style.height 															= "10px";
		obj.style.marginBottom 														= "-" + (nopx(obj.style.height)/2) + "px";
		this.grow_disp_w();
		new Ajax.Updater("disp_div_"+this.disp_id, this.page, {
			method: 'get',
			parameters: {req: "true"},
			evalScripts:true,
			onCreate:function(){
				$("disp_div_"+slide_obj.disp_id).innerHTML							= "<div style='margin:25% auto;height:36px;width:36px;'><img src='images/loading.gif'></div>";
			},
			onComplete:function(){
				//6LcJzLkSAAAAAP-Q45rzmSeij_OaZHFkCcky2QVF
				Recaptcha.create("6LdkCboSAAAAAPVE9wT_dee_-jpp5cdgHr-EOT-O",
					"recaptcha_div", {
					theme: "white"
				});
				clearInterval(this.my_timer_c);
				this.my_timer_c 													= setInterval( function() {
					this.check_captcha();
				}.bind(this),0);
			}.bind(this)
		});
	},
	check_captcha:function(){
	    if($("recaptcha_response_field")){
			$("recaptcha_response_field").onkeyup = function(){
				try{
					check_register();
				}catch(ex){}
				try{
					check_forgot();
				}catch(ex){}
			}
			clearInterval(this.my_timer_c);
		}else{
			clearInterval(this.my_timer_c);
			this.my_timer_c 														= setInterval( function() {
					this.check_captcha();
			}.bind(this),0);
		}
	},
	close_disp:function(){
		clearInterval(this.my_timer_a);
		this.my_timer_a 															= setInterval( function() {
			this.fade_out();
		}.bind(this),0);
		clearInterval(this.my_timer_b);
		this.my_timer_b 															= setInterval( function() {
			this.fade_out_bg();
		}.bind(this),0);
	},
	get_new_id:function(){
		return slide_win_array.length;
	},
	fade_in:function(){
		try{
			var obj 																= $("disp_div_"+this.disp_id);
			if((obj.style.opacity*1)<1){
				alphas(obj, (this.box_fadeout_speed));
				clearInterval(this.my_timer_a);
				this.my_timer_a														= setInterval( function() {
					this.fade_in();
				}.bind(this),30);
			}else{
				clearInterval(this.my_timer_a);
			}
		}catch(ex){
		}
	},
	fade_in_bg:function(){
		try{
			var obj 																= $("cover");
			obj.style.display 														= "block";
			if((obj.style.opacity*1)<1){
				alphas(obj, (this.bg_fadein_speed));
				clearInterval(this.my_timer_b);
				this.my_timer_b														= setInterval( function() {
					this.fade_in_bg();
				}.bind(this),30);
			}else{
				clearInterval(this.my_timer_b);
			}
		}catch(ex){
		}
	},
	grow_disp_h:function(){
		var my_obj 																	= this;
		var obj 																	= $("disp_div_"+this.disp_id);
		if( nopx(obj.style.height) < this.size_h){
			obj.style.height 														= (nopx(obj.style.height)+this.scale_speed)+"px";
			obj.style.marginBottom 													= ((nopx(obj.style.marginBottom))-(this.scale_speed/2))+"px";
			clearInterval(this.my_timer_h);
			this.my_timer_h 														= setInterval( function() {
				this.grow_disp_h();
			}.bind(this),30);
		}else{
			if( nopx(obj.style.height) > this.size_h){
				obj.style.height 													= this.size_h + "px";
				obj.style.marginBottom 												= "-" + (nopx(obj.style.height)/2) + "px";
			}
			clearInterval(this.my_timer_h);
		}
	},
	grow_disp_w:function(){
		var obj 																	= $("disp_div_"+this.disp_id);
		var my_speed 																= this.scale_speed;
		var my_width 																= this.size_w;
		my_speed 																	= (my_width-nopx(obj.style.width))/10;
		if(my_speed < 2){
			my_speed 																= 2;
		}
		if( (nopx(obj.style.width)) < my_width){
			if( (nopx(obj.style.width) + my_speed) > my_width){
				obj.style.width														= my_width + "px";
				obj.style.marginRight												= "-" + (my_width/2) + "px";
			}else{
				obj.style.width 													= ((nopx(obj.style.width))+my_speed)+"px";
				obj.style.marginRight 												= ((nopx(obj.style.marginRight))-(my_speed/2))+"px";
			}
			clearInterval(this.my_timer_w);
			this.my_timer_w 														= setInterval( function() {
				this.grow_disp_w();
			}.bind(this),30);
		}else{
			if( (nopx(obj.style.width)) > my_width){
				obj.style.width 													= my_width + "px";
				obj.style.marginRight 												= "-" + (nopx(obj.style.width)/2) + "px";
			}
			clearInterval(this.my_timer_w);
			clearInterval(this.my_timer_h);
			this.grow_disp_h();
		}
	},
	fade_out:function(){
		var i 																		= return_i(slide_win_array, this.disp_id);
		var obj 																	= $("disp_div_"+this.disp_id);
		if((obj.style.opacity*1)>0){
			alphas(obj, (-1*this.box_fadeout_speed));
			clearInterval(this.my_timer_a);
			this.my_timer_a															= setInterval( function() {
				this.fade_out();
			}.bind(this),30);
		}else{
			clearInterval(this.my_timer_a);
			var ele 																= $("disp_div_"+this.disp_id);
            d.body.removeChild(ele);
			slide_win_array.remove(i);
		}
	},
	fade_out_bg:function(){
		var obj 																	= $("cover");
		if((obj.style.opacity*1)>0){
			alphas(obj, (-1*this.bg_fadeout_speed));
			clearInterval(this.my_timer_b);
			this.my_timer_b															= setInterval( function() {
				this.fade_out_bg();
			}.bind(this),30);
		}else{
			clearInterval(this.my_timer_b);
			obj.style.display 														= "none";
		}
	},
	clean_up:function(){
		try{
			for(var i=0; i<slide_win_array.length;i++){
				if(slide_win_array[i].disp_id != this.disp_id){
					for(var z=0; z<slide_win_array[i].my_timers.length; z++){
						clearInterval(slide_win_array[i].my_timers[z]);
					}
					var ele 														= $("disp_div_"+slide_win_array[i].disp_id);
					d.body.removeChild(ele);
					slide_win_array.remove(i);
				}
			}
		}catch(ex){
		}
	},
	init:function(){
		return;
	}
}
