function palert(msg){
    if (document.getElementById('mb')) return;
    var clientHeight;
    if (window.innerHeight) {
        clientHeight = ((!window.ie) ? window.innerHeight : Math.min(window.innerHeight, document.documentElement.clientHeight));
    } else {
        clientHeight = document.documentElement.clientHeight;
    }
    var mb = document.createElement("div");
    mb.className = "modalbackground";
    mb.id = "mb";
    mb.style.height = clientHeight;
    document.body.insertBefore(mb, document.body.firstChild);
    
    var box = document.createElement("div");
    box.className = "alertbox";
    box.id = "box";
    box.innerHTML = '<div class="modaltitle">PapayaMobile</div><div class="rc_content" style="width: 278px"><p style="margin-top: 15px; color: red">'
                    +msg+'</p><p style="margin-top: 15px"><input id="okbtn" onclick="closeAlert(); return false;" style="text-align: center; padding-top: 2px;" class="btn_70_20" value="OK" /></p></div><div class="modalbtm"></div>';
    document.body.insertBefore(box, document.body.firstChild);
    window.onresize = function(){ moveModal(); }
    window.onscroll = function(){ moveModal(); }
    
    document.body.style.height = clientHeight;
    document.body.style.overflow = "hidden";
}
function moveModal(){
    var clientWidth;
    if (window.innerWidth) {
        clientWidth = ((!window.ie) ? window.innerWidth : Math.min(window.innerWidth, document.documentElement.clientWidth));
    } else {
        clientWidth = document.documentElement.clientWidth;
    }
    var clientHeight;
    if (window.innerHeight) {
        clientHeight = ((!window.ie) ? window.innerHeight : Math.min(window.innerHeight, document.documentElement.clientHeight));
    } else {
        clientHeight = document.documentElement.clientHeight;
    }
    document.body.style.width = clientWidth;
    document.body.style.height = clientHeight;
    var m = document.getElementById('mb');
    m.style.width = clientWidth;
    m.style.height = clientHeight;
}
function closeAlert(){
    document.body.removeChild(document.body.firstChild);
    document.body.removeChild(document.body.firstChild);
    document.body.style.height = "";
    document.body.style.overflow = "";
    window.onresize = function(){}
    window.onscroll = function(){}
}
function reEnter(elname){el=document.getElementById(elname);el.focus();el.select();}function validEmail(emailaddr){var emailPtn=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;if(!emailaddr.match(emailPtn)){return false}return true}function isNumber(num,field){if(num.match(/\d+/g)==num){return true}else{palert("Not a valid "+field+", please try again.");return false}}function show(el){el.style.display="block"}function hide(el){el.style.display="none"}String.prototype.replaceAll=function(AFindText,ARepText){raRegExp=new RegExp(AFindText,"g");return this.replace(raRegExp,ARepText)};String.prototype.endsWith=function(str){return(str==this.substr(this.length-str.length))};
function toggleDisplay(el){if (el.style.display=='none')show(el);else hide(el);}
