﻿function openMedia(width,height,file) {
    x = (640 - width)/2, y = (480 - height)/2;
    if (screen) {
        y = (screen.availHeight - height)/2;
        x = (screen.availWidth - width)/2;
    }
    if (screen.availWidth > 1800) {
        x = ((screen.availWidth/2) - width)/2;
    }
    newWindow=window.open(file,'newWin','width='+width+',height='+height+',screenX='+x+',screenY='+y+',top='+y+',left='+x+',scrollbars=no,toolbar=no,menubar=no,status=no');
}


rnd.today=new Date();
rnd.seed=rnd.today.getTime();

function rnd() {
        rnd.seed = (rnd.seed*9301+49297) % 233280;
        return rnd.seed/(233280.0);
};

function rand(number) {
        return Math.ceil(rnd()*number);
};

function answer(el){
    if (el.value.substring(0,1) == '+') { 
       alert('CORRECT: ' + el.title); 
    } 
    if (el.value.substring(0,1) != '+') { 
       alert('INCORRECT: ' + el.title); 
    }  
 }  


 function submitSection(form) {
    var oktogo = validateFORM1();
    //if (oktogo) {    
    //   var inputs  = document.getElementsByTagName("input"); 
    //   var skip   = 0
    //   var done   = 0   
    //   if (inputs!=null) {
    //      for (i=0; i < inputs.length; i++) {
    //         if (inputs[i].value.substring(0,1) == '-' && inputs[i].checked) {
    //            alert("You have not answered all questions correctly");  
    //            oktogo = false; i = 99999;
    //         } 
    //      }
    //   } 
    //} else {
   // }
     
    //alert(oktogo); 
    if (oktogo) {           
//alert('about to submit');    
       form.submit(); 
//alert('submited');           
    }
}
         
         



function ValidateTextField(field) {
    if (field.value == '') {
        alert
    }
}


function ValidateEmail(field) {
    if (field.length > 0) {
        var str = field.value;
        var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
        if (!str.match(re)) {
            alert('This email address does not appear to be valid.');
        }
    }
}
         
         
         
function validateFORM1() {
    var missinginfo = "";
    var valMsg = "";

    //alert('inside');

    // Name Field
    if (document.FORM1.NAME.value == '')
         valMsg += 'Name\n';


    // Email Address Field
    var str = document.FORM1.EMAIL.value;
        var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
        if (!str.match(re)) {
            valMsg += 'EMail\n';
        }

    // Phone Number
    if (document.FORM1.PHONE.value == '' || document.FORM1.PHONE.length < 10)
         valMsg += 'Phone\n';
         
    // Extension
    //if (!validateField(document.FORM1.EXTENSION,0,"TEXT","TEXT",0,0,0,"","","Extension"))
    //     valMsg += msg;
    //alert('5');           

    // Address
    //if (!validateField(document.FORM1.ADDRESS,0,"TEXT","TEXT",0,0,0,"","","Address"))
    //     valMsg += msg;
    //alert('6');           

    // Address 2
    //if (!validateField(document.FORM1.ADDRESS2,0,"TEXT","TEXT",0,0,0,"","","Address2"))
    //     valMsg += msg;
    //alert('7');           

    // Best time to call
    //alert(document.FORM1.BestTime.value);
    if (document.FORM1.BestTime.value == '') {
        valMsg += 'Best Time To Call\n';
    }

    // Comments
    if (document.FORM1.COMMENTS.value == '')
         valMsg += 'Comments\n';         

    //alert('8');           

    if (valMsg != "") {
         missinginfo = "The following fields were not entered correctly:\n" +
         "_____________________________________\n" +
         valMsg + "\n_____________________________________" +
         "\n\nPlease re-enter and submit again!";
         alert(missinginfo);
         return false;
    }
    else return true;
}  
       
       
       
       
