 var cur_imgcnt = 1;
var nxt_imgcnt = 0;
var cancelRotate = false;

function SelImage(cnt){
  var cur_imgall = document.all("slider").getElementsByTagName("img").length;
  
  for (x=1; x <= cur_imgall; x++) {
    document.all('still_'+x).style.display = '';
    document.all("slidecontrol").getElementsByTagName("a")[x-1].style.color="";
    }
  document.all('still_'+cnt).style.display = 'inline';
  document.all("slidecontrol").getElementsByTagName("a")[cnt-1].style.color="#fa4b00";
  cancelRotate = true;
}

function rotateImage(){
  var cur_imgall = document.all("slider").getElementsByTagName("img").length;
  
  if (cancelRotate) return;
  if (document.all('still_'+cur_imgcnt).style.display == 'inline') {
    if (cur_imgall == nxt_imgcnt) {
      nxt_imgcnt = 1;
      cur_imgcnt = cur_imgcnt;
      }
    else {
      nxt_imgcnt = cur_imgcnt + 1;
      cur_imgcnt = cur_imgcnt;
      }
    document.all('still_'+cur_imgcnt).style.display = '';
    document.all('still_'+nxt_imgcnt).style.display = 'inline';
    document.all("slidecontrol").getElementsByTagName("a")[cur_imgcnt-1].style.color="";
    document.all("slidecontrol").getElementsByTagName("a")[nxt_imgcnt-1].style.color="#fa4b00";
    cur_imgcnt = nxt_imgcnt;
    }
  if (!cancelRotate) window.setTimeout(rotateImage, 3000);
}

function SearchStr(tmpURL,tmpQry,tmpField,thisobj) {
  if (tmpQry == '') {
    window.location.href = tmpURL + '?filter=' + tmpField + '=\'' + thisobj.options[thisobj.selectedIndex].value + '\'';
    window.location.reload;
    }
  else {
    intsub = tmpQry.indexOf(tmpField);
    intsub2 = tmpQry.indexOf('AND',intsub);
    if (intsub > 0 && intsub2 > 0 ) {
      tmpQry = tmpQry.substr(0, intsub-4) + tmpQry.substr(intsub2) + ' AND ';
      }
    else if (intsub > 0 && intsub2 == -1 ) {
      tmpQry = tmpQry.substr(0, intsub-4) + ' AND ';
      }
    else if (intsub == 0 && intsub2 > 0 ) {
      tmpQry = tmpQry.substr(intsub2+4) + ' AND ';
      }
    else if (intsub == 0 && intsub2 == -1) {
      tmpQry = '';
      }
    else {
      tmpQry = tmpQry + ' AND ';
      }
    window.location.href = tmpURL + '?filter=' + tmpQry + tmpField + '=\'' + thisobj.options[thisobj.selectedIndex].value + '\'';
    window.location.reload;
    }
  return;
}

function SearchNum(tmpURL,tmpQry,tmpField,thisobj) {
  if (tmpQry == '') {
    window.location.href = tmpURL + '?filter=' + tmpField + '=' + thisobj.options[thisobj.selectedIndex].value;
    window.location.reload;
    }
  else {
    intsub = tmpQry.indexOf(tmpField);
    intsub2 = tmpQry.indexOf('AND',intsub);
    if (intsub > 0 && intsub2 > 0 ) {
      tmpQry = tmpQry.substr(0, intsub-4) + tmpQry.substr(intsub2) + ' AND ';
      }
    else if (intsub > 0 && intsub2 == -1 ) {
      tmpQry = tmpQry.substr(0, intsub-4) + ' AND ';
      }
    else if (intsub == 0 && intsub2 > 0 ) {
      tmpQry = tmpQry.substr(intsub2+4) + ' AND ';
      }
    else if (intsub == 0 && intsub2 == -1) {
      tmpQry = '';
      }
    else {
      tmpQry = tmpQry + ' AND ';
      }
    window.location.href = tmpURL + '?filter=' + tmpQry + tmpField + '=' + thisobj.options[thisobj.selectedIndex].value;
    window.location.reload;
    }
  return;
}

function SearchFilt(tmpURL,tmpQry,thisobj) {
  if (tmpQry == '') {
    window.location.href = tmpURL + '?subj=' + thisobj.options[thisobj.selectedIndex].value;
    window.location.reload;
    }
  else {
    intsub = tmpQry.indexOf('subj');
    if (intsub > 0 ) {
      tmpQry = tmpQry.substr(0, intsub-1);
      window.location.href = tmpURL + '?' + tmpQry + '&subj=' + thisobj.options[thisobj.selectedIndex].value;
      }
    else if (intsub == 0 ) {
      window.location.href = tmpURL + '?subj=' + thisobj.options[thisobj.selectedIndex].value;
      }
    else if (intsub == -1 ) {
      window.location.href = tmpURL + '?' + tmpQry + '&subj=' + thisobj.options[thisobj.selectedIndex].value;
      }
    window.location.reload;
    }
  return;
}

function toggleShow(thisobj) {
  if (thisobj.options[thisobj.selectedIndex].text == 'Teacher') {
    document.all('TeacherLevel').style.display = '';
    document.all('StudentLevel').style.display = 'none';
    }
  else if (thisobj.options[thisobj.selectedIndex].text == 'Student') {
    document.all('TeacherLevel').style.display = 'none';
    document.all('StudentLevel').style.display = '';
    }
  else {
    document.all('TeacherLevel').style.display = 'none';
    document.all('StudentLevel').style.display = 'none';
    }
  return;
}

function PollSubmit(jsPollQ,objPollC) {
  cntC = objPollC.length;
  PollChoice = 0;
  for (i=0; i<cntC; i++){
		if (objPollC[i].checked) var PollChoice = objPollC[i].value
	}
  window.open('mod_poll_vote.asp?pollQNum=' + jsPollQ + '&PollAns' + jsPollQ + '=' + PollChoice,'win','toolbar=no,scrollbars=yes,directories=no,status=yes,menubar=no,resizable=no,width=450,height=380');
  return;
}

function PollView(jsPollQ) {
  window.open('mod_poll_show.asp?pollQNum=' + jsPollQ,'win','toolbar=no,scrollbars=yes,directories=no,status=yes,menubar=no,resizable=no,width=450,height=380');
  return;
}

function PopModalWin(url) {
  window.open(url,null,'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=no,width=450,height=380,modal=yes');
  return;
}

function PopModalWin2(url) {
  window.open(url,null,'toolbar=yesno,location=no,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=800,height=600,modal=yes');
  return;
}

function PopTakeTour(url) {
  window.open(url,null,'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=no,width=600,height=450,modal=yes');
  return;
}

function PopModalView(url) {
  window.open(url,null,'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=no,width=500,height=205,modal=yes');
  return;
}

function PopModalView2(url) {
  window.open(url,null,'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=no,width=500,height=500,modal=yes');
  return;
}
