function xxyyxx(id, pid, name, url, title, target, icon, iconOpen, open) {
	this.id = id;
	this.pid = pid;
	this.name = name;
	this.url = url;
	this.title = title;
	this.target = target;
	this.icon = icon;
	this.iconOpen = iconOpen;
	this._io = open || false;
	this._is = false;
	this._ls = false;
	this._hc = false;
	this._ai = 0;
	this._p;
};

function altkategoriler(objName) {
	this.config = {
		target				: null,
		klasorLinks			: true,
		useSelection		: true,
		useCookies			: true,
		usecizgis			: true,
		useIcons			: true,
		useStatusText		: false,
		closeSameLevel		: false,
		inOrder				: false
	}

	this.icon = {
		anaarama		: 'http://statik.ototurk.com/img/anaarama.gif',
		klasor			: 'http://statik.ototurk.com/img/klasor.gif',
		klasoracik		: 'http://statik.ototurk.com/img/klasoracik.gif',
		xxyyxx			: 'http://statik.ototurk.com/img/sayfa.gif',
		zero			: 'http://statik.ototurk.com/img/zero.gif',
		cizgi			: 'http://statik.ototurk.com/img/cizgi.gif',
		alt				: 'http://statik.ototurk.com/img/alt.gif',
		altalt			: 'http://statik.ototurk.com/img/altalt.gif',
		acilir			: 'http://statik.ototurk.com/img/acilir.gif',
		acilirson		: 'http://statik.ototurk.com/img/acilirson.gif',
		kapa			: 'http://statik.ototurk.com/img/kapa.gif',
		kapason			: 'http://statik.ototurk.com/img/kapason.gif',
		nlacilir		: 'http://statik.ototurk.com/img/cizgiyok_acilir.gif',
		nlkapa			: 'http://statik.ototurk.com/img/cizgiyok_kapa.gif'
	};

	this.obj = objName;
	this.axxyyxxs = [];
	this.aIndent = [];
	this.anaarama = new xxyyxx(-1);
	this.selectedxxyyxx = null;
	this.selectedFound = false;
	this.completed = false;
};

altkategoriler.prototype.add = function(id, pid, name, url, title, target, icon, iconOpen, open) {
	this.axxyyxxs[this.axxyyxxs.length] = new xxyyxx(id, pid, name, url, title, target, icon, iconOpen, open);
};


altkategoriler.prototype.openAll = function() {
	this.oAll(true);
};

altkategoriler.prototype.closeAll = function() {
	this.oAll(false);
};

altkategoriler.prototype.toString = function() {
	var str = '<div class="altkategoriler" style="WIDTH: 160px;">\n';
	if (document.getElementById) {
		if (this.config.useCookies) this.selectedxxyyxx = this.getSelected();
		str += this.addxxyyxx(this.anaarama);
	} else str += 'Browser not supported.';
	str += '</div>';
	if (!this.selectedFound) this.selectedxxyyxx = null;
	this.completed = true;
	return str;
};

altkategoriler.prototype.addxxyyxx = function(pxxyyxx) {
	var str = '';
	var n=0;
	if (this.config.inOrder) n = pxxyyxx._ai;
	for (n; n<this.axxyyxxs.length; n++) {
		if (this.axxyyxxs[n].pid == pxxyyxx.id) {
			var cn = this.axxyyxxs[n];
			cn._p = pxxyyxx;
			cn._ai = n;
			this.setCS(cn);
			if (!cn.target && this.config.target) cn.target = this.config.target;
			if (cn._hc && !cn._io && this.config.useCookies) cn._io = this.isOpen(cn.id);
			if (!this.config.klasorLinks && cn._hc) cn.url = null;
			if (this.config.useSelection && cn.id == this.selectedxxyyxx && !this.selectedFound) {
					cn._is = true;
					this.selectedxxyyxx = n;
					this.selectedFound = true;
			}
			str += this.xxyyxx(cn, n);
			if (cn._ls) break;
		}
	}
	return str;
};


