var gAutoPrint = true; // Tells whether to automatically call the print function

function printSpecial()
{
if (document.getElementById != null)
{
var html = '<HTML>\n<HEAD>\n';

if (document.getElementsByTagName != null)
{
var headTags = document.getElementsByTagName("head");
if (headTags.length > 0)
html += headTags[0].innerHTML;
}

html += '\n</HE>\n<BODY>\n';
<!--

var printReadyElem = document.getElementById("printReady");

if (printReadyElem != null)
{
html += printReadyElem.innerHTML;
}
else
{
// alert("Could not find the printReady function");
return;
}

html += '\n</BO>\n</HT>';

var printWin = window.open("","printSpecial");
printWin.document.open();
printWin.document.write(html);
printWin.document.close();
if (gAutoPrint)
printWin.print();
}
else
{
alert("The print ready feature is only available if you are using a more recent browser. Please update your browswer to use this feature.");
}
}
/* function app()
{	
	var PWindow;  
	PWindow=window.open("http://www.bu.edu/brussels/graduate_program_enrollment/apply/reg1_thankyou.html","ask", "left=200,top=200,location=no,height=270,width=450,resizable");
	return PWindow;
}
function askExpress()
{	
	var PWindow;  
	PWindow=window.open("http://www.bu.edu/brussels/contact/ask_express.html","ask", "left=200,top=200,location=no,height=270,width=450,resizable");
	return PWindow;
}
function askCourse()
{	
	var PWindow;  
	PWindow=window.open("http://www.bu.edu/brussels/contact/ask_course.html","ask", "left=200,top=200,location=no,height=270,width=450,resizable");
	return PWindow;
}
function askProgram()
{	
	var PWindow;  
	PWindow=window.open("http://www.bu.edu/brussels/contact/ask_program.html","ask", "left=200,top=200,location=no,height=270,width=450,resizable");
	return PWindow;
}
function askPeople()
{	
	var PWindow;  
	PWindow=window.open("http://www.bu.edu/brussels/contact/ask_people.html","ask", "left=200,top=200,location=no,height=270,width=450,resizable");
	return PWindow;
}
function doorDay()
{	
	var PWindow;  
	PWindow=window.open("http://www.bu.edu/brussels/openhouse/rsvp.html","rsvp", "left=200,top=200,location=no,height=300,width=400,resizable");
	return PWindow;
}
*/
function brochure()
{	
	var PWindow;  
	PWindow=window.open("http://www.bu.edu/evergreen/brochure/index.html","Brochure", "left=200,top=200,location=no,height=350,width=375,resizable");
	return PWindow;
}
/*
function webinar()
{	
	var PWindow;  
	PWindow=window.open("http://www.bu.edu/brussels/webinar/index.html","webinar", "left=200,top=200,location=no,height=300,width=450,resizable");
	return PWindow;
}
function photoWindow()
{	
	var PWindow;  
	PWindow=window.open("http://www.bu.edu/brussels/graduation/slideshow.html","photo", "left=200,top=100,location=no,height=450,width=430,resizable");
	return PWindow;
}
function map()
{	
	var PWindow;  
	PWindow=window.open("http://www.bu.edu/brussels/people/student/bookmap.html","Map", "left=200,top=200,location=no,height=350,width=520,resizable");
	return PWindow;
}

function isnull(str)
{
	var xstr
	//xstr=xstr.trim();
	xstr=str;
	for (var iii=0;iii<xstr.length;iii++) {
		if (xstr.substring(iii,iii+1)!=" ") return false;
	}
	return true;
}

function Reg_Validator(theForm)
{
  if (isnull(theForm.email.value))
  {
    alert("Please enter your e-mail address.");
    theForm.email.focus();
    return (false);
  }

  var emailFormat=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
  if (!emailFormat.test(theForm.email.value))
  {
    alert("Please enter a valid e-mail address.");
    theForm.email.focus();
    return (false);
  }  

  return (true);    
}

function phone(theForm)
{
  if (theForm.home_phone.value =="" && theForm.work_phone.value =="")
  {
    alert("Please enter either your business or home phone number");
    theForm.work_phone.focus();
    return (false);
  }
}
/**
 * DHTML phone number validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */

// Declaring required variables
var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()- ";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
// Maximum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 10;
var maxDigitsInIPhoneNumber = 11;

function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function checkInternationalPhone(strPhone){
s=stripCharsInBag(strPhone,validWorldPhoneChars);
return (isInteger(s) && s.length >= minDigitsInIPhoneNumber && s.length <= maxDigitsInIPhoneNumber);
}

function phone2(theForm)
{
  if (theForm.home_phone.value =="" && theForm.work_phone.value =="")
  {
    alert("Please enter either your business or home phone number");
    theForm.work_phone.focus();
    return (false);
  }
  var Phone=document.myform.home_phone
  var Phone2=document.myform.work_phone
    if (checkInternationalPhone(Phone.value)==false && checkInternationalPhone(Phone2.value)==false){
			alert("Please Enter a Valid Phone Number")
			Phone.value=""
			Phone2.value=""
			document.myform.work_phone.focus()
			return false
		}
		if (checkInternationalPhone(Phone.value)==true || checkInternationalPhone(Phone2.value)==true){
			document.myform.submit();
		}
}
