/**
 * jQuery.ScrollTo - Easy element scrolling using jQuery.
 * Copyright (c) 2007 Ariel Flesler - aflesler(at)gmail(dot)com
 * Licensed under GPL license (http://www.opensource.org/licenses/gpl-license.php).
 * Date: 10/29/2007
 * @author Ariel Flesler
 * @version 1.2.2
 * Compatible with jQuery 1.2.1, tested on Firefox 2.0.0.7, and IE 6, both on Windows.
 **/
(function($){
	$.scrollTo=function(a,b){
		return $('html,body').scrollTo(a,b)
	};
	$.fn.scrollTo=function(e,f){
		f=$.extend({axis:'y',speed:1},f||{});
		if(f.axis.length!=2)f.queue=false;
		if(f.queue)f.speed=Math.ceil(f.speed/2);
		return this.each(function(){
			var d=$(this),t=e,k,l,u={};
			switch(typeof t){
				case'string':if(/^([+-]=)?\d+(px)?$/.test(t))break;
				t=$(t,this);
				case'object':k=$(t).offset()
			}
			$.each(f.axis.split(''),parse);
			animate(f.onAfter);
			function parse(i,a){
				var b=a=='x'?'Left':'Top',p=b.toLowerCase();
				var c='scroll'+b;u[c]=k?k[p]+(d.is('html,body')?0:d[0][c]-d.offset()[p]):t;
				if(f.margin&&typeof t=='object')u[c]-=parseInt($(t).css('margin'+b))||0;
				if(!i&&f.queue){
					if(d[0][c]!=u[c])animate(f.onAfterFirst);
					delete u[c]
				}
			};
			function animate(a){
				d.animate(u,f.speed,f.easing,a)
			}
		})
	}
})
(jQuery);

/**
 * jQuery.ScrollShow - Scrolling Slideshow.
 * Copyright (c) 2007 Ariel Flesler - aflesler(at)gmail(dot)com
 * Licensed under GPL license (http://www.opensource.org/licenses/gpl-license.php).
 * Date: 10/30/2007
 * @author Ariel Flesler
 * @version 0.7
 **/
(function($){
	var f={
		elements:'img',itemSize:{height:120,width:154},view:null,navigators:null,navigationMode:'s',speed:600,wrappers:'simple',circular:false,
		easing:'linear',axis:'x',margin:true,start:null,setWidth:false
	};
	function wrap(a,b,c){
		switch(b){
			case'crop':a=a.wrap('<div class="jq-ss-crop">').parent().css('overflow','hidden');
			case'resize':return a.css(c);case'simple':return a.wrap('<div class="jq-ss-simple">').parent();
			case'link':if(a.is('img'))return a.wrap('<a target="_blank" class="jq-ss-link">').parent().each(function(){
				this.href=this.firstChild.src
			});
			default:return a
		}
	};
	$.fn.scrollShow=function(e){
		e=$.extend({},f,e);
		return this.each(function(){
			//var d=this,$v=e.view?$(e.view,this):this,$e=$(e.elements,$v),l=$e.length,q=0;
			var d=this,$v=e.view?$(e.view,this):this,$e=$(e.elements,$v),l=$e.length-1,q=0; // last child is right last
			$.each(e.wrappers.split(/\s*,\s*/),function(i,a){
				$e=wrap($e,a,e.itemSize)
			});
			$e.css(e.itemSize);
			if(!e.navigators){
				e.navigators='';
				e.navigationMode='r'
			}
			if(e.navigators.constructor!=Array)e.navigators=[e.navigators];
			$.each(e.navigationMode.split(''),function(i,b){
				switch(b.charAt(0)){
					case's':$(e.navigators[i],d).eq(0).bind('click',{dir:-1},sequential).end().eq(1).bind('click',{dir:+1},sequential);
					break;
					case'r':var c=$(e.navigators[i]||$e,d),r=$e.length/c.length;
					if(r===Infinity)return;
					c.each(function(a){
						//$(this).bind('click',{pos:Math.floor(r*a)},random) // item klo di klik maka geser kanan
					});
					break
				}
			});
			(function(a,w){
				var b=(a.width()+attrs('margin')+attrs('padding')+attr('border'));
				do w-=b;
				while(w>0&&l--);
				if(!e.setWidth)return;
				do {
					a=a.parent();
					if(a[0]==$v[0])return
				}
				while(a.length>1);
				a.width(b*$e.length)
			})
			($e,$v.width());
			if(e.start!=null)random(e.start);
			function attrs(a){
				return attr(a+'Left')+attr(a+'Right')
			};
			function attr(a){
				return parseInt($e.css(a))||0
			};
			function sequential(a){
				a.data.pos=q+a.data.dir;
				return random(a)
			};
			function random(a){
				var b=typeof a=='number'?a:a.data.pos;
				//if(b<0)b=q==0&&e.circular?l:0;
				if(b<0)b=q==0&&e.circular?0:0; // stop kiri
				//else if(b>l)b=q==l&&e.circular?0:l;
				else if(b>l)b=q==l&&e.circular?l:l; // stop kanan
				$v.stop().scrollTo($e[b],e);
				q=b;return false
			}
		})
	}
})
(jQuery);