function showEvent(date){
  if (date.getDate() == 25 && date.getMonth() == 09-1 && date.getFullYear() == 2009){
    return [true, '', 'Event'];
  }
  else {
    return [false, '', 'No Event'];
  }
}

function expandEvent(date){
  $("#dialog").dialog({
    modal : true,
    resizable : false,
    closeOnEscape : true
  });
}

function scrollImage(sImage, sDistance, sTime, sDelay) {
  if (sImage == undefined) {
    sImage = 1;
  }
  $(".imgScroller a:nth-child(" + sImage + ")").fadeIn("slow");
  $(".imgScroller a:nth-child(" + sImage + ")").delay(sDelay || 1000).animate({
    top: (0 - sDistance) || ('-30') + 'px'
  }, sTime || 4000).fadeOut("slow", function(){
    sImage++;
    if (sImage <= $(".imgScroller").children().length) {
    scrollImage(sImage, sDistance, sTime, sDelay);
  }
  else {
    $(".imgScroller").children().css({
      top: '+0px'
    });
    sImage = 1;
    scrollImage(sImage, sDistance, sTime, sDelay);
  }
  });
}

function scrollNews(sDiv, sDelay) {
  if (sDiv == undefined) {
    sDiv = 1;
  }
  if ($("#newsFeed").children().length == 1){
    $("#newsFeed div:nth-child(" + sDiv + ")").toggle();
    return false;
  }
  $("#newsFeed div:nth-child(" + sDiv + ")").fadeIn("slow");
  $("#newsFeed div:nth-child(" + sDiv + ")").delay(sDelay || 1000).fadeOut("slow", function(){
    sDiv++;
    if (sDiv <= $("#newsFeed").children().length) {
    scrollNews(sDiv, sDelay);
  }
  else {
    sDiv = 1;
    scrollNews(sDiv, sDelay);
  }
  });
}

function popUp(URL, ID, Width, Height, toolbar, scrollbars, location, statusbar, menubar, resizable){
  FFpopUp = window.open(URL, ID, 'toolbar=' +toolbar+ ',scrollbars=' +scrollbars+ ',location=' +location+ ',statusbar=' +statusbar+ ',menubar=' +menubar+ ',resizable=' +resizable+ ',width=' +Width+ ',height=' +Height+ ',left=' +(screen.availWidth-10-Width)/2+ ',top=' +(screen.availHeight-30-Height)/2);
}

function ConfirmEntry(URL){
  extWeb=confirm("Please be aware that Fairfield High School is not responsible for the content of external internet websites.\n\nWe do not endorse views, products or services appearing on these sites.\n\nClick OK to continue to " +URL.replace('http://','')+ ".\nClick Cancel to stay at Fairfield High School.");
  if (extWeb==true){
    day = new Date();
    id = day.getTime();
    popUp(URL, id, '800', '600', '1', '1', '1', '1', '1', '1');
  }
}

function CheckEmail(email){
  if (email == ""){
    document.getElementById('EmailError').innerHTML="Please enter a valid email address"
    document.getElementById('submit').disabled=true;
  }

  AtPos = email.indexOf("@")
  StopPos = email.lastIndexOf(".")
  Errors = 0;

  if (AtPos == -1 || StopPos == -1){
    document.getElementById('EmailError').innerHTML="Please enter a valid email address";
    document.getElementById('submit').disabled=true;
    Errors = 1;
  }
  if (StopPos < AtPos){
    document.getElementById('EmailError').innerHTML="Please enter a valid email address";
    document.getElementById('submit').disabled=true;
    Errors = 1;
  }
  if (StopPos - AtPos == 1){
    document.getElementById('EmailError').innerHTML="Please enter a valid email address";
    document.getElementById('submit').disabled=true;
    Errors = 1;
  }
  
  if (Errors == 0){
    document.getElementById('EmailError').innerHTML="";
    document.getElementById('submit').disabled=false;
  }
}