/*Diverse Scripts*/
MAIN	=	{
	_startup	:	function(){
		this.ie6 = (navigator.appVersion.match(/MSIE 6|MSIE 5/))?true:false;
		this.docEl = (typeof document.compatMode != "undefined" && document.compatMode!= "BackCompat")? "documentElement" : "body";

		/*Png Fix*/
		if(this.ie6){
			var script= document.createElement('script');
			script.type= 'text/javascript';
			script.onreadystatechange= function () {
				if (this.readyState == 'complete' || this.readyState == 'loaded'){
					MAIN.bugfix_interval = setInterval("BugFixPngs()",250);
				}
			}
			script.src= 'js/BugFixPngs.js';
			document.getElementsByTagName('head')[0].appendChild(script);
		}

		MAIN.flags = [];
		MAIN.init_mousemove();
	},

	/*MouseMoving*/
	init_mousemove	:	function() {
	    if(document.layers) document.captureEvents(Event.MOUSEMOVE);
	    document.onmousemove =	MAIN.mousemove;
	},

	/*MouseMoving*/
	mousemove	:	function(e) {
	  	MAIN.xPos    =  e? e.pageX : window.event.clientX;
		MAIN.yPos    =  e? e.pageY : window.event.clientY;
		if (document.all && !document.captureEvents) {
		    MAIN.xPos    += document[MAIN.docEl].scrollLeft;
		    MAIN.yPos    += document[MAIN.docEl].scrollTop;
	    }
	    if (document.layers) routeEvent(e);
	},

	/*Entertaste checken*/
	chk_enter	:	function(event, method){
		if (event && (event.which == 13 || event.keyCode == 13)){
			switch(method){

			}
		}
	},

	/*Onload*/
	dom_loaded	:	function(){
		if(this.ie6){
			BugFixPngs();
			clearInterval(this.bugfix_interval);
		}
	},

	/*Bookmark*/
	bookmark : function(title,url) {
		if (window.sidebar) { // Mozilla Firefox Bookmark
			window.sidebar.addPanel(title, url,"");
		} else if( window.external ) { // IE Favorite
			window.external.AddFavorite( url, title); }
		else if(window.opera && window.print) { // Opera Hotlist
			return true; }
	},

	/*Create AJAX Request*/
	_createRequest :	function(){
		this.reqCounter = (!this.reqCounter)?1:this.reqCounter+1;
		var req = 0;
		if(navigator.appName.search("Microsoft")>-1){
			req = new ActiveXObject("Microsoft.XMLHTTP");
		}else{
			req = new XMLHttpRequest();
		}
		return req;
	},

	/*Run AJAX Request*/
	request	:	function(query, callback){
		var req = this._createRequest();
		req.open("POST", "ajax.php", true);
		req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		req.onreadystatechange = function (){
			if(typeof callback == "object"){
				if(req.readyState==4){
					if(typeof callback.Ready == "function"){
						callback.Ready(req.responseText);
					}
				}else {
					if(typeof callback.Loading == "function"){
						callback.Loading(req.readyState);
					}
				}
			}
		}
		req.send(query);
	},

	/*Download*/
	download	:	function(param){
		if(param.url!=0){
			document.getElementById('downloadframe').src = param.url;
		}
		var pop = document.getElementById('gbpopup');
		pop.style.top = this.yPos+"px";
		pop.style.left = this.xPos+"px";
		pop.style.display = 'block';
	}
}

MAIN._startup();
onload = MAIN.dom_loaded;