﻿
var Result;

function directLink(element) {
    $.ajax({
        type: "POST",
        contentType: "application/json; charset=utf-8",
        url: "Database.asmx/VerifyFixture",
        data: "{'param':'" + element.value.replace(/[\\']/, "") + "'}",
        dataType: "json",
        success: function(msg) {
            Result = eval(msg);
            if (Result.valid == "true") {
				switch (Result.brandId) {
					case "100":
						window.location = "http://www.specSPI.com/Fixture.aspx?catalogId=" + Result.catalogId.toString() + "";
						break;
					case "102":
						window.location = "http://www.specAdvent.com/Fixture.aspx?catalogId=" + Result.catalogId.toString() + "";
						break;
					case "4413":
						window.location = "http://www.specStile.com/Fixture.aspx?catalogId=" + Result.catalogId.toString() + "";
						break;
				}
            }
            else {
                Boxy.load("errInvalid.htm", { title: "Not Found", unloadOnHide: true, x: 120, modal: true });
            }
        },
        error: function(e) {
            alert("failed: " + e.statusText);
        }
    });
    return false;
}
function processKey(element, e) {
    var key;
    if (window.event)
        key = window.event.keyCode
    else
        key = e.which;
    if (key == 13)
        return directLink(element);
}
