/*
 * jCarousel for Moblie - jQuery Plugin
 * http://www.inkdesign.jp/donwload/jCarousel-mobile/
 *
 * Original: jCarousel - jQuery Plugin
 * http://d.hatena.ne.jp/kudakurage/
 *
 * Thanks for  Kazuyuki Motoyama
 *
 * Copyright (c) 2010 Hiroki Tani (EC studio, inkdesign)
 * Licensed under the MIT license
 *
 * $Date: 2010-09-09
 * $version: 1.1
 *
 * This jQuery plugin will only run on devices running Mobile Safari
 * on iPhone or iPod Touch devices running iPhone OS 2.0 or later.
 * http://developer.apple.com/iphone/library/documentation/AppleApplications/Reference/SafariWebContent/HandlingEvents/HandlingEvents.html#//apple_ref/doc/uid/TP40006511-SW5
 */
var jCarousel={ua:"pc",num:0,target:[],sel:[],activeBool:false,active:0,main:0,colorSet:{black:{back:"#39A855",active:"#FF6600",shadow:"#333"},white:{back:"#666",active:"#999",shadow:"#333"}}};jCarousel.set=function(d){jCarousel.color=jCarousel.colorSet.black;jCarousel.main=0;if(typeof d=="object"){if(d.color=="white"){jCarousel.color=jCarousel.colorSet.white}if(!isNaN(d.main)){jCarousel.main=eval(d.main)}}$(".jCarousel").each(function(){if(!$(this).attr("name")){var b=jCarousel.num,e=$(this).width(),i=$(this).find("li").length;$(this).attr("name",b);jCarousel.target[b]=this;jCarousel.sel[b]={width:e,max:i,left:0,current:0,startX:0,endX:0,auto:0};$(this).wrap('<div class="jCarouselWrapper'+b+'"></div>');for(var l="",j=0;j<i;j++){l+='<a rel="'+j+'" name="'+b+'"></a>'}$(".jCarouselWrapper"+b).append('<div class="jCarouselNavi">'+l+"</div>");$(".jCarouselWrapper"+b+' .jCarouselNavi a[rel="'+jCarousel.sel[b].current+'"]').addClass("selected");$(".jCarouselWrapper"+b).css({overflow:"hidden",width:"100%"});$(this).css({width:"900000px",listStyle:"none",padding:0,margin:0,backgroundColor:"transparent"});$(this).find("li").css("float","left");$(this).find("li").css({width:e+"px",listStyle:"none",padding:0,margin:0,color:"#000"});$(".jCarouselWrapper"+b+" .jCarouselNavi").css({clear:"both",textAlign:"center"});$(".jCarouselWrapper"+b+" .jCarouselNavi b").css({fontSize:"14px",margin:"0 3px",verticalAlign:"5px"});$(".jCarouselWrapper"+b+" .jCarouselNavi a").css({display:"inline-block",width:"12px",height:"12px",margin:"5px",padding:"0px",backgroundColor:jCarousel.color.back,cursor:"pointer",borderRadius:"4px",boxShadow:"0px -1px 1px "+jCarousel.color.shadow,webkitBorderRadius:"4px",webkitBoxShadow:"0px -1px 1px "+jCarousel.color.shadow});$(".jCarouselWrapper"+b+" .jCarouselNavi a.selected").css({backgroundColor:jCarousel.color.active});if(jCarousel.ua=="mobile"){$(this).bind("touchstart",function(){var a=$(this).attr("name");jCarousel.active=a;jCarousel.sel[a].startX=event.touches[0].pageX;jCarousel.activeBool=true});$(window).bind("touchmove",function(){if(jCarousel.activeBool){var a=jCarousel.active;jCarousel.sel[a].endX=event.touches[0].pageX;var c=-jCarousel.sel[a].startX+jCarousel.sel[a].endX;$(jCarousel.target[a]).css({marginLeft:jCarousel.sel[a].left+c+"px"})}});$(window).bind("touchend",function(){if(jCarousel.activeBool){jCarousel.activeBool=false;var a=jCarousel.active,c=-jCarousel.sel[a].startX+jCarousel.sel[a].endX,h=jCarousel.sel[a].width/5,g=jCarousel.sel[a].current,k=jCarousel.sel[a].max;if(c>h&&g>0){g--}else{c<-h&&g<k-1&&g++}jCarousel.slide(a,g,200)}})}$(".jCarouselNavi a").click(function(){var a=$(this).attr("name"),c=$(this).attr("rel");jCarousel.slide(a,c,800);return false});jCarousel.num++}})};jCarousel.ini=function(){var b=navigator.userAgent;jCarousel.ua=b.indexOf("iPhone")>-1||b.indexOf("iPad")>-1||b.indexOf("iPod")>-1?"mobile":"pc";$(window).bind("orientationchange",function(){jCarousel.resize()});$(window).resize(function(){jCarousel.resize()})};jCarousel.slide=function(d,b){jCarousel.activeBool=false;var e=-b*jCarousel.sel[d].width;$(jCarousel.target[d]).css({marginLeft:e+"px"});jCarousel.sel[d].left=e;jCarousel.sel[d].current=b;$(".jCarouselWrapper"+d+" .jCarouselNavi a").css({backgroundColor:jCarousel.color.back});$(".jCarouselWrapper"+d+" .jCarouselNavi a[rel='"+b+"']").css({backgroundColor:jCarousel.color.active})};jCarousel.resize=function(){$(".jCarousel").each(function(){var d=$(this).attr("name"),b=$(".jCarouselWrapper"+d).width();jCarousel.sel[d].width=b;var e=-jCarousel.sel[d].current*jCarousel.sel[d].width;jCarousel.sel[d].left=e;$(this).find("li").css({width:b+"px"});$(this).css({marginLeft:e+"px"})})};jQuery.extend(jQuery.easing,{easeCarousel:function(d,b,e,f,i){return f*((b=b/i-1)*b*b+1)+e}});$(function(){jCarousel.ini();jCarousel.set()});
