﻿
function ShowMsg(txt) {alert(txt);}

function vioTrim(str) { return str.replace(/^\s+|\s+$/g, '');}

function verifyEmail(mail) {
    var emailRegEx = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i;

    if (!emailRegEx.test(mail) || mail == "")
    {return false;}
    return true;
}

function checkSubscribe() {
    var _E_name = $get(_E_nameID);
    var _E_email = $get(_E_emailID);
    var n = (_E_name.value).trim();
    if (n.length == 0 || n == "Your name here") { 
      alert("Please, input your name!")
      _E_name.focus();
      return false;
      }
    n = (_E_email.value).trim();
    if (!verifyEmail(n)) {
        alert("Please, input your valid email address!");
      _E_email.focus();
      return false;
     }
     return true;  
}
//----------------------------------------------------------------------
function Loading() {
    if (__download) { __download = false; return; }
    if (_E_pnlRent) { _E_pnlRent.style.display = "none"; }
    _E_pnlResorces.style.display = "none";
    _E_pnlLogIn.style.display = "none";
    _E_pnlAgentRes.style.display = "none";
    _E_pnlAboutUs.style.display = "none";
    var o1 = window.$get('divLoad1');
    o1.style.width = (document.body.scrollWidth -1) + "px";
    o1.style.height = document.body.scrollHeight + "px";
    o1.style.display = "block";
    o1.style.cursor = "not-allowed";
}

function unLoading() {
    try {
        var o = $get("divLoad1");
        o.style.display = "none";
        o.style.cursor = "default"
        window.setTimeout(function () {document.body.style.cursor = "default"; }, 0);
         }
    catch (e) { }
}

 function openWindowX(src){
    w = window.open(src,"AmeriHomesProperty",
        "height=600,width=800,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,left=0,top=0");     
    w.focus();
  }
  
function openWindow(src){
    w = window.open(src,"AmeriHomesProperty",
        "height=600,width=800,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,left=0,top=0");     
    w.focus();
}

function openWindowWH(src, w, h) {
    w = window.open(src, "AmeriHomesProperty",
        "height=" + h + ",width=" + w + ",status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,left=0,top=0");
    w.focus();
}

function openProfile(src) {
    w = window.open(src,  "AmeriHomesProperty",
        "height=500,width=700,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,left=0,top=0");
    w.focus();
}   
function isNumberKey(evt){
    var charCode = getCode(evt);
         if (charCode > 31 && (charCode < 48 || charCode > 57)) return false;
         if (charCode == 13) {
             SearchByID(); 
             return false;
         }
         return true;
     }

function getCode(evt) {return (evt.which) ? evt.which : event.keyCode; }
//---------------ShowPopUp--------------
function ShowPopUp(td, lst) {
    __bubbling = false;
    var l = lst.style;
    if (l.display == 'none') {
        var element = td;
        var left = 0, top = 0;
        left += element.offsetLeft, top += element.offsetTop;
        while (element = element.offsetParent) {
            left += element.offsetLeft;
            top += element.offsetTop;
        }
        l.display = 'block';
        var w = (td.offsetWidth - lst.offsetWidth) / 2;
        l.top = (top - 0) + td.offsetHeight + 'px';
        l.left = (left + w) + 'px';
        lst.focus();
    }
    else {l.display = 'none' }
}

function hidePopUp() {
  //  $get("divResources").style.display = 'none';
}

var __bubbling = true;
function hidePopUpX() {
    if (__bubbling == false) { __bubbling = true; return; }
    hidePopUp();
}

function AddToMyList() {
    var o = $get("spMyListItems");
    var num = parseInt(o.innerHTML) + 1;
    o.innerHTML = num.toString();
 }

//---------------AddListener--------------
function AddListenerEx(element, type, expression, bubbling) {
    bubbling = bubbling || false;
    if (window.addEventListener) { //-- Standard		
        element.addEventListener(type, expression, bubbling);
        return true;
    }
    else if (window.attachEvent) { //-- IE		
        element.attachEvent('on' + type, expression);
        return true;
    }
    else return false;
}
//AddListenerEx(document, 'click', hidePopUpX);
//AddListenerEx(window, 'resize', hidePopUp);

function IsMobile() {
    var vioAgent = navigator.userAgent.toLowerCase();
    if (vioAgent.indexOf(" applewebkit/") >= 0 && vioAgent.indexOf(" mobile/") >= 0) {
        alert("Browser does not support Flash Player.\nClick Download Our New Online Magazine.");
        return true;
       //TTP_USER_AGENT=Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) 
      //AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1C25 Safari/419.3
    }
    return false;
 }
 //--------------------------------------------------------
// var CRmsg="Copyrighted Material";
// function disableIE() { if (document.all) { alert(CRmsg); return false; } }
// function disableNS(e) {
//     if (document.layers || ($get && !document.all)) { if (e.which == 2 || e.which == 3) { alert(CRmsg); return false; } }
// }
//if (document.layers) {document.captureEvents(Event.MOUSEDOWN);document.onmousedown=disableNS;}
//else { document.onmouseup = disableNS; document.oncontextmenu = disableIE; }
//document.oncontextmenu = new Function("alert(CRmsg);return false")

