
/*  해당 banner의 bannerID, bannerType(top:세로, left:가로)을 파라미터로 받음 
 * */

/* 다음 배너 보이기 기본 */
function nextBannerList(bannerID, bannerType, playTime, isStart){
  if( isStart == "false" ){    
    stopBannerList(bannerID);
  }
  
  var obj = $("#"+bannerID+">li:last");  
  if(bannerType == 'top'){
    $("#"+bannerID+">li").animate({ top : getHeight(obj, bannerType)}, playTime, function() {
      $("#"+bannerID+">li").css(bannerType,0); 
      obj.prependTo($("#"+bannerID));    
    });
    
  }else if (bannerType == 'left'){
    $("#"+bannerID+">li").animate({ left : getHeight(obj, bannerType)}, playTime, function() {
      $("#"+bannerID+">li").css(bannerType,0); 
      obj.prependTo($("#"+bannerID));    
    });    
  }  
  if( isStart == "false" ){
    //$("#"+bannerID).attr("timer", setInterval("nextBannerList('"+bannerID+"','"+bannerType+"')", playTime, "false"));
  }
}

/* 이전 배너 보이기 */
function prevBannerList(bannerID, bannerType, playTime, isStart){
  
  stopBannerList(bannerID);
 
  var obj = $("#"+bannerID+">li:first");
  
  if(bannerType == 'top'){    
  $("#"+bannerID+">li").animate({ top : getHeight(obj, bannerType) * (-1)}, playTime, function() {
    $("#"+bannerID+">li").css(bannerType,0);
    obj.appendTo($("#"+bannerID));
    });
  } else if ( bannerType == "left") {
    $("#"+bannerID+">li").animate({ left : getHeight(obj, bannerType) * (-1)}, playTime, function() {
      $("#"+bannerID+">li").css(bannerType,0);
      obj.appendTo($("#"+bannerID));
    });    
  }
  
  //$("#"+bannerID).attr("timer", setInterval("nextBannerList('"+bannerID+"','"+bannerType+"')", playTime, "false"));
}
function stopBannerList(bannerID){
  
  clearInterval($("#"+bannerID).attr("timer"));
  
}

/* 해당 객체의 높이를 구함 */
function getHeight(obj, bannerType) {
  
  var height = null;
  if ( bannerType == "top" ) {    
    height = ( obj.outerHeight(true) - obj.outerHeight() ) / 2 + obj.outerHeight();
  }else if ( bannerType == "left" ) {
    height = ( obj.outerWidth(true) - obj.outerWidth() ) / 2 + obj.outerWidth();
  }
  
  return height;
}