var Server = "www.thesagegateshead.";
var pdf = ".pdf";
var mailingServer = "tickets.thesagegateshead.org";

function openJbox(strPath)
{
	window.open(strPath,"juke","width=390,height=272");
}

function jbInit() 
{
	if(document.getElementById) {
		//var jBoxLink = document.getElementById("jBox");
		//if(jBoxLink) {
		//	jBoxLink.onclick = function() { openJbox(this.href); return false; };

			// whilst we're looking at the jukebox link, extract from the
			// href property the name of the server this js code is running from.
			// This value is then used to replace the Server var defined above
			// and is subsequently used in the code below to apply a target="_bank"
			// attribute to any anchor tag in a page that links to an external website
			// i.e. any anchor tags that have the Server var in their href will
			// be classed as relative links and wont have the target attribute applied
		//	var thisServerHref = jBoxLink.href;
		//	if(thisServerHref.indexOf("http://") > -1) {
		//		thisServer = thisServerHref.substring(7,thisServerHref.indexOf("/",7));
		//		Server = thisServer;
		//	}
		//}

	// ** modify onfocus behaviour of the search input box on each page to clear contents on click
	var searchFld = document.getElementById("searchStr");
	if( searchFld )
		searchFld.onfocus = function() { this.value = ""; };
	}

	// ** search for all anchor tags and for those that reference an external website
	// (must start with http://) modify behaviour so that they open in a new window
	
	if(document.getElementsByTagName){
		var links = document.getElementsByTagName("a");
		for(var i=0;i<links.length; i++){
			if(((links[i].href.indexOf(Server) <= 0) && (links[i].href.indexOf(mailingServer) <= 0))||links[i].href.indexOf(pdf) > 0)
				links[i].target = "_blank";
		}
	}

}