// JavaScript Document




//this function renders a div with a specific height
function renderDiv(height)
{
	document.write("<div style=\"height:"+ height +"px; font-size: 1px;\"></div>");
}
//end of function

function showsubnav(id)
{
	
	document.getElementById(id).className = "subnav_show_"+id;	
	document.getElementById(id +'_link').className = "mouseover"; 
}
//end of function

function hidesubnav(id)
{
	document.getElementById(id).className = "subnav_noshow";	
	document.getElementById(id +'_link').className = "";
}
//end of function


function showsubnav_subpage(id)
{
	//close the other link first
	for (i=0;i<main_nav.length;i++)
	{
		if(main_nav[i] != id)
		{
			document.getElementById(main_nav[i]).className = "subnav_noshow";	
			document.getElementById(main_nav[i] +'_link').className = "";	
		}
		
	}
	document.getElementById(id).className = "subnav_show_long";	
	document.getElementById(id +'_link').className = "mouseover"; 
}
//end of function

function hidesubnav_subpage(id)
{
	document.getElementById(id).className = "subnav_noshow_long";	
	document.getElementById(id +'_link').className = "";
	
	//set thhe navigation to the current page
	for (i=0;i<main_nav.length;i++)
	{
		if(document.getElementById(main_nav[i] +'_link').rel == "current")
		{
			document.getElementById(main_nav[i]).className = "subnav_show_long";	
			document.getElementById(main_nav[i] +'_link').className = "mouseover"; 
			i = main_nav.length; //break off the loop	
		}
	}
}
//end of function


function textCounter(field, countfield, maxlimit)
{
	if (field.value.length > maxlimit) // if too long...trim it!
	field.value = field.value.substring(0, maxlimit);
	// otherwise, update 'characters left' counter
	else 
	countfield.value = maxlimit - field.value.length;
}


//----------------------------------make it equal column ---------------------------------------------------------------//

/* 
  ------------------------------------------------
  PVII Equal CSS Columns scripts -Version 2
  Copyright (c) 2005 Project Seven Development
  www.projectseven.com
  Version: 2.1.0
  ------------------------------------------------
*/
function P7_colH2(){ //v2.1.0 by PVII-www.projectseven.com
 var i,oh,h=0,tg,el,np,dA=document.p7eqc,an=document.p7eqa;if(dA&&dA.length){
 for(i=1;i<dA.length;i+=2){dA[i+1].style.paddingBottom='';}for(i=1;i<dA.length;i+=2){
 oh=dA[i].offsetHeight;h=(oh>h)?oh:h;}for(i=1;i<dA.length;i+=2){oh=dA[i].offsetHeight;
 if(oh<h){np=h-oh;if(!an&&dA[0]==1){P7_eqA2(dA[i+1].id,0,np);}else{
 dA[i+1].style.paddingBottom=np+"px";}}}document.p7eqa=1;
 document.p7eqth=document.body.offsetHeight;
 document.p7eqtw=document.body.offsetWidth;}
}
function P7_eqT2(){ //v2.1.0 by PVII-www.projectseven.com
 if(document.p7eqth!=document.body.offsetHeight||document.p7eqtw!=document.body.offsetWidth){P7_colH2();}
}
function P7_equalCols2(){ //v2.1.0 by PVII-www.projectseven.com
 var c,e,el;if(document.getElementById){document.p7eqc=new Array();
 document.p7eqc[0]=arguments[0];for(i=1;i<arguments.length;i+=2){el=null;
 c=document.getElementById(arguments[i]);if(c){e=c.getElementsByTagName(arguments[i+1]);
 if(e){el=e[e.length-1];if(!el.id){el.id="p7eq"+i;}}}if(c&&el){
 document.p7eqc[document.p7eqc.length]=c;document.p7eqc[document.p7eqc.length]=el}}
 setInterval("P7_eqT2()",10);}
}
function P7_eqA2(el,p,pt){ //v2.1.0 by PVII-www.projectseven.com
 var sp=10,inc=20,g=document.getElementById(el);np=(p>=pt)?pt:p;
 g.style.paddingBottom=np+"px";if(np<pt){np+=inc;
 setTimeout("P7_eqA2('"+el+"',"+np+","+pt+")",sp);}
}

//------------------------------------end of make it equal column------------------------------------------------//


//------------------------jquery-----------------------------------------------------

$(document).ready(function(){
    $(".video_category").hover(
      function () {
        $(this).attr("class","video_category_selected");

      }, 
      function () {
        $(this).attr("class","video_category");
      }
    );
	
	$(".video_category").click(
      function () {
		target_cat = $(this).attr("title");  
		window.location = 'video_archive.asp?video_category=' + target_cat;  
        
      }
    );
	
	$('a.video_thumnail').cluetip({local:true, showTitle: false, cursor: 'pointer', leftOffset: -5});
   
});


//------------------------jquery Ends------------------------------------------------


//********************************************************AJAX function starts********************************************************




