var sTargetURL = "/Home.do";

// define image variables and preload
	var ismShareefOn = new Image();
	ismShareefOn.src = "/jsp/images/IsmShareef.gif";
	var ismShareefOff = new Image();
	ismShareefOff.src = "/jsp/images/sitebanner-fade.gif";
	
function doRedirect()
{
    //  The JavaScript 1.0 version of this function supports
    //  browsers that don't have the ability to replace this
    //  file in the browser history.  As a result we want to
    //  make sure that we briefly delay so when the visitor
    //  is moving back through their browser-history they
    //  will have time to press the back-button on this page
    //  before the script moves them to the redirection
    //  target page again.
    //
    //  Notice that we have the timeout the same amount as in
    //  the meta-refresh version.
    //
    setTimeout( "window.location.href = sTargetURL", 4*1000 );
    
    //  The 2*1000 equals 2 seconds.
}

function loadQuestion(id)
{
  location.href = "/RetrieveQuestion.do?questionId=" + id
}

function loadQuestionToApprove(id)
{
  location.href = "/RetrievePendingQuestion.do?questionId=" + id
}

function loadQuestionToResubmit(id)
{
  location.href = "/RetrieveRejectedQuestion.do?questionId=" + id
}

function rejectQuestion(id)
{
  location.href = "/RejectQuestion.do?questionId=" + id
}

function loadUser(id)
{
  location.href = "/FindUserById.do?userId=" + id
}

function clearSearchFields()
{
  elems = document.getElementsByTagName("input");
  for(i=0; i< elems.length; i++)
  {
    if(elems[i].name == 'subject')
    {
    	alert(elems[i].value);
    	elems[i].value = '';
    	alert(elems[i].value);
    }
  }
}

function setHelpLabel(label, text)
{
  document.forms[1].helplabel.value = label;
  document.forms[1].helptext.value = text;
  helpWinWidth = 300;
  helpWinHeight = 300;
  helpWinTop = (screen.height/2)-(helpWinHeight/2);
  helpWinLeft = (screen.width/2)-(helpWinWidth/2);
  window.open("/jsp/help-popup.html","helpWin","toolbar=no,menubar=no,location=no,scrollbars=no,resizeable=no,status=no,width=" + helpWinWidth + ",height=" + helpWinHeight + ",top=" + helpWinTop + ",left=" + helpWinLeft);
}

function launchHelpPage(anchor)
{
  helpWinWidth = 400;
  helpWinHeight = 400;
  helpWinTop = (screen.height/2)-(helpWinHeight/2);
  helpWinLeft = (screen.width/2)-(helpWinWidth/2);
  window.open("/jsp/HelpManual.html" + "#" + anchor,"helpWin","toolbar=no,menubar=no,location=no,scrollbars=no,resizeable=no,status=no,width=" + helpWinWidth + ",height=" + helpWinHeight + ",top=" + helpWinTop + ",left=" + helpWinLeft);
}

function showDiv(id)
{
  var elem = document.getElementById(id);
  elem.style.display = 'block';
}

function hideDiv(id)
{
  var elem = document.getElementById(id);
  elem.style.display = 'none';
}
