﻿function validateLicenseCode()
{
    if (document.getElementById("txtUse") && trim(document.getElementById("txtUse").value) == "")
    {
        document.getElementById("txtUse").focus();
        alert("No license code entered.");
        return false;
    }

    return true;
}

function raiseError(message)
{
    try
    {
        document.getElementById("txtUse").focus();
    }
    catch(e)
    {
    }

    alert("ERROR: " + message);
}

function displayCode()
{
    var licenseCodeDescription = getHttpResponse("../Postback/LicenseCodeLookup.aspx?licenseCode=" + encodeURIComponent(trim(document.getElementById("txtSingleCode").value)));

    if (!licenseCodeDescription)
    {
        alert("Invalid license code provided. Make sure to provide a single license code to look up. Use the Decoder Box below to decode a complete license summary code.");
        return;
    }

    var win = window.open("LicenseCodeDescription.aspx?licenseCodeDescription=" + encodeURIComponent(trim(licenseCodeDescription)), "LicenseCodeDescription", "top=50,left=150,width=500,height=90,resizable=0,scrollbars=0,status=0");

	if (win && win.open)
	{
		win.focus();
	}
	else
	{
		alert("Your browser's pop-up blocker is preventing the term window from displaying on your screen. " +
	    	  "Please set your pop-up blocker to allow this site to open the window.");
    } 
}

function autoLookup(e)
{
    var key = navigator.appName == 'Netscape' ? e.which : e.keyCode;

    if (key == 13)
    {
	    displayCode();
	    return false;
    }

    return true;
}

