function go(url)
{
	if (url)
		document.location.href = url;
}

function setCheck(state, frmID)
{
	if (!frmID) frmID = 'mainform';
	var list = $(frmID).getElementsByTagName('input');
	for(var i=0; i<list.length; i++)
	{
	    if (list[i].type == 'checkbox' && list[i].className == 'checkbox')
	       list[i].checked = state;
	}
}

explodeEmail = function(id)
{
	var elm = document.getElementById('email').value;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	
	if (filter.test(elm))
	{
		var email = elm.split('@');
		document.getElementById('username').value = email[0];
		document.getElementById('pop3host').value = email[1];
		document.getElementById('loginPage').submit();
	}
	else 
	{
		alert('Please enter a valid e-mail address.');
	}
}

toggleText = function(text, id)
{
	var elm = document.getElementById(id);
	if (elm.value == text)
		elm.value='';
 	else 
 		elm.value=text;
}

var common={
	// default ajax loader image
	img: 'loader.gif',
	// request method
	request:function(method)
	{
		new Ajax.Request(
			method,
			{	
				method: 'get',
				evalScripts:true,
				asynchronous:true,
				onSuccess: function(transport) {
					// make something
				}
			}
		);
	},
	// load method
	load:function(method, id, img)
	{
		img = (img) ? img : common.img;

		new Ajax.Updater(
			id,
			method, 
			{
				method: 'get',
				evalScripts: true,
				asynchronous:true,
				onCreate: function() {
				     $(id).update('<div class="loading"><img src="http://www.enigmalok.com/img/' + img + '"></div>');
				}
			}
		);
	},
	// update method
	update:function(method, id, params, img, complete)
	{
		img = (img) ? img : common.img;

		new Ajax.Updater(
			id,
			method, 
			{
				asynchronous:true,
				evalScripts:true,
				method: 'post',
				  onCreate: function() {
				     $(id).update('<div class="loading"><img src="http://www.enigmalok.com/img/' + img + '"></div>');
				  },
				  onComplete: function() {
				  	complete;
				  },
				parameters:params
			}
		)
	},
	
	// empty element method
	close:function(id)
	{
		$(id).update('');
	},

	toInt:function(item)
	{
		return ( isNaN(parseInt(item))) ? 0 : parseInt(item);
	},
	toFloat:function(item)
	{
		return ( isNaN(parseFloat(item))) ? 0 : parseFloat(item);
	}
}