function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function setSearchBox(isSubmit,formField) { 
	var defaultVal = "Search by College Name, Major or City";
	var searchField = document.getElementById(formField); //document.getElementById('searchBox');
	var searchVal = searchField.value;
	if(isSubmit==1){
		if(searchVal==defaultVal){
			searchField.value = '';
		}
	} else {
		if(searchVal==''){
			/*if(searchField.oldValue != defaultVal){
				defaultVal = searchField.oldValue;
			}*/
			searchField.value = defaultVal;
		}
	}
}
function checkEnter(e,formName){ //e is event object passed from function invocation
	var characterCode;
	if(e && e.which){ //if which property of event object is supported (NN4)
		e = e;
		characterCode = e.which; //character code is contained in NN4's which property
	} else {
		e = event;
		characterCode = e.keyCode; //character code is contained in IE's keyCode property
	}
	if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
		document.getElementById(formName).submit(); //submit the form
		//return false; 
	} else {
		return true; 
	}
}

function addCollege(colID){
	if(loggedIn == 1){
		window.location="/add-college/"+colID;
	} else {
		alert("You must be logged in to add colleges.");	
	}
}
function moreInfo(colID){
	if(colID != 0){
		window.open("/more-info/"+colID);
	} else {
		alert("We're sorry, this college has not provided a free information link.");	
	}		
}
function homeColHeight(){
	maxHeight = 0;
	for(var i=1;i<4;i++){ 
		var colDiv = document.getElementById('homeCol'+i);
		if(colDiv.offsetHeight){
			divHeight=colDiv.offsetHeight;
		} else if(colDiv.style.pixelHeight){
			divHeight=colDiv.style.pixelHeight;
		} 
		maxHeight=Math.max(maxHeight,divHeight); 
	}
	for(var i=1;i<4;i++){ 
		document.getElementById('homeCol'+i).style.height=maxHeight+"px";
	}
}
function setCookie(c_name,value,expiredays){
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString())+";path=/";
}
function getCookie(c_name){
	if (document.cookie.length>0){
  		c_start=document.cookie.indexOf(c_name + "=");
		if (c_start!=-1){ 
			c_start=c_start + c_name.length+1; 
			c_end=document.cookie.indexOf(";",c_start);
			if (c_end==-1) c_end=document.cookie.length;
				return unescape(document.cookie.substring(c_start,c_end));
		} 
  }
return "";
}
function advSearchToggle(direction){
	var aSearch = document.getElementById('searchAdv');
	if(direction){
		aSearch.style.display = direction;
	} else {
		aSearch.style.display = (aSearch.style.display == "none" ? "block" : "none");
	}
}
function advSearchCheck(){
	aSearch=getCookie('vcAdvSearch');
	if (aSearch!=null && aSearch!="" && aSearch!="0"){
		advSearchToggle('block');
		document.getElementById('advSearchTypeLabel').innerHTML = "BASIC";
		vcAdvSearchValue = '0';
		vcAdvSearchDisplay = 'none';
	} else {
		advSearchToggle('none');
		document.getElementById('advSearchTypeLabel').innerHTML = "ADVANCED";
		vcAdvSearchValue = '1';
		vcAdvSearchDisplay = 'block';
	}
}
function detailTab(tabContent){
	for(i=0;i<tabList.length;i++){
		if(tabList[i]!=tabContent){
			document.getElementById('tab'+tabList[i]).className = '';
			document.getElementById('tab'+tabList[i]+'Cap').className = '';
		}
	}
	document.getElementById('tab'+tabContent).className = 'detailNavTab';
	document.getElementById('tab'+tabContent+'Cap').className = 'detailNavTabCap';
	document.getElementById('detailViewer').innerHTML = document.getElementById('detail'+tabContent).innerHTML;
	if(tabContent == 'General' || tabContent == 'Admissions'){
		document.getElementById('detailViewer').className = 'detailDash';
	} else {
		document.getElementById('detailViewer').className = '';
	}
}
function detailPhoto(photoNum,caption){
	for(i=1;i<=photoTotal;i++){
		if(i != photoNum){
			document.getElementById('photoLink'+i).className = '';
		}
	}
	document.getElementById('photoLink'+photoNum).className = 'selected';
	if(caption){
		document.getElementById('detailPhotoImg').alt = caption;
	}
}
function administratorTab(tabContent){
	tabList = new Array('Overview', 'General', 'Admissions', 'Majors', 'Athletics', 'Activities', 'Financial', 'Photos');
	for(i=0;i<tabList.length;i++){
		if(tabList[i]!=tabContent){
			document.getElementById('tab'+tabList[i]).className = '';
			document.getElementById('tab'+tabList[i]+'Cap').className = '';
		}
	}
	document.getElementById('tab'+tabContent).className = 'detailNavTab';
	document.getElementById('tab'+tabContent+'Cap').className = 'detailNavTabCap';
}
function windowPopup(toPage) { 
  if(toPage == 'refer'){
  	window.open('/refer-a-friend','vcPopup','scrollbars=yes,width=400,height=240');
  }
  if(toPage == 'save'){
  	window.open('/save-search','vcPopup','scrollbars=yes,width=400,height=240');
  }
}
function checkCompare() {
	var f = document.getElementById('compareForm');
	var checkCount = 0;
	for(var i=0; i<f.length; i++){
		if(f[i].type=='checkbox' && f[i].checked){
			++checkCount;	
		}
	}
	if(checkCount<1){
		alert('Please select at least one college to compare.');
		return false;
	}
	if(checkCount>4){
		alert('Only 4 colleges can be compared at once.  Please only check 4 colleges.');
		return false;
	}
	f.submit();
}

var vcAdvSearchValue;
var vcAdvSearchDisplay;

//Kill Frames
if (window!= top){
  top.location.href=location.href;
}
