/***********************************************
* AnyLink Drop Down Menu- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

// contents for menu 1
var menu1=new Array()
// menu1[0]='<div class="dropdown"><a href="http://www.alumni.ubc.ca/connect/trekconnect/index.php" class="dropdown"><em>TrekConnect</em></a></div>'
menu1[0]='<div class="dropdown"><a href="http://www.alumni.ubc.ca/blogs/index.php" class="dropdown">Student Life Blogs</a></div>'
menu1[1]='<div class="dropdown"><a href="http://www.alumni.ubc.ca/connect/podcasts/index.php" class="dropdown">Podcasts</a></div>'
menu1[2]='<div class="dropdown"><a href="http://www.alumni.ubc.ca/connect/youngalumni/index.php" class="dropdown">Young Alumni Network</a></div>'
menu1[3]='<div class="dropdown"><a href="http://www.alumni.ubc.ca/connect/networks/index.php" class="dropdown">Regional Networks</a></div>'
menu1[4]='<div class="dropdown"><a href="http://www.alumni.ubc.ca/connect/mentorship/index.php" class="dropdown">Mentorship Program</a></div>'
menu1[5]='<div class="dropdown"><a href="http://www.alumni.ubc.ca/connect/volunteer/index.php" class="dropdown">Get Involved</a></div>'
menu1[6]='<div class="dropdown"><a href="http://www.alumni.ubc.ca/connect/facultyalumni/index.php" class="dropdown">Faculty Alumni</a></div>'
menu1[7]='<div class="dropdown"><a href="http://www.alumni.ubc.ca/world/index.php" class="dropdown">It&#146;s Your World</a></div>'
menu1[8]='<div class="dropdown"><a href="http://www.alumni.ubc.ca/connect/bookclub/index.php" class="dropdown">Alumni Book Club</a></div>'
menu1[9]='<div class="dropdown"><a href="http://www.alumni.ubc.ca/connect/emailforwarding/index.php" class="dropdown">Alumni Email Forwarding</a></div>'
menu1[10]='<div class="dropdown"><a href="http://www.alumni.ubc.ca/connect/socialnetwork/index.php" class="dropdown">Social Networking</a></div>'

// contents for menu 2
var menu2=new Array()
menu2[0]='<div class="dropdown"><a href="http://www.alumni.ubc.ca/trekmagazine/index.php" class="dropdown">Trek Magazine</a></div>'
menu2[1]='<div class="dropdown"><a href="http://www.alumni.ubc.ca/grad_gazette/index.php" class="dropdown">Grad Gazette Newsletter</a></div>'
menu2[2]='<div class="dropdown"><a href="http://www.alumni.ubc.ca/publications/ubc.php" class="dropdown">University-wide Publications</a></div>'

// contents for menu 3
var menu3=new Array()
menu3[0]='<div class="dropdown"><a href="http://www.alumni.ubc.ca/events/calendar/index.php" class="dropdown">Calendar of Events</a></div>'
// menu3[1]='<div class="dropdown"><a href="http://www.alumni.ubc.ca/100/index.php" class="dropdown">UBC Centenary</a></div>'
menu3[1]='<div class="dropdown"><a href="http://www.alumni.ubc.ca/events/reunions/index.php" class="dropdown">Class Reunions</a></div>'
menu3[2]='<div class="dropdown"><a href="http://www.alumni.ubc.ca/events/alumniweekend/index.php" class="dropdown">Alumni Weekend</a></div>'
menu3[3]='<div class="dropdown"><a href="http://www.alumni.ubc.ca/events/awards/index.php" class="dropdown">Alumni Achievement Awards</a></div>'
menu3[4]='<div class="dropdown"><a href="http://www.alumni.ubc.ca/events/ubcbound/index.php" class="dropdown">UBC Bound!</a></div>'
menu3[5]='<div class="dropdown"><a href="http://www.alumni.ubc.ca/events/dialogues/index.php" class="dropdown">UBC Dialogues</a></div>'
menu3[6]='<div class="dropdown"><a href="http://www.alumni.ubc.ca/events/nextstep/index.php" class="dropdown">The Next Step</a></div>'
menu3[7]='<div class="dropdown"><a href="http://www.alumni.ubc.ca/events/graduation/index.php" class="dropdown">Graduation</a></div>'
menu3[8]='<div class="dropdown"><a href="http://www.alumni.ubc.ca/events/homecoming/index.php" class="dropdown">Homecoming</a></div>'
menu3[9]='<div class="dropdown"><a href="http://www.alumni.ubc.ca/events/sponsorship/index.php" class="dropdown">Sponsorship Opportunities</a></div>'
menu3[10]='<div class="dropdown"><a href="http://www.alumni.ubc.ca/wp/wp-content/plugins/falbum/wp/album.php" class="dropdown">Photo Gallery</a></div>'
menu3[11]='<div class="dropdown"><a href="http://www.alumni.ubc.ca/events/videos/thisweekatubc/index.php" class="dropdown">This Week at UBC: Video</a></div>'

// contents for menu 4
var menu4=new Array()
menu4[0]='<div class="dropdown"><a href="http://www.alumni.ubc.ca/rewards/index.php" class="dropdown">Alumni Rewards</a></div>'
menu4[1]='<div class="dropdown"><a href="http://www.alumni.ubc.ca/rewards/acard.php" class="dropdown">Alumni ACard</a></div>'
menu4[2]='<div class="dropdown"><a href="http://www.alumni.ubc.ca/rewards/career.php" class="dropdown">Career Resources</a></div>'
menu4[3]='<div class="dropdown"><a href="http://www.alumni.ubc.ca/rewards/travel.php" class="dropdown">Travel Program</a></div>'
menu4[4]='<div class="dropdown"><a href="http://www.alumni.ubc.ca/rewards/life.php" class="dropdown">Life Insurance</a></div>'
menu4[5]='<div class="dropdown"><a href="http://www.alumni.ubc.ca/rewards/homeauto.php" class="dropdown">Home &amp; Auto Insurance</a></div>'
menu4[6]='<div class="dropdown"><a href="http://www.alumni.ubc.ca/rewards/mastercard.php" class="dropdown">MasterCard</a></div>'
menu4[7]='<div class="dropdown"><a href="http://www.alumni.ubc.ca/rewards/wealthmanagement.php" class="dropdown">Wealth Management</a></div>'
menu4[8]='<div class="dropdown"><a href="http://www.alumni.ubc.ca/rewards/frames.php" class="dropdown">Degree Frames</a></div>'
menu4[9]='<div class="dropdown"><a href="http://www.alumni.ubc.ca/rewards/milestones.php" class="dropdown">Celebrating Your Milestones</a></div>'
menu4[10]='<div class="dropdown"><a href="http://www.alumni.ubc.ca/rewards/wine.php" class="dropdown">Alumni Wine Program</a></div>'


// contents for menu 5
var menu5=new Array()
//menu5[0]='<div class="dropdown"><a href="http://www.alumni.ubc.ca/about/message.php" class="dropdown">Executive Director&#146;s Message</a></div>'
menu5[1]='<div class="dropdown"><a href="http://www.alumni.ubc.ca/about/mission.php" class="dropdown">Mission &amp; Vision</a></div>'
menu5[2]='<div class="dropdown"><a href="http://www.alumni.ubc.ca/about/board.php" class="dropdown">Board of Directors</a></div>'
menu5[3]='<div class="dropdown"><a href="http://www.alumni.ubc.ca/about/advocacy/" class="dropdown">Advocacy</a></div>'
menu5[4]='<div class="dropdown"><a href="http://www.alumni.ubc.ca/about/annualreport.php" class="dropdown">Annual Report</a></div>'
menu5[5]='<div class="dropdown"><a href="http://www.alumni.ubc.ca/about/fiftyyears.php" class="dropdown">The First Fifty Years</a></div>'
menu5[6]='<div class="dropdown"><a href="http://www.alumni.ubc.ca/about/bpr/" class="dropdown">Business Process Reengineering</a></div>'
menu5[7]='<div class="dropdown"><a href="http://www.alumni.ubc.ca/about/faq.php" class="dropdown">Frequently Asked Questions</a></div>'
menu5[8]='<div class="dropdown"><a href="http://www.alumni.ubc.ca/alumnicentre/index.php" class="dropdown">Alumni Centre</a></div>'

// contents for menu 6
var menu6=new Array()
menu6[0]='<div class="dropdown"><a href="http://www.alumni.ubc.ca/contact/index.php" class="dropdown">Contact Information</a></div>'
menu6[1]='<div class="dropdown"><a href="http://www.alumni.ubc.ca/contact/staff.php" class="dropdown">Staff Listings</a></div>'
menu6[2]='<div class="dropdown"><a href="http://www.alumni.ubc.ca/contact/cecil.php" class="dropdown">Cecil Green Park House</a></div>'
menu6[3]='<div class="dropdown"><a href="http://www.alumni.ubc.ca/contact/welcomecentre.php" class="dropdown">UBC Welcome Centre</a></div>'
menu6[4]='<div class="dropdown"><a href="http://www.alumni.ubc.ca/contact/address.php" class="dropdown">Update Your Address</a></div>'

// global menu settings
var menuwidth='160px' //default menu width
var menubgcolor='#D0CCBD'  //menu bgcolor
var disappeardelay=100  //menu disappear speed onMouseout (in miliseconds)
var hidemenu_onclick="yes" //hide menu when user clicks within menu?

/////No further editing needed

var ie4=document.all
var ns6=document.getElementById&&!document.all

if (ie4||ns6)
document.write('<div id="dropmenudiv" style="visibility:hidden;width:'+menuwidth+';background-color:'+menubgcolor+'" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>')

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}


function showhide(obj, e, visible, hidden, menuwidth){
if (ie4||ns6)
dropmenuobj.style.left=dropmenuobj.style.top=-500
if (menuwidth!=""){
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=menuwidth
}
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
obj.visibility=visible
else if (e.type=="click")
obj.visibility=hidden
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=0
if (whichedge=="rightedge"){
var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
}
return edgeoffset
}

function populatemenu(what){
if (ie4||ns6)
dropmenuobj.innerHTML=what.join("")
}


function dropdownmenu(obj, e, menucontents, menuwidth){
if (window.event) event.cancelBubble=true
else if (e.stopPropagation) e.stopPropagation()
clearhidemenu()
dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv
populatemenu(menucontents)

if (ie4||ns6){
showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth)
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
}

return clickreturnvalue()
}

function clickreturnvalue(){
if (ie4||ns6) return false
else return true
}

function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function dynamichide(e){
if (ie4&&!dropmenuobj.contains(e.toElement))
delayhidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhidemenu()
}

function hidemenu(e){
if (typeof dropmenuobj!="undefined"){
if (ie4||ns6)
dropmenuobj.style.visibility="hidden"
}
}

function delayhidemenu(){
if (ie4||ns6)
delayhide=setTimeout("hidemenu()",disappeardelay)
}

function clearhidemenu(){
if (typeof delayhide!="undefined")
clearTimeout(delayhide)
}

if (hidemenu_onclick=="yes")
document.onclick=hidemenu


/***********************************************
* Ajax Ticker script (txt file source)- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/

// -------------------------------------------------------------------
// Ajax XML Ticker (txt file source)
// Author: Dynamic Drive (http://www.dynamicdrive.com)
// -------------------------------------------------------------------

////////////No need to edit beyond here//////////////

function createAjaxObj(){
var httprequest=false
if (window.XMLHttpRequest){ // if Mozilla, Safari etc
httprequest=new XMLHttpRequest()
if (httprequest.overrideMimeType)
httprequest.overrideMimeType('text/xml')
}
else if (window.ActiveXObject){ // if IE
try {
httprequest=new ActiveXObject("Msxml2.XMLHTTP");
} 
catch (e){
try{
httprequest=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e){}
}
}
return httprequest
}

// -------------------------------------------------------------------
// Main Ajax Ticker Object function
// ajax_ticker(xmlfile, divId, divClass, delay, optionalfadeornot)
// -------------------------------------------------------------------

function ajax_ticker(xmlfile, divId, divClass, delay, fadeornot){
this.xmlfile=xmlfile //Variable pointing to the local ticker xml file (txt)
this.tickerid=divId //ID of ticker div to display information
this.delay=delay //Delay between msg change, in miliseconds.
this.mouseoverBol=0 //Boolean to indicate whether mouse is currently over ticker (and pause it if it is)
this.pointer=0
this.opacitystring=(typeof fadeornot!="undefined")? "width: 100%; filter:progid:DXImageTransform.Microsoft.alpha(opacity=100); -moz-opacity: 1" : ""
if (this.opacitystring!="") this.delay+=500 //add 1/2 sec to account for fade effect, if enabled
this.opacitysetting=0.2 //Opacity value when reset. Internal use.
this.messages=[] //Arrays to hold each message of ticker
this.ajaxobj=createAjaxObj()
document.write('<div id="'+divId+'" class="'+divClass+'"><div style="'+this.opacitystring+'">Loading slideshow...</div></div>')
this.getXMLfile()
}

// -------------------------------------------------------------------
// getXMLfile()- Use Ajax to fetch xml file (txt)
// -------------------------------------------------------------------

ajax_ticker.prototype.getXMLfile=function(){
if (this.ajaxobj){
var instanceOfTicker=this
var url=this.xmlfile+"?bustcache="+new Date().getTime()
this.ajaxobj.onreadystatechange=function(){instanceOfTicker.initialize()}
this.ajaxobj.open('GET', url, true)
this.ajaxobj.send(null)
}
}

// -------------------------------------------------------------------
// initialize()- Initialize ticker method.
// -Gets contents of xml file and parse it using JavaScript DOM methods 
// -------------------------------------------------------------------

ajax_ticker.prototype.initialize=function(){ 
if (this.ajaxobj.readyState == 4){ //if request of file completed
if (this.ajaxobj.status==200 || window.location.href.indexOf("http")==-1){ //if request was successful
this.contentdiv=document.getElementById(this.tickerid).firstChild //div of inner content that holds the messages
var xmldata=this.ajaxobj.responseText
this.contentdiv.style.display="none"
this.contentdiv.innerHTML=xmldata
if (this.contentdiv.getElementsByTagName("div").length==0){ //if no messages were found
this.contentdiv.innerHTML="<b>Error</b> fetching remote ticker file!"
return
}
var instanceOfTicker=this
document.getElementById(this.tickerid).onmouseover=function(){instanceOfTicker.mouseoverBol=1}
document.getElementById(this.tickerid).onmouseout=function(){instanceOfTicker.mouseoverBol=0}
if (window.attachEvent) //Clean up loose references in IE
window.attachEvent("onunload", function(){instanceOfTicker.contentdiv=instanceOfTicker.ajaxobj=null})
//Cycle through XML object and store each message inside array
for (var i=0; i<this.contentdiv.getElementsByTagName("div").length; i++){
if (this.contentdiv.getElementsByTagName("div")[i].className=="message")
this.messages[this.messages.length]=this.contentdiv.getElementsByTagName("div")[i].innerHTML
}
this.contentdiv.innerHTML=""
this.contentdiv.style.display="block"
this.rotatemsg()
}
}
}

// -------------------------------------------------------------------
// rotatemsg()- Rotate through ticker messages and displays them
// -------------------------------------------------------------------

ajax_ticker.prototype.rotatemsg=function(){
var instanceOfTicker=this
if (this.mouseoverBol==1) //if mouse is currently over ticker, do nothing (pause it)
setTimeout(function(){instanceOfTicker.rotatemsg()}, 100)
else{ //else, construct item, show and rotate it!
this.fadetransition("reset") //FADE EFFECT- RESET OPACITY
this.contentdiv.innerHTML=this.messages[this.pointer]
this.fadetimer1=setInterval(function(){instanceOfTicker.fadetransition('up', 'fadetimer1')}, 100) //FADE EFFECT- PLAY IT
this.pointer=(this.pointer<this.messages.length-1)? this.pointer+1 : 0
setTimeout(function(){instanceOfTicker.rotatemsg()}, this.delay) //update container periodically
}
}

// -------------------------------------------------------------------
// fadetransition()- cross browser fade method for IE5.5+ and Mozilla/Firefox
// -------------------------------------------------------------------

ajax_ticker.prototype.fadetransition=function(fadetype, timerid){
var contentdiv=this.contentdiv
if (fadetype=="reset")
this.opacitysetting=0.2
if (contentdiv.filters && contentdiv.filters[0]){
if (typeof contentdiv.filters[0].opacity=="number") //IE6+
contentdiv.filters[0].opacity=this.opacitysetting*100
else //IE 5.5
contentdiv.style.filter="alpha(opacity="+this.opacitysetting*100+")"
}
else if (typeof contentdiv.style.MozOpacity!="undefined" && this.opacitystring!=""){
contentdiv.style.MozOpacity=this.opacitysetting
}
else
this.opacitysetting=1
if (fadetype=="up")
this.opacitysetting+=0.1
if (fadetype=="up" && this.opacitysetting>=1)
clearInterval(this[timerid])
}
