var in_search_form=Array(false,false),menu_pinned=false,menu_path='/images/menu/',timer=null
function getById(id) {return document.getElementById(id)}
function show_search_form(e)
{var obj=e.toElement?e.toElement:this
 if(getById("sform")){obj.style.display='none';getById("sform").style.display="inline"}
}
function hide_search_form(h)
{
if(!in_search_form[0]&&!in_search_form[1]){getById('sform').style.display='none';getById('menusearch').style.display='inline'}
}
function showmenu(id)
{
var wth=187,div=document.createElement('div')
div.id='MenuDiv'
div.style.cssText='width:'+wth+'px;position:absolute;top:50px;left:0px;font-weight:bold;font-family:sans-serif,Arial;line-height:1px;font-size:79%;text-align:right'
div.align='right'
out='<div style="background-image: url(\''+menu_path+'PD.gif\');width:'+wth+'px;height:24px; margin-bottom: -1px">\
<a href="#" onclick="draw_pinned_status(true);return false" style="vertical-align:middle;position:absolute;top:5;left:2px" id="menu_pin"></a>\
<span style="position:absolute; z-index:15; right: -14px; top: -45px">\
<a href="http://www.qc.cuny.edu" title="QC Web Site" target=_blank><img border=0 src="'+menu_path+'qlogo.gif" /></a></span>\
</div>'
out+='<a href="/" id="menuhome">Home</a>&nbsp;<img src="/images/menu/right.gif">\
<br><a href="/welcome.htm" id="menuwelcome">Welcome</a>&nbsp;<img src="/images/menu/right.gif">\
<br><a href="/information.php" clickable id="menuinfo">Information</a> / <a href="/news/" clickable id="menunews">News</a>&nbsp;<img src="/images/menu/right.gif">\
<br><a href="/prereg/" id="menuwaitl">Waiting List</a>&nbsp;<img src="/images/menu/fright.gif">\
<br><a href="/faculty.htm" clickable id="menufaculty">Faculty & Staff</a>&nbsp;<img src="/images/menu/right.gif">\
<br><a href="/class_schedule.php" id="menuclassschedule">Class Schedule</a>&nbsp;<img src="/images/menu/right.gif">\
<br><a href="/research.htm" id="menuresearch">Research</a>&nbsp;<img src="/images/menu/right.gif">\
<br><a href="/alumni.htm" id="menualumni">Alumni</a>&nbsp;<img src="/images/menu/right.gif">\
<br><a href="/graduateprogram.htm" id="menugradprog">Graduate Program</a>&nbsp;<img src="/images/menu/right.gif">\
<br><a href="/undergraduateprogram.htm" id="menuunderprog">Undergraduate Program</a>&nbsp;<img src="/images/menu/right.gif">\
<br><a href="/graduatestudents.htm" id="menugradstud">Graduate Students</a>&nbsp;<img src="/images/menu/right.gif">\
<br><a href="/colloq.php#next" id="menucolloq">Colloquium Schedule</a>&nbsp;<img src="/images/menu/right.gif">\
<br><img src="/images/menu/divider.gif">\
<br><a href="/gallery/" id="menuphoto">Photo Gallery</a>&nbsp;<img src="/images/menu/right.gif">\
<br><a href="/map.htm" clickable id="menumap">Campus Map</a>&nbsp;<img src="/images/menu/right.gif">\
<br><a href="/feedback_form.htm" id="menufeedback">Feedback</a>&nbsp;<img src="/images/menu/right.gif">\
<br><form id="sform" method=get action="/search/" style="margin:0px;padding:0px;display:none;height:17px;position:relative;top:3px" onmouseover="mover(0)" onmouseout="mout(0)"><input type=hidden name=search value=1><input type="text" name="query" style="width:120px;vertical-align:top;margin:0 0 0 0;border:0px;height:15px;font-size:10px;color:#777777;background-position:left top;background-image:url(\'/images/input-box-shadow.gif\')" onfocus="mover(1)" onblur="mout(1)"><img title="Search" src="/images/menu/loop.gif" onclick="if(this.previousSibling.value!=\'\')this.parentNode.submit();else window.location.href=\'/search/\'" style="cursor:pointer"></form>\
<a href="/search/" clickable id="menusearch">Search</a>&nbsp;<img src="/images/menu/right.gif">\
<br><img src="/images/menu/end.gif">\
<br>'
if (id=='welcome') 
out+='<a href="http://www.weatherforyou.com/cgi-bin/hw3/hw3.cgi?forecast=zandh&place=Flushing&state=ny&country=us&zipcode=11367" target=_blank><img src="http://www.weatherforyou.net/fcgi-bin/hw3/hw3.cgi?config=png&forecast=hourly&alt=hwihourly&place=Flushing&state=ny&zipcode=11367&icao=KLGA&country=us&hwvbg=transparent&hwvtc=green&metric=0&hwvdisplay=Queens+College" border="0" width="175" height="90"></a>&nbsp;'

div.innerHTML=out
document.write('<span id="attachmenu"></span>') //to fix stupid IE bug
getById('attachmenu').appendChild(div)
new FloatLayer("MenuDiv",0,45,5)
draw_pinned_status()
myEvent(getById('menusearch'),'mouseover',show_search_form,'+')  
update_selected_status(id) 
// Google statistics
document.write('<script src="http://www.google-analytics.com/urchin.js" type="text/javascript" onreadystatechange="run_google_analytics(this)" onload="run_google_analytics()"></script>')

}

