﻿function alternate() {
    if (document.getElementsByTagName) {
        var table = document.getElementById("alternate");
        var rows = table.getElementsByTagName("tr");
        for (i = 0; i < rows.length; i++) {
            if (i % 2 == 0) {
                rows[i].className = "light";
            }
            else {
                rows[i].className = "dark";
            }
        }
    }
}

function displayTableStyle(selectObj) {
    if (selectObj) {
        var table = selectObj;
        var rows = table.getElementsByTagName("tr");
        for (i = 0; i < rows.length; i++) {
            if (i % 2 == 0) {
                rows[i].className = "light";
               // alert('yes');
            }
            else {
                rows[i].className = "dark";
            }
        }
        
    }
    
}

function displayTableByTagP(selectObj) {
    alert('Good!!');
    if (selectObj) {
        var div = selectObj;
        var p = div.getElementsByTagName("p");
        for (i = 0; i < p.length; i++) {
            if (i % 2 == 0) {
                p[i].className = "light";
            }
            else {
                p[i].className = "dark";
            }
        }

    }
}

function alternatepartners(divid) {

    if (document.getElementsByTagName && document.getElementById(divid)) {
        var div = document.getElementById(divid);
        var p = div.getElementsByTagName("p");
        for (i = 0; i < p.length; i++) {
            if (i % 2 == 0) {
                p[i].className = "light";
            }
            else {
                p[i].className = "dark";
            }
        }

    }
}

function altpurchaserouting() {
    if (document.getElementsByTagName) {
        var table = document.getElementById("ResultsGrid");
        var rows = table.getElementsByTagName("tr");

        for (i = 0; i < rows.length; i++) {
            if (i % 2 == 0) {
                rows[i].className = "light";
            }
            else {
                rows[i].className = "dark";
            }
        }

    }

}

function alternateli() {
    if (document.getElementsByTagName) {
        var ul = document.getElementById("northamerica");
        var listitems = ul.getElementsByTagName("li");
        for (i = 0; i < listitems.length; i++) {
            if (i % 2 == 0) {
                listitems[i].className = "light";
            }
            else {
                listitems[i].className = "dark";
            }
        }
    }
}
function alternateli2() {

    var ul = document.getElementById("downloadslist");
    var listitems = ul.getElementsByTagName("li");
    for (i = 0; i < listitems.length; i++) {
        if (i % 2 == 0) {
            listitems[i].className = "dark";
        }
        else {
            listitems[i].className = "dark";
        }
    }

}
function EmailFocus(txtval) {
    if (txtval != "" && txtval != "undefined") {
        document.thisForm.Email.value = txtval;
    }
    if (document.thisForm.Email.value == "Enter in your email") {
        document.thisForm.Email.value = "";
    }
}

function EmailBlur() {
    if (document.thisForm.Email.value == "") {
        document.thisForm.Email.value = "Enter in your email";
    }
}

function validateEmail(emailTxt) {
    var allValid = true;
    var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_@.";
    var checkStr = emailTxt;

    for (i = 0; i < checkStr.length; i++) {
        ch = checkStr.charAt(i);
        for (j = 0; j < checkOK.length; j++) {
            if (ch == checkOK.charAt(j))
                break;
        }
        if (j == checkOK.length) {
            allValid = false;
            break;
        }
    }
    if (emailTxt == "Enter in your email" || emailTxt == "") {
        allValid = false;
    }
    if (!allValid) {

        alert("The email address can only contain letters, numbers and (@),( - ),( . )");
    }

    var myString = emailTxt;
    var myLength = myString.length;
    var myAt = "@";
    var myAtIndex = myString.indexOf(myAt);
    var myPeriod = ".";
    var myPeriodindex = myString.indexOf(myPeriod);

    if ((myAtIndex == -1) || (myAtIndex == 0) || (myAtIndex >= (myLength - 1))) {
        allValid = false;
    }
    if ((myPeriodindex == -1) || (myPeriodindex == 0) || (myPeriodindex == myLength)) {
        allValid = false;
    }
    if (myString.indexOf(myAt, (myAtIndex + 1)) != -1) {
        allValid = false;
    }
    if ((myString.substring((myAtIndex - 1), myAtIndex) == myPeriod) ||
       		(myString.substring((myAtIndex + 1), (myAtIndex + 2)) == myPeriod)) {
        allValid = false;
    }
    if (myString.indexOf(myPeriod, (myAtIndex + 2)) == -1) {
        allValid = false;
    }

    if (allValid) {
        document.thisForm.hdnsub.value = 'clicked';
        document.thisForm.submit();
    }
    else {
        alert("Please format your email address using the standard convention of 'username@domain.ext'");
    }
}