// JavaScript Document
function setCookie(name, value, expires)
{
	// no expiration date specified? use this date and it will just be deleted soon.
        if (!expires) expires = new Date(); 
	document.cookie = name + "=" + escape(value) + "; expires=" + expires.toGMTString() + "; path=/";
}

var expdate = new Date (); // pre-set to the current time and date

expdate.setTime(expdate.getTime() + 1000 * 60 * 60 * 24 * 365); // add one year to it 
//365 days/year * 24 hours/day * 60 minutes/hour * 60 seconds/minute * 1000 milliseconds/second
// = howevermany milliseconds/year. So this adds one year, it'll expire in one year.

function getCookie(name)
{
	var cookies = document.cookie;
	if (cookies.indexOf(name) != -1)
	{
		var startpos = cookies.indexOf(name)+name.length+1;
		var endpos = cookies.indexOf(";",startpos)-1;
		if (endpos == -2) endpos = cookies.length;
		return unescape(cookies.substring(startpos,endpos));
	}
	else
	{
		return false; // the cookie couldn't be found! it was never set before, or it expired.
	}
}

function updCookieLang() {
	var cookieLang = getCookie('lang');
}

function showLang() {
	document.write(cookieLang);
}

function setLang(setTo) {
	setCookie('lang',setTo,expdate);
	updCookieLang();
}

function setGal(setTo) {
	setCookie('gal',setTo,expdate);
}

function setPage(setTo) {
	setCookie('page',setTo,expdate);
}

function setBook(setTo) {
	setCookie('book',setTo,expdate);
}

updCookieLang();
