// error handling

function get_location(idOfControlToTag, divToPosition, divToPositionBackground, divToPositionColor, orientationVertical, orientationHorizontal, fixedWidth, offsetLeft) {
    var width = 0;
    var height = 0;
    var top = 0;
    var left = 0;
    var getAttributes = null;        
    document.getElementById("hdnDivToClose").value = divToPosition;
    if (document.getElementById(idOfControlToTag)) {
        getAttributes = $("#" + idOfControlToTag);
    } else {
        alert("Control to tag not found:" + idOfControlToTag);
        return false;
    }
    if (!(document.getElementById(divToPosition))) {
        alert("Div to position not found");
        return false;
    }    
    var pos = getAttributes.position();    
    if (fixedWidth) {
        width = fixedWidth;
    } else {
        width = document.getElementById(idOfControlToTag).offsetWidth;
    }
    height = document.getElementById(idOfControlToTag).offsetHeight;
    top = pos.top;
    if (offsetLeft) {        
        left = pos.left + offsetLeft;
    } else {
        left = pos.left;
    }
    set_position(width, height, top, left, divToPosition, divToPositionBackground, divToPositionColor, orientationVertical, orientationHorizontal, idOfControlToTag);
}

function set_position(w, h, t, l, d, bgColor, fgColor, orientVertical, orientHorizontal, setsFocus) {
    var container = document.getElementById(d);
    container.style.width = w + "px";
    if (orientHorizontal == "left") {
        container.style.left = (l - w) + "px";
    }
    if (orientHorizontal == "center") {
        container.style.left = l + "px";
    } else {
        if (orientVertical == "below") {
            t = t - h;
        } else {
            t = t + h;
        }
    }
    if (orientHorizontal == "right") {
        container.style.left = (l + w) + "px";
    }
    if (orientVertical == "below") {
        container.style.top = (t + h) + "px";
    }
    container.style.position = "absolute";
    container.style.zIndex = "100";
    container.style.backgroundColor = bgColor;
    container.style.color = fgColor;
    container.style.visibility = "hidden";
    container.style.display = "";
    if (orientVertical == "above") {
        container.style.top = (t - container.offsetHeight) + "px";
    }
    container.style.display = "none"
    container.style.visibility = "visible";
    fade_in(d, setsFocus);
}

function fade_in(divToAnimate, setsFocus) {    
    $("#" + divToAnimate).slideDown(500), function() {
        set_focus(setsFocus);
    }    
}

function set_focus(id) {
    $('#' + id).focus();
}

function hide_message() {
    if (document.getElementById("hdnDivToClose")) {
        if (document.getElementById("hdnDivToClose").value) {
            var id = document.getElementById("hdnDivToClose").value
            if (document.getElementById(id)) {
                document.getElementById(id).style.display = "none";
            }
        }
    }
}

function Check(id) {
     if (document.getElementById(id).checked) {
          document.getElementById(id).checked = false;
     } else {
          document.getElementById(id).checked = true;
     }
}

// update viewstate

function update_viewstate() {
    __theFormPostData = '';
    __theFormPostCollection = new Array();
    WebForm_InitCallback();
}
