/* Web Design and Programming by Cube Connection Ltd, Copyright 2006 - www.CubeConnection.co.uk */
var intImageID = 0;
var intFormID = 0;
var blnShowError = false;

function ShowEmail(username, hostname, friendlyname, displaystyle) {
	var linktext;
	if (friendlyname == "") {
		if (displaystyle == "") {
			linktext = username + "@" + hostname;
			document.write("<a href=" + "mail" + "to:" + username + "@" + hostname + ">" + linktext + "</a>");
		}
		else {
			linktext = username + "@" + hostname;
			document.write("<a href=" + "mail" + "to:" + username + "@" + hostname + " class='" + displaystyle + "'>" + linktext + "</a>");
		}
	}
	else {
		if (displaystyle == "") {
			linktext = username + "@" + hostname;
			document.write("<a href=" + "mail" + "to:" + username + "@" + hostname + ">" + friendlyname + "</a>");
		}
		else {
			linktext = username + "@" + hostname;
			document.write("<a href=" + "mail" + "to:" + username + "@" + hostname + " class='" + displaystyle + "'>" + friendlyname + "</a>");
		}
	}
	return true;
}

function HSFormsPopup() {
	hs.Expander.prototype.onAfterGetContent = function () {
		if(Left(this.a.id,10)=='uploadlink') {
			this.content.innerHTML = this.content.innerHTML.replace(/{xxx}/, this.custom.xxx);
			this.content.innerHTML = this.content.innerHTML.replace(/{yyy}/g, this.custom.yyy);
			if(intFormID==1 && blnShowError) {
				this.content.innerHTML = this.content.innerHTML.replace(/none;/, 'block;'); }
			else {
				this.content.innerHTML = this.content.innerHTML.replace(/block;/, 'none;'); }
		}
	}
	hs.Expander.prototype.onAfterClose = function () {
		blnShowError = false; //seen the error so set flag so we don't see again!
	}
	if(intFormID==1) {
		hs.addEventListener(window, "load", function() {
			document.getElementById('uploadlink'+intImageID).onclick(); });
		}
}

function HSPrint() {
	hs.Expander.prototype.printHtml = function () {
		var pw = window.open("about:blank", "_new");
		pw.document.open();
		pw.document.write(this.getHtmlPrintPage());
		pw.document.close();
		return false;
	};
	hs.Expander.prototype.getHtmlPrintPage = function() {
    // We break the closing script tag in half to prevent
    // the HTML parser from seeing it as a part of
    // the *main* page.
    var body = hs.getElementByClass(this.innerContent, 'DIV', 'highslide-body') || this.innerContent;

    return "<html>\n" +
        "<head>\n" +
        "<title>Temporary Printing Window</title>\n" +
        "<link rel='stylesheet' type='text/css' href='/includes/site_screen.css' media='screen, tv' />\n" +
        "<link rel='stylesheet' type='text/css' href='/includes/site_print.css' media='print' />\n" +
        "<script>\n" +"function step1() {\n" +
        "  setTimeout('step2()', 10);\n" +
        "}\n" +
        "function step2() {\n" +
        "  window.print();\n" +
        "  window.close();\n" +
        "}\n" +
        "</scr" + "ipt>\n" +
        "</head>\n" +
        "<body onLoad='step1()'>\n" +
        body.innerHTML +
        "</body>\n" +
        "</html>\n";
	};
}

function Left(str, n)
/***
  IN: str - the string we are LEFTing
      n - the number of characters we want to return
  RETVAL: n characters from the left side of the string
***/
{
	if (n <= 0)     // Invalid bound, return blank string
		return "";
	else if (n > String(str).length)   // Invalid bound, return
		return str;                // entire string
	else // Valid bound, return appropriate substring
		return String(str).substring(0,n);
}
