function makeCookie(form){	
	
	//array of field names to be stored in cookie
	var field_names = ['name','title','email','telephone','company','address1','address2','city','state','province','zip','country','platform'];
	
	//retain cookie by setting its expiry in the future
	var date = new Date(2007,07,31);
	date=date.toGMTString();
	//initialise variables
	var str = "";
	var add_amp = false;
	//loop through form and make a string of the name /values pairs like this: "name=value&name2=value2" etc.
	for (var loop=0; loop < field_names.length; loop++){		
		for (var loop2=0; loop2 < form.elements.length; loop2++){
			if (field_names[loop] == form.elements[loop2].name){
				if (add_amp == true) {str += "&";}
				//if statement for Netscape select method, note this records selectedIndex rather than value
				if (form.elements[loop2].type == "select-one"){
					str += form.elements[loop2].name + "=" + form.elements[loop2].selectedIndex;
					add_amp = true;
					break;
					}
					else{
					str += form.elements[loop2].name + "=" + form.elements[loop2].value;
					add_amp = true;
					break;
					}				
				}
			}
		}
	//create a cookie string using the string above and set its expiry using above date
	var the_cookie = "form_values=:"+escape(str)+";expires="+date;
	document.cookie = the_cookie;
	//alert('Form saved to cookie');
	}
	
	function readCookie(form){	
	//jeremy.wray@netdecisions.co.uk
	// load the cookie into a variable and unescape it
	var the_cookie = document.cookie;
	the_cookie = unescape(the_cookie);
	//check to see it has our string in the cookie
	if (the_cookie.indexOf("form_values") != -1){
		//get start/end points of relevant portion of cookie
		var start = the_cookie.indexOf("form_values");
		var end = the_cookie.indexOf(";",start);
		//check to see if our cookie is the last string in the cookie
		if (end == -1){ //if so, slice to end			
			the_cookie = the_cookie.slice(start);
			}
			else{ //otherwise slice to next ";"			
			the_cookie = the_cookie.slice(start,end);
			}
		}
		else{
		//if our string not in cookie, exit function
		return;
		}
	// separate the values from the cookie name
	var broken_cookie = the_cookie.split(":");
	//if cookie is emptied, exit function
	if (broken_cookie == "") {return;}
	//get cookie name/values
	var the_values = broken_cookie[1];
	//if name/values are empty, exit function
	if (the_values == "") {return;}
	// break each name:value pair into an array
	var separated_values = the_values.split("&");
	var property_value = "";
	
	//loop through form and check if value exists in cookie
	for (var loop = 0; loop<form.elements.length; loop++){
		
		// loop through the list of name/values in the cookie for comparison		
		for (var loop2 = 0; loop2 < separated_values.length; loop2++) {	
			property_value = separated_values[loop2];	
			var broken_info = property_value.split("=");	
			var the_name = broken_info[0];
			var the_value = broken_info[1];
			
			//compare with form
			if (form.elements[loop].name == the_name){	
				//place values back into form			
				if (form.elements[loop].type == "select-one"){
					form.elements[loop].selectedIndex = the_value;	
					break;
					}
					else{
					form.elements[loop].value = the_value;					
					break;
					}
				}					
			}
		}
	}
	
	function deleteCookie(){
	//jeremy.wray@netdecisions.co.uk
	//set a date in the past
	var date = new Date(1999,9,30);
	date=date.toGMTString();
	//set it's string to empty
	var str = "";	
	//delete cookie by setting it's expiry in the past
	var the_cookie = "form_values=:"+escape(str)+";expires="+date;
	document.cookie = the_cookie;
	alert('The cookie has been deleted');
	}
	
