
function clearDefault(el) {
    if (el.defaultValue == el.value) {
        el.value = "";
    }
}

function popUp(url, target) {
    window.open(url, target, 'height=300,width=400,top=375,left=500,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no');
}

/*
function popUpLearnMore()
{
window.open("../../test/include/learnMore.html", "", "'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=400,height=300,left = 500,top = 375');");
}
*/

//###################################################################
//M O D I F I C A T I O N    MARK SNYDER 6/10/08
//###################################################################
//###################################################################
//ATTEMPT TO LOCATE THE FORM ON WHICH THIS CONTROL RESIDES. IF FOUND,
//APPEND OR REPLACE THE QUERYSTRING NAME/VALUE PAIR.
//###################################################################
function updateQueryString(parmName, parmValue) {
    var mainForm;

    try {
        mainForm = document.forms['aspnetForm'];
        if (!mainForm) {
            mainForm = document.aspnetForm;
        }
    }
    catch (e) { }

    // If no aspnetForm is found, do not attempt to replace the name/value pair
    if (mainForm != null) {
        mainForm.action = replaceQueryStringParm(mainForm.action, parmName, parmValue);
    }
    return true;
}

//###################################################################
//M O D I F I C A T I O N    MARK SNYDER 6/10/08
//###################################################################
//###################################################################
//APPEND OR REPLACE THE QUERYSTRING NAME/VALUE PAIR.
//###################################################################  
function replaceQueryStringParm(url, parmName, parmValue) {
    var re = new RegExp("([?|&])" + parmName + "=.*?(&|$)", "i");
    if (url.match(re)) {
        return url.replace(re, '$1' + parmName + "=" + parmValue + '$2');
    }

    if (url.indexOf("?") == -1) {
        return url + '?' + parmName + "=" + parmValue;
    }
    else {
        return url + '&' + parmName + "=" + parmValue;
    }
}

//###################################################################
//M O D I F I C A T I O N    MARK SNYDER 7/1/08
//###################################################################
//###################################################################
//CALL THIS ON THE ONKEYPRESS EVENT OF A TEXTBOX TO CHECK FOR NUMERIC 
//CHARACTERS AND ALLOW ONLY NUMERIC CHARACTERS
//###################################################################
function numericOnly(e) {
    var key = String.fromCharCode(e.charCode ? e.charCode : e.keyCode);
    if (key >= 0 & key <= 9) {
        return true;
    }
    else {
        if (navigator.appVersion.indexOf("MSIE") != -1) {
            e.keyCode = 0;
            return false;
        }
        if (navigator.userAgent.indexOf("Firefox") != -1) {
            e.preventDefault();
            return false;
        }
        if (navigator.userAgent.indexOf("Safari") != -1) {
            e.preventDefault();
            return false;
        }
    }
}

//#########################################################################
// M O D I F I C A T I O N    Jonathan Parks 8/5/08     ISSUE # 4359
//#########################################################################
// This will be called from various support pages so we can manage changes
// to the chat queue's easier by only changing code in one place for them
//#########################################################################
function chatSelect(type) {
    if (type == "account") {
        window.open('http://www.charter.com/Visitors/chatlive.aspx?Chattype=Q_23170', '_charter_chat', 'width=550,height=660,left=50,top=15');
    }
    if (type == "cable") {
        window.open('http://www.charter.com/Visitors/chatlive.aspx?Chattype=Q_20957', '_charter_chat', 'width=550,height=660,left=50,top=15');
    }
    if (type == "internet") {
        window.open('http://www.charter.com/Visitors/chatlive.aspx?Chattype=Q_20956', '_charter_chat', 'width=550,height=660,left=50,top=15');
    }
    if (type == "telephone") {
        window.open('http://www.charter.com/Visitors/chatlive.aspx?Chattype=Q_21175', '_charter_chat', 'width=550,height=660,left=50,top=15');
    }
    if (type == "corporate") {
        window.open('http://www.charter.com/Visitors/chatlive.aspx?Chattype=Q_21193', '_charter_chat', 'width=550,height=660,left=50,top=15');
    }
    if (type == "order") {
        window.open('http://www.charter.com/Visitors/chatlive.aspx?Chattype=Q_21790', '_charter_chat', 'width=550,height=660,left=50,top=15');
    }
    if (type == "general") {
        window.open('http://www.charter.com/Visitors/chatlive.aspx?Chattype=CHATWINDOW', '_charter_chat', 'width=550,height=660,left=50,top=15');
    }
}


/*
This describes a weird difference in how Internet Explorer and Firefox 
handles the Document Object Model (DOM). In my case I got different 
browser-behaviour when using firstChild and nextSibling in a javascript. 
The problem is that the Firefox DOM does not ignore line breaks and whitespaces while IE does.

Instead of using firstChild and nextSibling you can use these functions (look below) that searches 
for the correct element in both major browsers.

Use getNextSibling(element) instead of element.nextSibling.
Use getFirstChild(element) instead of element.firstChild.

*/
function getNextSibling(startBrother) {
    endBrother = startBrother.nextSibling;
    while (endBrother.nodeType != 1) {
        endBrother = endBrother.nextSibling;
    }
    return endBrother;
}

function getFirstChild(elm) {
    if (!elm.childNodes.length) {
        return;
    }
    var children = elm.childNodes.length;
    for (var i = 0; i <= children; ++i) {
        if (elm.childNodes[i].nodeType == 1) {
            return elm.childNodes[i];
        }
    }
    return;
}