function createXMLHttpRequest() {
    try {return new ActiveXObject("Msxml2.XMLHTTP");} catch (e) {}
    try {return new ActiveXObject("Microsoft.XMLHTTP");} catch (e) {}
    try {return new XMLHttpRequest();} catch(e) {}
    return null;
}//end of function 

function postAndFetchXml(url, content, handler) 
{
   
	
	var xmlhttp = createXMLHttpRequest();
	if (xmlhttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 

   xmlhttp.onreadystatechange = function() 
   {
        
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
            handler(xmlhttp.responseXML);
        }
    };
	//alert(url);
	//alert(content);

    xmlhttp.open('POST', url);	
    xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlhttp.send(content);
	
}//end of function 


function postAndFetch(url, content, handler, area_id) 
{
	
	var xmlhttp = createXMLHttpRequest();
	if (xmlhttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 

   if(area_id != "")
   {
   		var indicator = document.getElementById(area_id);
		indicator.innerHTML="<img src='images/indicator.gif'>";
   }
   xmlhttp.onreadystatechange = function() 
   {
        
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) 
		{
            handler(xmlhttp.responseText, area_id);
        }
    };

    xmlhttp.open('POST', url, true);	
    xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlhttp.send(content);
	
}//end of function 

function postAndFetchForm(url, formId, handler, area_id) 
{
	
	var xmlhttp = createXMLHttpRequest();
	if (xmlhttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	
	content = ""
	//grab all the element value of this document
	var x=document.getElementById(formId);
	for (var i=0;i<x.length;i++)
  	{
  		if(i == 0)
			content =  x.elements[i].name + "=" +  x.elements[i].value ;
  		else
			content += "&" + x.elements[i].name + "=" +  x.elements[i].value ;
		
  	}

   
   var indicator = document.getElementById(area_id);
	indicator.innerHTML="<div><img src='images/indicator.gif'></div>";
   
   xmlhttp.onreadystatechange = function() 
   {
        
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) 
		{
            handler(xmlhttp.responseText, area_id);
        }
    };

    xmlhttp.open('POST', url, true);	
    xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlhttp.send(content);
	
}//end of function 


function generalHandler(Text, area_id)
{
	
	//alert(Text);
	var str= Text;
	
	var content = Text
	//alert(holder);
	
	if(area_id != "")
	{
		$("#"+ area_id).css({'display' : 'none'});
		var updateform = document.getElementById(area_id);
		   updateform.innerHTML=content;
		
		$("#"+ area_id).slideDown("slow");	
	}

}//end of function

function generalHandler_equal_column(Text, area_id)
{
	
	//alert(Text);
	var str= Text;
	
	var content = Text
	//alert(holder);
	
	if(area_id != "")
	{
		var updateform = document.getElementById(area_id);
		   updateform.innerHTML=content;
	}
	
	P7_equalCols2(0,'main_content_text','P','main_content_photo','P'); 
		
}//end of function

//********************************************************AJAX functions ends*********************************************************


//*******************************************************validation functions******************************************************

function validateCollegeQuiz()
{

	if(!document.getElementById("question1-1").checked && !document.getElementById("question1-2").checked && !document.getElementById("question1-3").checked )
	{
			alert("Question 1 must be answered.");	
			return false;	
	}	
		
	if(!document.getElementById("question2-1").checked && !document.getElementById("question2-2").checked && !document.getElementById("question2-3").checked )
	{
			alert("Question 2 must be answered.");	
			return false;	
	}	
		
	if(!document.getElementById("question3-1").checked && !document.getElementById("question3-2").checked )
	{
			alert("Question 3 must be answered.");	
			return false;	
	}	
	
	if(!document.getElementById("question4-1").checked && !document.getElementById("question4-2").checked && !document.getElementById("question4-3").checked )
	{
			alert("Question 4 must be answered.");	
			return false;	
	}	
		
	if(!document.getElementById("question5-1").checked && !document.getElementById("question5-2").checked && !document.getElementById("question5-3").checked && !document.getElementById("question5-4").checked )
	{
			alert("Question 5 must be answered.");	
			return false;	
	}
	
	if(!document.getElementById("question6-1").checked && !document.getElementById("question6-2").checked && !document.getElementById("question6-3").checked )
	{
			alert("Question 6 must be answered.");	
			return false;	
	}	
		
	if(!document.getElementById("question7-1").checked && !document.getElementById("question7-2").checked && !document.getElementById("question7-3").checked )
	{
			alert("Question 7 must be answered.");	
			return false;	
	}	
		
	if(!document.getElementById("question8-1").checked && !document.getElementById("question8-2").checked && !document.getElementById("question8-3").checked )
	{
			alert("Question 8 must be answered.");	
			return false;	
	}	
	
	if(!document.getElementById("question9-1").checked && !document.getElementById("question9-2").checked && !document.getElementById("question9-3").checked )
	{
			alert("Question 9 must be answered.");	
			return false;	
	}	
		
	if(!document.getElementById("question10-1").checked && !document.getElementById("question10-2").checked && !document.getElementById("question10-3").checked )
	{
			alert("Question 10 must be answered.");	
			return false;	
	}		
	
	return true;
}
//end of function


