﻿// JScript File

this.DefaultSearchText = "Search for an Author or Title";
this.SearchWindow = null;
this.NewsletterWindow = null;

window.onunload = function()
{
    if (this.SearchWindow) {
        this.SearchWindow.close();
    }
    if (this.NewsletterWindow) {
        this.NewsletterWindow.close();
    }
}

function search()
{
    var features = "directories=no,height=400,location=no,menubar=no,resizable=no,status=no,titlebar=no,toolbar=no,top=100,width=400,left=100";
    var searchText = document.getElementById("txt_SearchTNB").value;
    
    if (searchText != this.DefaultSearchText)
    {
        var url = encodeURI("tnbSearch.aspx?txt=" + searchText);
        this.SearchWindow = window.open(url, "_blank", features);
    }
}

function clearSearch()
{
    var search = document.getElementById("txt_SearchTNB");
    if (search.value == this.DefaultSearchText)
    {
        search.value = "";
    }
}

function setSearch()
{
    var search = document.getElementById("txt_SearchTNB");
    if (search.value == "")
    {
        search.value = this.DefaultSearchText;
    }
}

function signupNewsletter() {
    
    var url = "forms/newsletter.aspx";
    var def = "width=475,height=275,resizable=no,scrollbars=no,toolbar=no,location=no,directories=no,status=no,menubar=no,copyhistory=no";
    
    this.NewsletterWindow = window.open(url, null, def);
    
}
