//file: includes/commonJSScripts.js

/* ************************************************************************************** */

function changeCursor(inOut,curSpan) {
    switch (inOut) {
        case "in"  : eval("document.all." + curSpan + ".style.cursor = 'hand'"); break;
        case "out" : eval("document.all." + curSpan + ".style.cursor = 'pointer'"); break;
    }
}

/* ************************************************************************************** */

function checkData() {
    var email   = NPTForm.Email.value;
    var name    = NPTForm.Name.value;
    var nameValid, emailValid = false;
    
    if (name == "") {
        alert("You forgot to enter your name.");
    } else if (email == "") {
        alert("You forgot to enter your e-mail address.");
    } else {
        nameValid = true;
    }
    
    if (email != "") {
        //if (!validateEmail(email)) {
        if (!checkemail()) {
            alert("Your e-mail address appears to be invalid.  Please correct it before continuing.");
        } else {
            emailValid = true;
        }
    }
    
    if ((nameValid) && (emailValid)) {
        NPTForm.submit();
    }
}

/* ************************************************************************************** */

var testresults

function checkemail(){
 var str=NPTForm.Email.value
 var filter=/^.+@.+\..{2,3}$/

 if (filter.test(str))
    testresults=true
 else {
    alert("Please input a valid email address!")
    testresults=false
}
 return (testresults);
}

/* ************************************************************************************** */

function validateEmail( strValue) {
/************************************************
DESCRIPTION: Validates that a string contains a
  valid email pattern.

 PARAMETERS:
   strValue - String to be tested for validity

RETURNS:
   True if valid, otherwise false.

REMARKS: Accounts for email with country appended
  does not validate that email contains valid URL
  type (.com, .gov, etc.) or valid country suffix.
*************************************************/
var objRegExp  = /(^[a-z]([a-z_\.-]*)@([a-z_\.-]*)([.][a-z]{3})$)|(^[a-z]([a-z_\.-]*)@([a-z_\.-]*)(\.[a-z]{3})(\.[a-z]{2})*$)/i;

  //check for valid email
  return objRegExp.test(strValue);
}


/* ************************************************************************************** */

function loadPages(sectionName) {
    switch (sectionName) {
        case "snapshots" : document.all.topPage.src    = "snapshots/snapTop.html";
                           document.all.bottomPage.src = "snapshots/snapBottom.html";
                           break;
        case "resume"    : document.all.topPage.src    = "resume/resumeTop.html";
                           document.all.bottomPage.src = "resume/resumeBottom.html";
                           break;
        case "theatre"   : parent.document.all.bottomPage.src = "resume/theatre.html";
                           break;
        case "film"      : parent.document.all.bottomPage.src = "resume/film.html";
                           break;
        case "television": parent.document.all.bottomPage.src = "resume/television.html";
                           break;
        case "training"  : parent.document.all.bottomPage.src = "resume/training.html";
                           break;
        case "skills"    : parent.document.all.bottomPage.src = "resume/skills.html";
                           break;
        case "bio"       : document.all.topPage.src    = "bioTop.html";
                           document.all.bottomPage.src = "bioBottom.html";
                           break;
        case "contact"   : document.all.topPage.src    = "contactTop.html";
                           document.all.bottomPage.src = "contactBottom.html";
                           break;
        case "oncamera"  : document.all.topPage.src    = "onCamera/onCameraTop.html";
                           document.all.bottomPage.src = "onCamera/onCameraBottom.html";
                           break;
        case "home"      : document.all.topPage.src    = "blank.html";
                           document.all.bottomPage.src = "blank.html"; 
                           break;
    }
}

/* ************************************************************************************** */

function resetForm() {
    contactWilliam.name.value           = "";
    contactWilliam.emailAddress.value   = "";
    contactWilliam.comment.value        = "";
}

/* ************************************************************************************** */

function showMenuHdr(sectionName) {
    switch (sectionName) {
        case "oncamera"    : document.all.titleBarRight.innerHTML = "on camera"; break;
        case "snapshots"   : document.all.titleBarRight.innerHTML = "snap shots"; break;
        case "soundbytes"  : document.all.titleBarRight.innerHTML = "sound bytes"; break;
        case "resume"      : document.all.titleBarRight.innerHTML = "resume"; break;
        case "bio"         : document.all.titleBarRight.innerHTML = "bio"; break;
        case "contact"     : document.all.titleBarRight.innerHTML = "contact"; break;
        case "home"        : document.all.titleBarRight.innerHTML = "<img src='images/spacer.gif' width='40' height='0' border='0'>"; break;
    }
}

/* ************************************************************************************** */

function showImage(imgNum) {
    var newImg      = "<img src='images/full/" + imgNum + "' width='150' height='224' border='0'>";
    var imgDispArea = "<img src='images/spacer.gif' width='15' height='0' border='0'>" + newImg;
    
    if (imgNum != "blank") {
        parent.frames.document.all.bottomLeftCell.innerHTML = imgDispArea;
    } else {
        parent.frames.document.all.bottomLeftCell.innerHTML = "&nbsp;";
    }
}

/* ************************************************************************************** */

function loadVideo(video) {
    switch (video) {
        //case "reelAct"      : window.open("http://www.reelact.com/userPages/viewVideo.php?id=517",'reelACT','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,width=480,height=380'); break;
        case "reelAct"      : parent.frames.document.all.bottomPage.src = "onCamera/reelAct.html";
                              parent.frames.document.all.bottomLeftCell.innerHTML = "<br><br> ReelACT"; break;
        case "boyWillie"    : parent.frames.document.all.bottomPage.src = "onCamera/pianoLesson.html";
                              parent.frames.document.all.bottomLeftCell.innerHTML = "<br><br><br> Boy Willie <br> 'Piano Lesson'"; break;
        case "kadi"         : parent.frames.document.all.bottomPage.src = "onCamera/visualAspirations.html";
                              parent.frames.document.all.bottomLeftCell.innerHTML = "<br><br><br> Kadi <br> 'Visual Aspirations'"; break;
    }
}

/* ************************************************************************************** */
