﻿function popup(sUrl, width, height) {
    // add ts to make the popup url unique
    //sUrl += ((sUrl.toString().indexOf("?") != -1) ? "&" : "?") + "ts=" + (new Date()).getTime();
    // Getting rad window manager
    var oManager = GetRadWindowManager();
    // get window by name
    var oWindow = oManager.Open(sUrl, "PopupWindow");
    if (width != undefined)
        oWindow.SetWidth(width);
    if (height != undefined)
        oWindow.SetHeight(height);
    oWindow.Show();
    oWindow.Center();
}

function closePopup() {
    var oManager = GetRadWindowManager();
    if (typeof (oManager) != "undefined") {
        var wnd = oManager.GetWindowByName("PopupWindow");
        if (wnd != null)
            wnd.Close();
    }
}

function popup2(sUrl, width, height, target) {
    // add ts to make the popup url unique
    //sUrl += ((sUrl.toString().indexOf("?") != -1) ? "&" : "?") + "ts=" + (new Date()).getTime();
    var newWin = window.open(sUrl, target, "status=no,toolbar=no,location=no,resizable=yes,menubar=no,width=" + width + ",height=" + height);
    newWin.focus();
}

function ManageProductImage(productImageId)
{
    popup("/WebAppAdmin/PopupProductImageManager.aspx?ProductImageId=" + productImageId, 640, 480);
}

function ManageProductPrice(productImageId)
{
    popup("/WebAppAdmin/PopupProductPriceManager.aspx?ProductImageId=" + productImageId, 640, 525);
}

function btSearchGo_Click(searchUrl, txtFieldId)
{
    var field = document.getElementById(txtFieldId);
    if (field.value)
        location = searchUrl + '?' + field.value;
}

function GetRadWindow()
{
    var oWindow = null;
    if (window.radWindow) oWindow = window.radWindow;
    else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
    return oWindow;
}

function CloseOnReload()
{
    GetRadWindow().Close();
}

function RefreshParentPage()
{
    GetRadWindow().BrowserWindow.location.reload();
}

function ViewSizeGuideline()
{
    alert("view size guideline...");
}