
// used for arrows on navigation
var theBaseUri = "/";
var today = new Date();
var expires = new Date(today.getTime() + (365 * 86400000));

function showPopup(url, name, height, width, scroll, resizable, statusbar, screenpos) {
	var Xwin = width;
	var Ywin = height;
	var Xsize = screen.availWidth;
	var Ysize = screen.availHeight;
	var Xpos = 0;
	var Ypos = 0;
	switch(screenpos) {
		case "topleft":
			Xpos = 0;
			Ypos = 0;
			break;
		case "topright":
			Xpos = Xsize - width;
			Ypos = 0;
			break;
		case "bottomleft":
			Xpos = 0;
			Ypos = Ysize - height;
			break;
		case "bottomright":
			Xpos = Xsize - width;
			Ypos = Ysize - height;
			break;
		default:
			Xpos = (Xsize - width) / 2;
			Ypos = (Ysize - height) / 2;
			break;
	}
	var popwin;
	var opts = "status=" + statusbar + ",resizable=" + resizable + ",scrollbars=" + scroll + ",height=" + Ywin + ",width=" + Xwin + ",left=" + Xpos + ",top=" + Ypos;
	popwin = window.open(url, name, opts);
	popwin.focus();
}

function quickWin(url, name, source) {
	showPopup(url, name, 450, 450, 0, 0, 1, 'default');
	if (source != "quickfind") {
		return false;
	}
}

function submitForm(url, name) {
	showPopup(url, name, 150, 300, 0, 0, 1, 'default');
}

function showConfirm() {
	if (confirm("Are you sure?")) return true;
	else return false;
}

function getCookie(name) {
	var start = document.cookie.indexOf(name+"=");
	var len = start+name.length+1;
	if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
	if (start == -1) return null;
	var end = document.cookie.indexOf(";",len);
	if (end == -1) end = document.cookie.length;
	return unescape(document.cookie.substring(len,end));
}

function setCookie(name, value, expires, path, domain, secure) {
	path = "/";
	document.cookie = name + "=" +escape(value) +
	((expires) ? ";expires=" + expires.toGMTString() : "") +
	((path) ? ";path=" + path : "") + 
	((domain) ? ";domain=" + domain : "") +
	((secure) ? ";secure" : "");
}

function pickRandomNumber(num) {
	return Math.round(num*Math.random());
}

function arrayShuffle(u_array, n) {
	var i, j, k;
	var temp;
	for (i = 0; i < n; i++)
	for (j = 0; j < u_array.length; j++) {
		k = Math.floor(Math.random() * u_array.length);
		temp = u_array[j];
		u_array[j] = u_array[k];
		u_array[k] = temp;
	}
}

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

function changeStyle(element, strClass) {
	element.className = strClass;
}

function changeStyle2(element, strClass) {
	element2 = document.getElementById(element);
	element2.className = strClass;
}

function toggleNode(strNode) {
	theNode = document.getElementById(strNode);
	theMark = document.getElementById("mark"+strNode);
	if (theNode) {
		if (theNode.className == "hideMe") {
			theNode.className = "showMe";
			changeImages("mark" + strNode, theBaseUri + "images/navMinus.gif");
		} else if (theNode.className == "showMe") {
			theNode.className = "hideMe";
			changeImages("mark" + strNode, theBaseUri+ "images/navPlus.gif");
		}
	} else {
		// alert("node does not exist: " + theNode + " (" + strNode + ")");
	}
}

function collapseAll() {
	// collapse all switches
	NavAnchors = document.getElementsByTagName("img");
	for (i=0; i<NavAnchors.length; i++) {
		switchString = String(NavAnchors[i].id);
		if (switchString.indexOf("mark") != -1) {
			theNodeToBeSwitched = switchString.slice(switchString.indexOf("mark") + 4);
			if (doDebug) alert("collapsed: " + nodesToSwitch[i]);
			toggleNode(theNodeToBeSwitched);
		}
	}
}

function expandSelectedNodes() {
	// expand path to this page
	// nodesToSwitch is generated from navStrings output include
	if (nodesToSwitch != "") {
		if (nodesToSwitch.slice(nodesToSwitch.lastIndexOf("|||")) == "|||") {
			// removes trailing |||
			nodesToSwitch = nodesToSwitch.slice(0, nodesToSwitch.lastIndexOf("|||"));
		}
		// splits values into array for easier switching
		nodesToSwitch = nodesToSwitch.split("|||");
		for (i=0; i<nodesToSwitch.length; i++) {
			theNode = document.getElementById(nodesToSwitch[i]);
			if (theNode) {
				if (doDebug) alert("expanded: " + nodesToSwitch[i]);
				toggleNode(nodesToSwitch[i]);
			} else {
				// alert("could not find node!");
			}
		}
	}
}

function toggleCompanyToContactSelectBox() {
	var isDisabled = document.forms["contactUs"]["companyToContact"].disabled;
	isDisabled = (isDisabled == false) ? true : false;
	document.forms["contactUs"]["companyToContact"].disabled = isDisabled;
}

function pickRandomNumber(num) {
	return Math.round(num*Math.random());
}

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_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_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 MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}


/* start menu.js */

//<a href="default.htm" onClick="return clickreturnvalue()" onMouseover="dropdownmenu(this, event, menu1, '150px')" onMouseout="delayhidemenu()">Web Design</a> |
//<a href="default.htm" onClick="return clickreturnvalue()" onMouseover="dropdownmenu(this, event, menu2, '150px')" onMouseout="delayhidemenu()">Web Design</a> |
//<a href="default.htm" onClick="return clickreturnvalue()" onMouseover="dropdownmenu(this, event, menu3, '150px')" onMouseout="delayhidemenu()">Web Design</a> |
//<a href="default.htm" onClick="return clickreturnvalue()" onMouseover="dropdownmenu(this, event, menu4, '150px')" onMouseout="delayhidemenu()">Web Design</a> |
//<a href="default.htm" onClick="return clickreturnvalue()" onMouseover="dropdownmenu(this, event, menu5, '150px')" onMouseout="delayhidemenu()">Web Design</a> |


