MDMG_menusection = new Array();

MDMG_MovabilityOfSubMenuPositions = "static";

MDMG_menusection[1] = "independant_living";
MDMG_menusection[2] = "community_services";
MDMG_menusection[3] = "residential_care";
MDMG_menusection[4] = "our_organisation";


MDMG_menusection[0] = "unused";
MDMG_menusectionprinted = new Array();
for(i = 0; i < MDMG_menusection.length; i++) { MDMG_menusectionprinted[i] = false; }
bNS4 = bNS6 = bIE = bOPERA = false;
if     (navigator.userAgent.indexOf("Opera") != -1) { bOPERA = true; }
else if(navigator.userAgent.indexOf("Gecko") != -1) { bNS6 = true;   }
else if(document.layers)                            { bNS4 = true;   }
else if(document.all)                               { bIE = true;    }

MDMGx = MDMGxx = MDMGy = MDMGyy = 0;
var MDMG_mousex;
var MDMG_mousey;
STO = null;
if(bNS4 || bNS6 || bOPERA) { document.captureEvents(Event.MOUSEMOVE); }
document.onmousemove = MDMG_getmouseposition;


// Functions used by all browsers

function MDMG_getmouseposition(e){
if(bIE || bOPERA) { 
	MDMG_mousex = event.clientX;
	MDMG_mousey = event.clientY;
	}
else if(bNS6 || bNS4) {
	MDMG_mousex = e.pageX;
	MDMG_mousey = e.pageY;
	}
} // MDMG_getmouseposition()

function MDMG_HideIfOutsideRectangle()
{
	if(MDMG_mouseinrectangle()) { STO = setTimeout('MDMG_HideIfOutsideRectangle()',500); }
	else { clearTimeout(STO); MDMG_hideallmenusections(); }
} // MDMG_HideIfOutsideRectangle()

function MDMG_mouseinrectangle() {
if(MDMG_mousex >= MDMGx && MDMG_mousex <= MDMGxx && MDMG_mousey >= MDMGy && MDMG_mousey <= MDMGyy) { return true; }
else { return false; }
} // MDMG_mouseinrectangle()



// Functions to relay browser type to custom functions

function MDMG_showsection(m_section) {
clearTimeout(STO);
if(bIE) {
	MDMG_bIE_hideallmenusections();
	MDMG_bIE_showit(m_section);
	}
else if(bNS6) {
	MDMG_bNS6_hideallmenusections();
	MDMG_bNS6_showit(m_section);
	}
else if(bOPERA) {
	MDMG_bOPERA_hideallmenusections();
	MDMG_bOPERA_showit(m_section);
	}
else if(bNS4) {
	MDMG_bNS4_hideallmenusections();
	MDMG_bNS4_showit(m_section);
	}
} // MDMG_showsection()

function MDMG_hideallmenusections() {
clearTimeout(STO);
if(bIE) { MDMG_bIE_hideallmenusections(); }
else if(bNS6) { MDMG_bNS6_hideallmenusections(); }
else if(bOPERA) { MDMG_bOPERA_hideallmenusections(); }
else if(bNS4) { MDMG_bNS4_hideallmenusections(); }
} // MDMG_hideallmenusections()



// IE functions

function MDMG_bIE_hidesection(m_section) {
if(MDMG_mouseinrectangle()) { return; }
eval(MDMG_menusection[m_section] + '.style.visibility="hidden"');
MDMG_menusectionprinted[m_section] = false;
} // MDMG_bIE_hidesection()

function MDMG_bIE_hideallmenusections() {
for(i = 1; i < MDMG_menusection.length; i++) { 
	eval(MDMG_menusection[i] + '.style.visibility="hidden"');
	MDMG_menusectionprinted[i] = false;
	}
} // MDMG_bIE_hideallmenusections()

