// JavaScript Document
function ss(){
	
	this.current_slide = null;
	this.next_slide = null;
	this.slides = Array();
	
	this.is_ie = function(){
		var re = new RegExp("MSIE","i");
		var is_ie = re.test(navigator.userAgent);
		return is_ie;
	}
		
	this.get_next_slide = function(_this){
		var current_slide = _this.current_slide;
		var next_slide = (current_slide+1 >= _this.slides.length) ? 0 : current_slide+1 ;
		_this.hide_slide(_this.slides[current_slide]);
		_this.load_slide(_this.slides[next_slide]);
		_this.current_slide = next_slide;
		var nt = setTimeout(_this.get_next_slide_wrap,15000);
	}
	
	this.start = function(){
		if(this.slides){
			if(this.slides.length >= 1){
				this.load_slide(this.slides[this.current_slide]);
				if(this.slides.length > 1){
					var st = setTimeout(this.get_next_slide_wrap,15000);
				}
			}
		}
	}
	
	this.add_e_handler = function(obj, e, func){
		//test if func exists - prevents problems in IE
		if(typeof func != "undefined"){		
			if(obj.attachEvent){
				obj.attachEvent('on' + e, func);
			}else if(obj.addEventListener){
				obj.addEventListener(e, func, false);
			}else{
				obj['on' + e] = func;
			}
		}
	}
	
	this.remove_e_handler = function(obj, e, func){
		//test if func exists - prevents problems in IE		
		if(typeof func != "undefined"){
			if (obj.detachEvent){
				obj.detachEvent('on' + e, func);
			}else if(obj.removeEventListener){
				obj.removeEventListener(e, func, false);
			}else{
				obj['on' + e] = null;
			}
		}
	}	
	
	this.curry = function(method){
		var curried = [];
		for (var i = 1; i < arguments.length; i++) {
			curried.push(arguments[i]);
		}
		return function() {
			var args = [];
			for (var i = 0; i < curried.length; i++) {
				args.push(curried[i]);
			}
			for (var i = 0; i < arguments.length; i++) {
				args.push(arguments[i]);
			}
			return method.apply(null, args);
		}
	}
	
	// Callback fix for IE
	this.get_next_slide_wrap = this.curry(this.get_next_slide,this);

}
