﻿

//################################################################
// Purpose: Display a web page in a basic popup window
//################################################################
function popupBasic(url, target, width, height) {
    window.open(url, target, "width=" + width + ",height=" + height + ",toolbar=no,location=no,directories=no,status=no,resizable=yes,menubar=no,scrollbars=no");
}


//################################################################
// Purpose: Display a web page in a scrollable popup window
//################################################################
function popupScrollable(url, target, width, height) {
    window.open(url, target, "width=" + width + ",height=" + height + ",toolbar=no,location=no,directories=no,status=no,resizable=yes,menubar=no,scrollbars=yes");
}


//################################################################
// Purpose: Display a web page in a scrollable popup window
//################################################################
function popupMeasurementConversion(queryString) {
    popupBasic(pathToHome + 'Tools/MeasurementConversion/?' + queryString, '_blank', 565, 155);
}


//################################################################
// Purpose: Spamer-foiling output of email address
//
// email should have "$" in place of "@" (e.g., "bob$aol.com").
//################################################################
function antiSpamEmail(email) {
    document.write(email.replace("$", "@"));
}

function antiSpamMailTo(email) {
    document.write('<A HREF="mailto:' + email.replace("$", "@") + '">');
}

function antiSpamHyperlink(email) {
    document.write('<A HREF="mailto:' + email.replace("$", "@") + '">' + email.replace("$", "@") + '</A>');
}


//################################################################
// Purpose: Paired with returnHintText(), gives a text box
//   control the ability to automatically clear out hint text
//   when the user clicks on or tabs into it.
//
// Here's an example of how you would use this:
// 
// <input name="Keywords" value="Keywords" class="SearchText_Empty"
//   onfocus="clearHintText(this, 'SearchText')"
//   onblur="returnHintText(this)"
// />
//################################################################
function clearHintText(textBox, newClassName) {
    if (textBox.clearHintTextDone != true) {
        textBox.clearHintTextDone = true;
        textBox.initialText = textBox.value;
        textBox.value = "";
        if (newClassName != null) {
            textBox.initialClassName = textBox.className;
            textBox.className = newClassName;
        }
    }
}

//################################################################
// Purpose: Paired with clearHintText(), fills the given text
//   box control with its original text and changes its class 
//   back to what it was before the user focused on it if it 
//   remains empty.
//################################################################
function returnHintText(textBox) {
    if (textBox.value == "") {
        textBox.clearHintTextDone = false;
        textBox.value = textBox.initialText;
        if (textBox.initialClassName != null) {
            textBox.className = textBox.initialClassName;
        }
    }
}