function MDMG_bIE_showit(m_section) {
	if(MDMG_menusectionprinted[m_section] == true) { return; }
	clearTimeout(STO);
	MDMG_bIE_hideallmenusections();
	MDMG_menusectionprinted[m_section] = true;
	var x = MDMG_mousex - 1;
	if(x < 0) { x = 0; }
	var y = MDMG_mousey - 1;
	if(y < 0) { y = 0; }
	if(MDMG_MovabilityOfSubMenuPositions != "static") {
		eval(MDMG_menusection[m_section] + '.style.left="' + x + '"');
		eval(MDMG_menusection[m_section] + '.style.top="' + y + '"');
		}
	eval(MDMG_menusection[m_section] + '.style.visibility="visible"');
	MDMGx = eval(MDMG_menusection[m_section] + '.style.pixelLeft');
	MDMGxx = eval(MDMG_menusection[m_section] + '.scrollWidth') + MDMGx;
	MDMGy = eval(MDMG_menusection[m_section] + '.style.pixelTop');
	MDMGyy = eval(MDMG_menusection[m_section] + '.scrollHeight') + MDMGy;
	STO = setTimeout('MDMG_HideIfOutsideRectangle()',6000);
} // MDMG_bIE_showit()



// Netscape 6 functions

function MDMG_bNS6_hidesection(m_section) {
if(MDMG_mouseinrectangle()) { return; }
document.getElementById(MDMG_menusection[m_section]).style.visibility="hidden";
MDMG_menusectionprinted[m_section] = false;
} // MDMG_bNS6_hidesection()

function MDMG_bNS6_hideallmenusections() {
for(i = 1; i < MDMG_menusection.length; i++) { 
	document.getElementById(MDMG_menusection[i]).style.visibility="hidden";
	MDMG_menusectionprinted[i] = false;
	}
} // MDMG_bNS6_hideallmenusections()

function MDMG_bNS6_showit(m_section) {
	if(MDMG_menusectionprinted[m_section] == true) { return; }
	clearTimeout(STO);
	MDMG_bNS6_hideallmenusections();
	MDMG_menusectionprinted[m_section] = true;
	var x = MDMG_mousex - 1;
	if(x < 0) { x = 0; }
	var y = MDMG_mousey - 1;
	if(y < 0) { y = 0; }
	if(MDMG_MovabilityOfSubMenuPositions != "static") {
		document.getElementById(MDMG_menusection[m_section]).style.left = x + 'px';
		document.getElementById(MDMG_menusection[m_section]).style.top = y + 'px';
		}
	document.getElementById(MDMG_menusection[m_section]).style.visibility="visible";
	var padding = 0;
	if(parseInt(document.getElementById(MDMG_menusection[m_section]).style.padding) > 0) { padding = parseInt(document.getElementById(MDMG_menusection[m_section]).style.padding) * 2; }
	MDMGx = parseInt(document.getElementById(MDMG_menusection[m_section]).style.left);
	MDMGxx = parseInt(document.getElementById(MDMG_menusection[m_section]).style.width) + MDMGx + padding;
	MDMGy = parseInt(document.getElementById(MDMG_menusection[m_section]).style.top);
	MDMGyy = parseInt(document.getElementById(MDMG_menusection[m_section]).style.height) + MDMGy + padding;
	STO = setTimeout('MDMG_HideIfOutsideRectangle()',6000);
} // MDMG_bNS6_showit()



// Opera 5 and Opera 6 functions
function MDMG_bOPERA_hidesection(m_section) {
if(MDMG_mouseinrectangle()) { return; }
document.getElementById(MDMG_menusection[m_section]).style.visibility="hidden";
MDMG_menusectionprinted[m_section] = false;
} // MDMG_bOPERA_hidesection()

function MDMG_bOPERA_hideallmenusections() {
for(i = 1; i < MDMG_menusection.length; i++) { 
	document.getElementById(MDMG_menusection[i]).style.visibility="hidden";
	MDMG_menusectionprinted[i] = false;
	}
} // MDMG_bOPERA_hideallmenusections()

