function notEmpty(ID) {
	if ($(ID).value != "") {
		return true;
	} else {
		return false;
	}
}
function addClick(id, target, article_id, thetime, action) {
	var divID = "none";
	var url = "php/js_addClick.php";
	var pars = "id=" + id + "&article_id=" + article_id + "&target=" + target + "&time=" + thetime + "&link=" + action + "&r=" + Math.floor(Math.random());
	var doAddClick = new Ajax.Updater(divID, url, {method: 'get', parameters: pars});
	return true;
}
function getMonth(divID, year_date, month) {
        var year = $(year_date);
        var year = $(year_date).value;
        if (year == "none") {
        	$(divID).update('');
        } else {
	        var url = "php/js_getMonths.php";
	        var pars = "year=" + year + "&month=" + month + "&r=" + Math.floor(Math.random()*1000);
	        var getMonths = new Ajax.Updater(divID, url, {method: 'get', parameters: pars});
		}
        return false;
}
function getSearch(thetype, searchDIV, search) {
	if (thetype == "date") {
		var year = $('year_date1').value;
		var month = $('month_date').value;
		var pars = "year=" + year + "&month=" + month + "&type=" + thetype
	}
	if (thetype == "cat") {
		var cat = $('the_cat').value;
		var year = $('year_cat').value;
		var month = $('month_cat').value;
		var pars = "year=" + year + "&month=" + month + "&type=" + thetype + "&cat=" + cat + "&r=" + Math.floor(Math.random());
	}
	if (thetype == "text") {
		var search = escape($('text_search').value);
		if (search != "") {
			var pars = "type=" + thetype + "&search=" + escape(search) + "&r=" + Math.floor(Math.random());
		} else {
			var pars = "";
		}
	}
	if (pars != "") {
		var divID = "response";
		var url = "php/js_getSearch.php";
		var generateSearch = new Ajax.Updater(divID, url, {method: 'get', parameters: pars});
	}
}
function doSubscribe() {
	var email = $('subscribe').value;
	if (email != "") {
		var url = "php/js_doSubscribe.php";
		var divID = "subscribe_response";
		var pars = "email=" + email;
		if ($('referred') != null) {
			pars = pars + "&referred=" + $('referred').value;
		}
		pars = pars + "&r=" + Math.floor(Math.random()*1000);
//		alert(pars);
		var subscribe = new Ajax.Updater(divID, url, {method: 'get', parameters: pars});
	}
	return false;
}
function getList() {
	var the_name = escape($F('subscribe'));
	if (the_name.length > 1) {
		var divID = "list";
		var url = "php/getList.php";
		var pars = "search=" + the_name + "&r=" + Math.floor(Math.random()*1000);
		var getMatches = new Ajax.Updater(divID, url, {method: 'get', parameters: pars});
	}
	return false;
}
function doForward(theaction) {
	var email = $('forward').value;
	if ($('ref') != null) {
		var sender = $('ref').value;
	} else {
		var sender = "";
	}
	if (email != "") {
		var divID = "forward_response";
		var url = "php/js_doForward.php";
		var pars = "email=" + email + "&sender=" + sender + "&r=" + Math.floor(Math.random()*1000);
//	alert(pars);
		var sendForward = new Ajax.Updater(divID, url, {method: 'get', parameters: pars});
	}
	return false;
}
function hideFeature() {
	$('displayFeatureBox').update('');
	return false;
}
function doRefer(email) {
	var to = $F('email');
	var first = $F('first');
	var last = $F('last');
	if (email == "") {
		alert("Please provide an email to send the insider to.");
		$('email').focus();
	} else if (first == "") {
		alert("Please provide your first name");
		$('first').focus();
	} else if (last == "") {
		alert("Please provide your last name");
		$('last').focus();
	} else {
		var firstname = escape($F('firstname'));
		var lastname = escape($F('lastname'));
		var message = escape($F('message'));
		var divID = "therefer";
		var url = "php/js_doRefer.php";
		var pars = "to=" + to + "&message=" + message + "&firstname=" + firstname + "&lastname=" + lastname + "&first=" + first + "&last=" + last + "&email=" + email + "&r=" + Math.floor(Math.random()*1000);
//		alert(pars);
		var sendRefer = new Ajax.Updater(divID, url, {method: 'get', parameters: pars});
	}
	return false;
}
