﻿// JScript File
function onKeywordSearch(txtFieldId)
{
    var txtField = document.getElementById(txtFieldId);
    if (txtField.value.length > 0 && txtField.value != "Keyword or item number") {
        window.location = "/SearchResult.aspx?Keywords=" + txtField.value;
    }
    else {
        alert("You must enter a keyword or item number to search.");
    }
}

function popupProductDetail(prodId) {
    var dh = document.documentElement.clientHeight;
    var dw = document.documentElement.clientWidth;
    var cw = dw > 1024 ? 1024 : dw - 20;
    var ch = dh > 728 ? 728 : dh - 20;
    popup("/popupProductDetail.aspx?ProdId=" + prodId, cw, ch);
}

function popUp(URL) 
{
    day = new Date();
    id = day.getTime();
    eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=440,height=550');");
}

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 GetRadWindow() {
    var oWindow = null;
    if (window.radWindow) oWindow = window.radWindow;
    else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
    return oWindow;
}

function CloseAndRedirect(sUrl) {
    try {
        GetRadWindow().BrowserWindow.location = sUrl;
    }
    catch (e) { }
}