function MDMG_bOPERA_showit(m_section) {
	if(MDMG_menusectionprinted[m_section] == true) { return; }
	clearTimeout(STO);
	MDMG_bOPERA_hideallmenusections();
	MDMG_menusectionprinted[m_section] = true;
	var x = MDMG_mousex - 1;
	if(x < 0) { x = 0; }
	var y = MDMG_mousey - 1;
	if(y < 0) { y = 0; }
	if(MDMG_MovabilityOfSubMenuPositions != "static") {
		document.getElementById(MDMG_menusection[m_section]).style.left = x + 'px';
		document.getElementById(MDMG_menusection[m_section]).style.top = y + 'px';
		}
	document.getElementById(MDMG_menusection[m_section]).style.visibility="visible";
	var padding = 0;
	if(parseInt(document.getElementById(MDMG_menusection[m_section]).style.padding) > 0) { padding = parseInt(document.getElementById(MDMG_menusection[m_section]).style.padding) * 2; }
	MDMGx = parseInt(document.getElementById(MDMG_menusection[m_section]).style.left);
	MDMGxx = parseInt(document.getElementById(MDMG_menusection[m_section]).style.width) + MDMGx + padding;
	MDMGy = parseInt(document.getElementById(MDMG_menusection[m_section]).style.top);
	MDMGyy = parseInt(document.getElementById(MDMG_menusection[m_section]).style.height) + MDMGy + padding;
	STO = setTimeout('MDMG_HideIfOutsideRectangle()',6000);
} // MDMG_bOPERA_showit()



// Netscape 4 functions

function MDMG_bNS4_hidesection(m_section) {
if(MDMG_mouseinrectangle()) { return; }
eval('document.' + MDMG_menusection[m_section] + '.visibility="hide"');
MDMG_menusectionprinted[m_section] = false;
} // MDMG_bNS4_hidesection()

function MDMG_bNS4_hideallmenusections() {
for(i = 1; i < MDMG_menusection.length; i++) { 
	eval('document.' + MDMG_menusection[i] + '.visibility="hide"');
	MDMG_menusectionprinted[i] = false;
	}
} // MDMG_bNS4_hideallmenusections()

function MDMG_bNS4_showit(m_section) {
	if(MDMG_menusectionprinted[m_section] == true) { return; }
	clearTimeout(STO);
	MDMG_bNS4_hideallmenusections();
	MDMG_menusectionprinted[m_section] = true;
	var x = MDMG_mousex - 1;
	if(x < 0) { x = 0; }
	var y = MDMG_mousey - 1;
	if(y < 0) { y = 0; }
	if(MDMG_MovabilityOfSubMenuPositions != "static") {
		eval('document.' + MDMG_menusection[m_section] + '.left="' + x + '"');
		eval('document.' + MDMG_menusection[m_section] + '.top="' + y + '"');
		}
	eval('document.' + MDMG_menusection[m_section] + '.visibility="show"');
	MDMGx = eval('parseInt(document.' + MDMG_menusection[m_section] + '.left)');
	MDMGxx = eval('parseInt(document.' + MDMG_menusection[m_section] + '.clip.width)') + MDMGx;
	MDMGy = eval('parseInt(document.' + MDMG_menusection[m_section] + '.top)');
	MDMGyy = eval('parseInt(document.' + MDMG_menusection[m_section] + '.clip.height)') + MDMGy;
	STO = setTimeout('MDMG_HideIfOutsideRectangle()',6000);
} // MDMG_bNS4_showit()

//Roll over Images for Title page.

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function printText(elem) { 
popup = window.open('','popup','toolbar=no,menubar=no,width=200,height=150'); 
popup.document.open(); 
popup.document.write("<html><head></head><body onload='print()'>"); 
popup.document.write(elem); 
popup.document.write("</body></html>"); 
popup.document.close(); 
} 



function popWin(pag) {
	window.open(pag, '', 'fullscreen=no, titlebar=no, scrollbars=auto, width=800, height=600, left=100, top=50');
	
}
function popSmallerWin(pag) {
	window.open(pag, '', 'fullscreen=no, titlebar=no, scrollbars=auto, width=500, height=700, left=100, top=50');
	
}
//-->
