window.onload = loadDispatcher;
function loadDispatcher(){
	loadVisitSched();
	loadProgram();
	loadAlumniProfile();
}
//THIS SECTION IS RESERVED FOR ASK IT/UW
var defaultStr = 'Type a question in sentence form.';
var cURL = 'http://uwindsor.intelliresponse.com/current/';
function isBlank(q) {
  var whitespace = new String(" \t\n\r");
 
  for (var i = 0; i<q.length; i++) {
    if (whitespace.indexOf(q.charAt(i)) == -1) {
      return false;
    }
  }
 
  return true;
}
 
function submitForm(){
  var d = document.questionForm;
  if (!isValidForm())
    return;
 
  d.submit();
}
 
function isValidForm(){
  var d = document.questionForm;
  if (d.question.value==defaultStr  ||  isBlank(d.question.value)) {
    return false;
  }
 
  d.action=cURL+'results.jsp';
  d.requestType.value='NormalRequest';
  return true;
}
 
function topTen(){
  var d = document.questionForm;
  d.action=cURL+'topQuestions.jsp';
  d.submit();
  d.action=cURL+'results.jsp';
}
 
function clearForm(){
  var d = document.questionForm;
  d.id.value=-1;
  d.reset();
  d.question.focus();
  d.question.value='';
}
function siteHideShowHighlight(myID){
	var myDirection = myID.replace('editSection', '');
	if($(myID)){
	 $(myID).style.backgroundImage='url(/uweb/futurestudents.nsf/screenshot'+myDirection+'.gif)';
	 setSiteHideText(myDirection);		 
	}		 		 
}

function siteHideHideHighlight(myID){
	if($(myID)){
		 $(myID).style.backgroundImage='none';
		 setSiteHideText('');		 
	}		 		 
}

function setSiteHideText(myDirection){
var innerText = '';
	switch(myDirection){
		case 'TopBar':
			innerText = 'Edit Top Utility Bar Links';
			break;
		case 'TopMenu':
			innerText = 'Edit the Top Menu';
			break;		 
		case 'Menu':
			innerText = 'Edit the Left-Hand Menu Items';
			break;		 
		case 'BannerImage':
			innerText = 'Edit the Main Display Image';
			break;
		case 'News':
			innerText = 'Edit the News Snippets';
			break;
		case 'NewsCards':
			innerText = 'Edit the News Cards';
			break;
		case 'Footer':
			innerText = 'Edit the Footer';
			break;				 
		default:
			innerText = 'Please select the portion of the page you wish to edit';
			break;		 
	}
	if($('editTopInstruction')){
		$('editTopInstruction').innerHTML = innerText;		 
	}
}
//This function allows for the first level menu item to stay highlighted,
//while the second level menu is used. Triggered by onmouseover defined in
//Script Library: makePopupMenu
function highlightParentMenu(hiWho){
	if(hiWho.parentNode){
		if((hiWho.parentNode).parentNode){
			var myParent = (hiWho.parentNode).parentNode;
			var anchorChildren = new Array();
			anchorChildren = myParent.childNodes;
			myParent.style.backgroundColor = '#005595';
			myParent.style.color = '#B2BB1E';
			for(var knt = 0; knt < anchorChildren.length; knt++){
				if(anchorChildren[knt].tagName == 'A'){
					anchorChildren[knt].style.backgroundColor = '#005595';
					anchorChildren[knt].style.color = '#B2BB1E';
				}
			}
		}
	}
}
//This function removes any style properties assigned to the first level menu item
//in the function highlightParentMenu. Triggered by onmouseout defined in
//Script Library: makePopupMenu
function lowlightParentMenu(loWho){
	if(loWho.parentNode){
		if((loWho.parentNode).parentNode){
			var myParent = (loWho.parentNode).parentNode;
			var anchorChildren = new Array();
			anchorChildren = myParent.childNodes;
			myParent.removeAttribute('style');
			for(var knt = 0; knt < anchorChildren.length; knt++){
				if(anchorChildren[knt].tagName == 'A'){
					anchorChildren[knt].removeAttribute('style');
				}
			}
		}
	}
}
var newsTO;
function showNewsStory(myNum){
	clearTimeout(newsTO);
	var myID = 'story'+myNum;
	$(myID).style.display = '';
	for(var knt = 1; knt <= 3; knt++){
		if($('story'+knt) && knt != myNum){
			hideNewsStory(knt);
		}
	}
}
function hideAllNewsStories(){
for(var knt = 1; knt <= 3; knt++){
	if($('story'+knt)){
			$('story'+knt).style.display = 'none';
		}
	}
clearTimeout(newsTO);
}
var hideNewsID;
function hideNewsStory(myNum){
	hideNewsID = 'story'+myNum;
	newsTO = setTimeout('disappearStory()', 750);
}
function disappearStory(){
	if($(hideNewsID)){
		$(hideNewsID).style.display = 'none';
		hideNewsID = '';	
		clearTimeout(newsTO);
	}
}
function switchSurveyContent(surveyMode){
	if(surveyMode == 1){
		$hide('surveyLinkContainer');
		$hide('alumniProfileContainer');
		$hide('programProfileContainer');
		$hide('careersContainer');
		$hide('contactUsContainer');
		$show('inlineSurveyContainer');
		if($('pageHelpfulY')){
			$('pageHelpfulY').focus();
		}
	}else if(surveyMode == 2){
		$hide('surveyLinkContainer');
		$hide('alumniProfileContainer');
		$hide('programProfileContainer');
		$hide('careersContainer');
		$show('contactUsContainer');
		$hide('inlineSurveyContainer');
		if($('contactName')){
			$('contactName').focus();
		}
		window.scroll(0, 400);
	}else{
		$hide('inlineSurveyContainer');
		$show('surveyLinkContainer');
		$show('alumniProfileContainer');
		$show('programProfileContainer');
		$hide('contactUsContainer');
		$show('careersContainer');
	}	
}
