/* Script for popup menu's Webplatform



	getStyle(name): routine to get the style object of an element with name 'name'

	showMenu(el): routine to show the submenu

	hideMenu(el): routine to hide the submenu again

	highlight(el): routine to highlight the submenu-item 'el' (ie switch styles)

	unhighlight(el): routine to turn the submenu-item 'el' back to normal (ie switch styles)



*/



function getStyle(name) {

  if (document.getElementById) return (document.getElementById(name)? document.getElementById(name).style : new Object()); // extra check to see if object really exists!

  else if (document.all) return (document.all[name]?document.all[name].style: new Object());  // extra check to see if object really exists!

  else return new Object(); // dummy

}




function getElement(name) {

  if (document.getElementById) return document.getElementById(name);

  else if (document.all) return document.all[name];

  else return new Object(); // dummy

}


function showMenu(el,firstEl,lastEl) {

	//if (getElement(firstEl).parentNode.offsetTop == getElement(lastEl).parentNode.offsetTop) {

		getStyle(el).visibility = 'visible';

		getStyle("selectedContainer").visibility = 'hidden';

	//}

}




function hideMenu(el) {

	getStyle(el).visibility = 'hidden';

	getStyle("selectedContainer").visibility = 'visible';

}





function highlight(el) {

	el.className = "submenuitemhighlight";

	return true;

}





function unhighlight(el) {

	el.className = "submenuitem";

	return true;

}





/* Not used */

function highlightSectionMenu(current, selected) {

  if (selected != 'si' && selected != current) {

    var SItem = getElement(selected);

    var CItem = getElement(current);

    SItem.className = "w3SBMItem";

    CItem.className = "w3SBMSelectedItem";

  }

  else if (selected == 'si') {

    var CItem = getElement(current);

    CItem.className = "w3SBMSelectedItem";

  }



  return true;

}



/* Not used */

function unhighlightSectionMenu(current, selected) {

  if (selected != 'si' && selected != current) {

    var SItem = getElement(selected);

    var CItem = getElement(current);

    SItem.className = "w3SBMSelectedItem";

    CItem.className = "w3SBMItem";    

  }

  else if (selected == 'si') {

    var CItem = getElement(current);

    CItem.className = "w3SBMItem";    

  }

    

  return true;

}





/* form disabler */



var dis_form = null;



function disableForm() {

  if (dis_form) {

    for (var i = 0; i < dis_form.elements.length; i++) {

        dis_form.elements[i].disabled='true';

    }

  }

}



function showBusy(form) {

  dis_form = form;

  setTimeout("disableForm();", 500); 

    if (document && document.body && document.body.style) {

        document.body.style.cursor = 'wait';

    }

} 



/* Xopus calls: */



function openXopus(url, mouse_event) {

	

  if (mouse_event.ctrlKey) {

   // ctrl-mouse click, open SpyX 

    document.location = "/_definition/shared/js/spyx.html#content=" + url; 

    mouse_event.cancelBubble = true;

  }

  else {

   var __xopus_frame = window;



   while (__xopus_frame && (__xopus_frame.name != 'xopus' || 

			    (!__xopus_frame.xopus_globs))) {

     if (__xopus_frame == top) {

       __xopus_frame = null;

       break;

     } else {

       __xopus_frame = __xopus_frame.parent;

     }

   }

   

   if (__xopus_frame && __xopus_frame.name == 'xopus' && 

       __xopus_frame.xopus_globs && __xopus_frame.xopus_globs.framework) {

     // already inside xopus: don't open frame

     document.location.href = url;

   }

   else {

     // open frame

     document.location.href = "/_definition/shared/xopus/xopus.html?rnd=1.0#content=" + url;

   }

  }

}



/* Notify the user when he has been diverted from www.rug.nl to the backup */



//if (document.referrer ) {

/*

var ref = '' + (document.referrer ? document.referrer : '');

var loc = '' + document.location;

if (loc.indexOf('http://backup.webplatform.rug.nl') == 0 &&

    (ref.indexOf('http://backup.webplatform.rug.nl') < 0)) {

  alert('U kijkt naar een backup van de RUG Website.\n\nDe actuele website is momenteel niet bereikbaar.');

}

*/

//}






