function ajaxRequest() {
	var xmlHttp;
	try {
		// Firefox, Opera 8.0+, Safari
		xmlHttp = new XMLHttpRequest();
	}
	catch (e) {
	// Internet Explorer
		try {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) {
			try {
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e) {
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
	return xmlHttp;
}

function createQuery() {
    var elms, elm, Qstring = '', k = 0;
    elms = document.forms[0].elements;
    while( elm = elms[k++] ) {
        if( elm.name && elm.value ) {
            Qstring += elm.name + '=' + escape( elm.value ) + '&';
		}
	}
    return Qstring.replace( /&$/, '' );
}

function sendEmail( con, action ) {
	if( con != null )
		var container = document.getElementById( con );
	var xmlHttp = ajaxRequest();
	xmlHttp.onreadystatechange = function() {
		if( xmlHttp.readyState == 4 ) {
			showElement( con );
			if( container )
				container.innerHTML = xmlHttp.responseText;
		}
	}
	xmlHttp.open( "POST", action, true );
	xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
	var querySTR = createQuery();
	xmlHttp.send( querySTR );
}

function getData( con, source ) {
	if( con != null )
		var container = document.getElementById( con );
	var xmlHttp = ajaxRequest();
	xmlHttp.onreadystatechange = function() {
		if( xmlHttp.readyState == 4 ) {
			showElement( con );
			if( container )
				container.innerHTML = xmlHttp.responseText;
		}
	}
	xmlHttp.open( "GET", source, true );
	xmlHttp.send( null );
}

function showElement( id ) {
	document.getElementById( id ).style.display = 'block';
}

function hideElement( id ) {
	document.getElementById( id ).style.display = 'none';
}