﻿function GoTypeMatic(str) {
    
    if (document.getElementById('search01').value == '') {
        hideTypeMaticBox();
    }

    else {
        ret = TypematicSearch.FindMatches(str, OnTypematicComplete, OnTypematicError, OnTypematicTimeout);
    }

    return true;
}

function OnTypematicComplete(arg) {
    
    //if (!arg==null) {

    if (arg == '') {
        hideTypeMaticBox();
    }
    else {
        document.getElementById("typematicResults").innerHTML = arg;
        showTypeMaticBox();
    }
    //}


}

function OnTypematicTimeout(arg) {
    alert('Timeout Error: ' + arg);
}

function OnTypematicError(arg) {
    alert('WebService Error: ' + arg);
}

function positionTypeMatic() {
    var Xc = findMyAbsoluteLeft(document.getElementById('search01')) + 1;
    var Yc;
    if (window.navigator.appName == 'Netscape') {
        Yc = findMyAbsoluteTop(document.getElementById('search01')) + 20;
    }
    else {
        Yc = findMyAbsoluteTop(document.getElementById('search01')) + 20;
    }
    var displayValue = document.getElementById("typematicBox").style.display;
    document.getElementById("typematicBox").style.cssText = 'top: ' + Yc + 'px; left: ' + (Xc - 2) + 'px; display:' + displayValue;
}

function showTypeMaticBox() {
    positionTypeMatic();
    var currentDisplay = document.getElementById("typematicBox").style.display;
    if (document.getElementById("typematicBox").style.display == 'none') {

        document.getElementById("typematicBox").style.display = 'block';
     ;
    }
}

function hideTypeMaticBox() {
    document.getElementById("typematicBox").style.display = "none";
}

function SetClickCondition() {
    if (document.getElementById('search01').value == 'Search by Part Number or Keyword') {
        document.getElementById('search01').value = '';
    }
} 
