var sv_slider=function(b){this.d=document.getElementById(b.id);if(!(!b||!b.id||!b.width||!b.height||!this.d)){var a=this;a.w=b.width;a.h=b.height;a.cb=b&&b.onstart?b.onstart:null;a.ce=b&&b.onend?b.onend:null;a.d.style.width=a.w+"px";a.d.style.height=a.h+"px";a.sts=b&&b.steps?b.steps:10;t=b&&b.speed?b.speed:400;a.tm=t/a.sts;a.del=b&&b.delay?b.delay:1E3;a.type=b&&b.type?b.type:"dropin";a.l=a.c=0;a.a=0;a.sw=Math.abs(a.w/a.sts);a.sh=Math.abs(a.w/a.sts);var d=a.d.getElementsByTagName("li");a.e=0;if(d.length> 0)for(b=0;b<d.length;b++){d[b].style.display=b==0?"block":"none";d[b].style.position="relative";a.e++}a.pl=function(){a.st();a.l=a.c;if(a.c==a.e-1)a.c=0;else a.c++;a.cb&&a.cb(a.c,a.l);a.an(true)};a.gt=function(c){if(!a.a&&c-1!=a.c){a.st();a.l=a.c;a.c=c-1;a._c()}};a._c=function(){a.cb&&a.cb(a.c,a.l);a.an(false)};a.nx=function(){if(!a.a){a.st();a.l=a.c;if(a.c==a.e-1)a.c=0;else a.c++;a._c()}};a.pr=function(){if(!a.a){a.st();a.l=a.c;if(a.c==0)a.c=a.e-1;else a.c--;a._c()}};a.an=function(c){d=a.d.getElementsByTagName("li"); el=d[a.l].style;ec=d[a.c].style;switch(a.type){case "dropandscroll":if(!a.a){a.t=0;a.cl=a.w;el.top="0px";el.left="0px";ec.top="0px";ec.left=a.w+"px";a.a=1}if(Math.abs(a.t)<Math.abs(a.h)){a.t+=a.sh;el.top=a.t+"px"}else if(a.cl>0){el.display="none";ec.display="block";if(a.cl-a.sw<0)a.cl=0;else a.cl-=a.sw;ec.left=a.cl+"px"}else{a.cl=a.w;a.t=0;a.a=0;a._e(c);return}a.ti=setTimeout(function(){a.an(c)},a.tm);break;case "scrollanddrop":if(!a.a){a.t=-a.h;a.cl=0;el.top="0px";el.left="0px";ec.top=-a.h+"px"; ec.left="0px";a.a=1}if(a.cl<a.w){if(a.cl+a.sw>a.w)a.cl=a.w;else a.cl+=a.sw;el.left=a.cl+"px"}else if(Math.abs(a.t)>0){el.display="none";ec.display="block";if(a.t+a.sh>0)a.t=0;else a.t+=a.sh;ec.top=a.t+"px"}else{a.cl=0;a.t=-a.h;a.a=0;a._e(c);return}a.ti=setTimeout(function(){a.an(c)},a.tm);break;case "slideout":if(!a.a){el.zIndex=1E3;ec.zIndex=1;a.cl=0;ec.display=el.display="block";if(a.l<a.c){el.top="0px";ec.top=-a.h+"px"}else{ec.top="0px";el.top=-a.h+"px"}el.left=ec.left="0px";a.a=1}if(a.cl<a.w){if(a.cl+ a.sw>a.w)a.cl=a.w;else a.cl+=a.sw;el.left=a.cl+"px"}else{el.display="none";ec.top="0px";a.cl=0;a.a=0;a._e(c);return}a.ti=setTimeout(function(){a.an(c)},a.tm);break;case "slidein":if(!a.a){el.zIndex=1;a.cl=a.w;ec.zIndex=1E3;ec.display=el.display="block";el.left="0px";ec.left=a.w+"px";if(a.l<a.c){el.top="0px";ec.top=-a.h+"px"}else{ec.top="0px";el.top=-a.h+"px"}a.a=1}if(a.cl>0){if(a.cl-a.sw<0)a.cl=0;else a.cl-=a.sw;ec.left=a.cl+"px"}else{el.display="none";ec.top="0px";a.cl=0;a.a=0;a._e(c);return}a.ti= setTimeout(function(){a.an(c)},a.tm);break;case "dropin":if(!a.a){a.a=1;el.zIndex=1;ec.zIndex=1E3;ec.display=el.display="block";el.left=ec.left="0px";if(a.l<a.c){el.top="0px";ec.top=-(2*a.h)+"px";a.ct=-(2*a.h)}else{ec.top=-a.h+"px";el.top=-a.h+"px";a.ct=-a.h}}if(a.l<a.c&&a.ct<-a.h){if(a.ct+a.sh>-a.h)a.ct=-a.h;else a.ct+=a.sh;ec.top=a.ct+"px"}else if(a.l>a.c&&a.ct<0){if(a.ct+a.sh>0)a.ct=0;else a.ct+=a.sh;ec.top=a.ct+"px"}else{el.display="none";ec.top="0px";a.ct=a.h;a.a=0;a._e(c);return}a.ti=setTimeout(function(){a.an(c)}, a.tm);break;case "riseout":if(!a.a){a.a=1;ec.zIndex=1;el.zIndex=1E3;ec.display=el.display="block";el.left=ec.left="0px";if(a.l<a.c){el.top="0px";ec.top=-a.h+"px";a.ct=0}else{ec.top="0px";el.top=-a.h+"px";a.ct=-a.h}}if(a.l<a.c&&a.ct>-a.h){if(a.ct-a.sh<-a.h)a.ct=-a.h;else a.ct-=a.sh;el.top=a.ct+"px"}else if(a.l>a.c&&a.ct>-(2*a.h)){if(a.ct-a.sh<-(2*a.h))a.ct=-(2*a.h);else a.ct-=a.sh;el.top=a.ct+"px"}else{el.display="none";ec.top="0px";a.ct=a.h;a.a=0;a._e(c);return}a.ti=setTimeout(function(){a.an(c)}, a.tm);break}};a._e=function(c){a.ce&&a.ce(a.c,a.l);if(c)a.ti=setTimeout(a.pl,a.del)};a.st=function(){clearTimeout(a.ti);a.ti=null};a.ti=setTimeout(a.pl,a.del)}};
var example1=function(id,id2,ani,ani2){
	// Set Script Options
	//random delay
	delay=[3000,4000,5000];

	var options = {
		"id":		id, // 			Required ID
		"width":	640,//			Required Width
		"height":	345,//			Required Height
		"delay":	delay[Math.floor(Math.random()*3)],//Optional Delay
		"speed":	400,//			Optional Speed
		"steps":	10,//			Optional Steps
		"onstart":	function(c,l){//Optional OnEnd Callback Function
						//Continually Alternate the type of slide transition effect
						sc.type=(sc.type==ani)?ani2:ani;
						//Change the class of the controls to reflect which slide is active
						c_div= document.getElementById(id2);
						divs=c_div.getElementsByTagName('div');
						divs[l].className='control_inactive';
						divs[c].className='control_active';					
					}
	};		

	///////////////////////////
	// Initialize The slider //
	///////////////////////////
	var sc= new sv_slider(options);
	// Immediately stop the playing of the slideshow to give us time
	// to setup the controls without interfering with the timing of 
	// the script
	sc.st();

	//Position the controls to lay on top of slideshow
	var c_div= document.getElementById(id2);
	c_div.style.position="relative";
	c_div.style.top=-(options.height-10)+"px";
	// Have to set the Z-index to higher then 1000 as the 
	// dropin,riseout,slidein and slideout animations set 
	// the slides zindex to 1000 at certain points.
	// This insures that the controls will always be visible
	c_div.style.zIndex=10000;

	//Add onclick event handlers to the controls
	var divs=c_div.getElementsByTagName('div');
	for(i=0;i<divs.length;i++){
		//The value of i coincides with the slide number that
		//each control will represent.
		//So all we have to do is call the 'goto' method of the class
		//and pass in the value of i.
		divs[i].num=i;
		divs[i].onclick=function(){sc.gt(this.num+1);};
	}

	//Now we start the slideshow back up by calling the play method.
	//If we were to call the play method immediately then the script
	//would switch to the next slide immediately.
	//To avoid this we use setTimeout
	// When setting the timeout it is best to catch the timer identifier 
	// returned and store it in the objects ti variable as it will allow
	// the controls to control the animation.
	sc.ti=setTimeout(function(){sc.pl(sc);},sc.del);

	};