altkategoriler.prototype.xxyyxx = function(xxyyxx, xxyyxxId) {
	var str = '<div class="altkategorilerxxyyxx" style="WIDTH: 160px;">' + this.indent(xxyyxx, xxyyxxId);
	if (this.config.useIcons) {
		if (!xxyyxx.icon) xxyyxx.icon = (this.anaarama.id == xxyyxx.pid) ? this.icon.anaarama : ((xxyyxx._hc) ? this.icon.klasor : this.icon.xxyyxx);
		if (!xxyyxx.iconOpen) xxyyxx.iconOpen = (xxyyxx._hc) ? this.icon.klasoracik : this.icon.xxyyxx;
		if (this.anaarama.id == xxyyxx.pid) {
			xxyyxx.icon = this.icon.anaarama;
			xxyyxx.iconOpen = this.icon.anaarama;
		}
		str += '<img border=0 id="i' + this.obj + xxyyxxId + '" src="' + ((xxyyxx._io) ? xxyyxx.iconOpen : xxyyxx.icon) + '" alt="" />';
	}
	if (xxyyxx.url) {
		str += '<a id="s' + this.obj + xxyyxxId + '" class="' + ((this.config.useSelection) ? ((xxyyxx._is ? 'xxyyxxSel' : 'xxyyxx')) : 'xxyyxx') + '" href="' + xxyyxx.url + '"';
		if (xxyyxx.title) str += ' title="' + xxyyxx.title + '"';
		if (xxyyxx.target) str += ' target="' + xxyyxx.target + '"';
		if (this.config.useStatusText) str += ' onmouseover="window.status=\'' + xxyyxx.name + '\';return true;" onmouseout="window.status=\'\';return true;" ';
		if (this.config.useSelection && ((xxyyxx._hc && this.config.klasorLinks) || !xxyyxx._hc))
			str += ' onclick="javascript: ' + this.obj + '.s(' + xxyyxxId + ');"';
		str += '>';
	}
	else if ((!this.config.klasorLinks || !xxyyxx.url) && xxyyxx._hc && xxyyxx.pid != this.anaarama.id)
		str += '<a href="javascript: ' + this.obj + '.o(' + xxyyxxId + ');" class="xxyyxx">';
	str += xxyyxx.name;
	if (xxyyxx.url || ((!this.config.klasorLinks || !xxyyxx.url) && xxyyxx._hc)) str += '</a>';
	str += '</div>';
	if (xxyyxx._hc) {
		str += '<div style="WIDTH: 160px; " id="d' + this.obj + xxyyxxId + '" class="clip" style="display:' + ((this.anaarama.id == xxyyxx.pid || xxyyxx._io) ? 'block' : 'none') + ';">';
		str += this.addxxyyxx(xxyyxx);
		str += '</div>';
	}
	this.aIndent.pop();
	return str;
};

altkategoriler.prototype.indent = function(xxyyxx, xxyyxxId) {
	var str = '';
	if (this.anaarama.id != xxyyxx.pid) {
		for (var n=0; n<this.aIndent.length; n++)
			str += '<img border=0 width=18 height=18 src="' + ( (this.aIndent[n] == 1 && this.config.usecizgis) ? this.icon.cizgi : this.icon.zero ) + '" alt="" />';
		(xxyyxx._ls) ? this.aIndent.push(0) : this.aIndent.push(1);
		if (xxyyxx._hc) {
			str += '<a href="javascript: ' + this.obj + '.o(' + xxyyxxId + ');"><img border=0 id="j' + this.obj + xxyyxxId + '" src="';
			if (!this.config.usecizgis) str += (xxyyxx._io) ? this.icon.nlkapa : this.icon.nlacilir;
			else str += ( (xxyyxx._io) ? ((xxyyxx._ls && this.config.usecizgis) ? this.icon.kapason : this.icon.kapa) : ((xxyyxx._ls && this.config.usecizgis) ? this.icon.acilirson : this.icon.acilir ) );
			str += '" alt="" /></a>';
		} else str += '<img border=0 src="' + ( (this.config.usecizgis) ? ((xxyyxx._ls) ? this.icon.altalt : this.icon.alt ) : this.icon.zero) + '" alt="" />';
	}
	return str;
};

altkategoriler.prototype.setCS = function(xxyyxx) {
	var lastId;
	for (var n=0; n<this.axxyyxxs.length; n++) {
		if (this.axxyyxxs[n].pid == xxyyxx.id) xxyyxx._hc = true;
		if (this.axxyyxxs[n].pid == xxyyxx.pid) lastId = this.axxyyxxs[n].id;
	}
	if (lastId==xxyyxx.id) xxyyxx._ls = true;
};

altkategoriler.prototype.getSelected = function() {
	var sn = this.getCookie('cs' + this.obj);
	return (sn) ? sn : null;
};

altkategoriler.prototype.s = function(id) {
	if (!this.config.useSelection) return;
	var cn = this.axxyyxxs[id];
	if (cn._hc && !this.config.klasorLinks) return;
	if (this.selectedxxyyxx != id) {
		if (this.selectedxxyyxx || this.selectedxxyyxx==0) {
			eOld = document.getElementById("s" + this.obj + this.selectedxxyyxx);
			eOld.className = "xxyyxx";
		}
		eNew = document.getElementById("s" + this.obj + id);
		eNew.className = "xxyyxxSel";
		this.selectedxxyyxx = id;
		if (this.config.useCookies) this.setCookie('cs' + this.obj, cn.id);
	}
};

altkategoriler.prototype.o = function(id) {
	var cn = this.axxyyxxs[id];
	this.xxyyxxStatus(!cn._io, id, cn._ls);
	cn._io = !cn._io;
	if (this.config.closeSameLevel) this.closeLevel(cn);
	if (this.config.useCookies) this.updateCookie();
};

