/* Common javascript functions in here */
/*function externalLinks() 
{
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) 
	{
		var anchor = anchors[i];
		var anchorVal = anchor.getAttribute("href");
		var anchorText = anchorVal.substring(0,7);
		
		if (anchorText == 'http://')
		{
			// make sure that link is not local
			var domain = 'http://'+ this.location.hostname;
			var domainlen = domain.length;
			if(anchorVal.substring(0,domainlen) != domain) anchor.target = "_blank";
			domain = domain.replace('www.','',domain);
			domainlen = domain.length;
			if(anchorVal.substring(0,domainlen) != domain) anchor.target = "_blank";
		}
	}
}
window.onload = externalLinks; */

function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\s)"+searchClass+"(\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

function checkSearch(f)
{
	if(!f.search.value)
	{
		alert("Please enter a search term");	
		f.search.focus();
		return false;
	}
}

function signupcheck(f,domain)
{
	if(!f.c_forename.value)
	{
		alert('Please enter your forename');
		f.c_forename.focus();
		return false;
	}	
	if(!f.c_name.value)
	{
		alert('Please enter your surname');
		f.c_name.focus();
		return false;
	}
	if(!f.c_email.value)
	{
		alert('Please enter your email address');
		f.c_email.focus();
		return false;
	}
	
	
	if (f.c_email.value.match(/\b@aol.\b/i)) 
	{
		alert('AOL Users:\n\nIf you do not receive the confirmation message within a few minutes of signing up, please check your spam folder just in case the confirmation email got delivered there instead of your inbox. If so, select the confirmation message and click This is Not Spam, which will allow future messages to get through.\n\nWe strongly recommend that you do the following to avoid accidentally filtering our future messages:\n\n1. Click Mail in the toolbar at the top of your AOL window\n2. Select Block Unwanted Mail\n3. Click Custom Sender List\n4. Select Allow only the senders and domains listed below\n5. Enter this domain: '+domain+'\n6. Click Save.');
	}

	if(!f.c_tel1.value && !f.c_tel2.value && !f.c_tel3.value)
	{
		alert('Please enter at least one phone number');
		f.c_tel1.focus();
		return false;
	}
	
	if(!f.ad_address1.value)
	{
		alert('Please enter line one of your address');
		f.ad_address1.focus();
		return false;
	}
	if(!f.ad_town.value)
	{
		alert('Please enter your town/city');
		f.ad_town.focus();
		return false;
	}
	if(!f.ad_postcode.value)
	{
		alert('Please enter your postcode/ZIP');
		f.ad_postcode.focus();
		return false;
	}
	if(!f.ad_county.value)
	{
		alert('Please enter your county/state');
		f.ad_county.focus();
		return false;
	}
	if(!f.ad_country.value)
	{
		alert('Please enter your country');
		f.ad_country.focus();
		return false;
	}
}

function currAlert(val)
{
alert('Please note that currencies other than GBP are provided for reference only, all transactions will be completed in GBP.');
}

// JavaScript Document
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function makeLightboxGallery()
{
	// scans file for images with rel=lightbox and adds them to lightbox gallery
}