function clickzoom(el)
{
	el.clickzoom();
}

//declaring the class
var ww_slide = Class.create();
//defining the rest of the class implmentation
ww_slide.prototype = {

	is_aktiv: false,
	auto_on: false,
	lastzoom: 0,
	imnum: -1,
	slTimer: null,
	slLast: '',
	slLast_disp: 0,

	slimg1_obj: '',
	slimg2_obj: '',
	fade_obj: '',

	slimg1: '',
	slimg2: '',
	fade_id: '',
	fade_off: false,
	gen_click: true,
	show_titel: true,
	play_imgon: '',
	play_imgoff: '',
	play_imgid: '',
	on_play: '',
	head_div: '',
	head_msg: '',
	array: '',
	numimg: 0,
	loading_img: '',
	loading_imgsrc: '',
	zoom_div: '',
	zoom_img: '',
	zoom_offset: 10,
	numimgs: 15,
	prev_ext: '',
	img_ext: '',
	img_ids: '',
	prev_class: '',
	prev_aclass: '',
	prev_lclass: '',
	show_time: 5,
	imgheight: 450,
	imgwidth: 450,
	

	initialize: function(options)
	{
		if(options.gen_click) this.gen_click=options.gen_click;
		if(options.show_titel) this.show_titel=options.show_titel;
		if(options.on_play) this.on_play=options.on_play;
		if(options.play_imgon) this.play_imgon=options.play_imgon;
		if(options.play_imgoff) this.play_imgoff=options.play_imgoff;
		if(options.play_imgid) this.play_imgid=options.play_imgid;
		if(options.head_div) this.head_div=options.head_div;
		if(options.head_msg) this.head_msg=options.head_msg;
		if(options.array) this.array=options.array;
		if(options.numimg) this.numimg=options.numimg;

		if(options.slimg1) this.slimg1=options.slimg1;
		if(options.slimg2) this.slimg2=options.slimg2;
		if(options.fade_id) this.fade_id=options.fade_id;
		if(options.fade_off) this.fade_off=options.fade_off;

		if(options.loading_img) this.loading_img=options.loading_img;
		if(options.loading_imgsrc) this.loading_imgsrc=options.loading_imgsrc;
		if(options.zoom_div) this.zoom_div=options.zoom_div;
		if(options.zoom_img) this.zoom_img=options.zoom_img;
		if(options.zoom_offset) this.zoom_offset=options.zoom_offset;
		if(options.numimgs) this.numimgs=options.numimgs;
		if(this.numimgs>this.numimg) this.numimgs=this.numimg; 
		if(options.prev_ext) this.prev_ext=options.prev_ext;
		if(options.img_ext) this.img_ext=options.img_ext;
		if(options.img_ids) this.img_ids=options.img_ids;
		if(options.prev_class) this.prev_class=options.prev_class;
		if(options.prev_aclass) this.prev_aclass=options.prev_aclass;
		if(options.prev_lclass) this.prev_lclass=options.prev_lclass;
		if(options.show_time) this.show_time=options.show_time;
		if(options.imgheight) this.imgheight=options.imgheight;
		if(options.imgwidth) this.imgwidth=options.imgwidth;

		var iobj=this;
		this.slimg1_obj = $(this.slimg1);
		this.fade_obj = wwInit_element(this.fade_id, {duration: 500,mtyp: 2,onComplete: function(){iobj.fade_complete()}});
		this.slimg1_obj.onload=function() { iobj.fade_in()};
		this.slimg2_obj = wwInit_element(this.slimg2, {duration: 500,mtyp: 2});

		if(this.zoom_img) setClick(this.zoom_img,function() { iobj.clickzoom()});
		this.stTimer = setInterval (function(){iobj.run();}, 1000);
		this.slLast=(new Date).getTime();
		addunLoadEvent(function(){ iobj.unload();})
		if(this.numimgs>=this.numimg)
		{
			for(i=0;i<this.numimgs;i++)
			{
				setSrc(this.img_ids+i,this.array[i][0]);
				setName(this.img_ids+i,''+i);
			}
		}
	},

	unload: function()
	{
		if(this.stTimer!=null)
		{
			clearInterval(this.stTimer);
			this.stTimer=null;
		}
		if(this.slimg1_obj!=null)
		{
			this.slimg1_obj.onclick=null;
			this.slimg1_obj.onload=null;
			this.slimg1_obj=null;
		}
		if(this.fade_obj!=null)
		{
			this.fade_obj.onComplete=null;
			this.fade_obj=null;
		}
		if(this.slimg2_obj!=null) this.slimg2_obj=null;
		if(this.img1!=null) this.img1.onload=null;
		this.on_play=null;
		this.array=null;
		for ( var i in this )
		{
			delete this[ i ];
		}
	},

	imover: function(obj,state)
	{
		if(state)
		{
			setSrc(this.zoom_img,obj.src);
			setTop(this.zoom_div,(findPosY(obj)-this.zoom_offset));
			setLeft(this.zoom_div,(findPosX(obj)-this.zoom_offset));
			show(this.zoom_div);
			this.lastzoom=obj.name;
		}
		else
		{
			hide(this.zoom_div);
		}
	},

	next: function()
	{
		this.imnum++;
		this.displclick(this.imnum);

	},

	prev: function()
	{
		this.imnum--;
		this.displclick(this.imnum);
	},

	displclick: function(num)
	{
		var obj=this;
		this.slLast=(new Date).getTime()+15000;
		setVisibility(this.loading_img,"visible");
		if(num<0)
		{
			num=this.numimg-1;;
		}
		if(num>=this.numimg)
		{
			num=0;
		}
		this.imnum=num;
		if(this.array[this.imnum][0]=='')
		{
			this.imnum=0;
		}
		if(this.numimgs>=this.numimg)
		{
			for(i=0;i<this.numimgs;i++)
			{
				setSrc(this.img_ids+i,this.array[i][0]+this.prev_ext);
				if(i==this.imnum)
				{
					setClass(this.img_ids+i,this.prev_aclass);
				}
				else
				{
					setClass(this.img_ids+i,this.prev_class);
				}
			}
		}
		else
		{
			for(i=0;i<this.numimgs;i++)
			{
				j=this.imnum-parseInt(this.numimgs/2)+i;
				if(j<0)
				{
					j+=this.numimg;
				}
				if(j>=this.numimg)
				{
					j-=this.numimg;
				}
				setSrc(this.img_ids+i,this.array[j][0]+this.prev_ext);
				if(j==this.imnum)
				{
					setClass(this.img_ids+i,this.prev_aclass);
				}
				else
				{
					if(j==this.numimg-1 && this.prev_lclass!='')
					{
						setClass(this.img_ids+i,this.prev_lclass);
					}
					else
					{
						setClass(this.img_ids+i,this.prev_class);
					}
				}
				setName(this.img_ids+i,''+j);
			}
		}
		if(this.is_aktiv)
			return;

		this.is_aktiv=true;
		ww_set_opacity(this.fade_obj,0);
		this.fade_obj.stNow=0;
		setVisibility(this.fade_obj,"hidden");
		setSrc(this.loading_img,this.loading_imgsrc);
		setTimeout(function() {obj.fade_start()},100);
	},

	fade_start: function()
	{
		this.slimg1_obj.src=this.array[this.imnum][0]+this.img_ext;
		this.slLast_disp=this.imnum;
		
	},

	run: function()
	{
		if(this.auto_on==true)
		{
			var time=(new Date).getTime();
			if((time-this.slLast) >= (this.show_time*1000))
			{
				this.imnum++;
				this.displclick(this.imnum);
				this.slLast=(new Date).getTime();
			}
		}
	},

	auto_stst: function(val)
	{
		var obj=this;
		if(val)
		{
			if(obj.on_play) obj.on_play(1);
			this.auto_on=true;
			this.slLast=0;
			if(this.play_imgid!='')
			{
				setClick(this.play_imgid,function()
				{
					obj.auto_stst(false);
				});
				setSrc(this.play_imgid,this.play_imgoff);
			}
		}
		else
		{
			this.auto_on=false;
			if(this.play_imgid!='')
			{
				setClick(this.play_imgid,function()
				{
					obj.auto_stst(true);
				});
				setSrc(this.play_imgid,this.play_imgon);
			}
		}
		if(this.on_play) this.on_play(val);
	},

	fade_in: function()
	{
		var obj=this;
		setTimeout(function() {setVisibility(obj.loading_img,"hidden")},10);
		this.slLast=(new Date).getTime();

		this.slimg1_obj.style.left=((this.imgwidth-this.slimg1_obj.offsetWidth)/2)+'px';
		this.slimg1_obj.style.top=((this.imgheight-this.slimg1_obj.offsetHeight)/2)+'px';
		ww_fade(this.fade_obj,100);
		if(this.fade_off)
		{
			this.slimg2_obj.stNow=100;
			ww_set_opacity(this.slimg2_obj,100);
			ww_fade(this.slimg2_obj,0);
		}
	},

	fade_complete: function()
	{
		var obj=this;

		if(this.show_titel)
		{
			setInnerHTML(this.head_div,this.array[this.slLast_disp][2]+this.head_msg+'('+(this.slLast_disp+1)+'/'+this.numimg+') ');
		}
		else
		{
			setInnerHTML(this.head_div,this.head_msg+'('+(this.slLast_disp+1)+'/'+this.numimg+')');
		}
		if(this.gen_click)
		{
			this.slimg1_obj.onclick=function()
			{
				location.href=obj.array[obj.slLast_disp][1];
			};
		}
		setTimeout(function() {obj.fade_switch()},100);
	},

	fade_switch: function()
	{
		var obj=this;

		this.slimg2_obj.style.left=this.slimg1_obj.style.left;
		this.slimg2_obj.style.top=this.slimg1_obj.style.top;
		this.slimg2_obj.src=this.slimg1_obj.src;
		this.slimg2_obj.stNow=100;
		ww_set_opacity(this.slimg2_obj,100);
		this.is_aktiv=false;
	},

	clickzoom: function()
	{
		this.displclick(eval(this.lastzoom));
		hide(this.zoom_div);
	}

};

