﻿/***********************************************
* Pop-it menu- � Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
var defaultMenuWidth="160px" //set default menu width.
 
var linkset=new Array()
//SPECIFY MENU SETS AND THEIR LINKS. FOLLOW SYNTAX LAID OUT
var mymenu=''
 
 
function coaches(e, which, optWidth){
 
 defaultMenuWidth = "200px"
 mymenu = '' 
 // mymenu='<a href="/usweb/Mat.asp?EsameID=UUUU&context=">Materiali per \'UUUU\'</a>'
 
 
 mymenu = JQ.ajax({ type: "GET", url: "/usweb/forum/CoachesForum.asp?forum=" + which, async: false }).responseText;
 
 //alert(mymenu); 
 
 showmenu(e, which, which, optWidth, 1, '');
}
function lm(e, which, optWidth){
 
 defaultMenuWidth = "150px"
 mymenu = ''
 // mymenu='<a href="/usweb/Mat.asp?EsameID=UUUU&context=">Materiali per \'UUUU\'</a>'
 mymenu = "<center><img src='/Disegni/loadingPiccola.gif' border='0'></center>"; 
 showmenu(e, which, which, optWidth, 1, 'leftmenu');
 
 //alert ("/usweb/utenza/MenuSx.asp?m=" + which + 'l='+ escape(location.href)) ; 
 
 mymenu = JQ.ajax({ type: "GET", url: "/usweb/utenza/MenuSx.asp?m=" + which + '&l='+ location.href, async: false }).responseText;
 
 // alert(mymenu);
 
 showmenu(e, which, which, optWidth, 1, 'leftmenu');
}
function showmenuEsame(e, which, optWidth) {
 
 defaultMenuWidth = "300px";
 mymenu = '';
 
 // mymenu='<a href="/usweb/Mat.asp?EsameID=UUUU&context=">Materiali per \'UUUU\'</a>'
 mymenu += '<a href="/usweb/Exams/UniversityExamsDetail.asp?exam=UUUU&context=" target="_top">UUUU</a>'
 mymenu += '<a href="/usweb/Appunti/Ricerca.asp?Materia=UUUU&context=" target="_top">Notes for UUUU</a>'
 mymenu += '<a href="/usweb/Suggerimenti/Elenco.asp?Materia=UUUU&context=" target="_top">Suggerimenti per UUUU</a>'
 mymenu += '<a href="/usweb/Domande/Elenco.asp?Materia=UUUU&context=" target="_top">Oral questions for UUUU</a>'
 mymenu += '<a href="/usweb/Forum/Welcome.asp?Link=WelcomePrev.asp&TipoForum=Materie#Materie" target="_top">Forum</a>'
 mymenu += '<a href="/usweb/Professori/Elenco.asp?Materia=UUUU&context=" target="_top">Professors</a>'
 
 showmenu(e, which, which, optWidth, 1);
}
////No need to edit beyond here
var ie5=document.all && !window.opera
var ns6=document.getElementById
if (ie5||ns6)
document.write('<div id="popitmenu" onMouseover="clearhidemenu();" onMouseout="dynamichide(event)"></div>')
function iecompattest(){
return (document.compatMode && document.compatMode.indexOf("CSS")!=-1)? document.documentElement : document.body
}
//function showmenu(e, which, optWidth, other){
function showmenu(e, which, whichEncode, optWidth, other, leftmenu){
 if (other != 1 ) {
 mymenu='<a href="/usweb/Forum/MostraProfilo.asp?Pseudonimo=EEEE&leftmenu=" target="_top">Show profile for UUUU </a>'
 mymenu+='<a href="/usweb/Comunicazioni/ContattaDettaglio.asp?Pseudonimo=EEEE&leftmenu=yes" target="_top">Contact UUUU</a>'
 mymenu+='<a href="/usweb/Utenza/GruppiUpdate.asp?Pseudonimo=EEEE&leftmenu=yes" target="_top">Add to my Groups</a>'
 mymenu+='<a href="/usweb/Forum/MostraProfilo.asp?Pseudonimo=EEEE&leftmenu=&TABforum=yes" target="_top">Forum post for UUUU</a>'
 mymenu+='<a href="/usweb/Forum/MostraProfilo.asp?Pseudonimo=EEEE&leftmenu=&TABcontributions=yes" target="_top">Materiali Inviati</a>'
 mymenu+='<hr>' 
 mymenu+='<a href="/usweb/GalleriaFoto/AutoreWelcome.asp?Pseudonimo=EEEE&leftmenu=" target="_top">His photos</a>'
 mymenu+='<a href="/usweb/GalleriaFoto/AlbumWelcome.asp?Pseudonimo=EEEE&leftmenu=" target="_top">His Albums</a>'
 mymenu+='<a href="/usweb/GalleriaFoto/SlideShow/SlideShow.asp?Pseudonimo=EEEE&leftmenu=" target="_top">Slideshow</a>' 
 } 
 //defaultMenuWidth = "200px"
 if (!document.all&&!document.getElementById)
 return
 
 clearhidemenu()
 menuobj=ie5 ? document.all.popitmenu : document.getElementById("popitmenu")
 
 //whichEscape = escape(which)
 if (whichEncode==null) {
 whichEncode=which;
 }
 
 menuobj.innerHTML=mymenu.replace(/EEEE/g, whichEncode).replace(/UUUU/g, which)
 
 // alert(menuobj.innerHTML + 'ciao');
 
 //alert(menuobj.innerHTML);
 //menuobj.innerHTML=mymenu.replace(/UUUU/g, which)
 
 
 menuobj.style.width=(typeof optWidth!="undefined")? optWidth : defaultMenuWidth
 menuobj.contentwidth=menuobj.offsetWidth
 menuobj.contentheight=menuobj.offsetHeight
 
 eventX=ie5? event.clientX : e.clientX
 eventY=ie5? event.clientY : e.clientY
 
 //Find out how close the mouse is to the corner of the window
 var rightedge = ie5 ? iecompattest().clientWidth-eventX : window.innerWidth-eventX
 var bottomedge = ie5 ? iecompattest().clientHeight-eventY : window.innerHeight-eventY
 //if the horizontal distance isn't enough to accomodate the width of the context menu
 
 
 if (rightedge<menuobj.contentwidth)
 //move the horizontal position of the menu to the left by it's width
 menuobj.style.left=ie5? iecompattest().scrollLeft+eventX-menuobj.contentwidth+"px" : window.pageXOffset+eventX-menuobj.contentwidth+"px"
 else
 //position the horizontal position of the menu where the mouse was clicked
 menuobj.style.left=ie5? iecompattest().scrollLeft+eventX+"px" : window.pageXOffset+eventX+"px"
 
 
 if (window.event) { 
 target = window.event.srcElement; 
 } else if (e) { 
 target = e.target; 
 } else { alert('errore event'); } 
 
 var nodeTop = target.offsetTop; 
 var nodeLeft = target.offsetLeft; 
 
 
 var targ;
 if (!e) var e = window.event;
 if (e.target) targ = e.target;
 else if (e.srcElement) targ = e.srcElement;
 if (targ.nodeType == 3) // defeat Safari bug
 targ = targ.parentNode; 
 //--------
 // alert(targ.top ); //e.fromElement.top);
 
 //alert ((findPosition( targ ))[1]) ;
 nodeTop = (findPosition( targ ))[1];
 nodeLeft = (findPosition( targ ))[0];
 
 /* var offset = JQ(this).offset();
 
 //JQ(this).offset();
 var nodeTop = offset.top;
 var nodeLeft = offset.left; 
 */
 //nodeTop = target.offsetTop + target.parentNode.offsetTop ;
 
 
 if (leftmenu == 'leftmenu') {
 menuobj.style.left = "303px";
 
 nodeLeft = nodeLeft + 160;
 
 if (rightedge<menuobj.contentwidth)
 //move the horizontal position of the menu to the left by it's width
 menuobj.style.left=ie5? iecompattest().scrollLeft+nodeLeft-menuobj.contentwidth+"px" : window.pageXOffset+nodeLeft-menuobj.contentwidth+"px"
 else
 //position the horizontal position of the menu where the mouse was clicked
 menuobj.style.left=ie5? iecompattest().scrollLeft+nodeLeft+"px" : window.pageXOffset+nodeLeft+"px"
 
 //menuobj.style.left= menuobj.style.left+170; 
 } 
 
 //---------
 
 
 // alert('a:' + nodeTop + '-' + nodeLeft); 
 
 //same concept with the vertical position
 if (bottomedge<menuobj.contentheight)
 menuobj.style.top=ie5? iecompattest().scrollTop+eventY-menuobj.contentheight+"px" : window.pageYOffset+eventY-menuobj.contentheight+"px"
 else
 menuobj.style.top=ie5? iecompattest().scrollTop+event.clientY+"px" : window.pageYOffset+eventY+"px"
 
 if (leftmenu == 'leftmenu') {
 menuobj.style.top=nodeTop + "px";
 } 
 
 menuobj.style.visibility="visible"
 
 return false
}
//-------------
function findPosition( oElement ) {
 if( typeof( oElement.offsetParent ) != 'undefined' ) {
 for( var posX = 0, posY = 0; oElement; oElement = oElement.offsetParent ) {
 posX += oElement.offsetLeft;
 posY += oElement.offsetTop;
 }
 return [ posX, posY ];
 } else {
 return [ oElement.x, oElement.y ];
 }
}
//-----------
function contains_ns6(a, b) {
//Determines if 1 element in contained in another- by Brainjar.com
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}
function hidemenu(){
if (window.menuobj)
menuobj.style.visibility="hidden"
}
function dynamichide(e){
if (ie5&&!menuobj.contains(e.toElement))
hidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
hidemenu()
}
function delayhidemenu(){
delayhide=setTimeout("hidemenu()",100)
}
function clearhidemenu(){
if (window.delayhide)
clearTimeout(delayhide)
}
if (ie5||ns6)
document.onclick=hidemenu
