/* 
AJAX Functions
---------------------------------------------
by Tobias Jacksteit 2009 
http://www.xtj7.de
Free to copy & use, keep this copyright info
*/

function loadZertifikat( seoname, url ) {
AJAX_get('zertifikat.php?id=' + seoname + '&js=true&' + url, function( text ) {
document.getElemewnt
document.getElementById( 'content' ).innerHTML = text;
});
}

function AJAX_init() {
	try { return( new ActiveXObject( "Msxml2.XMLHTTP" ) ); } catch ( e ) {}
	try { return( new ActiveXObject( "Microsoft.XMLHTTP" ) ); } catch ( e ) {}
	try { return( new XMLHttpRequest() ); } catch( e ) {}
	alert( "AJAX_init() failed. AJAX is not supported by this browser." );
	return( null );
}

function AJAX_get( query, func, async, method ) {
	var xhReq = AJAX_init();
	if( query == null || query == "" ) {
		alert( 'Invalid Query' );
		return( false );
	}
	if( method == null || method == "" ) {
		method = "get";
	}
	if( async == null || async == "" ) {
		async = true;
	}
	xhReq.open( method, query, async );
	var requestTimeout = setTimeout( function() { xhReq.abort(); }, 5000 );
	xhReq.onreadystatechange = function() {
		
		if( xhReq.readyState != 4 ) { 
			return( false ); 
		}
		
		clearTimeout( requestTimeout );
		
		if( xhReq.status != 200 ) {
			return( false );
		}
		
		var text = xhReq.responseText;
		if( text == null ) { text = ''; }
		if( !func || func == null || func == "" ) {
			return( true );
		} else if( typeof func == "function" ) {
			func( text );
		} else {
			eval( func );
		}
		return( xhReq.responseText );
	};
	xhReq.send( null );
	if( async == false ) {
		return( xhReq.responseText );
	}
}
