function putCookie() {

cookie_name = "fisherCookie";
var entry;

if(document.cookie != document.cookie)
{index = document.cookie.indexOf(cookie_name);}
else
{ index = -1;}

if (index == -1)
{
entry=document.Enter.username.value;
document.cookie=cookie_name+"="+entry+"; expires=Monday, 29-Jun-2010 05:00:00 GMT";
}

}


function OnLoad() 
{
	cookie_name = "fisherCookie";
	var retcookie;


	if(document.cookie)
	{
		index = document.cookie.indexOf(cookie_name);
		if (index != -1)
		{
			namestart = (document.cookie.indexOf("=", index) + 1);
			nameend = document.cookie.indexOf(";", index);
			if (nameend == -1) 
			{
				nameend = document.cookie.length;
			}
			retcookie = document.cookie.substring(namestart, nameend);
			document.Enter.username.value = retcookie;
			return retcookie;
		}
	}
	retcookie=getName();
	if (retcookie == "fisherCookie")
	{
		retcookie = "Nothing_Entered"
	}
}

	function Clear(){

		setTimeout("document.Enter.Password.value = ''", 1000);
		setTimeout("document.Enter.password.value = ''", 1000);

		return true;

	}

/*For rapid order items
function changeIt()
{
var i = 1;
express_product_code.innerHTML = express_product_code.innerHTML +"<br><input class='product_code_textbox' type='text' align='left' name='item[]'+ i>"

}
*/
/*Validate the main search box*/

function ValidateForm(){
	var checktext=document.search.q

	if((checktext.value==null)||(checktext.value=="")){
		//alert("Please enter a search word")
		toggleBox('required_message',1);
		checktext.focus()
		return false
	}else{
	return true
	}
 }

/*Validate the main MSDS box*/

function ValidateMSDSForm(){
	var checktext=document.msds.productCode

	if((checktext.value==null)||(checktext.value=="")){
		//alert("Please an MSDS product code")
		toggleBox('required_message',1);
		checktext.focus()
		return false
	}else{
	return true
	}
 }

/*Validate the main CofA box*/

function ValidateCofAForm(){
	var checktext=document.cofa.itemCode

	if((checktext.value==null)||(checktext.value=="")){
		//alert("Please enter an Item Code")
		toggleBox('required_message',1);
		checktext.focus()
		return false
	}else{
	return true
	}
 }
 
 function ValidateTZForm(){
	var checktext=document.tzsearchfrm.keyword

	if((checktext.value==null)||(checktext.value=="")){
		//alert("Please enter an Item Code")
		toggleBox('required_message',1);
		checktext.focus()
		return false
	}else{
	return true
	}
 }
 
  function addtobasket_message(){
	  var passbox=document.password
	  alert("Please be aware that if you log in to the web catalogue you will lose the items from your basket on this page.  If you have added items to the basket on this page, please use the progress order link");
 }



 function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
  endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
    return getCookieVal (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break;
  }
  return null;
}

function SetCookie (name, value) {
  var argv = SetCookie.arguments;
  var argc = SetCookie.arguments.length;
  var expires = (argc > 2) ? argv[2] : null;
  var path = (argc > 3) ? argv[3] : null;
  var domain = (argc > 4) ? argv[4] : null;
  var secure = (argc > 5) ? argv[5] : false;
  document.cookie = name + "=" + escape (value) +
   ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
   ((path == null) ? "" : ("; path=" + path)) +
   ((domain == null) ? "" : ("; domain=" + domain)) +
   ((secure == true) ? "; secure" : "");
}

//      - - - - - - - - End of Public Domain Cookie Code - - - - - - - -
//      - - - - - - - - JTotW Cookie Functions by Nick Heinle- - - - - - - -

function show_count() {
  var expdate = new Date();
  var num;
  expdate.setTime(expdate.getTime() +  (24 * 60 * 60 * 1000 * 31));
  if(!(num = GetCookie("jtotwcount")))
  num = 0;
  num++;
  SetCookie ("jtotwcount", num, expdate);
  if (num == 1) document.write("Thank you for visiting again.");
  else document.write("You have been here " + num + " times.");
}

function auto_show_name() {
  if(GetCookie("jtotwname") != null)
  document.write("Welcome back to this week\'s tip " + GetCookie('jtotwname') + ". ");
  else {
  document.write("<FORM>Please enter your name: <INPUT TYPE = \"text\" NAME = \"username\">" + "<BR><BR><INPUT TYPE = \"button\" VALUE = \"Save to Cookie\" onClick = \"set_name(this.form)\"></FORM>");
  document.write("Please enter your first name in the input" + " box and press the \"Save to Cookie\" button, then the page will automatically reload. ");
  }
}

function set_name(form) {
  var expdate = new Date ();
  expdate.setTime (expdate.getTime() + (24 * 60 * 60 * 1000 * 31));
  var username = form.username.value
//  if (username != "") {
//    if (confirm("Are you sure you want this saved as your name?")) {
      SetCookie ("jtotwname", username, expdate);
//    }
//  } else alert("Please enter your username and password.");
}