function run_google_analytics(obj)
{
 _uacct = "UA-3595747-1" 
if(obj&&(obj.readyState=='complete'||obj.readyState=='loaded')) urchinTracker()
 else if(!obj)urchinTracker() 
}
function mover(ind)
{in_search_form[ind]=true;timer=null}
function mout(ind)
{in_search_form[ind]=false;timer=setTimeout('hide_search_form()',1000)}

function update_selected_status(id)
{var obj=getById('menu'+id)
 if(!obj) {id='info';obj=getById('menu'+id)}
 if(obj.getAttribute('clickable')=='') 
  {obj.style.color='#000000';obj.title='Return to this page'}
  else
  {
   var sp=document.createElement('span')
   sp.title='You are here'
   sp.innerHTML=obj.innerHTML
   obj.parentNode.replaceChild(sp,obj)
  }
 if(id=='search') getById('MenuDiv').removeChild(getById('sform'))
}

function draw_pinned_status(change)
{
if(change){menu_pinned=!menu_pinned;Set_Cookie('menu_p',menu_pinned,100)}
 else menu_pinned=Get_Cookie('menu_p')?str2bool(Get_Cookie('menu_p')):false
var obj=getById('menu_pin')
obj.innerHTML='<img border=0 src="'+menu_path+'pin'+(menu_pinned?"on":"off")+'.gif">'
obj.title=(menu_pinned?"un":"")+"Fix menu position"
myEvent(window,'resize',alignFloatLayers,menu_pinned?'':'+')
myEvent(window,'scroll',alignFloatLayers,menu_pinned?'':'+')
alignFloatLayers()
}
function str2bool(val)
{return val=='true'?true:false}

// Cookie functions
function Set_Cookie(name,value,expires,path,domain,secure) 
{var today=new Date()
today.setTime(today.getTime())
if (expires) expires=expires*1000*60*60*24
var expires_date=new Date(today.getTime()+(expires))
document.cookie=name+"="+escape(value)+
((expires)?";expires="+expires_date.toGMTString():"")+
((path)?";path="+path:"")+ 
((domain)?";domain="+domain:"")+
((secure)?";secure":"")
}
function Get_Cookie(name){
var start=document.cookie.indexOf(name+"=")
var len=start+name.length+1
if ((!start)&&(name!=document.cookie.substring(0,name.length))) return null
if (start==-1) return null
var end=document.cookie.indexOf(";",len)
if (end==-1) end=document.cookie.length
return unescape(document.cookie.substring(len,end))}

function myEvent(where,evt,func,op)
{if (op=="+")
  {if (where.attachEvent) where.attachEvent("on"+evt,func)
  else if (where.addEventListener) where.addEventListener(evt,func,false)}
  else {if (where.detachEvent) where.detachEvent("on"+evt,func)
  else if (where.removeEventListener) where.removeEventListener(evt,func,false)}
}

