﻿/*
* use in \HomePageSkin\4_Columns.ascx for Ybrant child portals
* add animate windows to home page
*/

function homepageinit() {
    $('.scroll-pane').jScrollPane({ showArrows: true, scrollbarWidth: 19, dragMaxHeight: 19 });
    var categoryName = $.url.param("category");
    switch (categoryName) {
        case 'Publishers':
            column1expand(false);
            break;
        case 'Advertisers':
            column2expand(false);
            break;
        case 'Product':
            column3expand(false);
            break;
    }

}

function column1expand(isAnimate) {
    $("#column2").hide();
    $("#column3").hide();
    if (isAnimate) {
        $("#column1").animate({
            width: 930
        }, 930, null,
	                function() { $("#column1 .scroll-pane").jScrollPane({ showArrows: true, scrollbarWidth: 19, dragMaxHeight: 19 }); }).addClass('expanded');
    }
    else {
        var cssObj = { 'width': '930' }
        $("#column1 .scroll-pane").jScrollPane({ showArrows: true, scrollbarWidth: 19, dragMaxHeight: 19 });
        $("#column1").addClass('expanded');
        $("#column1").css(cssObj);
    }
    $("#column1 .scroll-pane").css({ 'overflow': 'hidden' });
    $("#column1 .scroll-pane").css({ 'width': '100%' });
}

function column1reduce() {
    reduce();
    $("#column1").removeClass('expanded').animate({
        width: 298
    }, 930, null,
        function() {
            $("#column2").show();
            $("#column3").show();
            restorescroll();
        }
   );
    
}

function column2expand(isAnimate) {
    $("#column1").hide();
    $("#column3").hide();
    if (isAnimate) {
        $("#column2").animate({
            width: 930
        }, 930, null,
	                function() {
	                    $("#column2 .scroll-pane").jScrollPane(
	                        { showArrows: true, scrollbarWidth: 19, dragMaxHeight: 19 });
	                }).addClass('expanded');
    }
    else {
        var cssObj = { 'width': '930' }
        $("#column2 .scroll-pane").jScrollPane({ showArrows: true, scrollbarWidth: 19, dragMaxHeight: 19 });
        $("#column2").addClass('expanded');
        $("#column2").css(cssObj);
    }
    $("#column2 .scroll-pane").css({ 'overflow': 'hidden' });
    $("#column2 .scroll-pane").css({ 'width': '100%' });
}

function column2reduce() {
    reduce();
    $("#column2").removeClass('expanded').animate({
        width: 298
    }, 930, function() {
        $("#column1").show();
        $("#column3").show();
        restorescroll();
    }
    );
    
}

function column3expand(isAnimate) {
    $("#column1").hide();
    $("#column2").hide();
    if (isAnimate) {

        $("#column3").animate({
            width: 930
        }, 930, null,
	                function() { $("#column3 .scroll-pane").jScrollPane({ showArrows: true, scrollbarWidth: 19, dragMaxHeight: 19 }); }).addClass('expanded');
    }
    else {
        var cssObj = { 'width': '930' }
        $("#column3 .scroll-pane").jScrollPane({ showArrows: true, scrollbarWidth: 19, dragMaxHeight: 19 });
        $("#column3").addClass('expanded');
        $("#column3").css(cssObj);
    }
    $("#column3 .scroll-pane").css({ 'overflow': 'hidden' });
}

function column3reduce() {
    reduce();
    $("#column3").removeClass('expanded').animate({
        width: 298
    }, 930, null, function() {
        $("#column1").show();
        $("#column2").show();
        restorescroll();
    }
    );
}

function reduce() {
    $("#column1 .scroll-pane").jScrollPaneRemove();
    $("#column2 .scroll-pane").jScrollPaneRemove();
    $("#column3 .scroll-pane").jScrollPaneRemove();
}

function restorescroll() {
    $(".scroll-pane").jScrollPane({ showArrows: true, scrollbarWidth: 19, dragMaxHeight: 19 });
}

