/* 
Template name	:	javascript.js
Author			:	Iris
Created			:	06/04/2009
Last modified	:	27/04/2009
Modified by		:	Iris
Usage			:	Called by display templates
Purpose			:	Global javascript functions
*/

// Bookmark this page
function BookMarkPage (url, title) {	
	if (window.sidebar) { // firefox
		window.sidebar.addPanel(title, url, '');
	} else if (window.opera && window.print) { // opera
		var elem = document.createElement('a');
		elem.setAttribute('href', url);
		elem.setAttribute('title', title);
		elem.setAttribute('rel', 'sidebar');
		elem.click();
	} else if (document.all) { // ie
		window.external.AddFavorite(url, title);
	}
}
// popup ok/cancel message box
function CheckFirst (message, url) {
	var popUpBox = confirm(message);
	if	(popUpBox == 1) {
		self.location = url;
	}
}
// check captcha field is filled in
function CheckCaptcha (formID) {
	if (document[formID].s_Captcha.value == "") {
		alert('Please enter the numerical validation code shown in the image');
		return false;
	} else if (document[formID].s_Captcha.value.length != 6) {
		alert('Validation code should be 6 numbers');
		return false;
	}
}
// validtate email address
function isEmail(string) {
	if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1) {
		return true;
	} else {
		return false;
	}
}
// Script		: share.js
// Author		: Dale Morrell <dalemorrell@irisassociates.com>
// Created		: 06/04/2009
function toggle_visibility(id) {
	var e = document.getElementById(id);
	if(e.style.display == 'block')
		e.style.display = 'none';
	else
		e.style.display = 'block';
}