/***********************************************
* AnyLink Drop Down Menu- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

var menu1 = ['<a href="/papers/default.aspx" title="All">All</a>','<a href="/papers/diagnostics.aspx" title="Diagnostics">Diagnostics</a>','<a href="/papers/sciences.aspx" title="Sciences">Sciences</a>','<a href="/papers/clinicalServices.aspx" title="Clinical Services">Clinical Services</a>','<a href="/papers/clinicalTechnologies.aspx" title="Clinical Technologies">Clinical Technologies</a>','<a href="/papers/pharmaServices.aspx" title="Pharma Services">Pharma Services</a>'];
var menu2 = ['<a href="/news/default.aspx" title="All">All</a>','<a href="/news/almac-group.aspx" title="Almac Group">Almac Group</a>','<a href="/news/diagnostics.aspx" title="Diagnostics">Diagnostics</a>','<a href="/news/sciences.aspx" title="Sciences">Sciences</a>','<a href="/news/clinicalServices.aspx" title="Clinical Services">Clinical Services</a>','<a href="/news/clinicalTechnologies.aspx" title="Clinical Technologies">Clinical Technologies</a>','<a href="/news/pharmaServices.aspx" title="Pharma Services">Pharma Services</a>'];
var menu3 = ['<a href="/careers/default.aspx" title="All">All</a>','<a href="/careers/almac-group.aspx" title="Almac Group">Almac Group</a>','<a href="/careers/diagnostics.aspx" title="Diagnostics">Diagnostics</a>','<a href="/careers/sciences.aspx" title="Sciences">Sciences</a>','<a href="/careers/clinicalServices.aspx" title="Clinical Services">Clinical Services</a>','<a href="/careers/clinicalTechnologies.aspx" title="Clinical Technologies">Clinical Technologies</a>','<a href="/careers/pharmaServices.aspx" title="Pharma Services">Pharma Services</a>'];
var menu4 = ['<a href="/events/default.aspx" title="All">All</a>','<a href="/events/almac-group.aspx" title="Almac Group">Almac Group</a>','<a href="/events/diagnostics.aspx" title="Diagnostics">Diagnostics</a>','<a href="/events/sciences.aspx" title="Sciences">Sciences</a>','<a href="/events/clinicalServices.aspx" title="Clinical Services">Clinical Services</a>','<a href="/events/clinicalTechnologies.aspx" title="Clinical Technologies">Clinical Technologies</a>','<a href="/events/pharmaServices.aspx" title="Pharma Services">Pharma Services</a>'];
var menu5 = ['<a href="/contact/default.aspx" title="All">All</a>','<a href="/contact/almac-group.aspx" title="Almac Group">Almac Group</a>','<a href="/contact/diagnostics.aspx" title="Diagnostics">Diagnostics</a>','<a href="/contact/sciences.aspx" title="Sciences">Sciences</a>','<a href="/contact/clinicalServices.aspx" title="Clinical Services">Clinical Services</a>','<a href="/contact/clinicalTechnologies.aspx" title="Clinical Technologies">Clinical Technologies</a>','<a href="/contact/pharmaServices.aspx" title="Pharma Services">Pharma Services</a>'];

var menuwidth='165px' //default menu width
var menubgcolor='#f1f1f1' //menu bgcolor
var disappeardelay=250 //menu disappear speed onMouseout (in miliseconds)
var hidemenu_onclick="yes" //hide menu when user clicks within menu?

/////No further editting needed

var ie4=document.all
var ns6=document.getElementById&&!document.all

if (ie4||ns6)
document.write('<div id="dropmenudiv" style="visibility:hidden;width:'+menuwidth+';background-color:'+menubgcolor+'" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>')

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}


function showhide(obj, e, visible, hidden, menuwidth){
if (ie4||ns6)
dropmenuobj.style.left=dropmenuobj.style.top="-500px"
if (menuwidth!=""){
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=menuwidth
}
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
obj.visibility=visible
else if (e.type=="click")
obj.visibility=hidden
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=0
if (whichedge=="rightedge"){
var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var topedge=ie4 && !window.opera? iecompattest().scrollTop : window.pageYOffset
var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move up?
edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either?
edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge
}
}
return edgeoffset
}

function populatemenu(what){
if (ie4||ns6)
dropmenuobj.innerHTML=what.join("")
}


function dropdownmenu(obj, e, menucontents, menuwidth){
if (window.event) event.cancelBubble=true
else if (e.stopPropagation) e.stopPropagation()
clearhidemenu()
dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv
populatemenu(menucontents)

if (ie4||ns6){
showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth)

dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
}

return clickreturnvalue()
}

function clickreturnvalue(){
if (ie4||ns6) return false
else return true
}

function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function dynamichide(e){
if (ie4&&!dropmenuobj.contains(e.toElement))
delayhidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhidemenu()
}

function hidemenu(e){
if (typeof dropmenuobj!="undefined"){
if (ie4||ns6)
dropmenuobj.style.visibility="hidden"
}
}

function delayhidemenu(){
if (ie4||ns6)
delayhide=setTimeout("hidemenu()",disappeardelay)
}

function clearhidemenu(){
if (typeof delayhide!="undefined")
clearTimeout(delayhide)
}

if (hidemenu_onclick=="yes")
document.onclick=hidemenu

/* end menu.js */