
var tld_ = new Array();
tld_[0] = "com";
tld_[1] = "org";
tld_[2] = "net";
tld_[3] = "ws";
tld_[4] = "info";
tld_[5] = "ca";
tld_[10] = "co.uk";
tld_[11] = "org.uk";
tld_[12] = "gov.uk";
tld_[13] = "ac.uk";
var topDom_ = 13;
var m_ = "mailto:";
var a_ = "@";
var d_ = ".";


var popUpWin=0;
function popUpWindow(URLStr, left, top, width, height)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}

function formatphonenumber(raw_num)
{
	if (raw_num.value.length==3) {raw_num.value=raw_num.value+'-';}
}
function formattollfreenumber(raw_num)
{
	if (raw_num.value.length==1) {raw_num.value=raw_num.value+' ';}
	if (raw_num.value.length==2) {raw_num.value=raw_num.value+'(';}
	if (raw_num.value.length==6) {raw_num.value=raw_num.value+')';}
	if (raw_num.value.length==7) {raw_num.value=raw_num.value+' ';}
	if (raw_num.value.length==11) {raw_num.value=raw_num.value+'-';}
}
function formatphonenumber2(raw_num)
{
	if (raw_num.value.length==3) {raw_num.value=raw_num.value+'-';}
	if (raw_num.value.length==7) {raw_num.value=raw_num.value+'-';}
}


function formatphonenumber2(raw_num, evt)
{
	var charCode = (evt.which) ? evt.which : event.keyCode;
	if(charCode < 48 || charCode > 57)
	{
		raw_num.value = raw_num.value.substring(0, raw_num.value.length - 1);
	}
	if (raw_num.value.length==3) {raw_num.value=raw_num.value+'-';}
	if (raw_num.value.length==7) {raw_num.value=raw_num.value+'-';}
}

function mail(name,dom,tl,params)
{
	var s = e(name,dom,tl);
	document.write('<a href="'+m_+s+params+'">'+s+'</a>');
}
function mail2(name,dom,tl,params,display)
{
	document.write('<a href="'+m_+e(name,dom,tl)+params+'">'+display+'</a>');
}
function e(name, dom, tl)
{
	var s = name+a_;
	if (tl!=-2)
	{
		s+= dom;
		if (tl>=0)
			s+= d_+tld_[tl];
	}
	else
		s+= swapper(dom);
	return s;
}
function swapper(d)
{
	var s = "";
	for (var i=0; i<d.length; i+=2)
		if (i+1==d.length)
			s+= d.charAt(i)
		else
			s+= d.charAt(i+1)+d.charAt(i);
	return s.replace(/\?/g,'.');
}

function create_box(boxid,inside, color,width,height, background){		
	titlecolor = "black"; 						
	opacitytitle = 45;   						
	if(!width){
	width = 500;            					
	height = 325;}								
	if(inside.indexOf(".htm") > inside.length -6)
	inside = "<iframe frameborder=0 name=\"box\" width="+(width-10)+" height="+(height-30)+" src=\""+inside+"\" scrolling=\"no\" ></iframe>"; 
	if(!color)
	color = "silver";				
	var thisspan1 = eval(boxid); 
	var thisspan = eval(boxid + ".style"); 	
	thisspan.visibility="visible";
	output = "<table cellpadding=0 cellspacing=0 width=" + width + " height=" + height + " border=1>";
	output += "<tr><td width=100% colspan=2><table cellpadding=1 cellspacing=1";   
	if(background)output += "style='background-color:\" " + background + "\"'";
	output += " width=100% height=100% bgcolor='"+color+"'><tr><td height=100% width=100% valign=top>"+ inside+"</td></tr></table></td></tr>";
	thisspan1.innerHTML = output;
}

function bookmarksite(title,url){
	if (window.sidebar) // firefox
		window.sidebar.addPanel(title, url, "");
	else if(window.opera && window.print){ // opera
		var elem = document.createElement('a');
		elem.setAttribute('href',url);
		elem.setAttribute('title',title);
		elem.setAttribute('rel','sidebar');
		elem.click();
	} 
	else if(document.all)// ie
		window.external.AddFavorite(url, title);
}

