// initialise plugins
		
var blob=0;
function hide_delivery(test){

if(test=="0"){
	document.getElementById('HIDE-DELIVERY').style.display = 'none';
	var blob=0;
	}

if(test=="1"){
	document.getElementById('HIDE-DELIVERY').style.display = 'block';
	var blob=1;
	}

}

function CheckFormNoRegister(which)
{
	if(CheckFormRegistration(which))return CheckForm(which);
	else return false;
}

function CheckForm(which)
{
	var x=0;var found=0;
	isIE6 = /msie|MSIE 6/.test(navigator.userAgent);

	var browser=navigator.appName;
	var b_version=navigator.appVersion;
	var version=parseFloat(b_version);

	if(which.elements['terms'])
	{
		if((browser!="Microsoft Internet Explorer") && (version!=4))
		{
			if(which.invoice)			//Skip all this if in noregister mode
			{
				if(!isIE6)
				{
					if(which.invoice.length)
					{
						while(x<which.invoice.length)
						{
							if(which.invoice[x].checked!=false){found=1;break;}
							x++;
						}
					}
					else {which.invoice.checked=true;found=1;}
				}
				else if(which.invoice.value)found=1;
				/*
					change change
				*/
				if(!found)
				{
					alert("Please choose the billing address of the credit card you will use or add a new one.");
					return false;
				}
				x=0;found=0;
				if(!isIE6)
				{
					if(which.delivery.length)
					{
						while(x<which.delivery.length)
						{
							if(which.delivery[x].checked!=false){found=1;break;}
							x++;
						}
					}
					else {which.delivery.checked=true;found=1;}
				}
				else if(which.delivery.value)found=1;
				if(!found)
				{
					//which.elements['delivery'].value=which.elements['invoice'].value;
					//which.elements['delivery'].checked=true;
					alert("Please choose the delivery address of the credit card you will use or add a new one.");
					return false;
				}
			}
		}
		if(!which.elements['terms'].checked && !which.elements['card'] && which.elements['terms'].type!="hidden")
		{
			alert("You have to agree to the terms and conditions to continue.");
			return false;
		}
	}
	if(which.elements['card'])
	{
		if(which.elements['card'].value=='--')
		{
			alert("Please choose the card type.");
			return false;
		}
		if(which.elements['cvv2'].value=='' && !which.elements['nocvv2'].checked)
		{
			alert("Please enter the last three numbers on the signature strip.");
			return false;
		}
		if(which.elements['cardnum'].value=='')
		{
			alert("Please enter card no.");
			return false;
		}
		if(which.elements['endmonth'].value=='--' || which.elements['endyear']=='--')
		{
			alert("Please select the correct expiry date.");
			return false;
		}
	}
	return true;

}

function CheckFormRegistration(which)
{
	if(!which.elements['title'][0].checked && !which.elements['title'][1].checked && !which.elements['title'][2].checked && !which.elements['title'][3].checked)
	{
		alert("Please choose your preferred title.");
		return false;
	}
	if(which.elements['title'][3].checked && which.elements['other2'].value=="")
	{
		alert("Please fill in the text box next to the 'Other' title.");
		return false;
	}
	if(which.elements['firstname'].value=="" || which.elements['surname'].value=="")
	{
		alert("You must enter a full name.");
		return false;
	}

	var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
	if(which.elements['email'].value.match(emailExp)){
		
	}
	else
	{
		alert("You must enter a valid email address.");
		return false;
	}

/*	if(which.elements['email'].value=="")
	{
		alert("You must enter a valid email address.");
		return false;
	}
*/

	if(which.elements['email'].value=="")
	{
		alert("You must enter a valid email address.");
		return false;
	}
	if(which.elements['pass1'])
	{
		if(which.elements['pass1'].value=="")
		{
			alert("You must enter a password and confirm that password in the confirm field.");
			return false;
		}
		if(which.elements['pass1'].value!=which.elements['pass2'].value)
		{
			alert("Your password does not match the confirmed password field.\nPlease ensure you've typed the same password in both fields.\n");
			return false;
		}
	}
	if(which.elements['heardfrom']){
		if(which.elements['heardfrom'].value=="--")
		{
			alert("Please tell us where you heard about our website.");
			return false;
		}
	}
	if(which.elements['rewardcard'].value!="" && !which.elements['rewardcard'].Match(/^[0-9]{9,10}$/))
	{
		alert("Your reward card number should be 9 or 10 digits.");
		return false;
	}
	if(which.elements['bname'].value=="")
	{
		alert("Please fill out the Address name field. This is what you can refer to this address as when ordering. E.G. Work or Home.");
		return false;
	}

	if(which.elements['bline1'].value=="" && which.elements['bline2'].value=="")
	{
		alert("Please fill out the house number and/or the first line of the address.");
		return false;
	}

	if(which.elements['bpostcode'].value=="")
	{
		alert("Please fill out the Postcode field");
		return false;
	}
	
	if(which.elements['bdayphone'].value=="")
	{
		alert("Please fill out the daytime phone number field");
		return false;
	}

	if(which.elements['delivery_address'].value=="1")
	{
		if(which.elements['dname'].value=="")
		{
			alert("Please fill out the Delivery Address name field. This is what you can refer to this address as when ordering. E.G. Work or Home.");
			return false;
		}
		if(which.elements['dline1'].value=="" && which.elements['dline2'].value=="")
		{
			alert("Please fill out the house number and/or the first line of the delivery address.");
			return false;
		}
		
		if(which.elements['dpostcode'].value=="")
		{
			alert("Please fill out the Delivery Postcode field");
			return false;
		}
		
		if(which.elements['ddayphone'].value=="")
		{
			alert("Please fill out the daytime phone number field");
			return false;
		}
		return true;
	}
	return true;
}

