function Set_Cookie( name, value, expires, path, domain, secure ) 
{
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );

/*
if the expires variable is set, make the correct 
expires time, the current script below will set 
it for x number of days, to make it for hours, 
delete * 24, for minutes, delete * 60 * 24
*/
if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
//alert(expires_date )
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
( ( path ) ? ";path=" + path : "" ) + 
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}

function Get_Cookie( check_name ) {

	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f
	
	for ( i = 0; i < a_all_cookies.length; i++ )
	{

		a_temp_cookie = a_all_cookies[i].split( '=' );
	
		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
	
		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return null;
	}
}	

function deleteAllCookies()
	{
	
	Delete_Cookie('title','','');
	Delete_Cookie('firstname','','');
	Delete_Cookie('surname','','');
	Delete_Cookie('email','','');
	Delete_Cookie('gender','','');
	Delete_Cookie('maritial_status','','');
	Delete_Cookie('homeowner','', '');
	Delete_Cookie('telephone','','');
	Delete_Cookie('dobYear','','');
	Delete_Cookie('mobile','','');
	Delete_Cookie('houseIncome','','');
	Delete_Cookie('employmentstatus','','');		
	Delete_Cookie('postcode','','');
	Delete_Cookie('post_town','','');
	Delete_Cookie('county','','');
	Delete_Cookie('line1','','');
	Delete_Cookie('line2','','');
	Delete_Cookie('line3','','');
	Delete_Cookie('line4','','');
	}

function Delete_Cookie( name, path, domain ) {
if ( Get_Cookie( name ) ) document.cookie = name + "=" +
( ( path ) ? ";path=" + path : "") +
( ( domain ) ? ";domain=" + domain : "" ) +
";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

function rememberMe()
{
	var frm,Title,firstname,surname,email,dobDay,dobMonth,dobYear,gender,maritial_status,homeowner,telephone,postcode,full_address,post_town,line1,line2,line3,line4,line5,offer1,offer2,offer3,yearOfBirth,mobile,houseIncome,employmentstatus;
				
		if(document.forms[0]){frm = document.forms[0];}else {return;}
				 
		Title 			= frm.Title;
		firstname 		= frm.firstname;
		surname 		= frm.surname;
		email 			= frm.email;
		gender      	= frm.gender;
		maritial_status = frm.maritial_status;
		homeowner   	= frm.homeowner;
		telephone       = frm.telephone;
		postcode    	= frm.postcode;
		post_town       = frm.post_town;
		county          = frm.county;
		line1       	= frm.line1; 
		line2       	= frm.line2;
		line3       	= frm.line3;   
		line4       	= frm.line4;
		yearOfBirth     = frm.yearOfBirth;
		mobile          = frm.mobile;
		houseIncome     = frm.HouseIncome;
		employmentstatus= frm.employmentstatus;
		
		Set_Cookie('title',Title.value,30, '/', '', '' );
		Set_Cookie('firstname',firstname.value,30, '/', '', '' );
		Set_Cookie('surname',surname.value,30, '/', '', '' );
		Set_Cookie('email',email.value,30, '/', '', '' );
		Set_Cookie('gender',Title.value.toLowerCase()=='mr'?'Male':'Female',30, '/', '', '' );
		Set_Cookie('maritial_status',maritial_status.value,30, '/', '', '' );
		Set_Cookie('homeowner',(homeowner[0].checked?homeowner[0].value:homeowner[1].value),30, '/', '', '' );
		Set_Cookie('telephone',telephone.value,30, '/', '', '' );
		Set_Cookie('dobYear',yearOfBirth.value,30, '/', '', '' );
		Set_Cookie('mobile',mobile.value,30, '/', '', '' );
		Set_Cookie('houseIncome',houseIncome[0].checked?houseIncome[0].value:houseIncome[1].value,30, '/', '', '' );
		Set_Cookie('employmentstatus',employmentstatus.value,30, '/', '', '' );		
		Set_Cookie('postcode',postcode.value,30, '/', '', '' );
		Set_Cookie('post_town',post_town.value,30, '/', '', '' );
		Set_Cookie('county',county.value,30, '/', '', '' );
		Set_Cookie('line1',line1.value,30, '/', '', '' );
		Set_Cookie('line2',line2.value,30, '/', '', '' );
		Set_Cookie('line3',line3.value,30, '/', '', '' );
		Set_Cookie('line4',line4.value,30, '/', '', '' );
		
	return;	
}