function filterNum(str) {
re = /^\$|,/g;
// remove "$" and ","
return str.replace(re, "");
}


function closebox(boxid)
{
	var thisspan = eval(boxid); 
	thisspan.style.visibility="hidden";
}

function show_box(boxid,msg,clr,ht,wt,bk)
{	
	create_box(boxid,msg,clr,ht,wt,bk);
}


imgout=new Image(9,9);
imgin=new Image(9,9);

/////////////////BEGIN USER EDITABLE///////////////////////////////
	imgout.src="/gfx/u.gif";
	imgin.src="/gfx/d.gif";
///////////////END USER EDITABLE///////////////////////////////////

//this switches expand collapse icons
function filter(imagename,objectsrc){
	if (document.images){
		document.images[imagename].src=eval(objectsrc+".src");
	}
}


function show_calendar()
{
	document.getElementById("calendar").style.display = 'block';
}

function hide_calendar()
{
	document.getElementById("calendar").style.display = 'none';
}

function filterNum(str) {
          re = /\$|,|@|#|~|`|\%|\*|\^|\&|\(|\)|\+|\=|\[|\-|\_|\]|\[|\}|\{|\;|\:|\'|\"|\<|\>|\?|\||\\|\!|\$|\./g;
          // remove special characters like "$" and "," etc...
          return str.replace(re, "");
     }


function removeSpaces(string) {
		var tstring = "";
		string = '' + string;
		splitstring = string.split(" ");
		for(i = 0; i < splitstring.length; i++)
		tstring += splitstring[i];
		return tstring;
	}	
	
	

function showhide(id){ 
	if (document.getElementById){ 
		obj = document.getElementById(id); 
			if (obj.style.display == "none")
			{ 
				obj.style.display = ""; 
			} 
			else 
			{ 
				obj.style.display = "none"; 
			} 
	} 
} 

function show(id){ 
	if (document.getElementById){ 
	obj = document.getElementById(id); 
		if (obj.style.display == "none")
		{ 
		obj.style.display = ""; 
		} 
	} 
} 

function toProperCase(obj)
{
	s = obj.value;
  	obj.value =  s.toLowerCase().replace(/^(.)|\s(.)/g, 
          function($1) { return $1.toUpperCase(); });
}

function toTitleCase(obj) 
{ 
	str = obj.value;
    obj.value = str.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();}); 
}

function isNumberKey(evt)
  {
     var charCode = (evt.which) ? evt.which : event.keyCode
     if (charCode > 31 && (charCode < 48 || charCode > 57))
        return false;

     return true;
  }
  
  
// Start Tool tip text  
  
var offsetxpoint=-60 //Customize x offset of tooltip
var offsetypoint=20 //Customize y offset of tooltip
var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
if (ie||ns6)
var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function ddrivetip(thetext, thecolor, thewidth){
if (ns6||ie){
if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
tipobj.innerHTML=thetext
enabletip=true
return false
}
}

function positiontip(e){
if (enabletip){
var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
//Find out how close the mouse is to the corner of the window
var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20
var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20

var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<tipobj.offsetWidth)
//move the horizontal position of the menu to the left by it's width
tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px"
else if (curX<leftedge)
tipobj.style.left="5px"
else
//position the horizontal position of the menu where the mouse is positioned
tipobj.style.left=curX+offsetxpoint+"px"

//same concept with the vertical position
if (bottomedge<tipobj.offsetHeight)
tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px"
else
tipobj.style.top=curY+offsetypoint+"px"
tipobj.style.visibility="visible"
}
}

function hideddrivetip(){
if (ns6||ie){
enabletip=false
tipobj.style.visibility="hidden"
tipobj.style.left="-1000px"
tipobj.style.backgroundColor=''
tipobj.style.width=''
}
}

document.onmousemove=positiontip

// End Tool tip text  

