﻿var origNoticeText = null;

function LoginOpen(o) {
    var SignInLink = document.getElementById("sign-in-link");
    var LoginBox = document.getElementById("ctl00_LogIn_LoginBox");
    var SignInArea = document.getElementById("SignInArea");
    var Navigation = document.getElementById("Navigation");
    var Notice = document.getElementById("Notice");

    if (origNoticeText == null && Notice != null) {
        origNoticeText = Notice.innerHTML;
    }
    
    LoginBox.style.top = "65px";

    if (SignInLink.innerHTML == "Log In") {
        if (Notice == null) {
            Navigation.style.visibility = "hidden";
        }
        LoginBox.style.left = SignInArea.offsetLeft + SignInArea.offsetWidth - 580 + "px";
        LoginBox.style.visibility = "visible";
        SignInLink.innerHTML = "[Close]";
        var txtBox = document.getElementById("ctl00_Login1_UserName");
        if (txtBox != null) txtBox.focus();
        
    }
    else {
        LoginBox.style.visibility = "hidden";
        if (Notice == null) {
            Navigation.style.visibility = "visible";
        }
        SignInLink.innerHTML = "Log In";
        
    }
}

function mouseOver(o) {
     o.style.borderBottom = '';
     o.style.backgroundColor = '#F5FAFA';
     o.style.border = 'solid 1px lightgray';
     o.style.padding = '3px';
}
function mouseOut(o)
{
     o.style.backgroundColor = '';
     o.style.border = 'none';
     o.style.border = 'solid 1px lightgray';
     o.style.padding = '3px';
}


//$(document).ready(function() {
//     $("#MyTreeDiv A").contextMenu({
//          menu: 'myMenu'
//     }, function(action, el, pos) {
//          alert(
//               'Action: ' + action + '\n\n' +
//               'Element text: ' + $(el).text() + '\n\n' + 
//               'GUID: ' + getGUID($(el).attr("href")) + '\n\n' + 
//               'X: ' + pos.x + ' Y: ' + pos.y + ' (relative to element)\n\n' + 
//               'X: ' + pos.docX + ' Y: ' + pos.docY+ ' (relative to document)');
//          });
//});

function getGUID(mystr) {
     var reGUID = /\w{8}[-]\w{4}[-]\w{4}[-]\w{4}[-]\w{12}/g 
     var retArr = [];
     var retval = '';
     retArr = mystr.match(reGUID);
     if(retArr != null)
     {
          retval = retArr[retArr.length - 1];
     }
     return retval;
}

function AutoCompleteTextBox_itemSelected(sender, e)
{
     // alert('Key: ' + e.get_text() + ' val: ' + e.get_value());
     var controlId = sender._id;// "ctl00_Content_ctl00_Content_AutoText_AutoCompl"
     controlId = controlId.substr(6);
     controlId = controlId.substr(0, controlId.length - 15);
     // alert(controlId);
     
     var textBox = document.getElementById(controlId);
     
     __doPostBack(textBox.name, e.get_value());
} 
               
function handleEnter(targetBtn, event)
{
     var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
     if (keyCode == 13) {
          document.getElementById(targetBtn).click();
          return false;
     }
     else
          return true;
}
