var TOOLS = {
	docTitle:'',
	w:0,
	h:0,
	l:0,
	t:0,
	isDefined: function (nobj) {return (typeof nobj!='undefined');},
	size: function(event) {
		try {
			var lw = 800, lh = 500, ll = 0, lt = 0;
			var lde = document.documentElement;
			var lbd = document.body;
			if (TOOLS.isDefined(window.innerWidth) && TOOLS.isDefined(window.innerHeight)) {lw = window.innerWidth;lh = window.innerHeight;} 
			else if(lbd && ( lbd.clientWidth || lbd.clientHeight ) ) { lw = lbd.clientWidth;lh = lbd.clientHeight;} 
			else if(lde && ( lde.clientWidth || lde.clientHeight ) ) {lw = lde.clientWidth;lh = lde.clientHeight;} 
			else if(lbd){lw = lbd.offsetWidth;lh = lbd.offsetHeight;}
			
			if( typeof( window.pageYOffset ) == 'number' ) {ll = window.pageXOffset;lt = window.pageYOffset;} 
			else {
				var de = document.documentElement;
				var bd = document.body;
				if ( lde && ( lde.scrollLeft || lde.scrollTop ) ) {ll = lde.scrollLeft;lt = lde.scrollTop;} 
				else if( lbd && ( lbd.scrollLeft || lbd.scrollTop ) ) {ll = lbd.scrollLeft;lt = lbd.scrollTop;}
			}
			if (ll < 0){ll = 0;}
			if (lt < 0){lt = 0;}

			TOOLS.l = ll;
			TOOLS.t = lt;
			TOOLS.w = lw;
			TOOLS.h = lh;
		} catch(err) {}
	},
	goOut: function(_link){
		var url=_link;
		var lcon = '' +
      	'<b>Bu bağlantı sizi "komikler.com" dışında bir siteye yönlendirecektir</b>. <br/><br/>' +
      	'"komikler.com" sitesinin, yönlendiğiniz bu site üzerinde hiçbir kontrolü yoktur ve kullanımından sorumlu değildir. <br/><br/>' +
      	'<b>' + _link + '</b> adresine bağlanmak istiyor musunuz?<br/><br/>' +
			'';
		
		var _buttons= new Array();
		_buttons[0] = {bg:'#F77F00',color:'#ffffff',caption:'Evet',action:'TOOLS.goOut_(\'' + _link + '\',\'\');'};
		_buttons[1] = {bg:'#DCFFBE',color:'#003e5c',caption:'Hayır',action:'TOOLS.closeDialog();'};
		TOOLS.showDialog('UYARI !',lcon,_buttons);
		
	},
	goOut_: function(nurl, ncde) {
		try {
			var lwin = window.open(nurl, ncde);
			if (!lwin) {alert('Yeni pencere, "Açılır pencere engelleyicisi" tarafından engellendi.');}
		} 
		catch(err) {alert('Yeni pencere, "Açılır pencere engelleyicisi" tarafından engellendi.\n' + err.description);}
	},
	getInt: function (nval, ndef) {
		if (!TOOLS.isDefined(ndef)){ndef = 0;}
		if (!TOOLS.isDefined(nval)){return ndef;}
		if(nval==''){return ndef;}
		var rtr=ndef;
		rtr=parseInt(nval+'');
		if(isNaN(rtr)){return ndef;}
		if(rtr==(rtr+1)){return ndef;}
		if (!TOOLS.isDefined(rtr)){return ndef;}
		if((typeof rtr)=='number'){return rtr;}
		return ndef;
	},	
	coorSet: function(nobj, ntyp, nval, npx) {
		nobj = TOOLS.getObject(nobj);
		if (!nobj) {return false;}
		var lpx = '';
		if (npx) {lpx = 'px';}
		var pxval = TOOLS.getInt(nval);
		if (pxval == 0) {pxval = 1;}
		if ((ntyp == 'w') || (ntyp == 'h')) {if (pxval < 0) {pxval = 1;}}
		if (npx) {pxval += '' + lpx;}
		try{
			if (ntyp == 'w') {nobj.style.width = pxval;} 
			else if (ntyp == 'h') {nobj.style.height = pxval;} 
			else if (ntyp == 't') {nobj.style.top = pxval;} 
			else if (ntyp == 'l') {nobj.style.left = pxval;}
		}
		catch(err) {}
		return true;
	},
	getObject: function (nobj) {
		if (typeof(nobj) == 'string') {
			if (nobj == '') {nobj = null;}
			if (document.getElementById) {nobj =  document.getElementById(nobj);} 
			else if (document.all) {nobj =  document.all[nobj];} 
			else if (document.layers) {nobj =  document.layers[nobj];} 
			else {nobj = null;}
		}
		if (!nobj) {return false;}
		return nobj;
	},	
	backgroundAlign: function() {
		TOOLS.coorSet('layerBG', 'w', TOOLS.w, true);
		TOOLS.coorSet('layerBG', 'h', TOOLS.h, true);
		TOOLS.coorSet('layerBG', 't', TOOLS.t, true);
	},
	backgroundShow: function() {
		TOOLS.size();
		try {document.body.style.overflow = 'hidden';} catch(err) {}
		TOOLS.backgroundAlign();
		if (!TOOLS.visibleGet('layerBG')) {
			TOOLS.visibleSet('layerBG', true);
		}
		TOOLS.opacitySet('layerBG', 80);
		return true;
	},
	backgroundHide: function() {
		TOOLS.visibleSet('layerBG', false);
		try {document.documentElement.style.overflow = '';} catch(err) {}
		try {document.body.style.overflow = '';} catch(err) {}
		return true;
	},
	visibleSet: function(nobj, nval) {
		nobj = TOOLS.getObject(nobj);
		if (!nobj) {return false;}
		if (nval) {nobj.style.display = 'block';} 
		else {nobj.style.display = 'none';}
		return true;
	},
	visibleGet: function(nobj) {
		nobj = TOOLS.getObject(nobj);
		if (!nobj) {return false;}
		if(nobj.style.display==''){nobj.style.display='block';}
		return (nobj.style.display != 'none');
	},
	opacitySet: function (nobj,nval) {
		nobj = TOOLS.getObject(nobj,true);
		if (!(nobj)) {return;}
		try{nobj.style.opacity = (nval / 100);} catch(err) {alert(err.description);}
		try{nobj.style.MozOpacity = (nval / 100);} catch(err) {alert(err.description);}
		try{nobj.style.KhtmlOpacity = (nval / 100);} catch(err) {alert(err.description);}
		try{nobj.style.filter = 'alpha(opacity=' + nval + ')';} catch(err) {alert(err.description);}
	},
	closeDialog: function(){
		var _pb = TOOLS.getObject('popUpBox');
		_pb.innerHTML='';
		TOOLS.visibleSet('popUpBox',false);
		TOOLS.backgroundHide();
	},
	showDialog: function(caption,string,buttons){
		try{
			var _w=450,_h=200;
			TOOLS.backgroundShow();
			var _returnString='';
			_returnString += '<div class="popupCaptionBar"><div class="popupCaption">' + caption + '</div></div>';
			_returnString += '<div class="popupBodyContainer">';
				_returnString += '<div class="popupBodyText">' + string + '</div>';
				_returnString += '<div class="popupButtonContainer">';
				for (var i=0;i<buttons.length;i++){
					_returnString += '<div class="popupButton" onclick="'+buttons[i].action+'" style="background:'+buttons[i].bg+';color:'+buttons[i].color+'">'+buttons[i].caption+'</div>';
				}
				_returnString += '<div class="c"></div>';
				_returnString += '</div>';
			_returnString += '</div>';			
			var _pb = TOOLS.getObject('popUpBox');
			_pb.innerHTML=_returnString;
			TOOLS.coorSet('popUpBox','w',_w);
			TOOLS.coorSet('popUpBox','h',_h);
			TOOLS.coorSet('popUpBox','l',TOOLS.getInt((TOOLS.w - _w)/2));
			TOOLS.coorSet('popUpBox','t',TOOLS.getInt((TOOLS.h - _h)/2));
			TOOLS.visibleSet('popUpBox',true);
			
		}
		catch(err){
			alert(err.description);
		}
	},
	___TEMP:0
}