//**********************************************************validation functions******************************************************

//***************************Function for student_bio.asp ************************************************
function student_move()
{
	student_id = document.getElementById('student_list').options[document.getElementById('student_list').selectedIndex].value
	window.location="student_bio.asp?student_id=" + student_id ;
}

//***************************Function for student_bio_forfaculty.asp ************************************************
function student_move2()
{
	student_id = document.getElementById('student_list').options[document.getElementById('student_list').selectedIndex].value
	window.location="student_bio_forfaculty.asp?student_id=" + student_id ;
}


//***************************Function for bio.asp ************************************************
function move(group)
{
	fid=document.getElementById('faculty').options[document.getElementById('faculty').selectedIndex].value
	window.location="bio.asp?group=" + group + "&fid=" + fid ;
}

//***************************Function for hcc.asp ************************************************

function filterYear()
{
		years = document.getElementById("filter_year").value;
		
		window.location = "hcc.asp?year=" + years
}

//***************************Function for take_GRE.asp*********************************

function valGREForm(){
	  with (document.myform){
	  	if (First_Name.value==''){
			alert('You must enter your first name.');
			First_Name.focus();
			return false;
		}
	  	if (Last_Name.value==''){
			alert('You must enter your last name.');
			Last_Name.focus();
			return false;
		}
	  	if (Email.value==''){
			alert('You must enter your Email address.');
			Email.focus();
			return false;
		}
	  }
	}

//***************************Function for faculty_profile_update.asp*********************************
function jumpDel(URL, name)
{
	var name = confirm("Do you really want to delete " + name +"?")
	if (name == true)
		window.location = URL
}//end of function


//***************************Function for faculty_manage_assignment.asp*********************************
function jumpDelAssignment(URL, name)
{
	var name = confirm("Do you really want to delete " + name +"? You will NOT be able to access your students' admissions anymore")
	if (name == true)
		window.location = URL
}//end of function



//***************************Function for waive_GRE.asp*********************************



	function valWaiveGREForm()
	{
	  	if(document.getElementById("First_Name").value.length < 1)
		{	
			alert("Please specify your first name");
			document.getElementById("First_Name").focus();
			return false;
		}
		
		if(document.getElementById("Last_Name").value.length < 1)
		{	
			alert("Please specify your last name");
			document.getElementById("Last_Name").focus();
			return false;
		}
		
		if(document.getElementById("Email").value.length < 1)
		{	
			alert("Please specify your email address");
			document.getElementById("Email").focus();
			return false;
		}
		
		/*
		if(!document.getElementById("check1").checked && !document.getElementById("check2").checked && !document.getElementById("check3").checked && !document.getElementById("check4").checked && !document.getElementById("check5").checked && !document.getElementById("check6").checked)
		{
			alert("You must choose at least one criteria, choose OTHER if you can't find one that matches");
			return false;
		}
		
		if(document.getElementById("check1").checked)
		{
			if(document.getElementById("criteria1_1").value.length < 1)
			{	
				alert("Please specify type of exam");
				document.getElementById("criteria1_1").focus();
				return false;
			}
			
			if(document.getElementById("criteria1_2").value.length < 1)
			{	
				alert("Please specify year of exam");
				document.getElementById("criteria1_2").focus();
				return false;
			}
			
			if(document.getElementById("criteria1_3").value.length < 1)
			{	
				alert("Please specify the score of the exam");
				document.getElementById("criteria1_3").focus();
				return false;
			}
			
			if(document.getElementById("criteria1_4").value.length < 1)
			{	
				alert("Please specify the percentile");
				document.getElementById("criteria1_4").focus();
				return false;
			}
			
		}//end of check1
		
		if(document.getElementById("check2").checked)
		{
			if(document.getElementById("criteria2_1").value.length < 1)
			{	
				alert("Please specify license type ");
				document.getElementById("criteria2_1").focus();
				return false;
			}
			
			if(document.getElementById("criteria2_2").value.length < 1)
			{	
				alert("Please specify state of licensure ");
				document.getElementById("criteria2_2").focus();
				return false;
			}
			
			if(document.getElementById("criteria2_3").value.length < 1)
			{	
				alert("Please specify license number ");
				document.getElementById("criteria2_3").focus();
				return false;
			}
			
		}//end of check2
		
		if(document.getElementById("check3").checked)
		{
			if(document.getElementById("criteria3_1").value.length < 1)
			{	
				alert("Please specify License Type ");
				document.getElementById("criteria3_1").focus();
				return false;
			}
			
			if(document.getElementById("criteria3_2").value.length < 1)
			{	
				alert("Please specify State of Licensure ");
				document.getElementById("criteria3_2").focus();
				return false;
			}
			
			if(document.getElementById("criteria3_3").value.length < 1)
			{	
				alert("Please specify License Number ");
				document.getElementById("criteria3_3").focus();
				return false;
			}
			
			if(document.getElementById("criteria3_4").value.length < 1)
			{	
				alert("Please specify Year of Experience ");
				document.getElementById("criteria3_4").focus();
				return false;
			}
			
		}//end of check3
		
		if(document.getElementById("check4").checked)
		{
			if(document.getElementById("criteria4_1").value.length < 1)
			{	
				alert("Please specify Degree ");
				document.getElementById("criteria4_1").focus();
				return false;
			}
			
			if(document.getElementById("criteria4_2").value.length < 1)
			{	
				alert("Please specify Area of Concentration ");
				document.getElementById("criteria4_2").focus();
				return false;
			}
			
			if(document.getElementById("criteria4_3").value.length < 1)
			{	
				alert("Please specify Years of Experience ");
				document.getElementById("criteria4_3").focus();
				return false;
			}

			
		}//end of check4
		
		if(document.getElementById("check5").checked)
		{
			if(document.getElementById("criteria5_1").value.length < 1)
			{	
				alert("Please specify Degree");
				document.getElementById("criteria5_1").focus();
				return false;
			}
			
			if(document.getElementById("criteria5_2").value.length < 1)
			{	
				alert("Please specify Area of Concentration ");
				document.getElementById("criteria5_2").focus();
				return false;
			}
			
			if(document.getElementById("criteria5_3").value.length < 1)
			{	
				alert("Please specify Years of Experience ");
				document.getElementById("criteria5_3").focus();
				return false;
			}
			
		}//end of check5
		
		if(document.getElementById("check6").checked)
		{
			if(document.getElementById("criteria6_1").value.length < 1)
			{	
				alert("If you choose other, please specify");
				document.getElementById("criteria6_1").focus();
				return false;
			}
			
			
		}//end of check6
		
		*/
		
		if(document.getElementById("statement_request").value.length < 1)
		{	
				alert("Please provide a statement of request");
				document.getElementById("statement_request").focus();
				return false;
		}
		
		return true;
	}//end of valform function
	
	
	function displayHideInputs(id)
	{
		
		
		if(document.getElementById('inputs'+id).className == 'hidden')
			document.getElementById('inputs'+id).className = 'shown';
		else if(document.getElementById('inputs'+id).className == 'shown')
			document.getElementById('inputs'+id).className = 'hidden';
	}





