var BackgroundTimerID = null, ScrollPosY = -578, scroll_side = true, side_scroll_amount = 1
var Menu_Container_OBJECT, Menu_Content_OBJECT

var Container_Height
var Content_Height
var Relative_Location
var Leeway, Leeway1
var New_Top
var Top_Limit = 60
var Bot_Limit = 60
var Pad_Limit = 20

var Menu_Y, Menu_Y1
var Menu_Timer_ID = null
var Move_Switch = true
var Menu_Speed = 1
var Mouse_Locator, Mouse_Loc_New_Top
var Watch

function scroll_sidebar(){
 if(scroll_side){
   ScrollPosY > 699 ? ScrollPosY = 0 : ScrollPosY += side_scroll_amount
   document.getElementById("CSU_SideBar_OBJECT").style.backgroundPosition = "0px " + ScrollPosY + "px"
 }
}


function Resize_Content_Area(obj){
 //Resizes the content area to match the dark curved edge of the template
 var theY, theX, theMaxY = 425, theTopY = 125, theLeft
 theY = (180 + (document.body.offsetHeight/2) - theTopY)/1.3
 if(theY > theMaxY)
   theY = theMaxY
 theX = Math.sqrt(250000 - theY*theY)
 theLeft = parseInt(730 - theX)
 obj.style.left = parseInt(730 - theX) + "px"

 //For IE6
 if(IE6){
   obj.style.width = (document.body.offsetWidth - theLeft - 40) + "px"
   obj.style.height = (document.body.offsetHeight - 200) + "px"
 }
}

function MouseX(e){
  return (window.event?window.event.clientX:(window.captureEvents?e.clientX:0))
}

function MouseY(e){
  return (window.event?window.event.clientY:(window.captureEvents?e.clientY:0))
}



function Scroll_Menu(e){
 Container_Height = this.offsetHeight
 Content_Height = this.childNodes[0].offsetHeight
 Relative_Location = MouseY(e) - Top_Limit
 Leeway = Content_Height - Container_Height

 if(Leeway > 0){
   New_Top = (-1 * Relative_Location * (Leeway/Container_Height))

   if(Math.abs(New_Top - parseInt(this.childNodes[0].style.top)) > Menu_Speed && Move_Switch == true){
     clearInterval(Menu_Timer_ID)
     Menu_Timer_ID = setInterval(Move_Menu, 5)
   }else{
     clearInterval(Menu_Timer_ID)
     this.childNodes[0].style.top = New_Top + "px"
   }
 }else{
   this.childNodes[0].style.top = "0px"
 }
}


function Move_Menu(){
 Menu_Y = parseInt(Menu_Content_OBJECT.style.top)
 var Increment = Menu_Speed * (New_Top - Menu_Y)/(Math.abs(New_Top - Menu_Y))
 Menu_Y += Increment
 Menu_Content_OBJECT.style.top = Menu_Y + "px"

 if(Math.abs(New_Top - Menu_Y) < Menu_Speed){
   clearInterval(Menu_Timer_ID)
   Menu_Content_OBJECT.style.top = New_Top + "px"
   Move_Switch = false
 }
 //Adjust Menu Speed
 Menu_Speed = parseInt(Math.abs(New_Top - Menu_Y) * 0.35)
 if(Menu_Speed < 1){
   Menu_Speed = 1
   Move_Switch = false
 }
}

function Resize_Menu(){
 if(IE6){
   Menu_Container_OBJECT.style.height = (document.body.offsetHeight - 120) + "px"
 }
 Menu_Content_OBJECT.style.top = "0px"
}

function Adjust_Main_Photo(){
  if(document.getElementById("Avery_Glow_Conainer_OBJECT").offsetHeight < 643)
    document.getElementById("Avery_Glow_Conainer_OBJECT").className = "Avery_Glow_Container_CLASS2"
  else
    document.getElementById("Avery_Glow_Conainer_OBJECT").className = "Avery_Glow_Container_CLASS1"
}

function Page_Resized(){
 var t = document.location + ""
 Resize_Content_Area(document.getElementById("Content_Container_OBJECT"))
 Resize_Menu()

 if(t.toLowerCase() == "http://www.coppin.edu/inauguration/"){
   Adjust_Main_Photo()
 }
}

function Reset_Menu_Action(){
 Move_Switch=true
}

function Suspend_Sidebar(){
 scroll_side = false
}

function Activate_Sidebar(){
 scroll_side = true
}

window.onload = function(){
 var t = document.location + ""
 if(t.toLowerCase() == "http://www.coppin.edu/inauguration/"){
   BackgroundTimerID = setInterval("scroll_sidebar();", 85)
   Adjust_Main_Photo()
   document.getElementById("Invite_OBJECT").onmouseover = Reset_Menu_Action
 }
 Resize_Content_Area(document.getElementById("Content_Container_OBJECT"))
 document.getElementById("Content_Container_OBJECT").style.visibility = "visible"
 Menu_Container_OBJECT = document.getElementById("Menu_Container_OBJECT")
 Menu_Content_OBJECT = document.getElementById("Menu_Content_OBJECT")
 Resize_Menu()
 document.getElementById("Menu_Container_OBJECT").onmousemove = Scroll_Menu
 // Menu_Container_OBJECT.onmouseleave = Reset_Menu_Action
 document.getElementById("Header_OBJECT").onmouseover = Reset_Menu_Action
 document.getElementById("Footer_OBJECT").onmouseover = Reset_Menu_Action
 document.getElementById("Menu_Divide_OBJECT").onmouseover = Reset_Menu_Action
 //Watch = document.getElementById("Watch")
}

window.onresize = Page_Resized