
/*
 * A simple utility function to confirm accessing a URL. It will display
 * the given message in a alert box and proceed to the given URL if the
 * user clicks OK.
 */
function confirmUrl(message, url) {
	if(confirm(message)) 
		location.href = url;
}



/**
  * Selects the text in a textbox. Use such as:
  * <input type="text" name="userId" maxlength="20" value="user name" onclick="removeText(this)"/>
  */
function selectText(element) {
	element.select();
}


/**
  * Removes the text in a textbox. Use such as:
  * <input type="text" name="userId" maxlength="20" value="user name" onclick="removeText(this)"/>
  */
function removeText(element) {
	element.value = "";
}  



/*
 * Tries to copy the given string into the clipboard. If that fails, displays
 * a dialog.
 */	
function copyToClipboard(content) {
	if(window.clipboardData && clipboardData.setData) {
		window.clipboardData.setData("Text", content);
	}
	else {
		prompt('Sorry, your browser does not support copying data to the clipboard. Please copy the text from here by hand.\nThen click any button.', content);
	}
}



function hideDivChildren(parentId) {
	parent = document.getElementById(parentId);
	children = parent.getElementsByTagName('div');
	
	for(i=0; i<children.length; i++) {
		children[i].className = "invisible";
	}	
}


function toggleVisibility(id) {
	element = document.getElementById(id);
	if(element != null) {
		if(element.className == "visible")
			element.className = "invisible";
		else
			element.className = "visible";
	}
}



function showTab(sTabsDivId, sTabContentsDivId, nTabIndex) {
	// Set all tabs to inactive
	div = document.getElementById(sTabsDivId);
	children = div.getElementsByTagName('span');
	for(i=0; i<children.length; i++) {
		children[i].className = "tab";
	}
	
	// Set new tab as active
	if(nTabIndex != null && nTabIndex != -1) {
		e = document.getElementById(sTabsDivId+"_"+nTabIndex);
		if(e != null)
			e.className = "tabActive";
	}
	
	
	// Set all tab contentss to invisible
	div = document.getElementById(sTabContentsDivId);
	children = div.getElementsByTagName('div');
	for(i=0; i<children.length; i++) {
		children[i].className = "invisible";
	}
	
	// Set new tab as active
	if(nTabIndex != null && nTabIndex != -1) {
		e = document.getElementById(sTabContentsDivId+"_"+nTabIndex);
		if(e != null)
			e.className = "visible";
	}
}



function submitForm(sFormId) {
	form = document.getElementById(sFormId);
	if(form != null) {
		form.submit();
	}
	else
		alert("Can't find form element with name ["+sFormId+"]");
}

<!--
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];}
}
//-->


<!-- hide this script from non-javascript-enabled browsers
     function popupWindow(popupURL, width, height, scrollbars) {
        // Provide default values
        if(width == null) width = 600;
        if(height == null) height = 500;
        if(scrollbars == null) scrollbars = 'yes';
	   
        // Open window and bring to front
        win = window.open(popupURL, 'popupWin', 'toolbars=0,top=50,left=50,resizable=no,width='+width+',height='+height+',scrollbars='+scrollbars);   
        win.focus();
    } 
// stop hiding -->


<!-- // hidden email addresses
// (obfuscator encription generated at www.codehouse.com/webmaster_tools/email_obfuscator/)

// TRACY EMAIL (V1) - using name as link
function tracymail() {
	var linkstart = '<a href="mailto:';
	var mailname = '\u0074\u0072\u0061\u0063\u0079';
	var domain = '\u0063\u006c\u0061\u0073\u0073\u0069\u0063\u0077\u0069\u006e\u0065\u0074\u0072\u0061\u0069\u006c' + '\u002e\u0063\u006f\u002e\u006e\u007a';
	var subject = '?subject=Enquiry%20from%20website">';
	var linkend = '</a>';
document.write(linkstart + mailname + "\u0040" + domain + subject + mailname + "\u0040" + domain + linkend);
}

// TRACY EMAIL (V2) - using name as link
function tracymail2() {
	var linkstart = '<a href="mailto:';
	var mailname = '\u0074\u0072\u0061\u0063\u0079';
	var domain = '\u0063\u006c\u0061\u0073\u0073\u0069\u0063\u0077\u0069\u006e\u0065\u0074\u0072\u0061\u0069\u006c' + '\u002e\u0063\u006f\u002e\u006e\u007a';
	var subject = '?subject=Enquiry%20from%20website">';
	var linkend = '</a>';
document.write(linkstart + mailname + "\u0040" + domain + subject + "Contact us" + linkend);
}

// FOR TESTING ORDER FORM (Martin (HoHouse) email address)
function regformtest() {
	var inputstart = '<input type="hidden" name="recipient" value="';
	var mailname = '\u006d\u0061\u0072\u0074\u0069\u006e';
	var domain = '\u0068\u006f\u0074\u0068\u006f\u0075\u0073\u0065' + '\u002e\u0063\u006f\u002e\u006e\u007a';
	var inputend = '" />';
document.write(inputstart + mailname + "\u0040" + domain + inputend);
}