function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);


function printDate() {
    var months = new Array("Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sept.","Oct.","Nov.","Dec.")
    var days   = new Array("Sun.","Mon.","Tue.","Wed.","Thu.","Fri.","Sat.")

    var today  = new Date()
    var tDate  = today.getDate() >= 10 ? today.getDate() : "0" + today.getDate()
    var tDay   = today.getDay()
    var tMonth = today.getMonth()
    var tYear  = today.getFullYear()
    var tHours = today.getHours()>12 ? today.getHours()%12 : today.getHours()
    var tMins  = today.getMinutes() >= 10 ? today.getMinutes() : "0" + today.getMinutes()
    var tSecs  = today.getSeconds()

    if (tSecs<10) { tSecs = "0" + tSecs; }

    var time_of_day = today.getHours() >= 12 ? "PM" : "AM"

    //document.write(days[tDay] + " "+ tDate + " " + months[tMonth] + " " + tYear + " " + tHours + ":" + tMins + " " + time_of_day)
    document.all.clock.innerHTML = days[tDay] + " " + tDate + " " + months[tMonth] + " " + tYear + " " + tHours + ":" + tMins + ":" + tSecs + " " + time_of_day;
}


function showHelptip(targetID, theText) {
    var mouseLocTop, mouseLocLeft;
    mouseLocLeft = window.event.clientX;
    mouseLocTop  = window.event.clientY;

    tElement = document.getElementById(targetID);
    tElement.innerHTML = theText;
    tElement.style.font = "normal normal 12px, Arial, sans-serif";;
    tElement.style.top = (mouseLocTop + 15) + "px";
    tElement.style.left = (mouseLocLeft - 70) + "px";
    tElement.style.visibility = "visible";
}

function hideHelptip(targetID) {
    document.getElementById(targetID).style.visibility = "hidden";
}


function validateApplicationForm() {
    //initialize the error message
    var errMsg = "";
    var valid = false;

    if (appForm.target_position_1.value=="") {
        errMsg = errMsg + "Please type your desired Position.\r\n";
    }

    if (appForm.twobytwo_file.value=="") {
        errMsg = errMsg + "Please upload your Scanned 2x2 Picture.\r\n";
    }

    if (appForm.fullbody_file.value=="") {
        errMsg = errMsg + "Please upload your scanned Full Body Picture.\r\n";
    }

    if (appForm.msword_resume.value=="") {
        errMsg = errMsg + "Please upload your MSWord Formatted Resume.\r\n";
    }

    if (appForm.surname.value=="") {
        errMsg = errMsg + "Please type your Last Name.\r\n";
    }

    if (appForm.first_name.value=="") {
        errMsg = errMsg + "Please type your First Name.\r\n";
    }

    if (appForm.present_address.value=="") {
        errMsg = errMsg + "Please enter your present Address.\r\n";
    }

    if (appForm.email_address.value=="") {
        errMsg = errMsg + "Please type your valid Email address.\r\n";
    } else {
        if (appForm.email_address.value.indexOf('@')==-1 || !validateEmail(appForm.email_address.value)) {
            errMsg = errMsg + "Please provide us your valid email address.\r\n";
        }
    }


    if (appForm.age.options[0].selected) {
        errMsg = errMsg + "Please select your current Age.\r\n";
    }

    if (appForm.bday_month.options[0].selected) {
        errMsg = errMsg + "Please choose the Month of your Birth Date.\r\n";
    }

    if (appForm.bday_day.options[0].selected) {
        errMsg = errMsg + "Please choose the Day of your Birth Date.\r\n";
    }

    if (appForm.bday_year.options[0].selected) {
        errMsg = errMsg + "Please choose the Year of your Birth Date.\r\n";
    }

    if (!(appForm.sex[0].checked || appForm.sex[1].checked)) {
        errMsg = errMsg + "Please choose your Gender.\r\n";
    }

    if (appForm.height_feet.value=="") {
        errMsg = errMsg + "Please select your Height.\r\n";
    }

    if (appForm.civil_status.options[0].selected) {
        errMsg = errMsg + "Please choose your Civil Status.\r\n";
    }

    //if there are errors found, alert the applicant
    if (errMsg) {
        errMsgHeadings = "[ MISSING OR INCOMPLETE INFORMATION ]\r\n";
        errMsgHeadings = errMsgHeadings + "===========================\r\n";
        alert(errMsgHeadings + errMsg);
        event.returnValue=false;
    }
}

function validateEmail(email) {
    if (email==null || email.length==0) { return false; }

    if (email.indexOf("@") > 1) {
        var addr = email.substring(0, email.indexOf("@"));
        var domain = email.substring(email.indexOf("@") + 1, email.length);
        // top level domain
        if (domain.indexOf('.') == -1) {
            return false;
        }
        // parse address portion first, character by character
        for (var i = 0; i < addr.length; i++) {
            oneChar = addr.charAt(i).charCodeAt(0);
            // dot or hyphen not allowed in first position; dot in last
            if ((i == 0 && (oneChar == 45 || oneChar == 46))  ||
                (i == addr.length - 1 && oneChar == 46)) {
                return false;
            }
            // acceptable characters (- . _ 0-9 a-z)
            if (oneChar == 45 || oneChar == 46 || oneChar == 95 ||
                (oneChar > 47 && oneChar < 58) || (oneChar > 96 && oneChar < 123)) {
                continue;
            } else {
                return false;
            }
        }
        for (i = 0; i < domain.length; i++) {
            oneChar = domain.charAt(i).charCodeAt(0);
            if ((i == 0 && (oneChar == 45 || oneChar == 46)) ||
                ((i == (domain.length - 1)  || i == (domain.length - 2)) && oneChar == 46)) {
                return false;
            }
            if (oneChar == 45 || oneChar == 46 || oneChar == 95 ||
                (oneChar > 47 && oneChar < 58) || (oneChar > 96 && oneChar < 123)) {
                continue;
            } else {
                return false;
            }
        }
    }
    return true;
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function openLocationMap() {
    window.open('location_map.htm','locationmap','width=660, height=440');
}

function viewAdvertisement() {
    window.open('advertisements/05.htm','Advertisement',scrollbars=true, resizable=true, width=110, height=200);
}