var SCROLLER={};

function $$(i){return document.getElementById(i)}
function $$$(e,p){p=p||document; return p.getElementsByTagName(e)}

SCROLLER.slider=function(n){
	
	this.infoSpeed=this.imgSpeed=this.speed=10;
	this.thumbOpacity=this.navHover=70;
	this.scrollSpeed=5;
	this.n=n;
	this.c=0;
	this.a=[]
};

SCROLLER.slider.prototype={
	init:function(s){
		s=$$(s);
		var m=this.children(s), i=0, w=0;
		this.l=m.length;
		
		var u=$$(this.left), r=$$(this.right);
		u.onmouseover=new Function(this.n + '.autoCenterThumb=false; SCROLLER.scroll.init("'+this.n+'",-1,'+this.scrollSpeed+')');
		u.onmouseout=r.onmouseout=new Function('SCROLLER.scroll.cl("'+this.n+'")');
		r.onmouseover=new Function(this.n + '.autoCenterThumb=false; SCROLLER.scroll.init("'+this.n+'",1,'+this.scrollSpeed+')');
		this.p=$$(this.n)
		
		for(i;i<this.l;i++){
			this.a[i]={};
			var h=m[i], a=this.a[i];
			
			var subItems = this.children(h);
			//a.d=subItems[1].innerHTML;
			
			//a.l=subItems[2] && subItems[2].href != window.location?subItems[2].href:'';
			
			a.l=subItems[0]?subItems[0].href:'';
			var g=subItems[1];
			a.g = g;
			var ghover=subItems[2];
			a.ghover = ghover;
			
			var thumbCont = document.createElement('div');
			thumbCont.className = "thumbContainer";
			thumbCont.appendChild(g);
			this.p.appendChild(thumbCont);
			w+=parseInt(thumbCont.offsetWidth);
			if(i!=this.l-1){
				thumbCont.style.marginRight=this.spacing+'px';
				w+=this.spacing
			}
			this.p.style.width=w+'px';
			g.style.opacity=this.thumbOpacity/100;
			g.style.filter='alpha(opacity='+this.thumbOpacity+')';
			g.onmouseover=new Function('SCROLLER.alpha.set(this,100,5); this.s' + 'rc = "'+a.ghover.src+'";');
			g.onmouseout=new Function('if(!this.activeThumb) {SCROLLER.alpha.set(this,'+this.thumbOpacity+',5)} this.s' + 'rc = "'+a.g.src+'";');
			g.onclick=new Function(this.n+'.autoCenterThumb=true; window.location.href="'+a.l+'"');
			
		}
	},
	sibling:function( n, elem ) {
			var r = [];
	
			for ( ; n; n = n.nextSibling ) {
				if ( n.nodeType === 1 && n !== elem ) {
					r.push( n );
				}
			}
	
			return r;
		},	
	children:function( elem ) {
			return this.sibling( elem.firstChild );
	}
};

SCROLLER.scroll=function(){
	return{
		init:function(e,d,s){
			e=typeof e=='object'?e:$$(e); var p=e.style.left||SCROLLER.style.val(e,'left'); e.style.left=p;
			var l=d==1?parseInt(e.offsetWidth)-parseInt(e.parentNode.offsetWidth):0; e.si=setInterval(function(){SCROLLER.scroll.mv(e,l,d,s)},20)
		},
		mv:function(e,l,d,s){
			var c=parseInt(e.style.left); if(c==l){SCROLLER.scroll.cl(e)}else{var i=Math.abs(l+c); i=i<s?i:s; var n=c-i*d; e.style.left=n+'px'}
		},
		cl:function(e){e=typeof e=='object'?e:$$(e); clearInterval(e.si)}
	}
}();
SCROLLER.alpha=function(){
	return{
		set:function(e,a,s){
			e=typeof e=='object'?e:$$(e); var o=e.style.opacity||SCROLLER.style.val(e,'opacity'),
			d=a>o*100?1:-1; e.style.opacity=o; clearInterval(e.ai); e.ai=setInterval(function(){SCROLLER.alpha.tw(e,a,d,s)},20)
		},
		tw:function(e,a,d,s){
			var o=Math.round(e.style.opacity*100);
			if(o==a){clearInterval(e.ai)}else{var n=o+Math.ceil(Math.abs(a-o)/s)*d; e.style.opacity=n/100; e.style.filter='alpha(opacity='+n+')'}
		}
	}
}();
SCROLLER.alphatext=function(){
	return{
		set:function(e,s,content,target){
			a=0;
			e=typeof e=='object'?e:$$(e); var o=e.style.opacity||SCROLLER.style.val(e,'opacity'),
			d=a>o*100?1:-1; e.style.opacity=o; clearInterval(e.ai); e.ai=setInterval(function(){SCROLLER.alphatext.tw(e,a,d,s,content, target)},20)
		},
		tw:function(e,a,d,s,content, target){
			var o=Math.round(e.style.opacity*100);
			if(o==a){target.innerHTML=content; clearInterval(e.ai); SCROLLER.alpha.set(e,100,s);}else{var n=o+Math.ceil(Math.abs(a-o)/s)*d; e.style.opacity=n/100; e.style.filter='alpha(opacity='+n+')'}
		}
	}
}();

SCROLLER.style=function(){return{val:function(e,p){e=typeof e=='object'?e:$$(e); return e.currentStyle?e.currentStyle[p]:document.defaultView.getComputedStyle(e,null).getPropertyValue(p)}}}();

