var today = new Date();
var expiry = new Date(today.getTime() + 28 * 24 * 60 * 60 * 1000);
function getCookie(name) {
	var re = new RegExp(name + "=([^;]+)");
	var value = re.exec(document.cookie);
	return (value != null) ? unescape(value[1]) : null;
}
function setCookie(name, value) {
	document.cookie=name + "=" + escape(value) + "; expires=" + expiry.toGMTString();
}
function a(module, action, id, msg) {
	if(typeof(msg)== 'string') {
		if (! confirm(msg)) {
			return;
		}
	}
	setCookie(module + "-" +action, id);
	var url = document.location.href;
	var re = new RegExp("^(.+?)\#?$");
	var value = re.exec(url);
	url=value[1];
	document.location.href=url;
}

// Popup
function popup(url, width, height) {
	//alert(width);
	window.open(url,'livestylewin','width=' + width + ',height=' + height + ',left=300,top=300,scrollbars=yes,menubar=no,resizable=no,toolbar=no,status=no'); 
	//return true;
}

function newFreeCap() {
	// loads new freeCap image
	if(document.getElementById) {
			// extract image name from image source (i.e. cut off ?randomness)
		var theImage = document.getElementById("captcha_image");
		var parts = theImage.src.split("&");
			// add ?(random) to prevent browser/isp caching
			// parts[0] should be id=page_id
			// parts[1] should be L=sys_language_uid
		theImage.src = parts[0] + "&" + parts[1] + "&set=" + Math.round(Math.random()*100000);
	} else {
		alert("Sorry, cannot autoreload new image\nSubmit the form and a new image will be loaded");
	}
}
