﻿function txtPageNo_OnKeyUp(txt)
{
    var pageNo = txt.value;

    if (pageNo.length > 0)
    {
        if (isNaN(pageNo))
        {
            alert("Page No. must be a valid numeric value.");
            txt.value = "";
            return false;
        }

        if (parseInt(pageNo, 10) <= 0)
        {
            alert("Page No. must be greater than 0.");
            txt.value = "";
            return false;
        }

        if (pageNo.indexOf(".") > -1)
        {
            alert("Page No. must be a valid numeric value.");
            txt.value = "";
            return false;
        }
    }
}

function btnSearch_OnClick()
{
    var message = '';
    var kw = document.getElementById("dnn_ctr862_CatalogueSearch_txtKeywords");
    var keyword = '';
    if(kw != null)
    {
        keyword = kw.value;
    }
    
    var cat = document.getElementById("dnn_ctr862_CatalogueSearch_ddlCategories");
    
    var catid = '';
    if(cat != null)
    {
        catid = cat.value;
    }
    
    var sale = document.getElementById("dnn_ctr862_CatalogueSearch_ddlSales");
    
    var saleref = '';
    if(sale != null)
    {
        saleref = sale.value;
    }
    
    if(keyword == '' && catid == '' && saleref == '')
    {
        message = "Please select a sale or category, or enter a keyword for your search";
    }

    if(message != '')
    {
        alert(message);
        return false;
    }    
    
    
    return true;
}

function btnClear_OnClick()
{
    document.getElementById("dnn_ctr862_CatalogueSearch_ddlCategories").selectedIndex = 0;
    document.getElementById("dnn_ctr862_CatalogueSearch_txtKeywords").value = '';
    document.getElementById("dnn_ctr862_CatalogueSearch_txtPageNo").value = '';
    document.getElementById("dnn_ctr862_CatalogueSearch_txtLotNo").value = '';
}

function displaylargeimage(saleref, lotno)
{
    var url = PAGE_IMAGEDISPLAY + "?saleref=" + saleref + "&lotno=" + lotno;
    
    windowOpener(url, "windowname", "height=700 width=700 scrollbars=1 resizable=1 toolbar=0 menubar=0" );    
}

function windowOpener(url, name, args) {
if (typeof(popupWin) != "object"){
popupWin = window.open(url,name,args);
} else {
if (!popupWin.closed){ 
popupWin.location.href = url;
} else {
popupWin = window.open(url, name,args);
}
}
popupWin.focus();
}

function ShowCatUpload()
{
    var url = PAGE_CATUPLOAD;
    windowOpener(url, "catUpload", "height=300 width=600 scrollbars=0 resizable=0 toolbar=0 menubar=0 status=1" );
}

