function cookieWrite(key, value, duration)
{
		value = encodeURIComponent(value);
		if (duration)
		{
			var date = new Date();
			date.setTime(date.getTime() + duration * 24 * 60 * 60 * 1000);
			value += '; expires=' + date.toGMTString();
		}
		document.cookie = key + '=' + value + '; path=/';
}


function cookieRead(key)
{
		var value = document.cookie.match('(?:^|;)\\s*' + key.escapeRegExp() + '=([^;]*)');
		return (value) ? decodeURIComponent(value[1]) : null;
}

function splashClick(label, target)
{
	// Set the cookie
//	cookieWrite('woodtone_id', label, 30);
	jQuery.cookie('woodtone_id', label, { expires: 30 });
	
	// Redirect
	splashRedirect(label, target);
}

function splashReadCookie()
{
	//return cookieRead('woodtone_id');
	return jQuery.cookie('woodtone_id');
}

function splashClearCookie(target)
{
	var redir = false;
	if(target && target.length > 0)
		redir = true;
		
	if(target == '/')
		target = '';
		
	cookieWrite('woodtone_id', '', -1);
	//jQuery.cookie('woodtone_id', null);
	
	//alert('Got here! redir = '+redir+'; target = '+target);
	if(redir)
		//document.location.href = target+'/';
		setTimeout('document.location.href = \''+target+'/\';', 200);
}

function splashRedirect(label, target)
{
	if(target == '/')
		target = '';
	
	
	if(label && label != null)
		document.location.href = target+'/Home/'+label+'.html';
	else
	{
		// Retrieve the cookie, if it exists
		var c;
//		if(c = splashReadCookie())
		if(c = jQuery.cookie('woodtone_id'))
			document.location.href = target+'/Home/'+c+'.html';
	}
}
