


//  Function to swap  the main product images.
function prodimageswap(imageid, imagefile) {
    document.getElementById(imageid).src = imagefile;
}

/***********************************************
* Bookmark site script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

/* Modified to support Opera */

function bookmarksite(title,url){
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);
}


//  define function to open Seasalt pages in a pop-up
function SeasaltPopUp(sUrl, Name, nWidth, nHeight)
  	{  
	window.open(sUrl, Name, 'width=' + nWidth + ',height=' + nHeight + ',top=10,scrollbars, resizable');
	}
// define function to validate tell a friend form routine
	function tellafriend() {
		if (document.forms) {
			if (document.forms["frmtellafriend"].visitorname.value.length == 0) {
				alert("You must enter your name in the field provided.");
				document.forms["frmtellafriend"].visitorname.focus();
				return false;
			}
			if (!doValidateMail(document.forms["frmtellafriend"].visitormail)) {
				document.forms["frmtellafriend"].visitormail.select();
				document.forms["frmtellafriend"].visitormail.focus();
				return false;			
			}
			if (document.forms["frmtellafriend"].friendname.value.length == 0) {
				alert("You must enter your friend's name in the field provided.");
				document.forms["frmtellafriend"].friendname.focus();
				return false;
			}
			if (!doValidateMail(document.forms["frmtellafriend"].friendmail)) {
				document.forms["frmtellafriend"].friendmail.select();
				document.forms["frmtellafriend"].friendmail.focus();
				return false;			
			}
			return true;
		} 
	}	
//  define function to validate family form routine
	function valfamily() {
		if (document.forms) {
			/* if (document.forms["frmfamily"].title.value.length == 0) {
				alert("You must select a choice from the Titles dropdown.");
				document.forms["frmfamily"].title.focus();
				return false;
			} */
			if (document.forms["frmfamily"].first_name.value.length == 0) {
				alert("You must enter your First Name in the field provided.");
				document.forms["frmfamily"].first_name.focus();
				return false;
			}
			if (document.forms["frmfamily"].surname.value.length == 0) {
				alert("You must enter your Surname in the field provided.");
				document.forms["frmfamily"].surname.focus();
				return false;
			}
			if (!doValidateMail(document.forms["frmfamily"].email)) {
				document.forms["frmfamily"].email.select();
				document.forms["frmfamily"].email.focus();
				return false;			
			}
			return true;
		}
	}
 //Define the email address validation function
	function doValidateMail(field) {
	var email = field.value;
	var invalid_chars = " /:,;";
	if (email == "") {
		alert("You must enter an Email Address in the field provided.");			
		return false;
	}
	for (var i = 0;i < invalid_chars.length;i++) {
		bad_char = invalid_chars.charAt(i);
		if (email.indexOf(bad_char,0) > -1) {
			alert("You cannot enter blank space, slash, colon, comma or semicolon characters in an email address.");
			field.focus();
			field.select();
			return false;
		}
	}
	at_pos = email.indexOf("@",1);
	if (at_pos == -1) {
		alert("You must include the @ character in an email address.");
		field.focus();
		field.select();
		return false;
	}
	if (email.indexOf("@",at_pos + 1) > -1) {
		alert("You must have only one @ character in an email address.");
		field.focus();
		field.select();
		return false;
	}
	period_pos = email.indexOf(".",at_pos);
	if (period_pos == -1) {
		alert("You must include the domain extension (ie .com, .co.uk) in an email address.");
		field.focus();
		field.select();
		return false;
	}
	if (period_pos + 3 > email.length) {
		alert("You have entered an invalid domain extension in the email address.");
		field.focus();
		field.select();
		return false;
	}
	return true;
}
// Define function to display this year
function getThisYear(){
	var dNow = new Date()
	var year = dNow.getFullYear();
	document.write(year)
}
// define MM functions
function findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function swapImage() { //v3.0
  var i,j=0,x,a=swapImage.arguments; document.sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=findObj(a[i]))!=null){document.sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function swapImgRestore() { //v3.0
  var i,x,a=document.sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function preloadImages() { //v3.0
 var d=document; if(d.images){ if(!d.p) d.p=new Array();
   var i,j=d.p.length,a=preloadImages.arguments; for(i=0; i<a.length; i++)
   if (a[i].indexOf("#")!=0){ d.p[j]=new Image; d.p[j++].src=a[i];}}
}
function displayStatusMsg(msgStr) { //v1.0
  status=msgStr;
  document.returnValue = true;
}
function ReloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.pgW=innerWidth; document.pgH=innerHeight; onresize=ReloadPage; }}
  else if (innerWidth!=document.pgW || innerHeight!=document.pgH) location.reload();
}