function JoinOurTeam(which)
{
	if(which.elements['name'].value=="")
	{
		alert("You must enter a full name.");
		return false;
	}

	var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
	if(which.elements['email'].value.match(emailExp)){
		
	}
	else
	{
		alert("You must enter a valid email address.");
		return false;
	}

	if(which.elements['email'].value=="")
	{
		alert("You must enter a valid email address.");
		return false;
	}

	if(which.elements['phone'].value=="")
	{
		alert("You fill out the Phone Number field.");
		return false;
	}
	
	if(which.elements['address1'].value=="" || which.elements['address2'].value=="")
	{
		alert("Please fill out the Address field.");
		return false;
	}

	if(which.elements['postcode'].value=="")
	{
		alert("Please fill out the Postcode field");
		return false;
	}

	if(which.elements['appliedfor'].value=="")
	{
		alert("Please fill out the Position Applied For field");
		return false;
	}
	
	if(which.elements['experience'].value=="")
	{
		alert("Please fill out the Qualifications & Experience field");
		return false;
	}

	return true;
}

function callBack(which)
{
	if(which.elements['firstname'].value=="" || which.elements['surname'].value=="")
	{
		alert("You must enter a full name.");
		return false;
	}

	if(which.elements['phone'].value=="")
	{
		alert("You fill out the Phone Number field.");
		return false;
	}


	var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
	if(which.elements['email'].value.match(emailExp)){
		
	}
	else
	{
		alert("You must enter a valid email address.");
		return false;
	}

	if(which.elements['email'].value=="")
	{
		alert("You must enter a valid email address.");
		return false;
	}


	return true;
}

function checkReviewForm(which)
{
	if(which.elements['reviewname'].value=="")
	{
		alert("You must enter a name.");
		return false;
	}
	
	var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
	if(!which.elements['reviewemail'].value.match(emailExp))
	{
		alert("You must enter a valid email address.");
		return false;
	}
	
		
	if(which.elements['reviewtext'].value=="")
	{
		alert("Please type your text in the box provided.");
		return false;
	}
	if(which.elements['reviewrating'].selectedIndex==0)
	{
		alert("Please rate the product.");
		return false;
	}
}



function checkCompForm(which)
{
	if(which.elements['namefrom'].value=="")
	{
		alert("You must enter your name.");
		return false;
	}
	
	var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-\_]+\.[a-zA-z0-9]{2,4}$/;
	if(!which.elements['emailfrom'].value.match(emailExp))
	{
		alert("You must enter a valid email address.");
		return false;
	}
	
	
	if(which.elements['comments'].value=="")
	{
		alert("Please type your comments in the box provided.");
		return false;
	}
	
	if(!which.elements['discipline_game'].checked && !which.elements['discipline_sea'].checked && !which.elements['discipline_coarse'].checked && !which.elements['discipline_predator'].checked && !which.elements['discipline_flytying'].checked)
	{
		alert("Please select your fishing discipline.");
		return false;
	}
	
	if(which.elements['attachment'].value=="")
	{
		alert("Please select a file for upload.");
		return false;
	}
}




/*function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

window.onload = function(e) {
  var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
  if(document.getElementById('HIDE-DELIVERY'))document.getElementById('HIDE-DELIVERY').style.display='none';
}

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);
*/

window.onload = function(e) {
  if(document.getElementById('HIDE-DELIVERY'))document.getElementById('HIDE-DELIVERY').style.display='none';
}

function bigImageZoom()
{
	var img=document.getElementById('popup_img');
	var container=document.getElementById('popupimage');
	if(img.style.maxWidth=='none')
	{
		img.style.maxWidth='100%';
		img.style.maxHeight='100%';
		container.style.overflow='none';
	}
	else
	{
		img.style.maxWidth='none';
		img.style.maxHeight='none';
		container.style.overflow='auto';
	}
}

function bigImage(a)
{
	var popup=document.getElementById('popup');
	var container=document.getElementById('popupimage');
	var img=document.getElementById('popup_img');
	if(!img)
	{
		img=document.createElement('img');
		img.id='popup_img';
		img.src=a.href;
		img.addEventListener("click",bigImageZoom,false);
		container.appendChild(img);
	}
	else img.src=a.href;
	popup.style.top=(window.scrollY+40)+'px';
	container.style.overflow='none';
	img.style.maxWidth='100%';
	img.style.maxHeight='100%';
	popup.style.display='block';
	return false;
}

