/*
  Add by lin
*/
$(document).ready(function(){
	comLinkInit();
	ddtiv_init();
}); 
function comLinkInit(){
	aniSpeed=1000;//動画スピード
	boxWidth=140;//ulの横幅
	timer(6000,function(){nextComLink();});
	//nextComLink();
}
function nextComLink(){
	UlHTML="<ul>"+$("#tempComBanner ul:first").html()+"</ul>";
	$("#comBanner ul").before(UlHTML);
	$("#comBanner ul:not(.currentUl)").addClass("before");
	$("#comBanner").css("width",(boxWidth*2)+"px");
	$("#comBanner").css("left",-boxWidth);
	$("#comBanner .currentUl").css("left",boxWidth);
	$("#comBanner").animate({left: 0}, aniSpeed,"expoinout",function(){moveUL("before");}); 
}

function moveUL(className){
	UlHTML="<ul>"+$("#comBanner .currentUl").html()+"</ul>";
	$("#comBanner .currentUl").remove(); 
	$("#tempComBanner ul:first").remove(); 
	$("#tempComBanner").append(UlHTML);
	$("#comBanner").css("width",boxWidth+"px");
	$("#comBanner").css("left","0");
	$("#comBanner ."+className).removeClass().addClass("currentUl"); 
}
function timer(interval, callback)
 {
    var interval = interval || 100;
    if (!callback)
        return false;   
    _timer = function (interval, callback) {
        this.stop = function () {
            clearInterval(self.id);
        };      
        this.internalCallback = function () {
            callback(self);
        };     
        this.reset = function (val) {
            if (self.id)
                clearInterval(self.id);       
            var val = val || 100;
            this.id = setInterval(this.internalCallback, val);
        };    
        this.interval = interval;
        this.id = setInterval(this.internalCallback, this.interval);
        
        var self = this;
    };  
    return new _timer(interval, callback);
 };
