// JScript File
//Check browser close
function HandleOnClose() 
{    
    //user click "X" button on the browser
    if (event.clientY < 0 && event.clientX > 500) 
    {
        window.open("SessionEnd.aspx", "_parent")
    }
}  

//investors.aspx textBoxUserName.onkeyup
function checkenter()
{
    //keyCode==13 enter key
    //keyCode==9 tab key
    if(event.keyCode==13 || event.keyCode==9)
    {
        var hdnCheckPwd = document.getElementById("ctl00_hdnCheckPwd");
        hdnCheckPwd.value = "0" //if user login as different user, reset hdnCheckPwd to 0
        var doc = document.forms[0];
        doc.submit();        
    }
}

//investors.aspx textBoxUserName.onfocusout
function checktab()
{
    if (event.keyCode==0)//tab click
    {
        var hdnCheckPwd = document.getElementById("ctl00_hdnCheckPwd");
        hdnCheckPwd.value = "0" //if user login as different user, reset hdnCheckPwd to 0
        var doc = document.forms[0];
        doc.submit();
    }
}

//hf.aspx expand or collapse
//function doshow(id, img)
//{		    
//    var image = document.getElementById(img);
//    if (image.title == '0')
//    {
//        //expand
//        document.getElementById(id).style.display ="block";
//        image.src="Images/minus.gif"
//        image.setAttribute("title", 1);
//    }
//    else
//    {
//        //collapse
//        document.getElementById(id).style.display ="none";
//        image.src="Images/plus.gif"
//        image.setAttribute("title", 0);
//    }
//}

//menu change image
function change(id, src)
{
    var img = document.getElementById(id);
    if (img != null && src != "")
    {
        //change image
        img.src = src;
    }
}

//check terms for investors.aspx
//function check()
//{
//    var terms = document.getElementById("terms");
//    var checkBoxTerms = document.getElementById("ctl00_ContentPlaceHolderMain_CheckBoxTerms");
//    var labelError = document.getElementById("ctl00_ContentPlaceHolderMain_LabelTerms");
//        
//    if (checkBoxTerms.checked == true && (terms.scrollHeight - terms.scrollTop > terms.clientHeight))
//    {
//        checkBoxTerms.checked = false;
//    }
//}

////launch remote desktop connection mstsc.exe
//function launchrdc(ip)
//{
//    var ws = new ActiveXObject("WScript.Shell");
//    ws.Exec("c:\\WINDOWS\\system32\\mstsc.exe /v:"+ip);
//}

//check if user click the Agree checkbox in CoInvConfiAgr.aspx
function CheckAgree(source, args) 
{
    //args.IsValid = document.getElementById('<%= CheckBoxAgree.ClientID %>').checked;
    args.IsValid = document.getElementById('ctl00_ContentPlaceHolderLogin_CheckBoxAgree').checked;
}

function getGoogleMapKey() {
    //alert(window.location.host);
    if (window.location.host == 'zcap.net' || window.location.host == 'www.zcap.net') {
        document.write('<script src=\"http:\/\/maps.google.com\/maps?file=api&amp;v=2&amp;key=ABQIAAAAe0g-0D_-_ubhxSdl8w3zHhRSeOfcyUH0xdgtKmbD_rm9UXId4xRgFYhr27G3xyebiSeu09b_nKAmOA&sensor=false\" type=\"text\/javascript\"><\/script>');
    }
    else if (window.location.host == 'zcapwebhost') {
        document.write('<script src=\"http:\/\/maps.google.com\/maps?file=api&amp;v=2&amp;key=ABQIAAAAe0g-0D_-_ubhxSdl8w3zHhQzkYlQcK4R7vLOmhqbmUnxlMgCuBT51Ud9hK3Cwm2QZE8ewfOxbmYK7g&sensor=false\" type=\"text\/javascript\"><\/script>');
    }
    else if (window.location.host.indexOf('localhost') == 0) {
        document.write('<script src=\"http:\/\/maps.google.com\/maps?file=api&amp;v=2&amp;key=abcdef&sensor=false\" type=\"text\/javascript\"><\/script>');
    }     
}

function initializeMap(width, height) {
    if (GBrowserIsCompatible()) {
        //alert(window.location.host);
        //choose key based on domains                    
        var map = new GMap2(document.getElementById("map_canvas"), { size: new GSize(width, height) });
        map.setCenter(new GLatLng(42.241704, -87.898436), 13);
        var point = new GLatLng(42.241704, -87.898436);
        map.addOverlay(new GMarker(point));
        map.setUIToDefault();
    }
}

