$(document).ready(function(){
        initPage();
});

function initPage() {

    // $("#ProgramScrollPane").jScrollPane({autoReinitialise: true});


    $("div.SplashScrollable").scrollable({ 
        size: 1, 
        speed: 2000,
        easing: "swing",
        clickable: false, 
        disabledClass: "scrollDisabled",
        circular: true,
        keyboard: 'static'
    }).autoscroll({interval: 8000});

}

function showDetail(url, product_name) {

    var dcontent='<div id="ProductDetail" class="ProductDetailContent" title="' + product_name + '"></div>';
    var dmessage=$(dcontent);

    dmessage.appendTo($('#Content'));
    dmessage.dialog({
       resizable: false,
       height:680,
       width:800,
       modal: true,
       open: function() {
          $.ajax({
              url:  url,
              cache: false,
              success: function(html){
                  $(".ProductDetailContent").html(html);
              }
          });
       },
       overlay: {
           backgroundColor: '#666',
           opacity: 0.5
       },
       buttons: {
           'Close': function() {
                dmessage.dialog('destroy');
            }
       }
    });
}


function modalECoupon()
{
    var w = '650';
    var h = '560';
    var auto = {w: w,h: h};
    var offsetWidth  = function(){return (($(window).width() / 2) - (auto.w / 2));};
    var offsetHeight = function(){return (($(window).height() / 2) - (auto.h / 2));};
    var containerCss = {width: w + 'px', height: h + 'px'};

    $(".AddECoupon").click(function(){
        $(this).effect("highlight", {}, 750);
        var body = $("#modal-content");
        body.attr('rel', 'Add eCoupons');
        body.modal({
            overlayId: 'modal-overlay',
            containerId: 'modal-container',
            containerCss: containerCss,
            closeHTML: dialog.titleBar,
            minHeight: h,
            opacity: 65, 
            position:[offsetHeight, offsetWidth],
            overlayClose:true,
            onOpen: dialog.onOpenAdd,
            onClose: dialog.onClose
        });
    });
}


var dialog = {
    h: '650',
    w: '850',
    body: function(){return $("#modal-content");},
    offsetWidth: function(){return (($(window).width() / 2) - (dialog.w / 2));},
    offsetHeight: function(){return (($(window).height() / 2) - (dialog.h / 2));},
    containerCss: function(){return {width: dialog.w + 'px', height: dialog.h + 'px'};},
    titleBar: '<div class="modal-close"><a class="simplemodal-close-button" style="cursor:pointer;">x</a><div class="simplemodal-title">Title</div><div class="Clear"><img src="/images/blank.gif" alt="" /></div></div>',
    onClose: function (d){
        var self = this;
        var body = $('#modal-content');
        d.container.slideUp('slow',
            function(){
                $('#modal-container').removeClass('ui-corner-all');
                self.close(); // or $.modal.close();
        });
    },
    onOpenAdd: function(d){
        var self = this;
        var body = $('#modal-content');
        self.container = d.container[0];
        $('#modal-container').addClass('ui-corner-all');
        d.overlay.fadeIn('fast', function (){
            $(".simplemodal-title", body.parent().parent()).html(body.attr('rel'));
                body.show();
                d.container.slideDown('slow');
        });
    }
};



