var sliders;
var slidesBox;
var totalSlides;
var curslide;
var dir;
var offset;
var IE6=(navigator.appVersion.indexOf("MSIE 6.0")>-1);
	$(document).ready(function() {
		if (IE6) {							   
			 $(".pngfix").each(function() {
				DD_belatedPNG.fixPng(this);
			});
		}
		sliders = $(".sld");
		initSliders();
	});
	function initSliders() {
		sliders.each(function() {
			this.slidebox = $(".slides", $(this));
			this.slides = $(".slide", $(this));
			this.total = this.slides.length;
			this.arws  = $('.arw', $(this));
			this.offset = parseInt(this.slides.outerWidth());
			this.cur = 1;
			
			
			this.slidebox.width(this.slides.outerWidth()*this.total);
			if (this.total<2) {
				/// IE6 FIX	///
				if (IE6) {
					$(this.arws[1]).css('background-position', 'right bottom');	
					$(this.arws[0]).css('background-position', '0 bottom');
				}
				/// IE6 FIX	\\\
				this.arws.addClass('dis');
			}
			else {
				/// IE6 FIX	///
				if (IE6)	$(this.arws[0]).css('background-position', '0 bottom');
				/// IE6 FIX	\\\
				$(this.arws[0]).addClass('dis');
			}
			this.arws.bind('click', moveSlider);
			this.arws.bind('mousedown mouseup mouseout mouseenter', downstate);
		});
	}
	function downstate(e) {
		
		if ($(this).hasClass('dis')) return;
		if (e.type == "mousedown") {
			/// IE6 FIX	///
			if (IE6) {
				if (this.className.indexOf('rt')>-1) {
					$(this).css('background-position', 'right 1px');	
				}
				else $(this).css('background-position', '0 1px');
			}
			/// IE6 FIX	\\\
			$(this).addClass('down');
		}
		/// IE6 FIX	///
		else if (e.type == "mouseenter") {
			if (IE6) {
				if (this.className.indexOf('rt')>-1) {
					$(this).css('background-position', 'right -114px');	
				}
				else $(this).css('background-position', '0 -114px');
			}
		}
		/// IE6 FIX	\\\
		else if (e.type == "mouseup" || e.type == "mouseout") {
			
			/// IE6 FIX	///
			if (IE6) {
				if (this.className.indexOf('rt')>-1) {
					$(this).css('background-position', 'right -229px');	
				}
				else $(this).css('background-position', '0 -229px');
			}
			/// IE6 FIX	\\\
			$(this).removeClass('down');
		}
	}
	function moveSlider() {
		var $this = $(this);
		var which = $this.parent('.sld').get(0);
		if ($this.hasClass('dis')) return;
		else if ($this.hasClass('lft')) {
			which.slidebox.animate({'margin-left':"+="+which.offset});
			which.cur--;
		}
		else {
			which.slidebox.animate({'margin-left':"-="+which.offset});
			which.cur++;
		}
		checkSlider(which);
	}
	
	function checkSlider(who) {
		/// IE6 FIX	///
		if (IE6) {
			$(who.arws[0]).css('background-position', '0 -229px');
			$(who.arws[1]).css('background-position', 'right -229px');
		}
		/// IE6 FIX	\\\
		who.arws.removeClass('dis');
		if (who.cur==1) {
			/// IE6 FIX	///
			if (IE6) $(who.arws[0]).css('background-position', '0 bottom');
			/// IE6 FIX	\\\
			$(who.arws[0]).addClass('dis');	
		}
		else if (who.cur==who.total) {
			/// IE6 FIX	///
			if (IE6) $(who.arws[1]).css('background-position', 'right bottom');
			/// IE6 FIX	\\\			
			$(who.arws[1]).addClass('dis');
		}
		else return;
	}
