// popup windows functions - see Design guidelines on intranet



/* add Array.push if needed (for IE5.x) */

if (Array.prototype.push == null) {

	Array.prototype.push = function(item) {

		this[this.length] = item; return this.length;

	}

}



/* Add Event function taken from http://www.dustindiaz.com/rock-solid-addevent/ */



function addEvent( obj, type, fn ) {

	if (obj.addEventListener) {

		obj.addEventListener( type, fn, false );

		EventCache.add(obj, type, fn);

	}

	else if (obj.attachEvent) {

		obj["e"+type+fn] = fn;

		obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }

		obj.attachEvent( "on"+type, obj[type+fn] );

		EventCache.add(obj, type, fn);

	}

	else {

		obj["on"+type] = obj["e"+type+fn];

	}

}



/*	EventCache Version 1.0

	Copyright 2005 Mark Wubben

	Provides a way for automagically removing events from nodes and thus preventing memory leakage.

	See <http://novemberborn.net/javascript/event-cache> for more information.

	This software is licensed under the CC-GNU LGPL http://creativecommons.org/licenses/LGPL/2.1/ */

	

var EventCache = function(){

	var listEvents = [];

	return {

		listEvents : listEvents,

		add : function(node, sEventName, fHandler){

			listEvents.push(arguments);

		},

		flush : function(){

			var i, item;

			for(i = listEvents.length - 1; i >= 0; i = i - 1){

				item = listEvents[i];

				if(item[0].removeEventListener){

					item[0].removeEventListener(item[1], item[2], item[3]);

				};

				if(item[1].substring(0, 2) != "on"){

					item[1] = "on" + item[1];

				};

				if(item[0].detachEvent){

					item[0].detachEvent(item[1], item[2]);

				};

				item[0][item[1]] = null;

			};

		}

	};

}();



/* doTheLinks manages all links in document with specific class names */



function doTheLinks() {

	if (!document.getElementsByTagName) return false;

	var links = document.getElementsByTagName("a");

	for (var i=0; i < links.length; i++) {

		if (links[i].className && links[i].className.match("popUp")) {

			hideSpan = document.createElement('span');

			hideSpan.className = 'hiddenText';

			hideText = document.createTextNode(' - this link will open in a new window');

			hideSpan.appendChild(hideText);

			links[i].setAttribute("title", "This link will open in a new window");

			links[i].appendChild(hideSpan);

// IE 5 needs special treatment because it's a bit special

if(!links[i].ownerDocument) {

				blankImg = document.createElement('img');

				blankImg.src = '/images/blank.gif';

				blankImg.className = 'borderNone';

				links[i].appendChild(blankImg);

			}

		}

		if (links[i].className && links[i].className.match("externalLink")) {

			hideSpan = document.createElement('span');

			hideSpan.className = 'hiddenText';

			hideText = document.createTextNode(' link to external site, this link will open in a new window');

			hideSpan.appendChild(hideText);

			links[i].setAttribute("title", "Link to external site, this link will open in a new window");

			links[i].appendChild(hideSpan);

// IE 5 needs special treatment because it's a bit special

if(!links[i].ownerDocument) {

				blankImg = document.createElement('img');

				blankImg.src = '/images/blank.gif';

				blankImg.className = 'borderNone';

				links[i].appendChild(blankImg);

			}

		}

		// attributes if single page only e.g. Durable URL - named 'popUpSmall'

		// change PRODUCT for your product name and add attributes as required

		if (links[i].className && (' ' + links[i].className + ' ').indexOf(' popUpSingle ') != -1) {

			links[i].onclick = function() {

window.open(this.href,'PRODUCTPopUpSingle','width=480,height=360,resizable=1,toolbar=1,location=0,directories=0,addressbar=1,scrollbars=1,status=0,menubar=0');

				return false;

			}

		} 

		// attributes if medium popup - named 'popUpHelp'

// change PRODUCT for your product name and add attributes as required

		else if (links[i].className && (' ' + links[i].className + ' ').indexOf(' popUpHelp ') != -1) {

			links[i].onclick = function() {

window.open(this.href,'PRODUCTPopUpHelp','width=520,height=480,resizable=1,toolbar=1,location=1,directories=0,addressbar=1,scrollbars=1,status=0,menubar=0');

				return false;

			}

		} 

		// attributes if large popup - named 'popUpMulti' and 'externalLink'

		// change PRODUCT for your product name and add attributes as required

		else if (links[i].className && (' ' + links[i].className + ' ').indexOf(' popUpMulti ') != -1 || (' ' + links[i].className + ' ').indexOf(' externalLink ') != -1) {

			links[i].onclick = function() {

window.open(this.href,'','width=800,height=740,resizable=1,toolbar=1,location=1,directories=0,addressbar=1,scrollbars=1,status=0,menubar=0');

				return false;

			}

		}

	}

}



/* Focus any window as it loads */



function doFocus() {

	window.focus();

}



/* Calls for above functions */



addEvent(window,'load',doFocus);

addEvent(window,'load',doTheLinks);

addEvent(window,'unload',EventCache.flush);

 

//new durable url layer

/***********************************************

* Drop Down/ Overlapping Content- © Dynamic Drive (www.dynamicdrive.com)

* This notice must stay intact for legal use.

* Visit http://www.dynamicdrive.com/ for full source code

***********************************************/

function getposOffset(URLoverlay, offsettype){

var totaloffset=(offsettype=="left")? URLoverlay.offsetLeft : URLoverlay.offsetTop;

var parentEl=URLoverlay.offsetParent;

while (parentEl!=null){

totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;

parentEl=parentEl.offsetParent;

}

return totaloffset;

}



function URLoverlay(curobj, subobjstr, opt_position){

if (document.getElementById){

var subobj=document.getElementById(subobjstr)

subobj.style.display=(subobj.style.display!="block")? "block" : "none"

var xpos=getposOffset(curobj, "left")+((typeof opt_position!="undefined" && opt_position.indexOf("right")!=-1)? -(subobj.offsetWidth-curobj.offsetWidth): 0) 

var ypos=getposOffset(curobj, "top")+((typeof opt_position!="undefined" && opt_position.indexOf("bottom")!=-1)? curobj.offsetHeight : 0)

subobj.style.left=xpos+"px"

subobj.style.top=ypos+"px"

return false

}

else

return true

}



function URLoverlayclose(subobj){

document.getElementById(subobj).style.display="none"

}  