var slideShowClass = Class.create();
slideShowClass.prototype = {
  initialize: function(element, sliderLeft, sliderRight, scrollMain, scrollChild, elementMargin) {
		this.elementMargin = elementMargin;
		this.mainDiv = $(element);
		this.sliderLeft = sliderLeft
		this.sliderRight = sliderRight;
		this.scrollMain = scrollMain;
		this.scrollChild = scrollChild;
		this.elementMargin = elementMargin;
		this.intialScroll = 0;
		this.scrollChildWidth = this.scrollMain.getWidth();
		this.register_events();
		this.initailizeSlide();
  },
  
  register_events: function() {
	Event.observe(this.sliderRight, 'click', this.slideRight.bindAsEventListener(this));
	Event.observe(this.sliderLeft, 'click', this.slideLeft.bindAsEventListener(this));
  },
   
  initailizeSlide: function() {
	this.singleElementWidth = this.scrollChild.down('li').getWidth() + this.elementMargin;
	this.currentPosition = 1;
	this.scrollChild.style.width = (this.scrollChild.childElements().length * this.singleElementWidth)  + "px";
	this.scrollChild.style.left = '0px';
	this.intialScroll = this.scrollChild.positionedOffset().left;
	this.totalPage = (this.scrollChild.getWidth() / this.scrollChildWidth).ceil();
	this.removeSlider();
  },
  
  slideRight: function(event) {
	if(this.currentPosition < this.totalPage) {
		new Effect.Move(this.scrollChild, {x: this.scrollChildWidth * -1,  transition: Effect.Transitions.linear,duration: 0 });
		this.currentPosition++;
	}
	this.removeSlider();
  },
 
  slideLeft: function(event) {
	if(this.currentPosition > 1) {
		new Effect.Move(this.scrollChild, {x: this.scrollChildWidth,  transition: Effect.Transitions.linear,duration: 0 });
		this.currentPosition--;
	}
	this.removeSlider();
  },
  
  removeSlider: function(event) {
	if(this.currentPosition == 1) {
		this.sliderLeft.style.visibility = 'hidden';
	} else {
		this.sliderLeft.style.visibility = 'visible';
	}
	if(this.currentPosition == this.totalPage) {
		this.sliderRight.style.visibility = 'hidden';
	} else {
		this.sliderRight.style.visibility = 'visible';
	}
  },
  
  f_clientWidth: function() {
	return this.f_filterResults (
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
  },
  
  f_clientHeight: function() {
	return this.f_filterResults (
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
  },
  
  f_scrollLeft: function() {
	return this.f_filterResults (
		window.pageXOffset ? window.pageXOffset : 0,
		document.documentElement ? document.documentElement.scrollLeft : 0,
		document.body ? document.body.scrollLeft : 0
	);
  },
  
  f_scrollTop: function() {
	return this.f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
  },
  
  f_filterResults: function(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
  },
  
  browser: function() {
	var ua=navigator.userAgent.toLowerCase();
	is=function(t){ return ua.indexOf(t) != -1; };
	h=document.getElementsByTagName('html')[0];
	return (!(/opera|webtv/i.test(ua))&&/msie (\d)/.test(ua))?('ie ie'+RegExp.$1):is('gecko/')? 'gecko':is('opera/9')?'opera opera9':/opera (\d)/.test(ua)?'opera opera'+RegExp.$1:is('konqueror')?'konqueror':is('applewebkit/')?'webkit safari':is('mozilla/')?'gecko':'';
  }
}