altkategoriler.prototype.oAll = function(status) {
	for (var n=0; n<this.axxyyxxs.length; n++) {
		if (this.axxyyxxs[n]._hc && this.axxyyxxs[n].pid != this.anaarama.id) {
			this.xxyyxxStatus(status, n, this.axxyyxxs[n]._ls)
			this.axxyyxxs[n]._io = status;
		}
	}
	if (this.config.useCookies) this.updateCookie();
};

altkategoriler.prototype.openTo = function(nId, bSelect, bFirst) {
	if (!bFirst) {
		for (var n=0; n<this.axxyyxxs.length; n++) {
			if (this.axxyyxxs[n].id == nId) {
				nId=n;
				break;
			}
		}
	}
	var cn=this.axxyyxxs[nId];
	if (cn.pid==this.anaarama.id || !cn._p) return;
	cn._io = true;
	cn._is = bSelect;
	if (this.completed && cn._hc) this.xxyyxxStatus(true, cn._ai, cn._ls);
	if (this.completed && bSelect) this.s(cn._ai);
	else if (bSelect) this._sn=cn._ai;
	this.openTo(cn._p._ai, false, true);
};

altkategoriler.prototype.closeLevel = function(xxyyxx) {
	for (var n=0; n<this.axxyyxxs.length; n++) {
		if (this.axxyyxxs[n].pid == xxyyxx.pid && this.axxyyxxs[n].id != xxyyxx.id && this.axxyyxxs[n]._hc) {
			this.xxyyxxStatus(false, n, this.axxyyxxs[n]._ls);
			this.axxyyxxs[n]._io = false;
			this.closeAllChildren(this.axxyyxxs[n]);
		}
	}
}

altkategoriler.prototype.closeAllChildren = function(xxyyxx) {
	for (var n=0; n<this.axxyyxxs.length; n++) {
		if (this.axxyyxxs[n].pid == xxyyxx.id && this.axxyyxxs[n]._hc) {
			if (this.axxyyxxs[n]._io) this.xxyyxxStatus(false, n, this.axxyyxxs[n]._ls);
			this.axxyyxxs[n]._io = false;
			this.closeAllChildren(this.axxyyxxs[n]);		
		}
	}
}

altkategoriler.prototype.xxyyxxStatus = function(status, id, bottom) {
	eDiv	= document.getElementById('d' + this.obj + id);
	ealt	= document.getElementById('j' + this.obj + id);
	if (this.config.useIcons) {
		eIcon	= document.getElementById('i' + this.obj + id);
		eIcon.src = (status) ? this.axxyyxxs[id].iconOpen : this.axxyyxxs[id].icon;
	}
	ealt.src = (this.config.usecizgis)?
	((status)?((bottom)?this.icon.kapason:this.icon.kapa):((bottom)?this.icon.acilirson:this.icon.acilir)):
	((status)?this.icon.nlkapa:this.icon.nlacilir);
	eDiv.style.display = (status) ? 'block': 'none';
};

altkategoriler.prototype.clearCookie = function() {
	var now = new Date();
	var yesterday = new Date(now.getTime() - 1000 * 60 * 60 * 24);
	this.setCookie('co'+this.obj, 'cookieValue', yesterday);
	this.setCookie('cs'+this.obj, 'cookieValue', yesterday);
};

altkategoriler.prototype.setCookie = function(cookieName, cookieValue, expires, path, domain, secure) {
	document.cookie =
		escape(cookieName) + '=' + escape(cookieValue)
		+ (expires ? '; expires=' + expires.toGMTString() : '')
		+ (path ? '; path=' + path : '')
		+ (domain ? '; domain=' + domain : '')
		+ (secure ? '; secure' : '');
};

altkategoriler.prototype.getCookie = function(cookieName) {
	var cookieValue = '';
	var posName = document.cookie.indexOf(escape(cookieName) + '=');
	if (posName != -1) {
		var posValue = posName + (escape(cookieName) + '=').length;
		var endPos = document.cookie.indexOf(';', posValue);
		if (endPos != -1) cookieValue = unescape(document.cookie.substring(posValue, endPos));
		else cookieValue = unescape(document.cookie.substring(posValue));
	}
	return (cookieValue);
};

altkategoriler.prototype.updateCookie = function() {
	var str = '';
	for (var n=0; n<this.axxyyxxs.length; n++) {
		if (this.axxyyxxs[n]._io && this.axxyyxxs[n].pid != this.anaarama.id) {
			if (str) str += '.';
			str += this.axxyyxxs[n].id;
		}
	}
	this.setCookie('co' + this.obj, str);
};

altkategoriler.prototype.isOpen = function(id) {
	var aOpen = this.getCookie('co' + this.obj).split('.');
	for (var n=0; n<aOpen.length; n++)
		if (aOpen[n] == id) return true;
	return false;
};

if (!Array.prototype.push) {
	Array.prototype.push = function array_push() {
		for(var i=0;i<arguments.length;i++)
			this[this.length]=arguments[i];
		return this.length;
	}
};

if (!Array.prototype.pop) {
	Array.prototype.pop = function array_pop() {
		lastElement = this[this.length-1];
		this.length = Math.max(this.length-1,0);
		return lastElement;
	}
};