function valRSVPeventForm(){
	
	  	if (document.myform.First_Name.value==''){
			alert('You must enter your first name.');
			document.myform.First_Name.focus();
			return false;
		}
	  	if (document.myform.Last_Name.value==''){
			alert('You must enter your last name.');
			document.myform.Last_Name.focus();
			return false;
		}
	  	if (document.myform.Email.value==''){
			alert('You must enter your Email address.');
			document.myform.Email.focus();
			return false;
		}
		
		if(!CheckEmail(document.myform.Email.value))
			return false;
		
		if (document.myform.Phone.value==''){
			alert('You must enter your phone number.');
			document.myform.Phone.focus();
			return false;
		}
		
		if (document.myform.Home_Address.value==''){
			alert('You must enter your mailing address.');
			document.myform.Home_Address.focus();
			return false;
		}
		
		if (document.myform.City.value==''){
			alert('City name is required.');
			document.myform.City.focus();
			return false;
		}
		
		if (document.myform.State.value==''){
			alert('Please specify your state.');
			document.myform.State.focus();
			return false;
		}
		
		if (document.myform.Zip.value==''){
			alert('You must enter your zip code.');
			document.myform.Zip.focus();
			return false;
		}
		
		
		
		
		if (document.getElementById("mailing_list1").checked == false && document.getElementById("mailing_list2").checked == false)
		{
			alert('Please confirm the mailing list');
			
			
			return false;
		}
	 	
		if (document.getElementById("submit_info1").checked == false && document.getElementById("submit_info2").checked == false)
		{
			alert('Please confirm whether you have submitted your info in the past');
			
			
			return false;
		}
		
		if (document.myform.confirm_text.value==''){
			alert('Confirmation characters are required.');
			document.myform.confirm_text.focus();
			return false;
		}
		
	  
	  return true;
	}


//for faculty_work_history.asp
function validateFacultyWorkHistory()
{
	x=document.myForm
	
	title=x.title.value
	organization=x.organization.value
	submitOK="True"
	
	if (title.length < 1)
	 {
	 alert("title is required")
	 submitOK="False"
	 }
	 
	 if (organization.length < 1)
	 {
	 alert("Organization is required")
	 submitOK="False"
	 }
	
	 
	if (submitOK=="False")
	 {
	 return false
	 }
}//end of function



	



//***************************Date validation function mm/dd/yyyy ************************************************

