//Pop-it submenu- By Dynamic Drive
//For full source code and more DHTML scripts, visit http://www.dynamicdrive.com
//This credit MUST stay intact for use

//var ie4=document.all&&window.navigator.userAgent.indexOf("Opera")==-1
var ie4=document.all
var ns6=document.getElementById&&!document.all
var ns4=document.layers

function showsubmenu(e,which){

if (!document.all&&!document.getElementById&&!document.layers)
return

clearhidesubmenu()

submenuobj=ie4? document.all.popsubmenu : ns6? document.getElementById("popsubmenu") : ns4? document.popsubmenu : ""
submenuobj.thestyle=(ie4||ns6)? submenuobj.style : submenuobj

if (ie4||ns6) {
	submenuobj.innerHTML=sublinkset[which];
} else {
	submenuobj.document.write('<layer name="subgui" style="position: absolute;" onmouseover="clearhidesubmenu()" onmouseout="hidesubmenu()">'+sublinkset[which]+'</layer>')
	submenuobj.document.close()
}

linkobj = document.getElementById('submenu_' + which)
linkobj.contentleft=(ie4||ns6)? linkobj.offsetLeft : submenuobj.document.subgui.document.left
linkobj.contenttop=(ie4||ns6)? linkobj.offsetTop : submenuobj.document.subgui.document.top
linkobj.contentwidth=(ie4||ns6)? linkobj.offsetWidth : submenuobj.document.subgui.document.width
submenuobj.contentwidth=(ie4||ns6)? submenuobj.offsetWidth : submenuobj.document.subgui.document.width
submenuobj.contentheight=(ie4||ns6)? submenuobj.offsetHeight : submenuobj.document.subgui.document.height
eventX=ie4? event.clientX : ns6? e.clientX : e.x
eventY=ie4? event.clientY : ns6? e.clientY : e.y

//Find out how close the mouse is to the corner of the window
var rightedge=ie4? document.body.clientWidth-eventX : window.innerWidth-eventX
var bottomedge=ie4? document.body.clientHeight-eventY : window.innerHeight-eventY
submenuobj.thestyle.left = findPos(linkobj)[0] - document.getElementById('main').offsetLeft + linkobj.contentwidth - 15 + 'px';
submenuobj.thestyle.top = linkobj.contenttop + 140 + 'px';
//if the horizontal distance isn't enough to accomodate the width of the context submenu
/* if (rightedge<submenuobj.contentwidth)
//move the horizontal position of the submenu to the left by it's width
submenuobj.thestyle.left=ie4? document.body.scrollLeft+eventX-submenuobj.contentwidth : ns6? window.pageXOffset+eventX-submenuobj.contentwidth : eventX-submenuobj.contentwidth
else
//position the horizontal position of the submenu where the mouse was clicked
submenuobj.thestyle.left=ie4? document.body.scrollLeft+eventX : ns6? window.pageXOffset+eventX : eventX */
//submenuobj.thestyle.left=142

/* //same concept with the vertical position
if (bottomedge<submenuobj.contentheight)
submenuobj.thestyle.top=ie4? document.body.scrollTop+eventY-submenuobj.contentheight : ns6? window.pageYOffset+eventY-submenuobj.contentheight : eventY-submenuobj.contentheight
else
submenuobj.thestyle.top=ie4? document.body.scrollTop+event.clientY : ns6? window.pageYOffset+eventY : eventY */
submenuobj.thestyle.display="block"
return false
}


function hidesubmenu(){
if (window.submenuobj)
	submenuobj.thestyle.display="none";
}

function dynamichidesub(e){
if (ie4&&!submenuobj.contains(e.toElement))
hidesubmenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
hidesubmenu()
}

function delayhidesubmenu(){
if (ie4||ns6||ns4)
delayhidesub=setTimeout("hidesubmenu()",300)
}

function clearhidesubmenu(){
if (window.delayhidesub)
clearTimeout(delayhidesub)
}

function highlightsubmenu(e,state){
if (document.all)
source_el=event.srcElement
else if (document.getElementById)
source_el=e.target
else{
while(source_el.id!="popsubmenu"){
source_el=document.getElementById? source_el.parentNode : source_el.parentElement
}
}
}

if (ie4||ns6)
document.onclick=hidesubmenu