﻿var methodHandlers = {};
methodHandlers.ShowItem = function(obj) {
    $("#ItemPopup").html(obj);

    $.openDOMWindow({
        loader: 1,
        positionType: 'centered',
        draggable: 1,
        loader: 1,
        loaderHeight: 158,
        loaderImagePath: 'http://admin.furnituredealer.net/images/bigSpinner.gif',
        loaderWidth: 191,
        width: 450,
        height: 300,
        overlayOpacity: 50,
        windowSourceID: '#ItemPopup',
        borderSize:'2',
        windowPadding:0
    });
};

methodHandlers.ShowExtendedItem = function(obj) {
    ShowItemPopupest(obj);
};

methodHandlers.UpdateExtendedItem = function(obj) {
    UpdateItemPopup(obj);
};

methodHandlers.ShowWishlistStatus = function(obj) {
    $("#WishlistStatus").html("<span class=\"WishListStatus\">" + obj + "</span>");
    //document.getElementById("WishlistStatus").innerHTML = obj;
};

function ShowItemPopupest(obj) {
    $("#ItemPopup").html(obj);

    $.openDOMWindow({
        positionType: 'centered',
        draggable: 1,
        loader: 1,
        loaderHeight: 158,
        loaderImagePath: 'http://admin.furnituredealer.net/images/bigSpinner.gif',
        loaderWidth: 191,
        width:750,
        height: 570,
        overlayOpacity:50,
        windowSourceID: '#ItemPopup',
        borderSize: '5',
		windowPadding:0
    });
}

function UpdateItemPopup(obj) {
    //document.getElementById("silversiteExtendedInfoPopupInternal").innerHTML = null;
    //alert(obj);
    $("#silversiteExtendedInfoPopupInternal").html(obj).show("slow");
}

/// --------------------------------------------------
/// popupInfo object
/// --------------------------------------------------
var popupInfo =
{
    result: null
}

popupInfo.Init = function() {
    
};

popupInfo.GetInfoPopupHtml = function(dealerId, customerId, sessionId, imageUrl, itemId, itemNum, targetMethod, parameters) {
    PageMethods.InfoPopupHtml(dealerId, customerId, sessionId, imageUrl, itemId, itemNum, targetMethod, parameters, popupInfo.ExecuteCommandCallback, popupInfo.ExecuteCommandFailed);
};

popupInfo.GetExtendedInfoPopupHtml = function(dealerId, customerId, sessionId, imageUrl, itemId, itemNum, targetMethod, parameters) {
    PageMethods.ExtendedInfoPopupHtml(dealerId, customerId, sessionId, imageUrl, itemId, itemNum, targetMethod, parameters, popupInfo.ExecuteCommandCallback, popupInfo.ExecuteCommandFailed);
};

popupInfo.SaveWishlistItem = function(dealerId, customerId, sessionId, itemId, itemNum, targetMethod, parameters) {
    PageMethods.SaveWishlistItem(dealerId, customerId, sessionId, itemId, itemNum, targetMethod, parameters, popupInfo.ExecuteCommandCallback, popupInfo.ExecuteCommandFailed);
};

popupInfo.ExecuteCommandCallback = function(result) {
    if (result) {
        try {
            popupInfo.result = result[0];
            eval(result[1] + "(popupInfo.result);");
        } catch (err) {
            //alert(err);
        }
    }
};

popupInfo.ExecuteCommandFailed = function(error, userContext, methodName) {
    if (error) {
    }
};


///
Sys.Application.add_load(applicationLoadHandler);
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endRequestHandler);
Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(beginRequestHandler);

function applicationLoadHandler() {
    /// <summary>
    /// Raised after all scripts have been loaded and 
    /// the objects in the application have been created 
    /// and initialized.
    /// </summary>
    popupInfo.Init()
}

function endRequestHandler() {
    /// <summary>
    /// Raised before processing of an asynchronous 
    /// postback starts and the postback request is 
    /// sent to the server.
    /// </summary>

    // TODO: Add your custom processing for event
}

function beginRequestHandler() {
    /// <summary>
    /// Raised after an asynchronous postback is 
    /// finished and control has been returned 
    /// to the browser.
    /// </summary>

    // TODO: Add your custom processing for event
}

function showTab(divtoshow, tabtoactive) {
    document.getElementById('ItemPage_Tab1Content').className = 'ItemPage_HiddenTab';
    document.getElementById('ItemPage_Tab2Content').className = 'ItemPage_HiddenTab';
    document.getElementById('ItemPage_Tab3Content').className = 'ItemPage_HiddenTab';
    document.getElementById('ItemPage_Tab4Content').className = 'ItemPage_HiddenTab';
    document.getElementById(divtoshow).className = 'ItemPage_ShownTab';
    document.getElementById('ItemPage_Tab1').className = '';
    document.getElementById('ItemPage_Tab2').className = '';
    document.getElementById('ItemPage_Tab3').className = '';
    document.getElementById('ItemPage_Tab4').className = '';
    document.getElementById(tabtoactive).className = 'active';
}