//>> compatibility:
var IE4 = (document.all && !document.getElementById) ? 1 : 0;
var NS4 = (document.layers) ? 1 : 0;
var IE5 = (document.all && document.getElementById) ? 1 : 0;
var NS6 = (document.getElementById && !document.all) ? 1 : 0;
var NS = ((NS4 + NS6) > 0) ? 1 : 0;

function DOMswitch(){
	if(is.ns4) {
	  doc = "document";
	  sty = "";
	  htm = ".document"
	} else if(is.ie4) {
	  doc = "document.all";
	  sty = ".style";
	  htm = ""
	};
};
//<< compatibility

//>>START divShowHide(arg)
// this does not work in NS...
// arg = [divName,0or1]
// EXAMPLE OF USE: <TAG onmouseover="divShowHide(['layername1',1])"></TAG>
function divShowHide(arg){
var layerName = arg[0];
var showhide = arg[1]; // 0 = hide, 1 = show
var parentDiv; // enables you to setup this menu inside other DIVs
	showhide = ["hidden", "visible"][showhide] ;

	if (document.layers)  {
		parentDiv = document.layers;
		parentDiv[layerName].visibility=showhide;
	}
	else {
		parentDiv = document.all;
		parentDiv[layerName].style.visibility=showhide;
	};
};
//<<END divShowHide(arg)

//>>START MM_reloadPage(init)
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//<<END MM_reloadPage(init)



function tx2num(arg,dec){
// converts arg to a num and returns num
// dec, if present, is the number of decimal places you want.
// unless the conversion goes wrong in which case it returns 
	//	the number-like string "00000" to attract the attention of the user!
if(arg==""){arg="0"};
if(arg==null){arg="0"};
if(arg==0){arg="0"};
//the user might put a comma intothe number and we need to allow for this:
arg=arg.split(",").join("");
// we also allow for other possible error characters:
arg=arg.split("£").join("");
arg=arg.split("$").join("");
arg=arg.split("A").join("");

arg=parseFloat(arg);
if (isNaN(arg)){arg="00000";}
	else
	{
	arg=arg+".0";
	arg=arg.split(".");
	if (dec){
		arg[1]=arg[1]+"00000000000000000000000000000";
		arg[1]=arg[1].substr(0,dec);
		};
	arg=arg[0]+"."+arg[1];
	};
return arg;
};

function percCheck(){
// checks percentage figs are +ve and less than 100
// not operational yet...
1
};






//start uphex
function uphex(arg1,arg2){
(str2hex(arg1),str2hex(arg2))
return hexSum(str2hex(arg1),str2hex(arg2));
};//end uphex

// start hex functions  ///////////////////////////////////////////////////////
function str2hex(arg){
	var argHex = "";
// assume arg is str or num and only use 1st 16 chars
	arg = ""+arg+"";
	arg = arg.substr(0,16);

	for(i=0;i<(16 - arg.length);i++){
		argHex=argHex + "00" ;
	};
		
	for(i=0;i<arg.length;i++){
			argHex=argHex + arg.charCodeAt(i).toString(16);
		};
return argHex;
};

function hexSum(a,b){
// adds two  8 char hex strs
// returns 9 char str
// eg  (parseInt("0x"+"1fffffffe") + parseInt("0x"+"1")).toString(16) returns "1ffffffff"
a = (parseInt("0x"+ a) + parseInt("0x"+b)).toString(16);
return ("0000000000".substr(0, 9 - a.length) + a);
};

function hexAdd(a,b){
// adds two 32 char hex strs with no loss of formatting
// eg  (parseInt("0x"+"1ffffff1fffffffe") + parseInt("0x"+"1")).toString(16) returns "1ffffff1ffffffff"
var ha,hb,hAra,hArb,hAr;

//a = "1ffffff1fffffffe";
//b = "1";
a = "000000000000000000000000000000000000".substr(0, 32 - a.length) + a;//alert("a="+a);
b = "000000000000000000000000000000000000".substr(0, 32 - b.length) + b;//alert("b="+b);
ha = a.substr(0,8) + "," + a.substr(8,8) + "," + a.substr(16,8) + "," + a.substr(24,8);
hAra = ha.split(",");
//alert(hAra.join("  --  "))
;
hb = b.substr(0,8) + "," + b.substr(8,8) + "," + b.substr(16,8) + "," + b.substr(24,8);
hArb = hb.split(",");
//alert(hArb.join("  --  "))
;
hAr = "00000000,00000000,00000000,00000000";
hAr = hAr.split(",");

//alert("hexsum="+ hexSum(hAra[0],hArb[0]));
for (i=0;i<4;i++){
	hAr[i] = hexSum(hAra[i],hArb[i]);
	//alert(hAr.join("  --  "));
};
for (i=3;i>0;i--){
	hb = hAr[i];
	ha = hAr[i-1];
	ha = hexSum(ha , hb.substr(0,1));
	hb = hb.substr(1);
	ha = ha + hb;
	hAr[i-1] = ha;
	//alert(hAr[i-1]);
	//alert(i);
};//hexAdd
//alert(hAr.join("  --  "));
;
//ha = hAr[0] ;
// lose first "0"s:
ha="0000000000000000000000000000000000" + ha;
i=0;
while  (ha.charAt(i)=="0"){
	i++;
	hb=ha.substr(i);
//	alert(hb);
};
ha=hb.toUpperCase();
if((ha.length)==0){ha="00"};
if((ha.length%2)==1){ha="0"+ha};


//alert("return" + ha);
return ha ;
};

function rwCookie(cname,cval){
//alert(cname);
	if (cval==undefined){
// read
		var allcookies=document.cookie;
		cval = allcookies.indexOf(cname + "=");
		if (cval != -1){
			var start = cval+cname.length+1;
			var end = allcookies.indexOf(";",start);
			if (end == -1)	 end = allcookies.length;
			cval = allcookies.substring(start,end);
		};
		//alert(cval);
		return cval;
	};
	else {
//write
		document.cookie=cname + "=" + cval;
	};
	
};// cval = unescape(cval);
// end hex functions ///////////////////////////////////////////////




//MM button rollover fun START
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];}
};
//MM button rollover fun END