﻿function ChangeBGColor(color, id) {
    document.getElementById(id).style.backgroundColor = color;
}
function ChangeBGImage(image, id) {
    var imageDir = '../images/'
    var value = 'url(' + imageDir + image + ')';
    document.getElementById(id).style.backgroundImage = value;
}

//Undoing Google Toolbar highlighting//
function jsAttachEvent() {
    if (window.attachEvent)
        window.attachEvent("onload", setListeners);
}
function setListeners() {
    inputList = document.getElementsByTagName("INPUT");
    for (i = 0; i < inputList.length; i++) {
        inputList[i].attachEvent("onpropertychange", restoreStyles);
        inputList[i].style.backgroundColor = "";
    }
    selectList = document.getElementsByTagName("SELECT");
    for (i = 0; i < selectList.length; i++) {
        selectList[i].attachEvent("onpropertychange", restoreStyles);
        selectList[i].style.backgroundColor = "";
    }
}
function restoreStyles() {
    if (event.srcElement.style.backgroundColor != "" && event.srcElement.style.backgroundColor != "") {
        event.srcElement.style.backgroundColor = ""; /* color of choice for AutoFill */
        document.all['googleblurb'].style.display = "block";
    }
}

//Used on Registration Page//
function toggleCheckBoxes(ckId, classToToggle) {
    var numOfClasses = classToToggle.length;
    var isChecked = $("#" + ckId + ":checkbox:checked").val() == 'on';
    for (var i = 0; i < numOfClasses; i++) {
        $("." + classToToggle[i] + " input").attr("checked", isChecked);
    }
}

//General jQuery additions
   //Clears a dropdown list with a given id  
   function clearDropDown(ddlId)
   {
     $("#" + ddlId + " > option").remove();
   }
   //Adds items to a drop down list with a give id and html
   function addDropDownItems(ddlId, html)
   {
     var ddl = $("#" + ddlId + "");
     ddl.append(html);
   }
   //Disables an Element with a given id
   function disableElement(elemId)
   {
      var elem = $("#" + elemId + "");
      elem.attr("disabled", "disabled");
    }
   //Enables an element with a given id
   function enableElement(elemId) {
     var elem = $("#" + elemId + "");
     elem.removeAttr("disabled");
    }
   //Creates an option html string
   function createOption(value, text) {
     var html = "<option value='" + value + "'>" + text + "</option>";
     return html;
   }
   function getSelectedItemInDropDownList(id) {
     return $("#" + id + " > option:selected").val();
   }
   function toggleVisibility(idToHide, idToShow) {
       $("#" + idToHide + "").addClass("displaynone");
       $("#" + idToShow + "").removeClass("displaynone");
   } 