var _Common_ = {
initRollovers:function(){
$('img[class=over]').hover(function(){
var src = $(this).attr("src");
var ftype = src.substring(src.lastIndexOf('.'), src.length);
$(this).attr("src",$(this).attr("src").replace(ftype,"_over"+ftype));
},function(){
$(this).attr("src",$(this).attr("src").replace("_over.","."));
});
return false;
},
scrollInit:function(){
$('a[href^=#],area[href^=#]').click(function(){
var href= this.hash;
if(href == "") return false;
var $target = $(href == '#TOP' ? 'body' : href);
if($target.size()){ 
var top = $target.offset().top; 
$($.browser.safari ? 'body' : 'html')
.animate({scrollTop:top}, 3000, 'easeOutCubic',function(){
location.href = href;
}); 
return false;
}
})

}
}

var index = {};
index.easing = "easeInOutExpo";
index.flag = "true";
index.timer = "";
index.second = 5000;
index.val = 683;
index.init = function(){

$(".control a,").hover(function(){
clearTimeout(index.timer);
var css = {width:"22px"};
$(this).stop().animate(css,300,'easeOutCubic');
},function(){
var css = {width:"22px"};
$(this).stop().animate(css,300,'easeOutCubic');
});
$(".prev a").click(function(){
index.set("prev");
return false;
});
$(".next a").click(function(){
index.set("next");
return false;
});


$(".main").hover(function(){
clearTimeout(index.timer);
},function(){
index.timer = setTimeout(function(){
index.set("next");
},index.second);
});

index.timer = setTimeout(function(){
index.set("next");
},index.second);



};
index.set = function(flag){
if(index.flag){
clearTimeout(index.timer);
index.flag = false;
var cssParam = {};
cssParam.marginLeft = (0 - index.val) + "px";
if(flag == "prev"){
$("ul.image li:last").insertBefore("ul.image li:first");
$("ul.image").stop().css(cssParam).animate({"marginLeft":"0px"}, 800 ,index.easing,function(){
Reset();     
});

}else{
$("ul.image").stop().animate(cssParam, 800 ,index.easing,function(){
Reset();
$("ul.image").append($("ul.image li:first"));
});
}
}


function Reset(){
var cssParam = {};
cssParam.marginLeft = "0px";
$("ul.image").css(cssParam);
index.flag = true;
index.timer = setTimeout(function(){
index.set("next");
},index.second);
}

};

$(function(){
   _Common_.initRollovers();
   index.init();
   $(".colorbox").colorbox({innerWidth:900,innerHeight:601,iframe:true,onOpen:function(){
index.flag = false;
clearTimeout(index.timer);
   },onClosed:function(){
index.timer = setTimeout(function(){
index.set("next");
},index.second);
index.flag = true;
   }})
});


jQuery.extend( jQuery.easing,
{
def: 'easeOutCubic',
easeOutCubic: function (x, t, b, c, d) {
return c*((t=t/d-1)*t*t + 1) + b;
},
easeOutExpo: function (x, t, b, c, d) {
return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
},
easeInOutExpo: function (x, t, b, c, d) {
if (t==0) return b;
if (t==d) return b+c;
if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
}
});