function XmlInstance(nRequest){
	this.running		= true;
	this.http			= null;
	this.browserType	= 'moz';
	this.read			= false;
	this.sent			= false;
	this.name			= "XmlInstance";
	this.request		= nRequest;
	this.clear= function() {this.http = null;this.read = false;this.sent = false;
	};
	this.ready= function() {
		if (!this) {return false;}
		if (!this.http) {return false;}
		try{if ((this.http.readyState == 4) || (this.http.readyState == 'complete')) {return (this.http.status >= 200);}} 
		catch(err) {}
		return false;
	};
	this.response=function(){
		switch(this.request._data){
			case "TEXT":return this.text();break;
			case "JSON":return this.json();break;
			case "XML":return this.xml();break;
			default:return this.text();break;
		}
	}
	this.json=function() {return eval ('('+this.http.responseText+')');};
	this.text=function() {return this.http.responseText;};
	this.xml= function() {return this.http.responseXML;};
	this.initialize= function() {
		if (window.XMLHttpRequest) {this.http = new XMLHttpRequest();browserType = 'moz';} 
		else if (window.ActiveXObject) { // IE
			browserType = 'ie';
			try {this.http = new ActiveXObject('Msxml2.XMLHTTP');} 
			catch(e) {this.http = new ActiveXObject('Microsoft.XMLHTTP');}
		} 
		else {return false;}
		this.http._parent=this;
		return true;
	};
	this.send= function() {
		if(this.request._param==''){this.request._param='_data=' + this.request._data;}
		else {this.request._param += '&_data=' + this.request._data;}
		if ( this.request._method == 'POST') {
			try{this.http.open('POST', this.request._url, true);}
			catch(err) {alert(err.description);alert('XML Oluşturulamadı / http.open!');return false;}
			this.http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded;charset=iso-8859-9');
			this.http.onreadystatechange = function() {
				if (!this._parent) {return;}
				if (this._parent.ready() && !this._parent.read) {
					this._parent.read = true;
					this._parent.request.onSuccess(this._parent);
				}
			};
			if (!(this.sent)) {this.request._param += '&__r=' + Math.random();this.http.send(this.request._param);this.sent = true;}
		} 
		else {
			if ( this.request._url.indexOf('?') != -1){ this.request._url = this.request._url + '&' + this.request._param;}
			else { this.request._url = this.request._url + '?' + this.request._param; }
			this.request._param += '&__r=' + Math.random();
			this.http.open('GET', this.request._url, true);
			this.http.onreadystatechange = function() {
				if (!this._parent) {return;}
				if (this._parent.ready() && !this._parent.read) {
					this._parent.read = true;
					this._parent.request.onSuccess(this._parent);
					
				}
			};
			if (browserType == 'moz') {if (!(this.sent)) {this.http.send(null);this.sent = true;}} 
			else {if (!(this.sent)) {this.http.send();this.sent = true;}}
		}
	};
	
	if(!this.initialize()){return false;}
	this.send();
}
var AX={
	getUserDetails:function (IMGFOLDER) {
		var _xml=new XmlInstance(
			{
				_method:'GET',
				_data:'JSON',
				_url:'http://www.komikler.com/__tools/ax/userdetails.php',
				_param:'',
				onSuccess: function(response){
					var _res=response.response();
					TOOLS.getObject('msgimg').src=_res.unreadmsgs>0?IMGFOLDER+'msgf.gif':IMGFOLDER+'msg.gif';
					TOOLS.getObject('txtMsgs').innerHTML=_res.unreadmsgs;
					if(_res.unreadmsgs>0){document.title='(' + _res.unreadmsgs + ') ' + TOOLS.docTitle;}
					TOOLS.getObject('txtOnln').innerHTML=_res.online;
					TOOLS.getObject('txtFrnd').innerHTML=_res.friends;
					TOOLS.getObject('txtCmnts').innerHTML=_res.waitingcmnts;
					TOOLS.getObject('txtInvt').innerHTML=_res.invitations;
				}
			}					
		);
	},
	___TEMP:0
}

TOOLS.docTitle=document.title;
