$(document).ready(function() {

});

$.ajaxSetup({
 url: '/ajax/index',
 dataType: 'json',
 type: 'POST'
});




function set_payment_method(type, oid, sid) {
// $('#msg_'+pid).text('');

 $.ajax({
  url: '/ajax/payment_method',
  data: { type: type, oid: oid, sid: sid },
  success: function(res) {
   
   if (!res.err) {
    $("p.info").remove();
    $("#payment_method_list").remove();
    $("#payment_method").show();
    $("#payment_method div").hide();
    $("#payment_method div#type_"+type).show();
    
    $("#payment_method ul li b.cost_order").text(res.cost_order);
   }
   
   else alert(res.err);
   
  }
  
 })
 
}








// dynamicSlideshow
jQuery.fn.dynamicSlideshow = function(attr) {
 attr = attr || {};
 attr.duration = attr.duration || 5000;
 function initSlider(container, img) {
  var curr = 1;
  setInterval( function(){
   if (curr == img.length) { curr = 0; }
   var i = new Image();
   $(i).load(function(){
    $(container).append(this);
    $(container).find('img:first').css({'z-index': 1});
    $(this).css({opacity: 0.0, 'z-index': 2}).animate({opacity: 1.0}, 1000, function() {
      $(container).find('img:first').remove();
     })
   }).attr('src', img[curr++]).css({position:'absolute',top:0,left:0,'z-index':8});
  }, attr.duration );
 };

 $(this).each(function(){
  var img = [];
  $(this).find("a").each(function(){
   img.push($(this).attr("href"));  
  });
  var j = new Image();
  var container = this;
  $(this).empty();
  $(j).attr('src', img[0]).css({position:'absolute',top:0,left:0,'z-index':0}).load(function(){
   $(container).append(this);
   initSlider(container, img);
  });
 });
}

