var cssdropdown={
disappeardelay: 300, //set delay in miliseconds before ul disappears onmouseout
disableulclick: false, //when user clicks on a ul item with a drop down ul, disable ul item's link?
enableswipe: 0, //enable swipe effect? 1 for yes, 0 for no
enableiframeshim: 1, //enable "iframe shim" technique to get drop down uls to correctly appear on top of controls such as form objects in IE5.5/IE6? 1 for yes, 0 for no

//No need to edit beyond here////////////////////////
dropulobj: null, ie: document.all, firefox: document.getElementById&&!document.all, swipetimer: undefined, bottomclip:0,

getposOffset:function(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;
},

swipeeffect:function(){
if (this.bottomclip<parseInt(this.dropulobj.offsetHeight)){
this.bottomclip+=10+(this.bottomclip/10) //unclip drop down ul visibility gradually
this.dropulobj.style.clip="rect(0 auto "+this.bottomclip+"px 0)"
}
else
return
this.swipetimer=setTimeout("cssdropdown.swipeeffect()", 17)
},

showhide:function(obj, e){
if (this.ie || this.firefox)
this.dropulobj.style.left=this.dropulobj.style.top="-500px"
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover"){
if (this.enableswipe==1){
if (typeof this.swipetimer!="undefined")
clearTimeout(this.swipetimer)
obj.clip="rect(0 auto 0 0)" //hide ul via clipping
this.bottomclip=0
this.swipeeffect()
}
obj.visibility="visible"
}
else if (e.type=="click")
obj.visibility="hidden"
},

iecompattest:function(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
},

clearbrowseredge:function(obj, whichedge){
var edgeoffset=0
if (whichedge=="rightedge"){
var windowedge=this.ie && !window.opera? this.iecompattest().scrollLeft+this.iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
this.dropulobj.contentmeasure=this.dropulobj.offsetWidth
if (windowedge-this.dropulobj.x < this.dropulobj.contentmeasure)  //move ul to the left?
edgeoffset=this.dropulobj.contentmeasure-obj.offsetWidth
}
else{
var topedge=this.ie && !window.opera? this.iecompattest().scrollTop : window.pageYOffset
var windowedge=this.ie && !window.opera? this.iecompattest().scrollTop+this.iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
this.dropulobj.contentmeasure=this.dropulobj.offsetHeight
if (windowedge-this.dropulobj.y < this.dropulobj.contentmeasure){ //move up?
edgeoffset=this.dropulobj.contentmeasure+obj.offsetHeight
if ((this.dropulobj.y-topedge)<this.dropulobj.contentmeasure) //up no good either?
edgeoffset=this.dropulobj.y+obj.offsetHeight-topedge
}
}
return edgeoffset
},

dropit:function(obj, e, dropulID){
if (this.dropulobj!=null) //hide previous ul
this.dropulobj.style.visibility="hidden" //hide ul
this.clearhideul()
if (this.ie||this.firefox){
obj.onmouseout=function(){cssdropdown.delayhideul()}
obj.onclick=function(){return !cssdropdown.disableulclick} //disable main ul item link onclick?
this.dropulobj=document.getElementById(dropulID)
this.dropulobj.onmouseover=function(){cssdropdown.clearhideul()}
this.dropulobj.onmouseout=function(e){cssdropdown.dynamichide(e)}
this.dropulobj.onclick=function(){cssdropdown.delayhideul()}
this.showhide(this.dropulobj.style, e)
this.dropulobj.x=this.getposOffset(obj, "left")
this.dropulobj.y=this.getposOffset(obj, "top")
this.dropulobj.style.left=this.dropulobj.x-this.clearbrowseredge(obj, "rightedge")+"px"
this.dropulobj.style.top=this.dropulobj.y-this.clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+1+"px"
this.positionshim() //call iframe shim function
}
},

positionshim:function(){ //display iframe shim function
if (this.enableiframeshim && typeof this.shimobject!="undefined"){
if (this.dropulobj.style.visibility=="visible"){
this.shimobject.style.width=this.dropulobj.offsetWidth+"px"
this.shimobject.style.height=this.dropulobj.offsetHeight+"px"
this.shimobject.style.left=this.dropulobj.style.left
this.shimobject.style.top=this.dropulobj.style.top
}
this.shimobject.style.display=(this.dropulobj.style.visibility=="visible")? "block" : "none"
}
},

hideshim:function(){
if (this.enableiframeshim && typeof this.shimobject!="undefined")
this.shimobject.style.display='none'
},

contains_firefox:function(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
},

dynamichide:function(e){
var evtobj=window.event? window.event : e
if (this.ie&&!this.dropulobj.contains(evtobj.toElement))
this.delayhideul()
else if (this.firefox&&e.currentTarget!= evtobj.relatedTarget&& !this.contains_firefox(evtobj.currentTarget, evtobj.relatedTarget))
this.delayhideul()
},

delayhideul:function(){
this.delayhide=setTimeout("cssdropdown.dropulobj.style.visibility='hidden'; cssdropdown.hideshim()",this.disappeardelay) //hide ul
},

clearhideul:function(){
if (this.delayhide!="undefined")
clearTimeout(this.delayhide)
},

startchrome:function(){
for (var ids=0; ids<arguments.length; ids++){
var ulitems=document.getElementById(arguments[ids]).getElementsByTagName("a")
for (var i=0; i<ulitems.length; i++){
if (ulitems[i].getAttribute("rel")){
var relvalue=ulitems[i].getAttribute("rel")
ulitems[i].onmouseover=function(e){
var event=typeof e!="undefined"? e : window.event
cssdropdown.dropit(this,event,this.getAttribute("rel"))
}
}
}
}
if (window.createPopup && !window.XmlHttpRequest){ //if IE5.5 to IE6, create iframe for iframe shim technique
document.write('<IFRAME id="iframeshim"  src="" style="display: none; left: 0; top: 0; z-index: 90; position: absolute; filter: progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)" frameBorder="0" scrolling="no"></IFRAME>')
this.shimobject=document.getElementById("iframeshim") //reference iframe object
}
}

}
