// JavaScript Document

// Generic email hiding routine from spam bots
// Copyright Edward Terry, http://www.emissary-consulting.co.uk, 8th August 2006
// You may copy this function but please keep the copyright notice with it
// The function takes 3 optional parameters
// 1 - The email prefix (e.g. "sales@", "myname@", etc). This is defaulted to "info" by the function if not supplied
// 2 - The text to display on the page (e.g. "myname"). If omitted, the full email address is shown
// 3 - The domain. This is defaulted in the function and is not usually supplied unless you want to display different domains
// Usage:
//		1. displayEmail();
//		   Result: info@mydomain.com
//		2. displayEmail('john.smith');
//		   Result: john.smith@mydomain.com
//		3. displayEmail('john.smith', 'Enquiries');
//		   Result: Email text link called Enquiries linked to john.smith@mydomain.com
//		4. displayEmail('john.smith', 'enquiries', 'myotherdomain.com');
//		   Result: Email text link called Enquiries linked to john.smith@myotherdomain.com
// Use cases 1-3 are the most common uses of this function

function displayEmail() {
	
	prefix	= "enquiries" ;
	url		= uri.dom ;
	
	// How many arguments passed?
	numargs = arguments.length ;

	if ( numargs >= 1 ) prefix 	= arguments[0] ;	// Set the new prefix to the first argument
	if ( numargs >= 2 ) text 	= arguments[1] ;	// Set the new text to the second argument
	if ( numargs >= 3 ) url 	= arguments[2] ;	// Set the new domain to the last argument

	// Build the default text to be displayed - only if not supplied as an argument
	if ( numargs <= 1 ) text	= prefix + "@" + url ;

	// Build the link
	mylink = "<a href='mailto:" + prefix + "@" + url + "'>" + text + "</a>" ;
	
	// Output
	document.write( mylink ) ;
	
}


// Current Page Reference
// Copyright Stephen Chapman, 1st Jan 2005
// You may copy this function but please keep the copyright notice with it
function getURL(uri) 
{
	uri.dir = location.href.substring(0, location.href.lastIndexOf('\/'));
	uri.dom = uri.dir.substring(uri.dir.indexOf('.')+1); 
	if (uri.dom.substr(0,7) == 'http:\/\/') uri.dom = uri.dom.substr(7);
	uri.path = ''; 
	var pos = uri.dom.indexOf('\/'); 
	if (pos > -1) {uri.path = uri.dom.substr(pos+1); uri.dom = uri.dom.substr(0,pos);}
	uri.page = location.href.substring(uri.dir.length+1, location.href.length+1);
	pos = uri.page.indexOf('?');
	if (pos > -1) {uri.page = uri.page.substring(0, pos);}
	pos = uri.page.indexOf('#');
	if (pos > -1) {uri.page = uri.page.substring(0, pos);}
	uri.ext = ''; 
	pos = uri.page.indexOf('.');
	if (pos > -1) {uri.ext =uri.page.substring(pos+1); 
	uri.page = uri.page.substr(0,pos);}
	uri.file = uri.page;
	if (uri.ext != '') uri.file += '.' + uri.ext;
	if (uri.file == '') uri.page = 'index';
	uri.args = location.search.substr(1).split("?");
	return uri;
}

var uri = new Object();
getURL(uri);