﻿$(document).ready(function() {
    /*$('#bannerslide').bxSlider({  
    mode: 'fade',  
    speed: 1000,  
    pause: 10000,  
    auto: true,  
    controls: true,  
    auto_direction: 'right',  
    next_text: 'next',  
    prev_text: 'previous',  
    width: 650,  
    wrapper_class: 'example3_container' 
    });  */

    $(".scrollable").scrollable({ circular: true }).autoscroll({ autoplay: true }); ;

    //banner admin functions
    $('.bannerup').live('click', function() {
        doProcess(getBannerID($(this).attr('href')), getCountryID($(this).attr('href')),"up");
    });
    $('.bannerdown').live('click', function() {
        doProcess(getBannerID($(this).attr('href')), getCountryID($(this).attr('href')), "down");
    });
    $('.bannerdelete').live('click', function() {
        doProcess(getBannerID($(this).attr('href')), getCountryID($(this).attr('href')), "delete");
    });
});

function getCountryID(hrefstring) {
    var id = hrefstring.substr(hrefstring.indexOf('|') + 1, hrefstring.length);
    return id;
   
}

function getBannerID(hrefstring) {
    var id = hrefstring.substr(0, hrefstring.indexOf('|'));
    return id;
}


function doProcess(bannerid, countryid, action) {
    var url = "";
    if (action == "up") url = "/siteadmin/banner.aspx/MoveBannerUp";
    else if (action == "down") url = "/siteadmin/banner.aspx/MoveBannerDown";
    else if (action == "delete") url = "/siteadmin/banner.aspx/DeleteBanner";
    if (url != "") {
        $.ajax({
            type: "POST",
            url: url,
            data: '{"bannerid":"' + bannerid + '","countryid":"' + countryid + '"}',
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function(obj) {
                window.location.href = "default.aspx";
            }
        });
    }
    return false;
}