var dtCh= "/";
var minYear=1900;
var maxYear=2100;

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++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(0,pos1)
	var strDay=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) 
		day=parseInt(strDay.substring(1));
	else
		day = parseInt(strDay.substring(0));
	
	if (strMonth.charAt(0)=="0" && strMonth.length>1) 
		month =parseInt(strMonth.substring(1))
	else
		month =parseInt(strMonth.substring(0))
	
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	
	//alert(strDay);
	//alert(strMonth);
	
	
	//alert(month);
	
	
	year=parseInt(strYr)
	
	//alert(month + " ," + day + ", " +year);
	//alert(strMonth + " ," + strDay + ", " +strYear);
	//alert(strMonth.length + " ," +  strDay.length + " ," + strYear.length)
	//if(parseInt(strDay.length) < 1)
		//alert("haha");
	//return false;
	
	
	if (pos1==-1 || pos2==-1){
		alert("The date format should be : mm/dd/yyyy")
		return false
	}
	if (strMonth.length<2 || month<1 || month>12){
		alert("Please enter a valid month")
		return false
	}
	if (strDay.length<2 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month])
	{
		alert("Please enter a valid day")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Please enter a valid date")
		return false
	}
	
	//checking for past date
	var myDate=new Date();
	myDate.setFullYear(year,month - 1,day);
	
	var today = new Date();
	/*
	if (myDate < today)
	{
		alert("You cannot put a past date")
		return false
	}
	*/
	
return true
}


	
//***************************Date validation function mm/dd/yyyy END************************************************


//-------------------------------Phone format (XXX)XXX-XXXX validation-----------------------------
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Original:  Roman Feldblum (web.developer@programmer.net) -->

