$(document).ready(function () {
    $( "#btn-review-open" ).click(function() {
        existUnsavedData = (existUnsavedData ? !confirm(gConfirmsavelesValue) : existUnsavedData);
        if(!$('#btn-review-open').hasClass('btn-vertical-right-select') && !existUnsavedData){
            $('#box-layout-east-title').html(gReviewTitle);
            $('#btn-review-open').removeClass('btn-vertical-right').removeClass('btn-vertical-right-unselect').addClass('btn-vertical-right-select');
            $('#btn-discussion-open').removeClass('btn-vertical-right').removeClass('btn-vertical-right-select').addClass('btn-vertical-right-unselect');
            loadreview();
        }
	});

    $( "#btn-discussion-open" ).click(function() {
        if ($("#main").css("padding-right") == "20px")
            $("#main").css("padding-right", "");
            
        existUnsavedData = (existUnsavedData ? !confirm(gConfirmsavelesValue) : existUnsavedData);
        if(!$('#btn-discussion-open').hasClass('btn-vertical-right-select') && !existUnsavedData){
            $('#box-layout-east-title').html(gForumTitle);
            $('#btn-discussion-open').removeClass('btn-vertical-right').removeClass('btn-vertical-right-unselect').addClass('btn-vertical-right-select');
            $('#btn-review-open').removeClass('btn-vertical-right').removeClass('btn-vertical-right-select').addClass('btn-vertical-right-unselect');
            if (typeof poll_goguid != 'undefined') {
                loadforum(poll_goguid, poll_grguid);
            }
        }
    });

    $(window).resize(function() {
        var $window = $(this),
            windowWidth = $window.width();
        if (typeof isMobileMode !== 'undefined' && isMobileMode != 1){
            if (windowWidth < 900 && $( ".ui-layout-button-open-east" ).length ) {
                $( ".ui-layout-button-open-east" ).css("right",'' + (windowWidth - 1000 + 100) + 'px'); //Task 63037
            } else {
                $( ".ui-layout-button-open-east" ).css("right", "0px");
            }
        } else {
            var panelwidth = $('#header-pane-north').width();
            //Task 71447
            $( "#btn-review-open" ).css("left",'' + (panelwidth + 20) + 'px'); 
            $( "#btn-discussion-open" ).css("left",'' + (panelwidth + 20) + 'px');
        }
    });    

    function resizeW(){
        $(window).resize();
    }
    if (typeof isMobileMode !== 'undefined' && isMobileMode != 1){
        resizeW();
    } else {
        setTimeout(resizeW, 150);
    }
});
