
function correctPNG()
 {
 for(var i=0; i<document.images.length; i++)
 {
 var img = document.images[i]
 var imgName = img.src.toUpperCase()
if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
 {
 var imgID = (img.id) ? "id='" + img.id + "' " : ""
 var imgClass = (img.className) ? "class='" + img.className + "' " : ""
 var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
 var imgStyle = "display:inline-block;" + img.style.cssText
 if (img.align == "left") imgStyle = "float:left;" + imgStyle
 if (img.align == "right") imgStyle = "float:right;" + imgStyle
 if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
 var strNewHTML = "<span " + imgID + imgClass + imgTitle
 + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
 + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
 + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
 img.outerHTML = strNewHTML
 i = i-1
 }
 }
 }
if (window.attachEvent) window.attachEvent("onload", correctPNG);

function doLogin()
{   
    debugLog.trace('doLogin() executing');
    var frm = ResidentPortal.findElement('formasplogin');
    if (frm)
    {
        frm.btnGo.value = '1';
        frm.submit();
    }
}
   
function doForgot()
{
    debugLog.trace('doForgot() executing');
    var frm = ResidentPortal.findElement('formasplogin');
    if (frm)
    {
        frm.btnForgot.value = '1';
        frm.submit();
    }
}

function doRegister()
{
	var PropertyID=document.getElementById('PropertyID').value;
	//alert('wrong');
    debugLog.trace('doRegister() executing');
    javascript:window.open('/system/residentportal/200607/profiles/default.asp?w=' + getPropName(PropertyID) + '&t=template_bonaventure&u=1&newuser=1','EditProfile','location=no,menubar=no,resizable=no,status=no,toolbar=no,width=600,height=500');
}

function doCancel()
{
	var PropertyID=document.getElementById('PropertyID').value;
    debugLog.trace('doCancel() executing');
    top.location.href = '/' + getPropName(PropertyID);
}

function passwordOnKeyPress(e)
{
    var kc = 0;
    if (window.event)
        kc = event.keyCode;
    else if (e)
        kc = e.which;
    if (kc == 13) doLogin();
}

function windowOnLoad()
{
    debugLog.trace('windowOnLoad() executing');
    var loginWidth = ResidentPortal.findElement('nWidth');
    if (loginWidth) {
        var nMinWd = 640;
        var nMinHt = 480;
        var nWd = parseInt(window.screen.availWidth);
        if (isNaN(nWd) || nWd < nMinWd) { nWd=nMinWd; }
        var nHt = parseInt(window.screen.availHeight);
        if (isNaN(nHt) || nHt < nMinHt) { nHt=nMinHt; }
        debugLog.debug('windowOnLoad(): setting loginWidth to ' + nWd);
        loginWidth.value = nWd;
        var loginHeight = ResidentPortal.findElement('nHeight');
        if (loginHeight) {
            debugLog.debug('windowOnLoad(): setting loginHeight to ' + nHt);
            loginHeight.value = nHt;
        }
    }
	var PropertyID=document.getElementById('PropertyID').value;
    var goBack = ResidentPortal.findElement('goback');
    if (goBack)
    {
        var backUrl = '/templates/template_bonaventure/login/login.asp?w=' + getPropName(PropertyID) + '&t=template_bonaventure&u=1';
        debugLog.debug('windowOnLoad(): setting goBack to ' + backUrl);
        goBack.value = backUrl;
    }
    var goNext = ResidentPortal.findElement('gonext');
    if (goNext)
    {
        var nextUrl = 'https://property.onesite.realpage.com/templates/template_bonaventure/residents_secure.asp?w=' + getPropName(PropertyID) + '&t=template_bonaventure&u=1&e=1330323&s=' + PropertyID +'&c=bonaventure%2Eonesite%2Erealpage%2Ecom';
        debugLog.debug('windowOnLoad(): setting goNext to ' + nextUrl);
        goNext.value = nextUrl;
    }
   
}


function HookupSite(s) {
 if (s.indexOf("w=") < 0) {
 s+="&w="+siteVal;
 }
 return s;
}

function VerifyCommunity() {
 if (siteVal.length > 0) {
 formasplogin.action=HookupSite(formasplogin.action);
 var goNext = ResidentPortal.findElement('gonext');
 if (goNext)
 {
 goNext.value=HookupSite(goNext.value);
 }
 return true;
 }
 var bMsgDone=false;
 var msgText='You need to select the community where you live, before you can do that.';
 var myspan=document.getElementById('pmcLogErrorMsg');
 if (myspan!=null) {
 myspan.innerText=msgText;
 bMsgDone=true;
 }
 if ( ! bMsgDone) {
 alert('Error: '+msgText);
 }
 return false;
}


window.onload = windowOnLoad;

