//ops is an array of values (host, path, secure, expire)
//just pass in what you want to define in the array for ops like setCookie('blah', blah', {path:'/', expire:365}) etc.
function setCookie(name, value, ops){
	var cookie = name + "=" + encodeURIComponent(value);
	if(ops){
		if(ops.host) cookie += "; domain=" + ops.host;
		if(ops.path) cookie += "; path=" + ops.path;
		if(ops.secure) cookie += "; secure=" + ops.secure;
		if(ops.expire){
			var ex = new Date();
			ex.setDate(ex.getDate() + ops.expire);
			cookie += "; expires=" + ex.toUTCString();
		}
	}
	document.cookie = cookie;
}

//get a cookie by name
function getCookie(name){
	if(document.cookie.length > 0){
		var start = document.cookie.indexOf(name + "=");
		if(start !== -1){
			start = start + name.length + 1;
			end = document.cookie.indexOf(";", start);
			if(end === -1) end = document.cookie.length;
			return decodeURIComponent(document.cookie.substring(start, end));
		}
	}
	return null;
}
