

  var expirationDate = new Date();
  var currYear = expirationDate.getYear();

  var nameValue;
  var colorValue;
  var firstValue;
  var annSaveGSTinc2Value;
  var transferValue;
  var designyetValue;

  var documentCookie = "";

  if (currYear < 1000) {

  	if (currYear >= 100)
  		currYear -= 100;

  	currYear += 2000;
  }

  function setFields() {

  	var aCount = 0;
  	var field = window.document.getFields;


  	expirationDate.setYear(currYear + 1);
  	expirationDate = expirationDate.toGMTString();

  	while (aCount < field.length) {

  		if (field[aCount].type == "text" && field[aCount].value != "") {

  			//alert(field + "= " + field.value + "; expires= " + expirationDate);
  			document.cookie = field[aCount].name + "= " + field[aCount].value + "; expires= " + expirationDate;

  		}
  		aCount += 1;
  	}


  }

  function getField(field) {

   	var dc = document.cookie;
    	var prefix = field + "=";
    	var begin = dc.indexOf("; " + prefix);
    	if (begin == -1) {
      	begin = dc.indexOf(prefix);
      	if (begin != 0) return null;
    	} else
      	begin += 2;
    	var end = document.cookie.indexOf(";", begin);
    	if (end == -1)
      	end = dc.length;
    	return unescape(dc.substring(begin + prefix.length, end));
  }

  function clearCookie() {

  expirationDate.setYear(currYear - 1);
  expirationDate = expirationDate.toGMTString();

  var dc = document.cookie;
  var tempString = "";
  var tempChar;
  var count = 0;
  var cookieLength = dc.length;

  while (count < cookieLength) {

  	tempChar = dc.charAt(count);
  	if (tempChar == '=') {

  		if (tempString == "nameBrand" || tempString == "nameBrand2" || tempString == "firstname" || tempString == "transfer" || tempString == "designyet" || tempString == "annSaveGSTinc2") {
  			document.cookie = tempString + "=null; expires= " + expirationDate;
  		}

  		tempString = "";
  	}

  	if (tempChar == ';') {

  		tempString = "";

  	}

  	if (tempChar != '=' && tempChar != ';' && tempChar != " ") {

  		tempString += tempChar;

  	}

  	count += 1;

  }

  location.reload();

  }

  function printCookie() {

  var dc = document.cookie;
  var tempString = "";
  var tempChar;
  var count = 0;
  var cookieLength = dc.length;
  var currentCookie;
  var nameBool = false;
  var colorBool = false;
  var firstBool = false;


  while (count < cookieLength) {


  	tempChar = dc.charAt(count);

  	if (tempChar != '=' && tempChar != ';' && tempChar != " ") {

  		tempString += tempChar;

  	}

  	if (tempChar == '=') {


  	    currentCookie = tempString;
  		tempString = "";

  	}

  	if (tempChar == ';' || count == cookieLength-1) {

  		if (currentCookie == "nameBrand") {
  			nameValue = tempString;
  		}

  		if (currentCookie == "nameBrand2") {
  			colorValue = tempString;
  		}

  		if (currentCookie == "firstname") {
  			firstValue = tempString;
  		}

   		if (currentCookie == "transfer") {
   			transferValue = tempString;
  		}

  		if (currentCookie == "designyet") {
			designyetValue = tempString;
  		}

  		if (currentCookie == "annSaveGSTinc2") {
			annSaveGSTinc2Value = tempString;
  		}

  		tempString = "";

  	}

  	if (nameValue && nameBool == false) {

  		documentCookie += "nameBrand=" + nameValue + "; "
  		nameBool = true;

  	}

  	if (colorValue && colorBool == false) {

  		documentCookie += "nameBrand2=" + colorValue + "; "
  		colorBool = true;

  	}

  	if (firstValue && firstBool == false) {

  		documentCookie += "firstname=" + firstValue + "; "
  		firstBool = true;

  	}

	if (transferValue && firstBool == false) {

   		documentCookie += "transfer=" + transferValue + "; "
   		firstBool = true;

  	}

   	if (designyetValue && firstBool == false) {

   		documentCookie += "designyet=" + designyetValue + "; "
   		firstBool = true;

  	}

   	if (annSaveGSTinc2Value && firstBool == false) {

   		documentCookie += "annSaveGSTinc2=" + annSaveGSTinc2Value + "; "
   		firstBool = true;

  	}


  	count += 1;
  }


  }
 
