// JavaScript Document

function test(str) {
	window.alert(str);	
}

function Analytic() {
	var thisObject = this;
	
	this.init = function() {
		var s = client_data('screen');
		var xmlhttp = new ajax(window.location.protocol + "//" + window.location.host + "/analytic/analytic.php5?screen=" + s[0] + "/" + s[1] + "&referrer=" + document.referrer + "&query=" + window.location.href + "&page=" + window.location.pathname + "&java=" + navigator.javaEnabled() + "&cockie=" + navigator.cookieEnabled);
		xmlhttp.wState = function() {
			if (xmlhttp.req.readyState==4) {
				//window.alert(xmlhttp.req.responseText);
			}
		}
		xmlhttp.doRequest();
	}	
}

var ajax = function(u, f, m, b, h, s) {
//*****************************************
//Ajax-Klasse
//*****************************************		
	this.url = u;
	this.wState = f || function() { };
	this.method = m || "GET";
	this.body = b || null;
	this.headers = h || false;
	this.sync = s || true;
	this.abortReq || false;
	
	this.req = (window.XMLHttpRequest)
				? 
				new XMLHttpRequest()
				:
				((window.ActiveXObject)
				?
				new ActiveXObject("Microsoft.XMLHTTP")
				:
				false
				);
			
	this.doRequest = function() {
			this.req.open(this.method, this.url, this.sync);
			
			if (this.headers) {
				for (var i = 0; i < this.headers.length; i+=2) {
					this.req.setRequestHeader(this.headers[i], this.headers[i+1]);
				}
			}
			this.req.onreadystatechange = this.wState;
			this.req.send(this.body);
		}
}

function client_data(info) {
	if (info == 'screen') {
		var s = new Array();
		s[0] = (screen.width) ? screen.width:'';
		s[1] = (screen.height) ? screen.height:'';
		// check for windows off standard dpi screen res
		if (typeof(screen.deviceXDPI) == 'number') {
			s[0] *= screen.deviceXDPI/screen.logicalXDPI;
			s[1] *= screen.deviceYDPI/screen.logicalYDPI;
		} 
		return (s);
	} else if (info == 'js' ) {
		document.write('<p class="right-bar">JavaScript is enabled.</p>');
	} else if ( info == 'cookies' ) {
		expires ='';
		Set_Cookie( 'cookie_test', 'it_worked' , expires, '', '', '' );
		string = '<h4  class="right-bar">Cookies</h4><p class="right-bar">';
		if ( Get_Cookie( 'cookie_test' ) )
		{
			string += 'Cookies are enabled</p>';
		}
		else {
			string += 'Cookies are disabled</p>';
		}
		document.write( string );
	}
}
