// substitute for target="_blank" which XHTML 1.0 strict doesn't allow: sort of a
// popup window routine except the window has all features and no specified size
function blank (url) {
	var blankWin = window.open(url,'_blank','menubar=yes,toolbar=yes,location=yes,directories=yes,fullscreen=no,titlebar=yes,hotkeys=yes,status=yes,scrollbars=yes,resizable=yes');
}


function checksearch (form) {
	if (!form.searchterm.value.match (/\w/)) {
		alert ('Please enter something to search for!');
		form.searchterm.focus();
		return false;
	}
	
	return true;
}


// mailto-hider
// arguments: text for link (or 'addr'); number of elements before the @;
// elements separated by @ or .
// returns: nothing
function noSpam() {
	var link = noSpam.arguments[0];	// text for link
	var pre = noSpam.arguments[1];	// number of elements before the @

	var myat = String.fromCharCode(64);		// @
	var mydot = String.fromCharCode(46);	// .
	
	// initialise the address string
	var addr = '';
	
	// loop through the elements of the address (starting at arguments[2])
	for (var i = 2; i < noSpam.arguments.length; i++) {
		// if we've already started the string, put a separator before the next element
		if (addr) {
			// if we've reached the element numbered the same as 'pre' we need the @
			// otherwise it's a .
			addr += (i == pre + 2) ? myat : mydot;
		}
		// then add the element itself
		addr += noSpam.arguments[i];
	}
	
	// initialise a string for the whole tag (or just address)
	var str = '';
	// if the first argument isn't an empty string we do the tag
	if (link) {
		// start with the mailto: part
		str = '<a href="mailto:' + addr + '">';
		// if the first argument is 'addr' we spell out the address verbatim
		// otherwise we put the text from the argument
		str += (link == 'addr') ? addr : link;
		// close the tag
		str += '<\/a>';
	}
	// first argument empty so we simply regurgitate the address as text
	else {
		str = addr;
	}
	
	// write whatever we've ended up with into the page
	document.write (str);
}


// open popup window for audio
// arguments: none (for now)
// returns: nothing
var audWin;
function play () {
	audWin = window.open('audiopop.php', 'audio', 'width=400,height=200');
	audWin.focus();
}


// open popup window for video
// arguments: filename, title, width and height of movie
// returns: nothing
var popviewer;
function popvideo (file, title, w, h) {
	// add to width and height for window size
	var ww = w + 80;
	var wh = h + 200;
	popviewer = window.open ('videopop?f=' + file + '&t=' + title + '&w=' + w + '&h=' + h, 'video', 'scrollbars,resizable,width=' + ww + ',height=' + wh);
	popviewer.focus();
}

