﻿function setFileViaHttpObject(file, callback) {
}

// Print a set of data stored as an array of rows
function printTableRows(data) {
    if (data == null)
      return;
      
    for (var j=0; j < data.length; j++) {
        document.write('<tr>');
    
        for (var i=0; i < data[j].length; i++) {
            document.write('<td>'+data[j][i]+'</td>');
        }
        document.write('</tr>');
    }
}

function fadeOut(id, timeToFade) {
    //speed for each frame 
    var speed = Math.round(timeToFade / 100); 
    var timer = 0; 

    //determine the direction for the blending, if start and end are the same nothing happens 
    for(i = 99; i >= 0; i--) { 
        setTimeout("changeOpacity(" + id + ",'" + i + "')",(timer * speed)); 
        timer++; 
    } 
}

function changeOpacity(id, opacity) { 
    var object = document.getElementById(id).style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
}

//Trim whitespace from both sides of a string
String.prototype.trim = function () {
    return this.replace(/^\s*/, "").replace(/\s*$/, "");
}

//Assuming that there are divs called varsity_sch, jv_sch, and frsh_sch, with
//corresponding buttons as named below, this function allows utilization of screen
//real estate by switching between them when clicked
  function switchSchTo(type) {
    var vSch = document.getElementById('varsity_sch');
    var vButton = document.getElementById('vSchButton');
    var jvSch = document.getElementById('jv_sch');
    var jvButton = document.getElementById('jvSchButton');
    var frshSch = document.getElementById('frsh_sch');
    var frshButton = document.getElementById('frshSchButton');
    var upButtonImage = "url("+httproot+"/css/images/page_buttonshort.jpg)";
    var downButtonImage = "url("+httproot+"/css/images/page_buttonshort_down.jpg)";
    
    if (type == 'jv') {
        vSch.style.display = "none";
        vButton.style.textDecoration = "underline";
        vButton.style.backgroundImage = upButtonImage;
        jvSch.style.display = "inline";
        jvButton.style.textDecoration = "none";
        jvButton.style.backgroundImage = downButtonImage;
        frshSch.style.display = "none";
        frshButton.style.textDecoration = "underline";
        frshButton.style.backgroundImage = upButtonImage;
    } else if (type == 'frsh') {
        vSch.style.display = "none";
        vButton.style.textDecoration = "underline";
        vButton.style.backgroundImage = upButtonImage;
        jvSch.style.display = "none";
        jvButton.style.textDecoration = "underline";
        jvButton.style.backgroundImage = upButtonImage;
        frshSch.style.display = "inline";
        frshButton.style.textDecoration = "none";
        frshButton.style.backgroundImage = downButtonImage;
    } else {
        vSch.style.display = "inline";
        vButton.style.textDecoration = "none";
        vButton.style.backgroundImage = downButtonImage;
        jvSch.style.display = "none";
        jvButton.style.textDecoration = "underline";
        jvButton.style.backgroundImage = upButtonImage;
        frshSch.style.display = "none";
        frshButton.style.textDecoration = "underline";
        frshButton.style.backgroundImage = upButtonImage;
    }
  }

//Redirect to a website after showing an alert message
function gotolink_with_alert(msg, link) {
    alert(msg);
    document.location = link;
}