<!--

/**  Function: null clearInput(ele, val)
*    ---------------------------------------------------------------- 
*    Purpose:           clear an input
*    Arguments:         ele			- str, the name of the element to clear
*						val			- str, the default value that should be cleared
*    Returns/Assigns:   none
*/

function clearInput(ele, val){
	if(ele.value == val){
		ele.value='';
	}
}


/**  Function: null openWin(windowURL, windowName, windowFeatures)
*    ---------------------------------------------------------------- 
*    Purpose:           opens a new window and sets its properties
*    Arguments:         windowURL			- str, the url
*						windowName			- str, the window name
*						windowFeatures		- str, the features of the window
*    Returns/Assigns:   none
*/

function openWin(windowURL, windowName, windowFeatures){
	window.open(windowURL, windowName, windowFeatures);
}


/**  Function: null writeEmail(user, domain, subject, text)
*    ---------------------------------------------------------------- 
*    Purpose:           writes an email address in a mailto link
*						if no 'text' is supplied it just writes the <a href="mailto:user@domain">
*						if 'text' is supplied it writes <a href="mailto:user@domain">text</a>
*						if 'subject' is supplied it writes <a href="mailto:user@domain?subject=subject">text</a>
*    Arguments:         user			- str, the username for the email address
*						domain			- str, the domain name of the email address
*						subject			- str, any subject line required
*						text			- str, text for the link
*    Returns/Assigns:   writes a mailto link
*/

function writeEmail(user, domain, subject, text){
	// open up a mailto and combine the user and domain into an email address
	document.write('<a href="mailto:' + user + '@' + domain);
	if(subject){
		// if there's a subject tack it on
		document.write('?subject=' + subject);
	}
	document.write('">');
	if(text){
		// if there's text for the link add it and close the link
		document.write(text + '</a>');
	}
}


/**  Function: null addToFavourites()
*    ---------------------------------------------------------------- 
*    Purpose:           add a link or text for adding to favourites
*    Arguments:         none
*    Returns/Assigns:   writes html to screen
*/

function addToFavourites(){
	if(document.all){
		document.write('<a href="javascript:window.external.AddFavorite(document.location.href, document.title);" class="book">Bookmark</a>'); 
	} else{ 
		document.write('<span class="book">Press Ctrl+D to bookmark</span>');
	}
}


function killPreviewMode(){
	alert('I am going to kill the preview mode');
}


/**  Function: null toggleDisplay(ele)
*    ---------------------------------------------------------------- 
*    Purpose:           toggle the display / hide property of an element
*    Arguments:         ele			- str, the name of the element
*    Returns/Assigns:   none
*/

function toggleDisplay(ele){
	var el = document.getElementById(ele);
	if(el.style.display == 'none'){
		el.style.display = '';
	}else{
		el.style.display = 'none';
	}
}

/**  Function: null toggleSelects()
*    ---------------------------------------------------------------- 
*    Purpose:           toggle the visibility of all selects on a page
*    Arguments:         none
*    Returns/Assigns:   none
*/

function toggleSelects(){
	var sels = document.getElementsByTagName('select');
	for(i=0;i<sels.length;i++){
		if(sels[i].style.visibility == 'visible' || sels[i].style.visibility == ''){
			sels[i].style.visibility = 'hidden';
		}else{
			sels[i].style.visibility = 'visible';
		}
	}
}

/**  Function: null hideSelects(show)
*    ---------------------------------------------------------------- 
*    Purpose:           alter the visibility of all selects on a page
*    Arguments:         show		- bln, whether to show or hide the selects
*    Returns/Assigns:   none
*/

function hideSelects(show){
	var sels = document.getElementsByTagName('select');
	for(i=0;i<sels.length;i++){
		if(show){
			sels[i].style.visibility = 'visible';
		}else{
			sels[i].style.visibility = 'hidden';
		}
	}
}


// -->