// All Javascript header code for various pages


function pop8x6plus(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=824,height=647,left=50,top=50');");
}

function pop8x6(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=800,height=600,left=0,top=0');");
}

function pop7x5(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=700,height=500,left=0,top=0');");
}

function calcPop(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=400,height=375,left=100,top=100');");
}

function inqPop(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width=560,height=500,left=50,top=50');");
}

function walPop(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width=580,height=525,left=50,top=50');");
}

function cessnaPop(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=360,height=277,left=100,top=100');");
}

function memPop(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=450,height=300,left=100,top=100');");
}
function sitePop(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=250,height=450,left=5,top=50');");
}

function timePop(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=750,height=550,left=50,top=50');");
}
function cardPop(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=910,height=520,left=50,top=50');");
}




//Form checking for internal forms - generic

function IsFormComplete(FormName)
{
var x       = 0
var FormOk  = true

while ((x < document.forms[FormName].elements.length) && (FormOk))
   {
     if (document.forms[FormName].elements[x].value == '')
     { 
        alert('Please enter the '+document.forms[FormName].elements[x].name +' and try again.');
        document.forms[FormName].elements[x].focus();
        FormOk = false ;
     }
     x ++;
   }
//return FormOk;

if(FormOk){
document.forms[FormName].submit();	

}
}

////////////////////////////////////////////////


function waiverForm(FormName){
	
var theList = ['lName','fName','connectionsID','studentID','testMonth','testDay','testYear','reqName','reqEmail'];

var theLength = theList.length;
var  x       = 0;
var FormOk  = true;
var AllOk = true;

// ---------->>>>>>>Check for Spam
	if (document.getElementById('tracker')==""){
var FormOk  = false;
alert("Possible Spam detected. Please call Sandra at the OLC");
	} // ---------->>>>>>>end Spam Check

if (FormOk) {// ---------->>>>>>>check entries for completion/////////////////
while (x < theLength && (FormOk))
   {
     if (document.getElementById(theList[x]).value == '')
     { 
        alert('Please enter the '+document.getElementById(theList[x]).name +' and try again.');
        document.getElementById(theList[x]).focus();
        FormOk = false ;
     }
     x ++;
   }
}// ---------->>>>>>>end form ok for checking entries/////////////////


if (FormOk){// ---------->>>>>>>Check to see that at least one of these is checked
	if ((document.getElementById('BUSN5600').checked == true) || (document.getElementById('BUSN5620').checked == true)){
		AllOk=true;
	}else{
		alert('You need to indicate which test to enroll the student in.');
		AllOk=false;
	}
}// ---------->>>>>>> End checking for exam choice

if(FormOk){// ---------->>>>>>>CARS/Faculty ID MUST be 7 digits, numbers only	
// first the length of the CARS ID
var $cars=document.getElementById('studentID').value;
if ($cars.length < 7){
alert('The Student ID must be seven digits. You have only entered '+ $cars.length +' numbers. \n If you do not know your ID please contact the Help Desk');
document.getElementById('studentID').focus();
AllOk = false;	
}
// now ensure that CARS ID are all numerals
var reg = new RegExp("[^0-9]");
if (reg.test($cars)) {
   alert('Your Student ID must be seven digits. You entered an non-numeric character in the field.');
   document.getElementById('studentID').focus();
  AllOk = false;
}
} //// ---------->>>>>>> End CARS ID Check	///////////////////////


if (FormOk){// ---------->>>>>>> checking to make sure the dates are all numeric
var $month=document.getElementById('testMonth').value;
var $day=document.getElementById('testDay').value;
var $year=document.getElementById('testYear').value;

var reg = new RegExp("[^0-9]");

if ($month.length < 2){
alert('The test month must be 2 digits');
document.getElementById('testMonth').focus();
AllOk = false;	
}
if ($day.length < 2){
alert('The test day must be 2 digits');
document.getElementById('testDay').focus();
AllOk = false;	
}
if ($year.length < 4){
alert('The test year must be 4 digits');
document.getElementById('testYear').focus();
AllOk = false;	
}

// now ensure that Date entries are all numerals

if (reg.test($month)) {
   alert('Your date must be numeric. You entered an non-numeric character in the field.');
   document.getElementById('testMonth').focus();
  AllOk = false;
}
if (reg.test($day)) {
   alert('Your date must be numeric. You entered an non-numeric character in the field.');
   document.getElementById('testDay').focus();
  AllOk = false;
}
if (reg.test($year)) {
   alert('Your date must be numeric. You entered an non-numeric character in the field.');
   document.getElementById('testYear').focus();
  AllOk = false;
}

}// ---------->>>>>>> END numeric Date Check

if (FormOk){// ---------->>>>>>> checking to make sure they are using their webster email
var mailAddress=document.getElementById('reqEmail').value;
var mailDomain=mailAddress.split('@');
if (mailDomain[1]!='webster.edu'){
alert('You must use your Webster email account.');
   document.getElementById('reqEmail').focus();
  AllOk = false;	
}
}// ---------->>>>>>> END webster email check

if((FormOk) && (AllOk)){
document.forms[FormName].submit();	
}
	
}//end waiverForm


function pageInit($pageName){
	//alert('works');
	
	if ($pageName=="bb9" ){
		
		var URL= String(window.location);
	var query=URL.split("?");
	 
	 
  if (query[1]=='redirected'){
	  
  var id = '#dialog';
	
		//Get the screen height and width
		var maskHeight = $(document).height();
		var maskWidth = $(window).width();
	
		//Set heigth and width to mask to fill up the whole screen
		$('#mask').css({'width':maskWidth,'height':maskHeight});
		
		//transition effect		
		$('#mask').fadeIn(500);	
		$('#mask').fadeTo("fast",0.7);	
	
		//Get the window height and width
		var winH = $(window).height();
		var winW = $(window).width();
              
		//Set the popup window to center
		$(id).css('top',  winH/2-$(id).height()/2);
		$(id).css('left', winW/2-$(id).width()/2);
	
		//transition effect
		$(id).fadeIn(2000); 
	
}// ends the  of redirected condition
	
	//if close button is clicked
	$('.window .close').click(function (e) {
		//Cancel the link behavior
		e.preventDefault();
		
		$('#mask').hide();
		$('.window').hide();
	});		
	
	//if mask is clicked
	$('#mask').click(function () {
		$(this).hide();
		$('.window').hide();
	});			
		
	}// end if pageName==bb9
	
}



