$(document).ready(function() { 
  //Toggle login/upload div
  $(".adminlog").click(function(){
    $('#login').show('fast')      
  });
  $(".logo").click(function(){
    $('#fileupload').hide('fast')    
  });
});          


function ajaxFileUpload(){   
/*
  $('#fileupload').hide('fast');
  $('#alert').show('fast');
  //add the indicator
  var img =document.createElement('img');
  img.src = "http://jefferson.osd.wednet.edu/media/jefferson/calendarupload/channelj/indicator.gif";
  img.setAttribute('id','working');
  var alertdiv = document.getElementById('alert');
  alertdiv.appendChild(img);
  //add the "working" text
  wrk = document.createTextNode("Working...");
  var work =document.createElement('h3');
  work.setAttribute('id','work');
  work.appendChild(wrk);
  var alertdiv = document.getElementById('alert');
  alertdiv.appendChild(img);
  alertdiv.appendChild(work);
*/
  $.ajaxFileUpload(
    {  
      url:'http://jefferson.osd.wednet.edu/media/jefferson/calendarupload/channelj/doajaxfileupload.php',
      secureuri:false,
      fileElementId:'fileToUpload',
      dataType: 'json',
      success: function (data, status){
        if(typeof(data.error) != 'undefined'){
          if(data.error != ''){
            $('#alert').hide('fast'); top.location="http://jefferson.osd.wednet.edu/media/jefferson/calendarupload/channelj/logout.php"
            alert(data.error);
          }else{
            var div = document.getElementById('alert');
            div.innerHTML = data.msg;
          }
        }
      },
      error: function(data, status, e){
        alert(e);
      }
    }
  )
  return false;
}