var agt 	= navigator.userAgent.toLowerCase();
var isNN 	= ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1) &&
(agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1) &&
(agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1)); 
var isMajor 	= parseInt(navigator.appVersion); 
var isMinor 	= parseFloat(navigator.appVersion); 
var isNN4 	= (isNN && (isMajor <= 4)); 
var isNN6up 	= (isNN && (isMajor >= 5)); 
var isIE 	= ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var isWin 	= (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera 	= (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

var w3c		= (document.getElementById)? true: false;
var ie5		= (w3c && document.all)? true : false;
var ns6		= (w3c && (navigator.appName=="Netscape"))? true: false;
var winH	= 0;
var winW	= 0;
var htmlH	= 0;
var htmlW	= 0;
var scrollX	= 0;
var scrollY	= 0;
var msMemberStatus	= 'N';

/**********************  relation clipboard functions  ******************************/
var aRelsStickie = new Array();  //STORES AN ARRAY OF RELATIONS FOR THE STICKIE PAD
function addStickieRelation(relation_key, father_key, mother_key, relation_forename, relation_surname, sex, year_of_birth, circa, year_of_death, death_circa, date_of_birth){
	var oSt = new Object();
	oST.relation_key 	= relation_key;
	oST.father_key 		= father_key; 
	oST.mother_key 		= mother_key; 
	oST.relation_forename 	= relation_forename; 
	oST.relation_surname 	= relation_surname; 
	oST.sex 		= sex; 
	oST.year_of_birth 	= year_of_birth; 
	oST.circa 		= circa; 
	oST.year_of_death	= year_of_death;
	oST.death_circa		= death_circa;
	oSt.date_of_birth	= date_of_birth;
	aRelsStickie[aRelsStickie.length] = oST;
	setNamedCookie('stickie', getRecoverableString(aRelsStickie));
}

function delStickieRelation(rel_key){
				
	for (var h=0; h<aRelsStickie.length; h++){
			
			if (aRelsStickie[h].relation_key = rel_key){
				//alert('del');
				//delete it
				aRelsStickie.splice(h, 1)
				//alert(getRecoverableString(aRelsStickie));
				setNamedCookie('stickie', getRecoverableString(aRelsStickie));
			}
	}
}

/**********************  end of relation clipboard functions  ******************************/

function clearForm(sForm){
	var frm = document.forms[sForm];
	if(frm){
		for(var i = 0; i < frm.elements.length; i++){
			el = frm.elements[i];
			if(el.type == 'hidden' || el.type == 'button' || el.type == 'submit'){
				//leave alone
			}else if(el.options){
				//selectbox
				el.selectedIndex =0;
			}else if(el.length){
				//multiple option radio
				for(var i = 0; i < el.length; i++){
					el[i].checked = false;
				}
			}else if(el.type == 'radio'){
				//single option radio
				el.checked = false;
			}else if(el.type == 'checkbox'){
				//checkbox
				el.checked =  false;
			}else{
				el.value = "";
			}
		}
	}
}

function getWinSize() {
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		winW	= window.innerWidth;
		winH	= window.innerHeight;
		scrollX = window.pageXOffset||0;
		scrollY = window.pageYOffset||0;
		htmlH	= window.scrollHeight || 0;
		htmlW	= window.scrollWidth || 0;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		winW 	= document.documentElement.clientWidth;
		winH 	= document.documentElement.clientHeight;
		scrollX	= document.documentElement.scrollLeft || 0;
		scrollY	= document.documentElement.scrollTop || 0;
		htmlH	= document.documentElement.scrollHeight || 0;
		htmlW	= document.documentElement.scrollWidth || 0;
 	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		winW 	= document.body.clientWidth;
		winH 	= document.body.clientHeight;
		scrollX	= document.body.scrollLeft || 0;
		scrollY	= document.body.scrollTop || 0;
		htmlH	= document.body.scrollHeight || 0;
		htmlW	= document.body.scrollWidth || 0;
	}
	//alert("winH="+winH+" winW="+winW+" htmlH="+htmlH+" htmlW="+htmlW+" scrollX="+scrollX+"  scrollY="+scrollY) ;
}

function getOffsetLeft(oNode){
	var nRet = 0;
	if (oNode.offsetParent){
		while (oNode.offsetParent){
			nRet += oNode.offsetLeft;
			if(oNode.scrollLeft) nRet -= oNode.scrollLeft;
			oNode = oNode.offsetParent;
		}
	}else if (oNode.x){
		nRet = oNode.x;
	}
	return nRet;
}

function getOffsetTop(oNode){ 
	var nRet = 0;
	if (oNode.offsetParent){
		while (oNode.offsetParent){
			nRet += oNode.offsetTop
			if(oNode.scrollTop) nRet -= oNode.scrollTop;
			oNode = oNode.offsetParent;
		}
	}else if (oNode.y){
		nRet = oNode.y;
	}
	return nRet;
}

function showStatusInfo(sText, sTarget){
	var oTarget = getlayer(sTarget);
	var oWait = getlayer("statusinfo");
	var oWaitText = getlayer("statusinfotext");
	
	if (oTarget && oWaitText){
		oWait.style.height = oTarget.offsetHeight + 'px';
		oWait.style.width = oTarget.offsetWidth + 'px';
		oWait.style.left =  getOffsetLeft(oTarget) + 'px';
		oWait.style.top =  getOffsetTop(oTarget) + 'px';
		oWaitText.style.height = '50px';
		oWaitText.style.width = '200px';
		oWaitText.style.left =  ((oTarget.offsetWidth / 2)-100) + 'px';
		oWaitText.style.top =  '450px';
		removeClass(oWait, 'statusinfotrans');
		addClass(oWait, 'statusinfotrans');	
		
		
		
	}
	if(oWait){
		while(oWait.childNodes.length>0){
			oWait.removeChild(oWait.firstChild);
		}
		
	//	
		//stepimg.src = 'image/icons/spin32.gif';
//		stepimg.style.width = '32px';
	//	stepimg.style.height = '32px';
		
	//	var h2 = document.createElement('h2');
//		h2.appendChild(document.createTextNode(sText));
//		stepimg.appendChild(h2);
		//oWait.appendChild(stepimg);		
		if(!oWaitText){
			var stepimg = document.createElement('img');
			stepimg.src = 'image/icons/spin32.gif';
			stepimg.style.width = '32px';
			stepimg.style.height = '32px';
			oWait.appendChild(stepimg);
			oWait.appendChild(document.createTextNode(sText));
		}
		layeron(oWait);
	}
	if(oWaitText){
		while(oWaitText.childNodes.length>0){
			oWaitText.removeChild(oWaitText.firstChild);
		}
		var oH2 = document.createElement('h2')
		oH2.appendChild(document.createTextNode(sText));
		oWaitText.appendChild(oH2);
		layeron(oWaitText);
	}
}

function hideStatusInfo(){
	var oWait = getlayer("statusinfo");
	if(oWait){
		layeroff(oWait);
	}
	var oWaitText = getlayer("statusinfotext");
	if(oWaitText){
		layeroff(oWaitText);
	}
}

function focusToOpener(){
	//FUNCTION TO GIVE FOCUS TO THE WINDOW THAT OPENED THE CURRENT POPUP WINDOW. CHECKS IF IT EXISTS AND IF IT IS STILL OPEN
	if(top.opener){
		if(!top.opener.closed){
			top.opener.focus();
		}
	}
	return false;
}

function truebody(){ 
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function getlayer(layername) {
	if (document.layers) {
		var theLayer=document.layers[layername]
	} else {
		if (document.getElementById) {
			var theLayer=document.getElementById(layername)
		} else {
			var theLayer=document.all[layername]
		}
	};

	return theLayer;
	
}

function getlayerdisplay(thelayer) {
	if (document.layers) {
		return (thelayer.display)
	} else {
		return thelayer.style.display
	}
}

function getlayervisibility(thelayer) {
	if (document.layers) {
		var vis = (thelayer.visibility=="hide") ? "hidden" : "visible"
	} else {
		var vis = thelayer.style.visibility
	}
	return vis
}



function layeron(slayer) {
	if(slayer){
		if (document.layers) {
			slayer.visibility="visible"
		} else {
			//if (isNN6up) {
				slayer.style.visibility="visible"
				slayer.style.display="inline"
			//} else {
				//slayer.style.visibility="visible"
				//slayer.style.display="inline"
			//}
		}
	}
}

function layeroff(slayer) {
	if(slayer){
		if (document.layers) {
			slayer.visibility="hide"
		} else {
			//if (isNN6up) {
				slayer.style.visibility="hidden";
				slayer.style.display="none"
			//} else {
				//slayer.style.visibility="hidden";
				//slayer.style.display="none"
			//}
		}
	}
}

function fadelayeron(slayer){
	if(slayer.filters){
		slayer.style.filter = "blendTrans(duration=0.5)";
		slayer.filters["blendTrans"].apply();
	}
	layeron(slayer)
	if(slayer.filters){
		slayer.filters["blendTrans"].play();
	}
}

function fadelayeroff(slayer){
	if(slayer.filters){
		slayer.style.filter = "blendTrans(duration=0.5)";
		slayer.filters["blendTrans"].apply();
	}
	layeroff(slayer)
	if(slayer.filters){
		slayer.filters["blendTrans"].play();
	}
}

function layerdisplayon(slayer) {
	layeron(slayer);
}

function layerdisplayoff(slayer) {
	layeroff(slayer);
}  

function fadelayertoggle(layerId){
	if (getlayer(layerId).style.visibility == "hidden" || getlayer(layerId).style.visibility == ""){
		fadelayeron(getlayer(layerId));
	}else{
		fadelayeroff(getlayer(layerId));
	}
}

function changeLayer(theLayer,imageName)
{
	
	if (getlayervisibility(theLayer) == 'hidden')
	{
		if(typeof imageName!='undefined'){
			imageName.src = 'image/minus.gif';
		}
		layerdisplayon(theLayer);
	}
	else
	{
		if(typeof imageName!='undefined'){
			imageName.src = 'image/plus.gif';
		}
		layerdisplayoff(theLayer);
	}
}

function changeLayerOn(theLayer,imageName)
{
		imageName.src = 'image/minus.gif';
		layerdisplayon(theLayer);
}

function changeLayerOff(theLayer,imageName)
{
		imageName.src = 'image/plus.gif';
		layerdisplayoff(theLayer);
}


function expandAll(totalrows)
{

	var checkImage1 = 'image/plus.gif';
	var checkImage2 =Alllayermin.src;
	var rvalue="";
	var results = checkImage2.replace(checkImage1, rvalue)
	if (checkImage2.length != results.length) {
		Alllayermin.src= 'image/minus.gif';
		for (i=0;i<totalrows;i++) {
			var l1='contact'+(i+1)
			var l2='contact'+(i+1)+'min'
			changeLayerOn(getlayer(l1),getlayer(l2));
		}
	}
	else {
		Alllayermin.src= 'image/plus.gif';
		for (i=0;i<totalrows;i++) {
			var l1='contact'+(i+1)
			var l2='contact'+(i+1)+'min'
			changeLayerOff(getlayer(l1),getlayer(l2));
		}
	}


}
var treewindow;
function OpenTreeWindow(nRelKey){
	var w1;
	var h1;
	var sExtra = '';
	if(nRelKey){
		sExtra = '&relation_key='+nRelKey;
	}
	w1=screen.availWidth-20;	
	h1=screen.availHeight-80;
	if (treewindow) {
		if (! treewindow.closed) {
			treewindow.close();
		}		
	};
	treewindow = window.open('tree.asp?wci=tree'+sExtra,'FamilyTree','resizable,toolbar=no,scrollbars=yes,directories=no,menubar=no, width='+w1+', height='+h1+',left=5, top=35,screenX=0,screenY=0');
	if (treewindow==null || typeof(treewindow)=="undefined") {
		alert('You have popups blocked.\n\nIf you look at the top of this page you will see a coloured bar saying \'Pop-up blocked\'. \n\nTo see the Family Tree Builder you should click on this coloured bar and choose \'Always allow pop-ups from this site\'.\n\nOR\n\n\'Temporarily allow pop-ups\'\n\nThis will cause no harm to your computer.\n\nWe do not open pop-ups from external sites on Genes Reunited');
	}else{
		treewindow.focus();




	}
	return false;
}

function newwindow(url_name,myname,w,h) 
{ 
	var win = null;
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;

	settings='toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',resizable'

	win = window.open(url_name,myname,settings)
	if(win.window.focus){win.window.focus();} 
} 

function validateSearchBox(theform,theFirstName,theLastName){
	var validForm = true;
	var alertMessage='';
	var s
	s = theLastName.value.replace(/ /g,'')
	if (( s == '') || ( theLastName.value == 'Last name')) {
		theLastName.style.borderWidth="1";
		theLastName.style.borderColor="red";
		theLastName.focus();
		alertMessage += 'In order to search please enter either a First name and Last name or just a Last name\n';
		validForm = false;
	}
	if (validForm == false) {
		alert(alertMessage);
	}
	else {
		if (theFirstName.value == 'First name'){
			theFirstName.value = '';
		}
	}
	return validForm;
}

function submitter(f) {
	var key;
	if (document.all) {
		e = window.event;
		key = e.keyCode;
		if (key==13) {
			document.forms(f).submit();
			e.returnValue = false;
		}
	}
	if (document.layers) {
	   key = e.which;
	   if (key==13) {
	    document.forms[f].submit();
	   }
	  }
} 

var bmurl="http://www.genesreunited.com"
var bmtitle="Genes Reunited"

function addbookmark(){
	if (document.all)
	window.external.AddFavorite(bmurl,bmtitle)
}

function clearSelectOptions(lControl){
	if(lControl){
		while(lControl.options.length>0){		
			lControl.removeChild(lControl.options[0])		
		}

	}	
}

function addSelectOption(lControl, DisplayText, Val){
	if(lControl){
		loption = new Option(DisplayText, Val);
		lControl.options[lControl.options.length] = loption;
	}
}

function fillSelectOptions(lControl, arrOptionValues, arrOptionText, defaultValue, selectedValue){
	var nloop, loption, isDefault, isSelected;
	
	
	safeSelected = -1;
	safeDefault = -1;
	
	if(lControl){
		
		for (nloop = 0; nloop < arrOptionValues.length; nloop++){
			if(arrOptionValues[nloop]==defaultValue){
				safeDefault = nloop;
			}
			if(arrOptionValues[nloop]==selectedValue){
				safeSelected = nloop;
			}
			addSelectOption(lControl, arrOptionText[nloop], arrOptionValues[nloop]);
		}
		if(safeSelected > -1){
			lControl.selectedIndex = safeSelected;
		}else if(safeDefault > -1){
			lControl.selectedIndex = safeDefault;
		}
	}
}

function replaceSelectOptions(lControl, arrOptionValues, arrOptionText, defaultValue, selectedValue){
	if(lControl){
		clearSelectOptions(lControl);
		fillSelectOptions(lControl, arrOptionValues, arrOptionText, defaultValue, selectedValue);
	}
}

function OpenMainSite(p){
	var bOpener = false;
	if (window.opener){
		bOpener = true;
		if(window.opener.closed){
			bOpener = false;
		}
	}
	if(bOpener){
		window.opener.location.href=p;
		window.opener.focus();
	}else{
		window.opener=self;
		document.location.href=p;		
	}
}

function SiteSearch(sFname, sSname, sYOB){
	var bOK = true;
	var sYOBrange = '';
	if(sSname == 'surname') sSname = '';
	if(sFname == 'forename') sFname = '';
	if(typeof(sYOB) == 'undefined'){
		sYOB = '';
	}
	if(sYOB != ''){
		sYOBrange = "&year_of_birth_range=5";
	}
	if(sSname == ''){
		bOK = false;
		alert('You must enter a surname, or a forename and surname to search.');
	}
	if(bOK){
		OpenMainSite('search.asp?WCI=relations&qsearch=1&relation_surname='+encodeURI(sSname)+'&relation_forename='+encodeURI(sFname)+'&year_of_birth='+encodeURI(sYOB)+sYOBrange);
	}
}

function checkAllBoxes(checked, frm, checknameinit){
	for(var i=0;i<frm.elements.length;i++){
    		var e = frm.elements[i];
		if(e.name.substring(0,checknameinit.length)==checknameinit) e.checked=checked;
	}
}

/* DOM Scripting funcs  */

function addLoadEvent(func){
	/* appends a function to the onload event */
	var oldonload = window.onload;
	if(typeof window.onload != 'function'){
		window.onload = func;
	}else{
		window.onload = function(){
			oldonload();
			func();
		}
	}
}

/* Add class to element (preserves any existing element classes) */
function addClass(element, value){
	if(!element.className){
		element.className = value;
	}else{
		element.className = element.className+" " + value;
	}
}

/* Checks if a class is among the classes used by an element */ 
   function hasClassName(element, className) { 
      //return (element.className.indexOf(className) > -1); 
      return element.className.match(new RegExp('(\\s|^)'+className+'(\\s|$)'));
   } 
    
    
function removeClass(element, className){
  if (hasClassName (element, className)){
    element.className = element.className.replace ( new RegExp( "(^|\\s)"+className+"(\\s|$)" ), "" 
    )
  }
}

/* End of DOM Scripting funcs  */

/* flash clicker fix  */
if(document.getElementsByTagName){
	var objects = document.getElementsByTagName("object");
	for (var i = 0; i < objects.length; i++)
	{
	    objects[i].outerHTML = objects[i].outerHTML;
	}
}
/* endflash clicker fix  */



//FUNC TO ALLOW ENUMERATED TYPES TO BE SET UP
function EnumeratedType() {
	for (var i = 0; i < arguments.length; i++) {
		// set up the identifier in the instance, and give
		// it a numerical value, unique to the instance
		this[arguments[i]] = i;
	}
}

//	EXAMPLE OF USE
//	
//	var meNodeType 	= new EnumeratedType('start', 'parent', 'spouse', 'child', 'copy', 'generic');
//	meNodeType.start will now equal 1, and meNodeType.copy will equal 4


function addStyleSheet(sHref){
	if(document.createStyleSheet) {
		document.createStyleSheet(sHref);
	}else if(document.getElementsByTagName && document.createElement){
		var styles 	= "@import url(sHref);";
		var newSS	= document.createElement('link');
		newSS.rel	= 'stylesheet';
		newSS.href	= 'data:text/css,'+escape(styles);
		document.getElementsByTagName("head")[0].appendChild(newSS);
	}
}


/* Browser detection */
// example of use. (has 3 properties)
//
//	if(BrowserDetect.browser == 'Firefox'){
//	//do something
//	}ese if(BrowserDetect.browser == 'Opera'){
//		//do something else
//	}else if(BrowserDetect.version > 1.5){
//		//do something else
//	}else if(BrowserDetect.OS > 'Windows'){
//		//do something else
//	}

var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{	// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 	// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();

//Returns a evalable string.
function getRecoverableString(oVar,notFirst) {
	var oType = typeof(oVar);
	if( ( oType == 'null' ) || ( oType == 'object' && !oVar ) ) {
		//most browsers say that the typeof for null is 'object', but unlike a real
		//object, it will not have any overall value
		return 'null';
	}
	if( oType == 'undefined' ) { return 'window.uDfXZ0_d'; }
	if( oType == 'object' ) {
		//Safari throws errors when comparing non-objects with window/document/etc
		if( oVar == window ) { return 'window'; }
		if( oVar == document ) { return 'document'; }
		if( oVar == document.body ) { return 'document.body'; }
		if( oVar == document.documentElement ) { return 'document.documentElement'; }
	}
	if( oVar.nodeType && ( oVar.childNodes || oVar.ownerElement ) ) { return '{error:\'DOM node\'}'; }
	if( !notFirst ) {
		Object.prototype.toRecoverableString = function (oBn) {
			if( this.tempLockIgnoreMe ) { return '{\'LoopBack\'}'; }
			this.tempLockIgnoreMe = true;
			var retVal = '{', sepChar = '', j;
			for( var i in this ) {
				if( i == 'toRecoverableString' || i == 'tempLockIgnoreMe' || i == 'prototype' || i == 'constructor' ) { continue; }
				if( oBn && ( i == 'index' || i == 'input' || i == 'length' || i == 'toRecoverableObString' ) ) { continue; }
				j = this[i];
				if( !i.match(basicObPropNameValStr) ) {
					//for some reason, you cannot use unescape when defining property names inline
					for( var x = 0; x < cleanStrFromAr.length; x++ ) {
						i = i.replace(cleanStrFromAr[x],cleanStrToAr[x]);
					}
					i = '\''+i+'\'';
				} else if( window.ActiveXObject && navigator.userAgent.indexOf('Mac') + 1 && !navigator.__ice_version && window.ScriptEngine && ScriptEngine() == 'JScript' && i.match(/^\d+$/) ) {
					//IE mac does not allow numerical property names to be used unless they are quoted
					i = '\''+i+'\'';
				}
				retVal += sepChar+i+':'+getRecoverableString(j,true);
				sepChar = ',';
			}
			retVal += '}';
			this.tempLockIgnoreMe = false;
			return retVal;
		};
		Array.prototype.toRecoverableObString = Object.prototype.toRecoverableString;
		Array.prototype.toRecoverableString = function () {
			if( this.tempLock ) { return '[\'LoopBack\']'; }
			if( !this.length ) {
				var oCountProp = 0;
				for( var i in this ) { if( i != 'toRecoverableString' && i != 'toRecoverableObString' && i != 'tempLockIgnoreMe' && i != 'prototype' && i != 'constructor' && i != 'index' && i != 'input' && i != 'length' ) { oCountProp++; } }
				if( oCountProp ) { return this.toRecoverableObString(true); }
			}
			this.tempLock = true;
			var retVal = '[';
			for( var i = 0; i < this.length; i++ ) {
				retVal += (i?',':'')+getRecoverableString(this[i],true);
			}
			retVal += ']';
			delete this.tempLock;
			return retVal;
		};
		Boolean.prototype.toRecoverableString = function () {
			return ''+this+'';
		};
		Date.prototype.toRecoverableString = function () {
			return 'new Date('+this.getTime()+')';
		};
		Function.prototype.toRecoverableString = function () {
			return this.toString().replace(/^\s+|\s+$/g,'').replace(/^function\s+[^\(]*\(/g,'function (').replace(/^function\s*\w*\([^\)]*\)\s*\{\s*\[native\s+code\]\s*\}$/i,'function () {[\'native code\'];}');
		};
		Number.prototype.toRecoverableString = function () {
			if( isNaN(this) ) { return 'Number.NaN'; }
			if( this == Number.POSITIVE_INFINITY ) { return 'Number.POSITIVE_INFINITY'; }
			if( this == Number.NEGATIVE_INFINITY ) { return 'Number.NEGATIVE_INFINITY'; }
			return ''+this+'';
		};
		RegExp.prototype.toRecoverableString = function () {
			return '\/'+this.source+'\/'+(this.global?'g':'')+(this.ignoreCase?'i':'');
		};
		String.prototype.toRecoverableString = function () {
			var oTmp = escape(this);
			if( oTmp == this ) { return '\''+this+'\''; }
			return 'unescape(\''+oTmp+'\')';
		};
	}
	if( !oVar.toRecoverableString ) { return '{error:\'internal object\'}'; }
	var oTmp = oVar.toRecoverableString();
	if( !notFirst ) {
		//prevent it from changing for...in loops that the page may be using
		delete Object.prototype.toRecoverableString;
		delete Array.prototype.toRecoverableObString;
		delete Array.prototype.toRecoverableString;
		delete Boolean.prototype.toRecoverableString;
		delete Date.prototype.toRecoverableString;
		delete Function.prototype.toRecoverableString;
		delete Number.prototype.toRecoverableString;
		delete RegExp.prototype.toRecoverableString;
		delete String.prototype.toRecoverableString;
	}
	return oTmp;
}
var basicObPropNameValStr = /^\w+$/, cleanStrFromAr = new Array(/\\/g,/'/g,/"/g,/\r/g,/\n/g,/\f/g,/\t/g,new RegExp('-'+'->','g'),new RegExp('<!-'+'-','g'),/\//g), cleanStrToAr = new Array('\\\\','\\\'','\\\"','\\r','\\n','\\f','\\t','-\'+\'->','<!-\'+\'-','\\\/');

function setDocumentCookie( oDoc, sName, sValue, bSessionCookie )
{

    /*
    dl 19/12/2007 
    if bSessionCookie is set and is true then this cookie will expire when the browser is closed
    if not the the cookie will last for a year
    */
    
    if(bSessionCookie) {
    	//alert('is');
    
    }

    if ( sName.length < 1 )
        return;

    if ( 0 < sValue.length )
    {
        // create a date for a year from now
        var expDate = new Date();
        expDate.setTime( expDate.getTime() + 365*24*60*60*1000 );

        // Notice that the cookie is actually two assignment strings.
        //  The first is "cookiename=value" and the second is
        //  "expires=date".  The two assignments are  separated by a
        //  semicolon.  If you do not have the "expires" assignment
        //  the cookie will disappear when the visitor's browser exits.
        //
        if(!bSessionCookie) {
        	oDoc.cookie = ""
                        + sName + "=" + sValue + "; "
        }else{
        	oDoc.cookie = ""
        		+ sName + "=" + sValue + "; "
                        + "expires=" + expDate.toGMTString();
        }
    }
    else
    {
        //  this will cause the named cookie to be deleted.
        oDoc.cookie = sName + "=";
    }
}

function setNamedCookie( sName, sValue )
{
    setDocumentCookie( document, sName, sValue );
}

function setBrowserSessionNamedCookie( sName, sValue )
{
    setDocumentCookie( document, sName, sValue, true );
}

function deleteDocumentCookie( oDoc, sName )
{
    oDoc.cookie = sName + "=";
}

function deleteCookie( sName )
{
    deleteDocumentCookie( document, sName );
}

//
//  This function will fetch a named cookie
//
function fetchDocumentCookie( oDoc, sName )
{
    var sValue = "";
    var index = 0;

    //  The "cookie" property on the document is actually a
    //  single string of the form "name=value; name2=value2; ..."
    //  As a result we must search through the cookie string
    //  to find the name=value pair that we are looking for.
    //
    if( oDoc.cookie )
        index = oDoc.cookie.indexOf( sName + "=" );
    else
        index = -1;

    if ( index < 0 )
    {
        sValue = "";
    }
    else
    {
        var countbegin = (oDoc.cookie.indexOf( "=", index ) + 1);
        if ( 0 < countbegin )
        {
            var countend = oDoc.cookie.indexOf( ";", countbegin );
            if ( countend < 0 )
                countend = oDoc.cookie.length;
            sValue = oDoc.cookie.substring( countbegin, countend );
        }
        else
        {
            sValue = "";
        }
    }
    
    return sValue;
}

function fetchNamedCookie( sName )
{
    return fetchDocumentCookie( document, sName );
}

function Mod(X, Y) {
	return X - Math.floor(X/Y)*Y
}

function OrdinalSuffix(nInt){
	//	returns a number plus it's correct suffix for any integer
	var nTemp =  Mod(nInt, 100);

	if(nTemp > 10 && nTemp < 20){
		return nInt + "th"
	}else{
		switch(Mod(nInt, 10)){
			case 1:
				return nInt + "st"
			case 2:
				return nInt + "nd"
			case 3:
				return nInt + "rd"
			default:
				return nInt + "th"
		}
	}
}

function repeatTerm(sTerm, nMultiple){
	//	returns a string of a term repeated multiple times. 
	//	ie repeatTerm('grand', 3) + ' grand father'
	//	returns 'great great great grand father'
	var aO = new Array();
	for(var i = 0; i < nMultiple; i++){
		aO.push(sTerm);
	}
	return aO.join(" ");
}



function getInputValue(el){
	/**************************************
	/
	/	function takes in reference to a form input and returns the current value
	/	if a checkbox is unchecked, will return a zero length string
	//	if a radio set is unselected, will return a zero length string
	/
	**************************************/
	var sRet = '';
	if(el.options){
		//selectbox
		sRet = el.options[el.selectedIndex].value;
	}else if(el.length){
		//multiple option radio
		for(var i = 0; i < el.length; i++){
			if(el[i].checked){
				sRet = el[i].value;
			}
		}
	}else if(el.type == 'radio'){
		//single option radio
		if(el.checked){
			sRet = el.value;
		}
	}else if(el.type == 'checkbox'){
		//checkbox
		if(el.checked){
			sRet = el.value;
		}
	}else{
		sRet = el.value;
	}
	return sRet;
}

function setInputValue(el, sValue){
	/**************************************
	/
	/	function takes in reference to a form input and the new value
	/	will set the value correctly for textboxes, radios, checkboxes and selectboxes
	/
	**************************************/
	if(el.options){
		//selectbox
		for(var i = 0; i<el.options.length; i++){
			if(el.options[i].value == sValue){
				el.selectedIndex = i;
				break;
			}
		}
	}else if(el.length){
		//multiple option radio
		for(var i = 0; i < el.length; i++){
			el[i].checked = false;
			if(el[i].value == sValue){
				el[i].checked = true;				
			}
		}
	}else if(el.type == 'radio'){
		//single option radio
		if(el.value == sValue){
			el.checked = true;
		}
	}else if(el.type == 'checkbox'){
		//checkbox
		el.checked = false;
		if(el.value == sValue){
			el.checked = true;
		}
	}else{
		el.value = sValue;
	}
}

/****************************************************
//
//	Scroll wheel event capture functions
//	
****************************************************/

function scrollWheelHandler(callFunc){

	var oThis = this;
	
	this.callFunc	= callFunc;	//Function to be called if wheeled up or down. Set on a page specific basis
	this.conditionFunc;		//Function to stop handler firing in certain circumstances. (Optional)
	
	this.wheel = function(event){	//Event handler for mouse wheel event. 
		if(oThis.conditionFunc){
			if(!oThis.conditionFunc()) 
				return true;		//not passed condition test, so exit and return true to continue with default scroll action
		}
	        var delta = 0;
	        if (!event) // For IE. 
	                event = window.event;
	        if (event.wheelDelta) { // IE/Opera. 
	                delta = event.wheelDelta/120;
	                // In Opera 9, delta differs in sign as compared to IE.
	                if (window.opera)
	                        delta = -delta;
	        } else if (event.detail) { /** Mozilla case. */
	                // In Mozilla, sign of delta is different than in IE.
	                // Also, delta is multiple of 3.
	                delta = -event.detail/3;
	        }
	        /* If delta is nonzero, handle it.
	         * Basically, delta is now positive if wheel was scrolled up,
	         * and negative, if wheel was scrolled down.
	         */
	        if (delta)
	                callFunc(delta);
	        /** Prevent default actions caused by mouse wheel.
	         * That might be ugly, but we handle scrolls somehow
	         * anyway, so don't bother here..
	         */
	        if (event.preventDefault)
	                event.preventDefault();
		event.returnValue = false;
	}
	
	// Initialization code. 
	if (window.addEventListener){
		// DOMMouseScroll is for mozilla. 
		window.addEventListener('DOMMouseScroll', this.wheel, false);
	}
	// IE/Opera. 
	window.onmousewheel = document.onmousewheel = this.wheel;
}

/*******************************************************************
//	EXAMPLE USAGE

function init(){
	//function triggered on page load that sets up the scroll wheel handler, passing in page specific function to pass the scroll amount to
	var oWheel = new scrollWheelHandler(scrollZoom);
	oWheel.conditionFunc	= doZoom;	//set the page specific function to be called to check if scroll handler should execute  (optional). 
}

addLoadEvent(init);	//trigger initialisation function on page load

function doZoom(){
	//function to decide if scroll handler should fire.
	// in this case the image has a property .zoom set to true when the mouse is over it and .zoom = false when the mouse is not over it.
	//ie only zoom when scrolling with mouse over the image
	var bRet = false;
	var el = document.getElementById("zoom");
	if(el){
		if(el.zoom){
			bRet = true;
		}
	}
	return bRet;
}

function scrollZoom(delta){
	//page specific function. 
	//takes value of delta (-ve is scrolled down, +ve is scrolled up)
	//page has an image id="zoom" which is increased in size on scrolling up, and decreased in size on scrolling down
	var el = document.getElementById("zoom");
	var w = parseInt(el.style.width);
	var h = parseInt(el.style.height);
	
	if (delta < 0){
		if(w > 10 && h > 10){
			el.style.width = (w - 10) + "px";
			el.style.height = (h - 10) + "px";
		}
	}else if(delta > 0){
		el.style.width = (w + 10) + "px";
		el.style.height = (h + 10) + "px";
	}
}

//	END OF SCROLL WHEEL FUNCTIONS
******************************************************************/

/******************************************************************/
//	CLIPBOARD FUNCTIONS

function clipboardObj(){
	var oThis 		= this;
	this.clipboard;
	this.items 		= new Array();
	this.onClearAllFunc	= "";
	this.OK 		= false;
	if(document.createElement && document.getElementById){
		this.OK = true;
	}
	
	this.addItem = function(nPos, sIcon, sText, onclickfunc){
		oThis.items.push(new oThis.item(nPos, sIcon, sText, onclickfunc));
	}
	this.removeItem = function(nPos){
		if(oThis.items.length > nPos){
			oThis.items.splice(nPos, 1);
		}
	}
	this.removeAllItems = function(){
		oThis.items 	= new Array();
		oThis.show();
	}
	this.initialise = function(){
		oThis.items 	= new Array();
		var clipholder 	= document.getElementById('clipboard');
		if(!clipholder){
			oThis.createClipboard();
			clipholder 	= document.getElementById('clipboard');
		}
		oThis.clipboard = clipholder;
	}
	this.populate = function(){
		var clipholder	= getlayer('clipboard');
		var clip	= getlayer('clipbody');
		var clipcount	= getlayer('clipcount');
		if(clipholder && clip && clipcount){
			removeChildnodes(clip);
			removeChildnodes(clipcount);
			if(oThis.items.length > 0){
				clipcount.appendChild(document.createTextNode(oThis.items.length + " - "));
				for(var i = 0; i < oThis.items.length; i++){
					clip.appendChild(oThis.items[i].obj());
				}
				clip.style.height = oThis.items.length * 12;
			}else{
				clip.appendChild(document.createTextNode("Your clipboard is empty"));
			}
		}
	}
	this.setTop = function(y){
		if(oThis.clipboard){
			oThis.clipboard.style.top = y + 'px';
		}
	}
	this.setLeft = function(x){
			if(oThis.clipboard){
				oThis.clipboard.style.left = x + 'px';
			}
	}
	this.show = function(){
		if(oThis.clipboard){
			if(oThis.clipboard.filters){
				oThis.clipboard.style.filter = "revealTrans(duration=0.25,transition=5)";
				oThis.clipboard.filters["revealTrans"].apply();
				layeron(oThis.clipboard);
				oThis.clipboard.filters["revealTrans"].play();
			}else{
				layeron(oThis.clipboard);
			}
		}
	}
	this.hide = function(){
		if(oThis.clipboard){
			if(oThis.clipboard.filters){
				oThis.clipboard.style.filter = "revealTrans(duration=0.25,transition=5)";
				oThis.clipboard.filters["revealTrans"].apply();
				layeroff(oThis.clipboard);
				oThis.clipboard.filters["revealTrans"].play();
			}else{
				layeroff(oThis.clipboard);
			}
		}
	}
	this.item = function(nPos, sIcon, sText, onclickfunc){
		this.pos = nPos;
		this.icon = sIcon;
		this.text = sText;
		
		this.obj = function(){
			var oItem = document.createElement("div");
			oItem.pos = this.pos;
			oItem.className = "clipitem";
			oItem.onmouseover = function(){
				this.className = "clipitemover";
			}
			oItem.onmouseout = function(){
				this.className = "clipitem";
			}
			oItem.onclick = function(){
				onclickfunc(this.pos);
				return false;
			}
			var oImg = document.createElement('img');
			oImg.src = this.icon;
			oItem.appendChild(oImg);
			var oTxt = document.createTextNode(this.text);
			oItem.appendChild(oTxt);
			return oItem
		}
	}
	this.createClipboard = function(){
		var oHldr = document.createElement("div");
		oHldr.setAttribute("id", "clipboard");
		oHldr.className = "dragroot clipboard";
		var oTit = document.createElement("div");
		//oTit.title = "Copy relation details from other trees or search results and paste them into your tree.";
		oTit.className = "cliptitle";

		var oImg = document.createElement("img");
		oImg.setAttribute("align", "right");
		oImg.setAttribute("src", "image/clipboard/clip_close.gif");
		oImg.setAttribute("alt", "close clipboard");
		oImg.onclick = function(){
			oThis.hide();
			return false;
		}
		var oSpan = document.createElement("span");
		oSpan.className = "clipfunc";
		oSpan.onmouseover = function(){
			this.className = "clipfuncover";
		}
		oSpan.onmouseout = function(){
			this.className = "clipfunc";
		}
		oSpan.appendChild(oImg);
		oTit.appendChild(oSpan);
		//CLEAR ALL
		if(typeof oThis.onClearAllFunc == 'function'){
			var oLink = document.createElement("a");
			oLink.setAttribute("href", "#");
			oLink.onclick = function(event){
				var aClipOptions = new Array();
				var o = createFuncOption("Clear All", "", false);
				o.onclick = function(){
					oThis.onClearAllFunc();
					return false;
				}
				aClipOptions.push(o);
				
				event = event || window.event;
				DDMenu(this, event, aClipOptions, '80px');
				return false
			}
			oLink.onmouseout=function(){
				DDMenuDelayHide();
			}
			var oImg = document.createElement("img");
			oImg.setAttribute("align", "right");
			oImg.setAttribute("src", "image/clipboard/clip_more.gif");
			oLink.appendChild(oImg);
			var oSpan = document.createElement("span");
			oSpan.className = "clipfunc";
			oSpan.onmouseover = function(){
				this.className = "clipfuncover";
			}
			oSpan.onmouseout = function(){
				this.className = "clipfunc";
			}
			oSpan.appendChild(oLink);
			oTit.appendChild(oSpan);
		}
		var oDrag = document.createElement("div");
		oDrag.className = "draghandle clipdrag";
			var oImg = document.createElement("img");
			oImg.setAttribute("src", "image/clipboard/clip_drag.gif");
			oDrag.appendChild(oImg);
		oTit.appendChild(oDrag);
		var oSpn = document.createElement("span");
		oSpn.setAttribute("id", "clipcount");
		oTit.appendChild(oSpn);
		var oSpan = document.createElement("span");
		oSpan.title = "Copy relation details from other trees or search results and paste them into your tree.";
		oSpan.appendChild(document.createTextNode("Clipboard"));
		oTit.appendChild(oSpan);
		oHldr.appendChild(oTit);
		var oTip = document.createElement("div");
		oTip.className = "cliptip";
		oTip.appendChild(document.createTextNode("Click an item to paste:"));
		oHldr.appendChild(oTip);
		var oBdy = document.createElement("div");
		oBdy.setAttribute("id", "clipbody");
		oBdy.className = "clipbody";
		oHldr.appendChild(oBdy);
		oThis.clipboard = oHldr;
		document.body.appendChild(oHldr);
		if(Drag){
			Drag.init(oDrag, oHldr);
		}
	}
	
}



	//END OF CLIPBOARD FUNCTIONS
/******************************************************************
* 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 mnDDMenuWidth='165px' //default menu width
var msDDMenuBGColor='white'  //menu bgcolor
var mnDDMenuisappearDelay=250  //menu disappear speed onMouseout (in miliseconds)
var msDDMenuHideOnclick="yes" //hide menu when user clicks within menu?

/////No further editting needed

var mbDDMenuie4=document.all;
var mbDDMenuns6=document.getElementById&&!document.all

if (mbDDMenuie4 || mbDDMenuns6)
	document.write('<div id="dropmenudiv" style="visibility:hidden;display:none;width:'+mnDDMenuWidth+';background-color:'+msDDMenuBGColor+'" onMouseover="DDMenuClearHide()" onMouseout="DDMenuDynamicHide(event)"></div>');

function DDMenugetposOffset(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 DDMenushowhide(obj, e, visible, hidden, nDDMenuWidth){
	if (mbDDMenuie4 || mbDDMenuns6)
		dropmenuobj.style.left=dropmenuobj.style.top="-500px"
	if (nDDMenuWidth!=0){
		dropmenuobj.widthobj=dropmenuobj.style
		dropmenuobj.widthobj.width= (nDDMenuWidth>0) ? nDDMenuWidth : mnDDMenuWidth
	}
	
	e = e ? e : window.event;
	if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover"){
		obj.visibility=visible;
		obj.display = 'block';
	}else if (e.type=="click"){
		obj.visibility=hidden;
		obj.display = 'none';
	}
}

function DDMenuiecompattest(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function DDMenuclearbrowseredge(obj, whichedge){
	var edgeoffset=0
	if (whichedge=="rightedge"){
		var windowedge= mbDDMenuie4 && !window.opera? DDMenuiecompattest().scrollLeft+DDMenuiecompattest().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= mbDDMenuie4 && !window.opera? DDMenuiecompattest().scrollTop : window.pageYOffset
		var windowedge= mbDDMenuie4 && !window.opera? DDMenuiecompattest().scrollTop+DDMenuiecompattest().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 populateDDMenu(what){
	if (mbDDMenuie4 || mbDDMenuns6){
		if(what.length > 0){
			if(typeof(what[0]) == 'string'){
				dropmenuobj.innerHTML = what.join("");
			}else if(typeof(what[0]) == 'object'){
				removeChildnodes(dropmenuobj);
				for(var i = 0; i < what.length; i++){
					dropmenuobj.appendChild(what[i]);
				}
			}
		}
	}
}

function DDMenu(obj, e, menucontents, nDDMenuWidth){
	if(!nDDMenuWidth){
		nDDMenuWidth = 0;
	}
	if (window.event) event.cancelBubble=true
	else if (e.stopPropagation) e.stopPropagation()
	DDMenuClearHide()
	dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv
	populateDDMenu(menucontents)
	if (mbDDMenuie4||mbDDMenuns6){
		DDMenushowhide(dropmenuobj.style, e, "visible", "hidden", nDDMenuWidth)
		dropmenuobj.x			= DDMenugetposOffset(obj, "left")
		dropmenuobj.y			= DDMenugetposOffset(obj, "top");
		dropmenuobj.style.left		= dropmenuobj.x-DDMenuclearbrowseredge(obj, "rightedge")+"px"
		dropmenuobj.style.top		= dropmenuobj.y-DDMenuclearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px";
	}
	return DDMenuClickReturnValue();
}

function DDMenuClickReturnValue(){
	if (mbDDMenuie4||mbDDMenuns6) return false
	else return true
}

function DDMenucontains_ns6(a, b) {
	if(b && a){
		while (b.parentNode)
			if ((b = b.parentNode) == a)
				return true;
	}
	return false;
}

function DDMenuDynamicHide(e){
	if (mbDDMenuie4&&!dropmenuobj.contains(e.toElement))
		DDMenuDelayHide()
	else if (mbDDMenuns6&&e.currentTarget!= e.relatedTarget&& !DDMenucontains_ns6(e.currentTarget, e.relatedTarget))
		DDMenuDelayHide()
}

function DDMenuHide(e){
	if (typeof dropmenuobj!="undefined"){
		if (mbDDMenuie4||mbDDMenuns6)
			dropmenuobj.style.visibility="hidden"
	}
}

function DDMenuDelayHide(){
	if (mbDDMenuie4||mbDDMenuns6)
		delayhide=setTimeout("DDMenuHide()",mnDDMenuisappearDelay)
}

function DDMenuClearHide(){
	if (typeof delayhide!="undefined")
		clearTimeout(delayhide)
}

if (msDDMenuHideOnclick=="yes") document.onclick=DDMenuHide


// END OF AnyLink Drop Down Menu
/******************************************************************/
var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
var FFextraHeight=getFFVersion>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers
function calcHeight(iframe, offset) {
	var i = 0;
	var dyniframe=new Array()
			dyniframe[0] = getlayer(iframe);
			if (dyniframe[i] && !window.opera){
				dyniframe[i].style.display="block"
				if (dyniframe[i].contentDocument && dyniframe[i].contentDocument.documentElement.offsetHeight) //ns6 syntax
					dyniframe[i].height = dyniframe[i].contentDocument.documentElement.offsetHeight+FFextraHeight+offset; 
				else if (dyniframe[i].Document && dyniframe[i].Document.body.scrollHeight) //ie5+ syntax
					dyniframe[i].height = dyniframe[i].Document.body.scrollHeight +offset ;
			}
}

function validateint(item, min, max){
	var returnval = false
	if (item.value.length > 0)
	{
		if (!isaposnum(item))
			{			
			alert ("Please enter a number")
			}
		else if (parseInt(item.value) < min)
			{
			//alert("Number too small")
			returnval = true
			}
		else if (parseInt(item.value) > max)
			{
			alert ("Number too large")
			}
		else
			{
			returnval = true
			}
	}
	else
	{
	returnval = true
	}
	return returnval
	
}

function isaposnum(item){
	if (parseInt(item.value,10) == item.value){
		return true}
	else
		{
		return false
		}
}


/* new method of making things invisible using LKs class-skip */
/* better becuase setting the class to nothing means the element will revert to 
whatever styles it had previously eg block OR inline */

function hideObj(sID,bVisibilityOnly) {
	//this function works in tandem with showObj
	//may need to alter it to preserve class?
	var elem=document.getElementById(sID);
	if(elem) {
		//store orig display property
		var currStyle=getStyle(elem,'display');
		//if we've previously set an origdisp then preserve that
		var origdisp=elem.getAttribute('origdisp');
		if(origdisp==null) {
			elem.setAttribute('origdisp',currStyle);
		}
		elem.style.visibility='hidden';
		if(!bVisibilityOnly) {
			elem.style.display='none';
		}
	}
}

function showObj(sID) {
	var elem = document.getElementById(sID);
	if(elem) {
		var origDisp=elem.getAttribute('origdisp');
		
		elem.style.visibility='visible';
		if(origDisp!=null){
			//alert(sID+" was "+origDisp);
			elem.style.display=origDisp;
		}else{
			//leave as is?
		}
	}
}


function getStyle(oElm, strCssRule){
	var strValue = "";
	if(document.defaultView && document.defaultView.getComputedStyle){
		strValue = document.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule);
	}
	else if(oElm.currentStyle){
		strCssRule = strCssRule.replace(/\-(\w)/g, function (strMatch, p1){
			return p1.toUpperCase();
		});
		strValue = oElm.currentStyle[strCssRule];
	}
	return strValue;
}

function setClassName(node, newClass) {
	sClassName = node.getAttribute('className');
	if(sClassName) {
		node.setAttribute('className',newClass);
	}else{
		sClassName = node.getAttribute('class');
		node.setAttribute('class',newClass);
	}
}

//qs funtions
function PageQuery(q) {
	if(q.length > 1) this.q = q.substring(1, q.length);
	else this.q = null;
	this.keyValuePairs = new Array();
	if(q) {
		for(var i=0; i < this.q.split("&").length; i++) {
			this.keyValuePairs[i] = this.q.split("&")[i];
		}
	}
	this.getKeyValuePairs = function() { return this.keyValuePairs; }
	this.getValue = function(s) {
		for(var j=0; j < this.keyValuePairs.length; j++) {
			if(this.keyValuePairs[j].split("=")[0].toLowerCase() == s.toLowerCase())
				return this.keyValuePairs[j].split("=")[1];
		}
		return false;
	}
	this.getParameters = function() {
		var a = new Array(this.getLength());
		for(var j=0; j < this.keyValuePairs.length; j++) {
			a[j] = this.keyValuePairs[j].split("=")[0];
		}
		return a;
	}
	this.getLength = function() { return this.keyValuePairs.length; }	
}

function queryString(key){
	var page = new PageQuery(window.location.search);
	return unescape(page.getValue(key)); 
}

function clearTableRows(oTbl) {
	if(!oTbl) return;
	allRows=oTbl.rows.length;
	for(var i=1;i<allRows;i++) {
		oTbl.deleteRow(1);
	}
}