var newname;
function saveIt(name,value,day) {
	newname=name;
	var x = value;
	if (!x)
		alert('Please fill in a value in the input box.');
	else {
		Cookies.create(name,x,day);
		//alert('Cookie created');
	}
}
 
function readIt(name) {
	//document.getElementById('formdiv').innerHTML='You allready Submit this form';
	//alert()
	//alert('The value of the cookie is ' + Cookies[name]);
	if(Cookies[name]=='submit')
	{
				  return true;
   }
	
}
 
function eraseIt(name) {
	Cookies.erase(name);
	alert('Cookie erased');
}
function init() {;
	for (var i=1;i<3;i++) {
		var x = Cookies[newname+ i];
		//if (x) alert('Cookie electrict' + i + '\nthat you set on a previous visit, is still active.\nIts value is ' + x);
	}
}
var Cookies = {
	init: function () {
		var allCookies = document.cookie.split('; ');
		for (var i=0;i<allCookies.length;i++) {
			var cookiePair = allCookies[i].split('=');
			this[cookiePair[0]] = cookiePair[1];
		}
	},
	create: function (name,value,days) {
		if (days) {
			var date = new Date();
			date.setTime(date.getTime()+(days*24*60*60*1000));
			var expires = "; expires="+date.toGMTString();
		}
		else var expires = "";
		document.cookie = name+"="+value+expires+"; path=/";
		this[name] = value;
	},
	erase: function (name) {
		this.create(name,'',-1);
		this[name] = undefined;
	}
};