<!-- Begin
<!-- This script is based on the javascript code of Roman Feldblum (web.developer@programmer.net) -->
<!-- Original script : http://javascript.internet.com/forms/format-phone-number.html -->
<!-- Original script is revised by Eralper Yilmaz (http://www.eralper.com) -->
<!-- Revised script : http://www.kodyaz.com -->

var zChar = new Array(' ', '(', ')', '-', '.');
var maxphonelength = 13;
var phonevalue1;
var phonevalue2;
var cursorposition;

function ParseForNumber1(object){
phonevalue1 = ParseChar(object.value, zChar);
}
function ParseForNumber2(object){
phonevalue2 = ParseChar(object.value, zChar);
}

function backspacerUP(object,e) {
if(e){
e = e
} else {
e = window.event
}
if(e.which){
var keycode = e.which
} else {
var keycode = e.keyCode
}

ParseForNumber1(object)

if(keycode >= 48){
ValidatePhone(object)
}
}

function backspacerDOWN(object,e) {
if(e){
e = e
} else {
e = window.event
}
if(e.which){
var keycode = e.which
} else {
var keycode = e.keyCode
}
ParseForNumber2(object)
}

function GetCursorPosition(){

var t1 = phonevalue1;
var t2 = phonevalue2;
var bool = false
for (i=0; i<t1.length; i++)
{
if (t1.substring(i,1) != t2.substring(i,1)) {
if(!bool) {
cursorposition=i
bool=true
}
}
}
}

function ValidatePhone(object){

var p = phonevalue1

p = p.replace(/[^\d]*/gi,"")

if (p.length < 3) {
object.value=p
} else if(p.length==3){
pp=p;
d4=p.indexOf('(')
d5=p.indexOf(')')
if(d4==-1){
pp="("+pp;
}
if(d5==-1){
pp=pp+")";
}
object.value = pp;
} else if(p.length>3 && p.length < 7){
p ="(" + p;
l30=p.length;
p30=p.substring(0,4);
p30=p30+")"

p31=p.substring(4,l30);
pp=p30+p31;

object.value = pp;

} else if(p.length >= 7){
p ="(" + p;
l30=p.length;
p30=p.substring(0,4);
p30=p30+")"

p31=p.substring(4,l30);
pp=p30+p31;

l40 = pp.length;
p40 = pp.substring(0,8);
p40 = p40 + "-"

p41 = pp.substring(8,l40);
ppp = p40 + p41;

object.value = ppp.substring(0, maxphonelength);
}

GetCursorPosition()

if(cursorposition >= 0){
if (cursorposition == 0) {
cursorposition = 2
} else if (cursorposition <= 2) {
cursorposition = cursorposition + 1
} else if (cursorposition <= 5) {
cursorposition = cursorposition + 2
} else if (cursorposition == 6) {
cursorposition = cursorposition + 2
} else if (cursorposition == 7) {
cursorposition = cursorposition + 4
e1=object.value.indexOf(')')
e2=object.value.indexOf('-')
if (e1>-1 && e2>-1){
if (e2-e1 == 4) {
cursorposition = cursorposition - 1
}
}
} else if (cursorposition < 11) {
cursorposition = cursorposition + 3
} else if (cursorposition == 11) {
cursorposition = cursorposition + 1
} else if (cursorposition >= 12) {
cursorposition = cursorposition
}

var txtRange = object.createTextRange();
txtRange.moveStart( "character", cursorposition);
txtRange.moveEnd( "character", cursorposition - object.value.length);
txtRange.select();
}

}

function ParseChar(sStr, sChar)
{
if (sChar.length == null)
{
zChar = new Array(sChar);
}
else zChar = sChar;

for (i=0; i<zChar.length; i++)
{
sNewStr = "";

var iStart = 0;
var iEnd = sStr.indexOf(sChar[i]);

while (iEnd != -1)
{
sNewStr += sStr.substring(iStart, iEnd);
iStart = iEnd + 1;
iEnd = sStr.indexOf(sChar[i], iStart);
}
sNewStr += sStr.substring(sStr.lastIndexOf(sChar[i]) + 1, sStr.length);

sStr = sNewStr;
}

return sNewStr;
}
//  End -->

//-------------------------------Phone format validation end-----------------------------








//***************************Function for faculty_add_assignment.asp ************************************************
function assignmentValidate()
	{
	  
	  	if (document.myForm.title.value==''){
			alert('The title of the assignment is required');
			document.myForm.title.focus();
			return false;
		}
		
		if (document.myForm.title.value==-1)
		{
			alert('Please specify the category of your project');
			document.myForm.category.focus();
			return false;
		}
	  	
		if (document.myForm.start_date.value=='')
		{
			alert('Start date of the assignment is required');
			document.myForm.start_date.focus();
			return false;
			
		}
		
		if (isDate(document.myForm.start_date.value)==false)
		{	
			document.myForm.start_date.focus();
			return false
		}	
		
		if (document.myForm.end_date.value=='')
		{
			alert('End date of the assignment is required');
			document.myForm.end_date.focus();
			return false;
			
		}
		
		if (isDate(document.myForm.end_date.value)==false)
		{	
			document.myForm.end_date.focus();
			return false
		}	
		
		
		//to check if end_date > start_date
		dtStr = document.myForm.start_date.value;
		var daysInMonth = DaysArray(12)
		var pos1=dtStr.indexOf(dtCh)
		var pos2=dtStr.indexOf(dtCh,pos1+1)
		var strMonth=dtStr.substring(0,pos1)
		var strDay=dtStr.substring(pos1+1,pos2)
		var strYear=dtStr.substring(pos2+1)
		strYr=strYear
		if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
		if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
		for (var i = 1; i <= 3; i++) {
			if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
		}
		start_month=parseInt(strMonth)
		start_day=parseInt(strDay)
		start_year=parseInt(strYr)
		
		dtStr = document.myForm.end_date.value;
		daysInMonth = DaysArray(12)
		pos1=dtStr.indexOf(dtCh)
		pos2=dtStr.indexOf(dtCh,pos1+1)
		strMonth=dtStr.substring(0,pos1)
		strDay=dtStr.substring(pos1+1,pos2)
		strYear=dtStr.substring(pos2+1)
		strYr=strYear
		if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
		if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
		for (var i = 1; i <= 3; i++) {
			if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
		}
		end_month=parseInt(strMonth)
		end_day=parseInt(strDay)
		end_year=parseInt(strYr)
		
		var startDate = new Date();
		var endDate = new Date();
		
		startDate.setFullYear(start_year,start_month - 1,start_day);
		endDate.setFullYear(end_year,end_month - 1,end_day);
		
		if (endDate < startDate)
		{
			alert("Start date cannot be after end date")
			return false
		}
		
		return true;
	  
	}
	//end of function


//***************************Function for request_brochure.asp ************************************************
function valForm()
	{
	  
	  	if (document.myform.First_Name.value==''){
			alert('You must enter your first name.');
			document.myform.First_Name.focus();
			return false;
		}
	  	if (document.myform.Last_Name.value==''){
			alert('You must enter your last name.');
			document.myform.Last_Name.focus();
			return false;
		}
	  	if (document.myform.Home_Address.value==''){
			alert('You must enter your home address.');
			document.myform.Home_Address.focus();
			return false;
		}
	  	if (document.myform.City.value==''){
			alert('You must enter your home city.');
			document.myform.City.focus();
			return false;
		}
	  	if (document.myform.State.value==''){
			alert('You must enter your home state.');
			document.myform.State.focus();
			return false;
		}
	  	if (document.myform.Zip.value==''){
			alert('You must enter your home zip.');
			document.myform.Zip.focus();
			return false;
		}
	  	if (document.myform.Country.value==''){
			alert('You must enter your home country.');
			document.myform.Country.focus();
			return false;
		}
	  	if (document.myform.Email.value==''){
			alert('You must enter your Email address.');
			document.myform.Email.focus();
			return false;
		}
		
		if (document.getElementById('learn3').checked == true)
		{
			if(parseInt(document.getElementById('publication').options[document.getElementById('publication').selectedIndex].value) == -1)
			{
				alert('If you choose publication, please specify.');
				
				return false;
			}
		}
		
		
		if (document.getElementById('learn5').checked == true)
		{
			if(document.getElementById('source').value.length < 1)
			{
				alert('If you choose other, you must specify the source.');
				source.focus();
				return false;
			}
		}
		
		return true;;
	  
	}
	
	
	function openDiv(id)
	{
					
		var folder = document.getElementById(id).style
			
		folder.display=""
		
		
	}//end of function
	
	function closeDiv(id)
	{
					
		var folder = document.getElementById(id).style
		
		folder.display="none"
	}//end of function

//***************************Function for current_students.asp, faculty.asp, alumni.asp ************************************************


function CheckEmail(email)
{
    var firstchunk,indx,secondchunk

    if (email == ""){
        alert("Please make sure you have entered a valid email before submitting the info.")

        return false
    }

    //get the zero-based index of the "@" character
    indx = email.indexOf("@")

    //if the string does not contain an @ then then return true
    if (indx == -1 ){

        alert("Please make sure you have entered a valid email before submitting the info.")

        return false
    }

    //if the first part of email is < 2 chars and second part < 7 chars
    //(arbitrary but workable criteria) then reject the input address

    firstchunk = email.substr(0,indx) //up to but not including the "@"

    //start at char following the "@" and include up to end of email addr
    secondchunk = email.substr(indx + 1) 

    //if the part  following the "@" does not include a period "." then
    //also return false
    if ((firstchunk.length < 2 ) || 
    (secondchunk.indexOf(".") == -1)){ 

    alert("Please make sure you have entered a valid email before submitting the info.")

    return false
	}

	//the email was okay; at least it had a @, more than 1 username chars,
	//more than 6 chars after the "@", and the substring after the "@"
	// contained a "." char
	
	return true

}

//*************************************used in the alumni_profile_update.asp*********************************
//Validate update alumni form
function AlumniUpdatevalidate()
{
	x=document.myForm
	
	firstname=x.firstname.value
	lastname=x.lastname.value
	email = x.email.value
	alternate_email = x.alternate_email.value
	
	password1 = x.password1.value
	password2 = x.password2.value
	
	degree1 = x.degree1.value
	degree2 = x.degree2.value
	degree3 = x.degree3.value
	
	university1 = x.university1.value
	university2 = x.university2.value
	university3 = x.university3.value
	
	interest1 = x.interest1.value
	interest2 = x.interest2.value
	interest3 = x.interest3.value
	
	expertise1 = x.expertise1.value
	expertise2 = x.expertise2.value
	expertise3 = x.expertise3.value
	
	submitOK="True"
	
	if (firstname.length < 1)
	{
	 	
		x.firstname.focus();
		alert("Firstname is required")
	 	return false;
	}
	 
	if (lastname.length < 1)
	{
	 	x.lastname.focus();
		alert("Lastname is required")
	 	return false;
	}
	
	if (!CheckEmail(email))
	{
	 	return false;
	}
	
	if(alternate_email.length > 0)
	{
		if (!CheckEmail(alternate_email))
		{
			return false;
		}
	}
	
	
	if (password1.length < 7)
	{
	 	x.password1.focus();
		alert("Password is required and must be at least 7 character long")
	 	return false;
	}
	
	if (password2.length < 7)
	{
	 	x.password2.focus();
		alert("Please retype your password")
	 	return false;
	}
	
	if(password1 != password2)
	{
		alert("Passwords do not match")
	 	return false;
	}
	
	
	if (degree1.length < 1)
	{
	 	x.degree1.focus();
		alert("At least one degree is required")
	 	return false;
	}
	
	if (university1.length < 1)
	{
	 	x.university1.focus();
		alert("Please specify the university where you got your degree from")
	 	return false;
	}
	
	if (degree2.length > 1) // the user specifies the second degree
	{
	 	if (university2.length < 1)
		{
			x.university2.focus();
			alert("Please specify the university where you got your degree from")
			return false;
		}
	}
	
	if (degree3.length > 1) // the user specifies the second degree
	{
	 	if (university3.length < 1)
		{
			x.university3.focus();
			alert("Please specify the university where you got your degree from")
			return false;
		}
	}
	
	if (interest1.length < 1 && interest2.length < 1 && interest3.length < 1)
	{
	 	x.interest1.focus();
		alert("Please specify at least one area of interest")
	 	return false;
	}
	
	if (expertise1.length < 1 && expertise2.length < 1 && expertise3.length < 1)
	{
	 	x.expertise1.focus();
		alert("Please specify at least one area of expertise")
	 	return false;
	}
	
	 
	return true;
}//end of function


//Validate update student form
function StudentUpdatevalidate()
{
	x=document.myForm
	
	firstname=x.firstname.value
	lastname=x.lastname.value
	email = x.email.value
	alternate_email = x.alternate_email.value
	
	password1 = x.password1.value
	password2 = x.password2.value
	
	degree1 = x.degree1.value
	degree2 = x.degree2.value
	degree3 = x.degree3.value
	
	university1 = x.university1.value
	university2 = x.university2.value
	university3 = x.university3.value
	
	interest1 = x.interest1.value
	interest2 = x.interest2.value
	interest3 = x.interest3.value
	
	expertise1 = x.expertise1.value
	expertise2 = x.expertise2.value
	expertise3 = x.expertise3.value
	
	submitOK="True"
	
	if (firstname.length < 1)
	{
	 	
		x.firstname.focus();
		alert("Firstname is required")
	 	return false;
	}
	 
	if (lastname.length < 1)
	{
	 	x.lastname.focus();
		alert("Lastname is required")
	 	return false;
	}
	
	if (!CheckEmail(email))
	{
	 	return false;
	}
	
	if(alternate_email.length > 0)
	{
		if (!CheckEmail(alternate_email))
		{
			return false;
		}
	}
	
	
	if (password1.length < 7)
	{
	 	x.password1.focus();
		alert("Password is required and must be at least 7 character long")
	 	return false;
	}
	
	if (password2.length < 7)
	{
	 	x.password2.focus();
		alert("Please retype your password")
	 	return false;
	}
	
	if(password1 != password2)
	{
		alert("Passwords do not match")
	 	return false;
	}
	
	
	if (degree1.length < 1)
	{
	 	x.degree1.focus();
		alert("At least one degree is required")
	 	return false;
	}
	
	if (university1.length < 1)
	{
	 	x.university1.focus();
		alert("Please specify the university where you got your degree from")
	 	return false;
	}
	
	if (degree2.length > 1) // the user specifies the second degree
	{
	 	if (university2.length < 1)
		{
			x.university2.focus();
			alert("Please specify the university where you got your degree from")
			return false;
		}
	}
	
	if (degree3.length > 1) // the user specifies the second degree
	{
	 	if (university3.length < 1)
		{
			x.university3.focus();
			alert("Please specify the university where you got your degree from")
			return false;
		}
	}
	
	if (interest1.length < 1 && interest2.length < 1 && interest3.length < 1)
	{
	 	x.interest1.focus();
		alert("Please specify at least one area of interest")
	 	return false;
	}
	
	if (expertise1.length < 1 && expertise2.length < 1 && expertise3.length < 1)
	{
	 	x.expertise1.focus();
		alert("Please specify at least one area of expertise")
	 	return false;
	}

	
	 
	return true;
}//end of function


//Validate update faculty form
function FacultyUpdatevalidate()
{
	x=document.myForm
	
	firstname=x.firstname.value
	lastname=x.lastname.value
	email = x.email.value
	
	password1 = x.password1.value
	password2 = x.password2.value
	
	interest1 = x.interest1.value
	interest2 = x.interest2.value
	interest3 = x.interest3.value
	expertise1 = x.expertise1.value
	expertise2 = x.expertise2.value
	expertise3 = x.expertise3.value
	
	submitOK="True"
	
	if (firstname.length < 1)
	{
	 	
		x.firstname.focus();
		alert("Firstname is required")
	 	return false;
	}
	 
	if (lastname.length < 1)
	{
	 	x.lastname.focus();
		alert("Lastname is required")
	 	return false;
	}
	
	if (!CheckEmail(email))
	{
	 	return false;
	}
	
	if (password1.length < 7)
	{
	 	x.password1.focus();
		alert("Password is required and must be at least 7 character long")
	 	return false;
	}
	
	if (password2.length < 7)
	{
	 	x.password2.focus();
		alert("Please retype your password")
	 	return false;
	}
	
	if(password1 != password2)
	{
		alert("Passwords do not match")
	 	return false;
	}
	
	if (interest1.length < 1 && interest2.length < 1 && interest3.length < 1)
	{
	 	x.interest1.focus();
		alert("Please specify at least one area of interest")
	 	return false;
	}
	
	if (expertise1.length < 1 && expertise2.length < 1 && expertise3.length < 1)
	{
	 	x.expertise1.focus();
		alert("Please specify at least one area of expertise")
	 	return false;
	}

	 
	return true;
}//end of function

function login_validate()
	{
		x=document.myForm
		
		email=x.email.value
		password=x.password.value
		
		if (email.length < 1)
		{
		 	alert("Email is required")
		 	return false;
		}
		if (password.length < 1)
		{
			 alert("Password is required")
			 return false;
		}
		
		return true;
	}


function changeGallery()
	{
		val = document.getElementById("galleryChoice").value
		
		if(val == 1) 
			window.location ="alumni.asp?gallery=1";
		else if(val == 2)
			window.location ="alumni.asp?gallery=2";
		else if(val == 3)
			window.location ="alumni.asp?gallery=3";
		
	}
	
//************************************Function for search_member.asp**************************************

function validateSearchMemberForm()
{
	x=document.search_member_form
	
	member_name=x.member_name.value
	organization=x.organization.value
	interest = x.interest.value
	expertise = x.expertise.value
	
	if (member_name.length < 2 && organization.length < 2 && interest.length < 2 && expertise.length < 2)
	{
		alert("you specify at least one of the criteria");	
		return false;	
	}
	
	return true;
}
//end of function
	

//***************************Function for emph_matter.asp ************************************************
function select_event()
{
	eid=document.getElementById('featured_event').options[document.getElementById('featured_event').selectedIndex].value
	window.location="emph_matter.asp?eid=" + eid ;
}

//***************************Function for course_listing.asp ************************************************


function spantitle(id)
{
				
	var folder = document.getElementById(id).style
	if (folder.display=="none")
	{	
		folder.display=""
	}
	else
	{	
		folder.display="none"
	}		
}