//floater
var FloatLayers       = new Array();
var FloatLayersByName = new Array();

function addFloatLayer(n,offX,offY,spd){new FloatLayer(n,offX,offY,spd);}
function getFloatLayer(n){return FloatLayersByName[n];}
function alignFloatLayers(){for(var i=0;i<FloatLayers.length;i++)FloatLayers[i].align();}

function getXCoord(el) {
    x=0;
    while(el){
        x+=el.offsetLeft;
        el=el.offsetParent;
    }
    return x;
}
function getYCoord(el) {
    y=0;
    while(el){
        y+=el.offsetTop;
        el=el.offsetParent;
    }
    return y;
}

FloatLayer.prototype.setFloatToTop=setTopFloater;
FloatLayer.prototype.setFloatToBottom=setBottomFloater;
FloatLayer.prototype.setFloatToLeft=setLeftFloater;
FloatLayer.prototype.setFloatToRight=setRightFloater;
FloatLayer.prototype.initialize=defineFloater;
FloatLayer.prototype.adjust=adjustFloater;
FloatLayer.prototype.align=alignFloater;

function FloatLayer(n, offX, offY, spd) {
    this.index=FloatLayers.length;

    FloatLayers.push(this);
    FloatLayersByName[n] = this;

    this.name    = n;
    this.floatX  = 0;
    this.floatY  = 0;
    this.tm      = null;
    this.steps   = spd;
    this.alignHorizontal=(offX>=0) ? leftFloater : rightFloater;
    this.alignVertical  =(offY>=0) ? topFloater : bottomFloater;
    this.ifloatX = Math.abs(offX);
    this.ifloatY = Math.abs(offY);
}


function defineFloater(){
    this.layer  = document.getElementById(this.name);
    this.width  = this.layer.offsetWidth;
    this.height = this.layer.offsetHeight;
    this.prevX  = this.layer.offsetLeft;
    this.prevY  = this.layer.offsetTop;
}

function adjustFloater() {
    this.tm=null;
    if(this.layer.style.position!='absolute')return;

    var dx = Math.abs(this.floatX-this.prevX);
    var dy = Math.abs(this.floatY-this.prevY);

    if (dx < this.steps/2)
        cx = (dx>=1) ? 1 : 0;
    else
        cx = Math.round(dx/this.steps);

    if (dy < this.steps/2)
        cy = (dy>=1) ? 1 : 0;
    else
        cy = Math.round(dy/this.steps);
    cx=0; //only vertical
    if (this.floatX > this.prevX)
        this.prevX += cx;
    else if (this.floatX < this.prevX)
        this.prevX -= cx;

    if (this.floatY > this.prevY)
        this.prevY += cy;
    else if (this.floatY < this.prevY)
        this.prevY -= cy;

    this.layer.style.left = this.prevX;
    this.layer.style.top  = this.prevY;

    
    if (cx!=0||cy!=0){
        if(this.tm==null)this.tm=setTimeout('FloatLayers['+this.index+'].adjust()',25)
    }else
        alignFloatLayers()
}

function setLeftFloater(){this.alignHorizontal=leftFloater;}
function setRightFloater(){this.alignHorizontal=rightFloater;}
function setTopFloater(){this.alignVertical=topFloater;}
function setBottomFloater(){this.alignVertical=bottomFloater;}

function leftFloater(){this.floatX = document.body.scrollLeft + this.ifloatX;}
function topFloater(){this.floatY = document.body.scrollTop + this.ifloatY;}
function rightFloater(){this.floatX = document.body.scrollLeft + document.body.clientWidth - this.ifloatX - this.width;}
function bottomFloater(){this.floatY = document.body.scrollTop + document.body.clientHeight - this.ifloatY - this.height;}

function alignFloater(){
    if(this.layer==null)this.initialize()
    this.alignHorizontal()
    this.alignVertical()
    if(this.prevX!=this.floatX || this.prevY!=this.floatY)
        if(this.tm==null)this.tm=setTimeout('FloatLayers['+this.index+'].adjust()',25)
}