// Forces a confirmation before allowing any link to take you outside of the current site
function blockExternalLinks(){
	var anchors = $$('a');
	for(i=0;i<anchors.length;i++){
		anchors[i].addEvent('click', function(){
			if(!this.href.match(document.domain) && this.href.match('http')){
				var ext_bg = new Element('div', {'id' : 'extNotify'});
				ext_bg.set('opacity', 0);
				ext_bg.addEvent('click', function(){
					fader = new Fx.Tween(ext_bg);
					fader.addEvent('onComplete', function(){ext_bg.dispose();});
					fader.start('opacity', 0);
				});
				ext_bg.innerHTML = 
				'<table id="ext_table" cellpadding="0" cellspacing="0" height="100%" width="100%"><tr>'+
				'<td id="ext_container" align="center" valign="middle"></td></tr></table>';
				var ext_confirm = new Element('div');
				ext_confirm.innerHTML = 
				'<table id="ext_content" cellpadding="20" cellspacing="0"><tr>'+
				'<td  valign="middle">'+
				'<h1>Notice:</h1>'+
				'You have clicked on a link that will take you outside of this site.<br>'+
				'Here is the URL:<br>'+
				'<a onClick="location.href=this.href;" href="'+this.href+'">'+this.href.replace('http://','').slice(0, -1)+'</a><br>'+
				'If you would like to continue, please click the URL above.<br>'+
				'Click outside this box to cancel.'+
				'</td></tr></table>';
				ext_bg.inject(document.body);
				ext_confirm.injectInside($('ext_container'));
				$('ext_content').addEvent('click', function(){return false});
				ext_bg.fade(0, 0.9);
				return false;
			}
		});
	}
}

function ajax(action, data){
	var request = new Request({
		method : 'post',
		url : 'ajax_control.php',
		async : false,
		onSuccess : function(responseTree){
			result = responseTree;
		}
	});
	request.send('action='+action+(data?'&'+data:''));
	return(result);
}

function purify(data){
	data = data.replace(/&/g, 'amp;');
	data = data.replace(/%/g, 'perc;');
	return data;
}
function is_numeric(value){
	if ((isNaN(value)) || (value.length == 0))
		return 0;
	else
		return 1;
}

