function hide(id) { document.getElementById(id).style.display = 'none'; }
function show(id) { document.getElementById(id).style.display = 'block'; }
function toggle(id) { if (document.getElementById(id).style.display == 'none') { show(id); } else { hide(id); } }
function getvalue(id) { return document.getElementById(id).value; }

function isset(variable_name) {
	try {
		if (typeof(eval(variable_name)) != 'undefined')
			if (eval(variable_name) != null)
				return true;
	} catch(e) { }
	return false;
}

function addEvent(elm, evType, fn, useCapture){
    if (elm.addEventListener)
    {
      elm.addEventListener(evType, fn, useCapture);
      return true;
    } else if (elm.attachEvent) {
      var r = elm.attachEvent('on' + evType, fn);
      return r;
    } else {
      elm['on' + evType] = fn;
    }
}

function doSearch() {
	window.location = '/search.php?q=' + getvalue('search');
	return false;
}

function doSubscribe() {
	new AJAXRequest('POST','/subscribe.php','email='+encode(getvalue('email')),processSubscribeReply);
}

function processSubscribeReply(myAJAX) {
	var msg;
	if (myAJAX.readyState == 4) {
	if (myAJAX.status == 200) {
			if (myAJAX.responseText == 'done') alert('Thank you for subscribing.');
			else alert('An error occurred. You are probably already in the mailing list or your e-mail is invalid.');
		}
	}
}
