// All js wrote by this project are here.

// For the e-mail sign up validate.
function checkEmail() {
        var email = document.getElementById("emailAdd").value;
        var reg = /^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/;
        if (reg.test(email)) {
            return true;
        }
        else {
            alert("Email's format is not right");
            return false;
        }
    }

function changeHighlight(highlight) {
    var headerStyle = document.getElementById(highlight + '-h').style;
    headerStyle.display = 'block';
    headerStyle.background = '#660000';
    headerStyle.height = '30px';
    headerStyle.padding = '0 12px';
    headerStyle.fontSize = '14px';
    headerStyle.fontFamily = 'Times New Roman';
    headerStyle.fontWeight = 'bold';
    headerStyle.color = '#FFFFFF';
    headerStyle.lineHeight = '30px';
    headerStyle.textdecoration = 'none';

    var footerStyle = document.getElementById(highlight + '-f').style;
    footerStyle.color = '#99CC00';
}

// For homepage video section.
function displayHomeVideo(youtube_id, count) {
    for (i = 1; i <= count; i++) {
      document.getElementById('homevideo' + i).style.display = 'none';
      document.getElementById('videotitle' + i).style.color = '#003366';
      document.getElementById('videolist' + i).style.background = 'transparent url(/wp-content/themes/chrome_10/images/arrow.gif) no-repeat scroll 3px 5px';
    }
    document.getElementById('homevideo' + youtube_id).style.display = 'block';
    document.getElementById('videotitle' + youtube_id).style.color = 'red';
    document.getElementById('videolist' + youtube_id).style.background = 'transparent url(/wp-content/themes/chrome_10/images/arrow_up.gif) no-repeat scroll 0 8px';
}

// Change the sidebar highlight
function hightlightSidebar(current_url) {
    var current_item = document.getElementById(current_url);
    if (current_item != null) {
        current_item.style.color = "#C4573C";
    }
}
// Set ids for li links
function setLiIds(topId) {
    var elem = document.getElementById(topId);
    if (elem != null) {
        var elem = elem.getElementsByTagName("a");
        for (var i = 0; i < elem.length; i++) {
            var id = elem[i].getAttribute('id');
            var href = elem[i].getAttribute('href');
            if (href != 'undefined' && href != '') {
                elem[i].setAttribute('id', href);
            }
        }
    }
}
