﻿if(typeof Mackolik=="undefined"){var Mackolik={};}
if(typeof Mackolik.widget=="undefined"){Mackolik.widget={};}

Mackolik.StringBuilder = function() {
    this._strings = [];
    this.append = function(s) { this._strings.push(s); };
    this.toString = function() { return this._strings.join(''); };
    this.appendFormat = function(pattern) {
        var args = arguments;
        var s = pattern.replace(/\{(\d+)\}/g,
            function(pattern, index) {
                return args[parseInt(index) + 1].toString();
            });
        this._strings.push(s);
    };
    return this;
};

Mackolik.widget.Carousel = function() {
	return this;
};

Mackolik.widget.Carousel.prototype = {
	init : function(el, oConfig) {
		this.oConfig = oConfig;
		this.sTag = oConfig.tag || "ul"
		this.nVisiblePanes = oConfig.visiblePanes || 1;
		this.nPanesToMove = oConfig.panesToMove || this.nVisiblePanes;
		this.bHorizontal = !oConfig.isVertical;
		this.bLoop = oConfig.loop || 0;
		this.oCont = YAHOO.util.Dom.get(el);
		this.oClip = YAHOO.util.Dom.getElementsByClassName('clip', 'div', this.oCont)[0];
		//this.aPanels = this.oCont.getElementsByTagName(this.sTag);
		this.aProviders = [];
		var aPanel = this.oCont.getElementsByTagName(this.sTag);
		
		for (var i=0; i<aPanel.length; i++) {
			this.aProviders[i] = {};
			this.aProviders[i].oPanel = aPanel[i];
			this.aProviders[i].nCurrentPane = 0;
		}
		this.nCurrentProvider = 0;
		//this.oPanel = this.oCont.getElementsByTagName(this.sTag)[0];
		this.oButtonCont = oConfig.buttonCont || this.oCont;
		//this.nCurrentPane = 0;
		YAHOO.util.Dom.addClass(this.oCont, "js");
		YAHOO.util.Dom.addClass(this.oCont, (this.bHorizontal) ? "horz" : "vert");
		this.assignElements();
		YAHOO.util.Dom.setStyle(this.oClip, "overflow", "hidden");
		YAHOO.util.Dom.setStyle(this.oClip, "clip", "rect(0 "
				+ this.oCont.offsetWidth + "px " + this.oCont.offsetHeight
				+ "px 0)");
		this.createNav();
		this.createEvents();
		this.onAnimStart.fire();
		return this;
	},
	changeClip : function () {
		//YAHOO.util.Dom.setStyle(YAHOO.util.Dom.getElementsByClassName('clip', 'div', this.oCont), "display", "none");
		this.oClip = YAHOO.util.Dom.getElementsByClassName('clip', 'div', this.oCont)[this.activeProvider];
		this.oPanel = this.oCont.getElementsByTagName(this.sTag)[this.activeProvider];
		this.nCurrentPane = 0;
		this.assignElements();
		YAHOO.util.Dom.setStyle(this.oClip, "overflow", "hidden");
		YAHOO.util.Dom.setStyle(this.oClip, "clip", "rect(0 "
				+ this.oCont.offsetWidth + "px " + this.oCont.offsetHeight
				+ "px 0)");		
	},
	assignElements : function() {
		for (var n=0; n<this.aProviders.length; n++){
			var oPanel = this.aProviders[n].oPanel;
			this.aProviders[n].aPanels = YAHOO.util.Dom.getElementsBy(function(o) {
				if (o.parentNode == oPanel) {
					return true;
				}
				return false;
			}, "li", this.aProviders[n].oPanel);
			var nPadding = this.getPadding(this.aProviders[n].aPanels[0]);
			var nPaddingCont = this.getPadding(this.oCont);
			this.nMoveInc = Math.floor((this.bHorizontal)
						? (this.oCont.offsetWidth - nPaddingCont) / this.nVisiblePanes
						: (this.oCont.offsetHeight - nPaddingCont) / this.nVisiblePanes)
				- nPadding;
			for (var i = 0, j = this.aProviders[n].aPanels.length; i < j; i++) {
				if (this.bHorizontal) {
					this.aProviders[n].aPanels[i].style.width = this.nMoveInc + "px";
				} else {
					this.aProviders[n].aPanels[i].style.height = this.nMoveInc + "px";
				}
			}
			this.nMoveInc += nPadding;
			this.aProviders[n].nPanes = this.aProviders[n].aPanels.length;
		}
	},
	getPadding : function(o) {
		return (this.bHorizontal)
				? (parseInt(YAHOO.util.Dom.getStyle(o, "paddingRight"))
						+ parseInt(YAHOO.util.Dom.getStyle(o, "paddingLeft"))
						+ parseInt(YAHOO.util.Dom.getStyle(o, "borderRightWidth").replace("medium", 0)) 
						+ parseInt(YAHOO.util.Dom.getStyle(o, "borderLeftWidth").replace("medium", 0)))
				: (parseInt(YAHOO.util.Dom.getStyle(o, "paddingBottom"))
						+ parseInt(YAHOO.util.Dom.getStyle(o, "paddingTop"))
						+ parseInt(YAHOO.util.Dom.getStyle(o, "borderTopWidth").replace("medium", 0)) 
						+ parseInt(YAHOO.util.Dom.getStyle(o, "borderBottomWidth").replace("medium", 0)));
	},
	createNav : function() {
		this.oButtonCont = YAHOO.util.Dom.get(this.oButtonCont);
		this.oBtnPrev = document.createElement("button");
		YAHOO.util.Dom.addClass(this.oBtnPrev, "btnprev");
		this.oBtnPrev.appendChild(document.createTextNode("<"));
		this.oButtonCont.appendChild(this.oBtnPrev);
		this.oBtnNext = document.createElement("button");
		YAHOO.util.Dom.addClass(this.oBtnNext, "btnnext");
		this.oBtnNext.appendChild(document.createTextNode(">"));
		this.oButtonCont.appendChild(this.oBtnNext);
	},
	createEvents : function() {
		this.onAnimStart = new YAHOO.util.CustomEvent("onAnimStart");
		this.onAnimEnd = new YAHOO.util.CustomEvent("onAnimEnd");

		this.onNavigate = new YAHOO.util.CustomEvent("onNavigate");
		this.onCarouselEnd = new YAHOO.util.CustomEvent("onCarouselEnd");
		
		this.onAnimStart.subscribe(this.enableButtons, this, true);
		this.onAnimEnd.subscribe(this.enableButtons, this, true);
		
		//this.onCarouselEnd.subscribe(function(){alert('end')}, this, true);
		
		YAHOO.util.Event.on(this.oBtnPrev, 'click', function(e) {
			this.moveBy(e, -1)
		}, this, true);
		YAHOO.util.Event.on(this.oBtnNext, 'click', function(e) {
			this.moveBy(e, 1)
		}, this, true);
	},
	enableButtons : function() {
		this.oBtnPrev.disabled = false;
		this.oBtnNext.disabled = false;

		YAHOO.util.Dom.removeClass(this.oBtnPrev, "btnprevdisabled");
		YAHOO.util.Dom.removeClass(this.oBtnNext, "btnnextdisabled");

		if ((!this.aProviders[this.nCurrentProvider].nCurrentPane && !this.bLoop)
				|| this.nVisiblePanes > this.aProviders[this.nCurrentProvider].nPanes) {
			YAHOO.util.Dom.addClass(this.oBtnPrev, "btnprevdisabled");
			this.oBtnPrev.disabled = true;
		}
		if ((this.aProviders[this.nCurrentProvider].nCurrentPane >= this.aProviders[this.nCurrentProvider].nPanes - this.nVisiblePanes && !this.bLoop)
				|| (this.bLoop && this.nVisiblePanes > this.aProviders[this.nCurrentProvider].nPanes)) {
			YAHOO.util.Dom.addClass(this.oBtnNext, "btnnextdisabled");
			this.oBtnNext.disabled = true;
		}
	},
	moveBy : function(e, nPanes) {
		if (e) {
			YAHOO.util.Event.preventDefault(e);
			this.onNavigate.fire();
		}
		this.aProviders[this.nCurrentProvider].nCurrentPane += nPanes * this.nPanesToMove;
		if (this.aProviders[this.nCurrentProvider].nCurrentPane + this.nVisiblePanes - this.nPanesToMove >= this.aProviders[this.nCurrentProvider].nPanes) {
			if (this.bLoop) {
				this.aProviders[this.nCurrentProvider].nCurrentPane = 0;
			}
			this.onCarouselEnd.fire();
		} else if (this.aProviders[this.nCurrentProvider].nCurrentPane <= -this.nPanesToMove) {
			if (this.bLoop) {
				this.aProviders[this.nCurrentProvider].nCurrentPane = this.aProviders[this.nCurrentProvider].nPanes + (nPanes * this.nPanesToMove);
			}
			this.onCarouselEnd.fire();
		}
		this.gotoPane(this.aProviders[this.nCurrentProvider].nCurrentPane);
	},
	gotoPane : function(nPane) {
		nPane = Math.max(0, nPane);
		if (nPane > this.aProviders[this.nCurrentProvider].nPanes - this.nVisiblePanes) {
			nPane = this.aProviders[this.nCurrentProvider].nPanes - this.nVisiblePanes;
		}
		this.aProviders[this.nCurrentProvider].nCurrentPane = nPane;
		var oAnim = new YAHOO.util.Anim(this.aProviders[this.nCurrentProvider].oPanel, (this.bHorizontal) ? {
			left : {
				to : -this.nMoveInc * nPane
			}
		} : {
			top : {
				to : -this.nMoveInc * nPane
			}
		}, this.oConfig.animDuration || 0.5, this.oConfig.easing
				|| YAHOO.util.Easing.easeBoth);
		var onAnimEnd = function(type, args) {
			this.onAnimEnd.fire();
		};
		oAnim.onComplete.subscribe(onAnimEnd, this, true);
		this.onAnimStart.fire();
		oAnim.animate();
	}
};

Mackolik.widget.Carousel.prototype.autoPlay = function(oConfig) {
	var self = this;
	if (oConfig) {
		this.oAutoConfig = oConfig;
		this.oBtnPause = document.createElement("button");
		YAHOO.util.Dom.addClass(this.oBtnPause, "btnpause");
		this.oBtnPause.appendChild(document.createTextNode(this.oAutoConfig.buttonLabel));
		this.oButtonCont.appendChild(this.oBtnPause);
		YAHOO.util.Event.on(this.oBtnPause, 'click', this.pause, this, true);
		this.onNavigate.subscribe(function() {
			this.pause(true)
		}, this, true);
	}
	if (this.nVisiblePanes >= this.aProviders[this.nCurrentProvider].nPanes) {
		return this;
	}
	this.bPaused = 0;
	YAHOO.util.Dom.removeClass(this.oBtnPause, "btnpausedisabled");
	this.oTimer = window.setInterval(function() {
		self.moveBy(null, 1);
	}, this.oAutoConfig.autoPlayDelay || 5000);
	
	this.oProviderTimer=window.setInterval(
		function(){
			var number = 0;
			if (self.nCurrentProvider == self.aProviders.length-1) {
				number = 0;
			} else {
				number = self.nCurrentProvider + 1;
			}
			changeTickerProvider(number);
			Mackolik.widget.DTKNav.tickerDrop.setLabelByNumber(number);
		}
		,this.oAutoConfig.providerDelay||30000);
	
	return this;
};

Mackolik.widget.Carousel.prototype.pause = function(e) {
	if (e && e !== true) {
		YAHOO.util.Event.preventDefault(e);
		if (this.bPaused) {
			this.moveBy(null, 1);
			return this.autoPlay();
		}
	}
	this.bPaused = 1;
	YAHOO.util.Dom.addClass(this.oBtnPause, "btnpausedisabled");
	clearTimeout(this.oTimer);
	clearTimeout(this.oProviderTimer);
};

Mackolik.widget.Carousel.prototype.enableCheckForUpdates = function(oConfig) {
	var self = this;
	this.oLoadConfig = oConfig;
	this.nMaxItems = oConfig.maxItems;
	this.oLoadTimer = window.setInterval(function() {
		self.checkForUpdates()
	}, this.oLoadConfig.checkDelay || 10000);
	this.onContentChange = new YAHOO.util.CustomEvent("onContentChange");
	return this;
};

Mackolik.widget.Carousel.prototype.infiniteScroll = function() {
	this.moveBy = function(e, nPanes) {
		if (this.bActive) {
			return;
		}
		if (e) {
			YAHOO.util.Event.preventDefault(e);
			this.onNavigate.fire();
		}
		this.aProviders[this.nCurrentProvider].nCurrentPane += nPanes * this.nPanesToMove;
		if (this.aProviders[this.nCurrentProvider].nCurrentPane + this.nVisiblePanes - this.nPanesToMove >= this.aProviders[this.nCurrentProvider].nPanes) {
			if (this.bLoop) {
				this.aProviders[this.nCurrentProvider].nCurrentPane = 0;
			}
			this.onCarouselEnd.fire();
		} else if (this.aProviders[this.nCurrentProvider].nCurrentPane <= -this.nPanesToMove) {
			if (this.bLoop) {
				return this.aProviders[this.nCurrentProvider].nCurrentPane = 0;
			}
			this.onCarouselEnd.fire();
		}
		this.gotoPane(this.aProviders[this.nCurrentProvider].nCurrentPane);
	}
	this.oClone = this.aProviders[this.nCurrentProvider].oPanel.getElementsByTagName("li")[0].cloneNode(true);
	this.aProviders[this.nCurrentProvider].oPanel.appendChild(this.oClone);
	this.assignElements();
	this.onAnimStart.subscribe(function() {
		this.bActive = 1;
	}, this, true);
	this.onAnimEnd.subscribe(function() {
		if (this.aProviders[this.nCurrentProvider].nCurrentPane == this.aProviders[this.nCurrentProvider].nPanes - 1) {
			this.aProviders[this.nCurrentProvider].oPanel.style.left = 0;
			this.aProviders[this.nCurrentProvider].nCurrentPane = 0;
		}
		this.bActive = 0;
	}, this, true);
	/*
	var self = this;
	this.oTimer=window.setInterval(function(){ self.getNextProvider(); },10000);
	*/
	return this;
};

Mackolik.widget.Carousel.prototype.getData = function() {
    
	YAHOO.util.Get.script(oAutoConfig.xmlAddress + "?p=" + oAutoConfig.siteName, {
		onSuccess : function(o) {
			if (window.TickerData) {
				this.tickerData = TickerData;
				this.activeProvider = 0;
				this.writeTickerProviders();
				this.writeTickerNodes();
				this.init('yeug-ticker', oCarouselConfig);
				this.autoPlay(oAutoConfig);
				this.infiniteScroll();
			}
		},
		onFailure : function(o) {
			YAHOO.log("transaction failed");
		},
		scope : this
	});
};

Mackolik.widget.Carousel.prototype.writeTickerNodes = function() {
	var element = document.getElementById("yeug-ticker");
	if (!element) {
		alert("Ticker element not found!");
		return;
	}
	var sbProvider = new Mackolik.StringBuilder();
	sbProvider.append("<div class='clip'>");

	for (var j=0; j<this.tickerData.providers.length; j++) {
		var providerData = this.tickerData.providers[j];
		var bgColor = providerData.provider.background;
		var fgColor = providerData.provider.foreground;
		
		sbProvider.appendFormat("<ul {0}>", j!=0 ? "style='display:none;'" : "");
		for (var i = 0; i < providerData.news.length; i++) {
			sbProvider.appendFormat("<li><a target='_blank' href='{0}' style='font-weight:bold;background-color:#{2};color:#{3}'>{1}</a></li>", 
				providerData.news[i].link, providerData.news[i].text, bgColor, fgColor);
		}
		sbProvider.append("</ul>");
	}			
	sbProvider.append("</div>")
	element.innerHTML = sbProvider;
}

Mackolik.widget.Carousel.prototype.getNextProvider = function() {
	this.activeProvider = this.activeProvider + 1;
	if (this.tickerData.providers.length == this.activeProvider) {
		this.activeProvider = 0;
	}
	this.writeTickerNodes();
	this.init('yeug-ticker', oCarouselConfig);
	this.autoPlay(oAutoConfig);
	this.infiniteScroll();
}

Mackolik.widget.Carousel.prototype.writeTickerProviders = function () {
	if (!this.tickerData){
		return;
	}
	var data = this.tickerData.providers;
	var temp = '<li class="drop-down" style="cursor:pointer;"><a {3} onclick="changeTickerProvider({0});"><img src="{1}" border=0 title="{2}"/></a></li>';
	var ComboBuilder = new Mackolik.StringBuilder();
	
	for(var i=0; i<data.length; i++){
		ComboBuilder.appendFormat(temp, i, data[i].provider.logoURL, data[i].provider.name, i==0 ? "class='selected' " : "");
	}
	document.getElementById("yeug-ticker-wrapper-drop").innerHTML = ComboBuilder;
	
	var aLabels = YAHOO.util.Dom.getElementsByClassName("selected", "a", "yeug-ticker-wrapper-drop");
	var oConfigTicker = {
		sNavContainerId : "yeug-ticker-wrapper",
		sClassNavParent : "yeug-ticker-wrapper-drop",
		sClassNavDrop : "drop-down",
		sClassNavRogue : "rogue",
		oTextNavItem : {
			label : (aLabels[0].firstChild) ? aLabels[0].firstChild.nodeValue : ' ' ,
			image : (aLabels.length) ? (aLabels[0].firstChild) : null,
			location : "#"
		},
		iColMax : (window.opener) ? 5 : 30
	};
	Mackolik.widget.DTKNav.tickerDrop = new Mackolik.widget.DTKNav.DropDown(oConfigTicker);
	Mackolik.widget.DTKNav.tickerDrop.create();
	Mackolik.widget.DTKNav.tickerDrop.changeLabelOnSelect();
	Mackolik.widget.DTKNav.tickerDrop.showDropper = function(e) {
		YAHOO.util.Dom.setStyle(this.dropper, 'display', 'block');
		var iRightWhitespace = 20;
		var iCParLeft = YAHOO.util.Dom.getX(this.oConfig.sNavContainerId);
		var iOrigLeft = (this.iLeft - this.iParLeft) + iCParLeft;
		YAHOO.util.Dom.setX(this.dropper, iOrigLeft - 2);
		if (navigator.userAgent.toLowerCase().indexOf('gecko') === -1) {
			var attributes = { height : { to : this.dropHeight } };
			var anim = new YAHOO.util.Anim(this.dropper, attributes, 0.3, YAHOO.util.Easing.backOut);
			anim.animate();
		} else {
			YAHOO.util.Dom.setStyle(this.dropper, 'height', this.dropHeight + 'px');
		}
		this.isActive = true;
	};
};

//YAHOO.namespace('Mackolik.widget.DTKNav');
if(typeof Mackolik.widget.DTKNav=="undefined"){Mackolik.widget.DTKNav={};}

Mackolik.widget.DTKNav.DropDown = function(oConfig) {
	this.oConfig = oConfig;
	this.dropper = '';
	this.dropLink = '';
	this.navBar = '';
	this.dropHeight = 0;
	this.iLeft = 0;
	this.iParLeft = 0;
	this.isActive = false;
	this.isMouse = false;
	this.create = function() {
		var oNavBar = YAHOO.util.Dom.getElementsByClassName(this.oConfig.sClassNavParent, 'ul', this.oConfig.sNavContainerId);
		if (oNavBar.length < 1) {
			return false;
		}
		this.navBar = oNavBar[0];
		var oDropItem = YAHOO.util.Dom.getElementsByClassName(this.oConfig.sClassNavDrop, 'li', this.navBar);
		if (oDropItem.length < 1) {
			return false;
		}
		var oDropWrap = document.createElement('div');
		var oDropDiv = document.createElement('div');
		var oDropTriggerTab = document.createElement('li');
		var oDropTriggerLink = document.createElement('a');
		var oDropTriggerSpan = document.createElement('span');
		var oDropUl = [];
		var iListCol;
		for (var i = 0, iListCol = Math.ceil(oDropItem.length / this.oConfig.iColMax); i < iListCol; i += 1) {
			oDropUl[i] = document.createElement('ul');
		}
		YAHOO.util.Dom.addClass(oDropTriggerTab, 'dtk-dropper');
		YAHOO.util.Dom.addClass(oDropWrap, 'navmore');
		YAHOO.util.Dom.addClass(oDropDiv, 'flyout');
		var parent = oDropItem[0].parentNode;
		var current = false;
		for (var i = 0, j = 0; i < oDropItem.length; i += 1) {
			var crumbFlag = false;
			if (YAHOO.util.Dom.hasClass(oDropItem[i], "selected") || YAHOO.util.Dom.hasClass(oDropItem[i], "current")) {
				YAHOO.util.Dom.removeClass(oDropItem[i], "selected");
				if (YAHOO.util.Dom.hasClass(parent, "main")) {
					YAHOO.util.Dom.removeClass(oDropItem[i], this.oConfig.sClassNavDrop);
					YAHOO.util.Dom.addClass(oDropItem[i], "crumb");
					crumbFlag = true;
					var current = oDropItem[i];
				} else if (YAHOO.util.Dom.hasClass(parent, "sub")) {
					YAHOO.util.Dom.addClass(oDropTriggerTab, "selected");
				}
			}
			if (!crumbFlag) {
				var clne = oDropItem[i].cloneNode(true);
				if ((i % this.oConfig.iColMax) === 0) {
					YAHOO.util.Dom.addClass(clne, 'first-child');
				}
				if (navigator.userAgent.toLowerCase().match(/safari/)) {
					var oAEl = clne.getElementsByTagName('a');
					for (var k = 0; k < oAEl.length; k += 1) {
						YAHOO.util.Dom.addClass(oAEl[k], 'safari');
					}
				}
				YAHOO.util.Dom.removeClass(clne, this.oConfig.sClassNavDrop);
				oDropUl[Math.floor(i / this.oConfig.iColMax)].appendChild(clne);
				parent.removeChild(oDropItem[i]);
			}
		}
		for (var i = 0; i < oDropUl.length; i += 1) {
			YAHOO.util.Dom.setStyle(oDropUl[i], 'width', (100 / iListCol) + '%');
			oDropDiv.appendChild(oDropUl[i]);
		}
		if (this.oConfig.oGeneralLinks) {
			var oGenLinksDiv = document.createElement('div');
			var oH = document.createElement('h2');
			var oHText = document.createTextNode(this.oConfig.oGeneralLinks.sTitle);
			var oLinks = this.oConfig.oGeneralLinks.oLinks;
			var oLinksCount = 0;
			for (i in oLinks) {
				oLinksCount++;
			}
			var oGenLinkUl = [];
			var iGenListCol = Math.ceil(oLinksCount / this.oConfig.oGeneralLinks.iColMax);
			for (var i = 0; i < iGenListCol; i += 1) {
				oGenLinkUl[i] = document.createElement('ul');
			}
			j = 0;
			for (var i in oLinks) {
				var tmpLi = document.createElement('li');
				var tmpA = document.createElement('a');
				var tmpSpan = document.createElement('span');
				var tmpTxt = document.createTextNode(i);
				tmpA.setAttribute('href', oLinks[i]);
				var x = Math.floor(j / this.oConfig.oGeneralLinks.iColMax);
				j += 1;
				YAHOO.util.Dom.setStyle(oGenLinkUl[x], 'width', (100 / iGenListCol) + '%');
				tmpSpan.appendChild(tmpTxt);
				tmpA.appendChild(tmpSpan);
				tmpLi.appendChild(tmpA);
				oGenLinkUl[x].appendChild(tmpLi);
			}
			YAHOO.util.Dom.addClass(oGenLinksDiv, 'general');
			oH.appendChild(oHText);
			oGenLinksDiv.appendChild(oH);
			for (i = 0; i < oGenLinkUl.length; i += 1) {
				oGenLinksDiv.appendChild(oGenLinkUl[i]);
			}
			oDropDiv.appendChild(oGenLinksDiv);
		}
		//var oDropTriggerText = document.createTextNode(this.oConfig.oTextNavItem.label);
		//oDropTriggerSpan.appendChild(oDropTriggerText);
		oDropTriggerSpan.appendChild(this.oConfig.oTextNavItem.image);
		oDropTriggerLink.setAttribute('href', this.oConfig.oTextNavItem.location);
		oDropTriggerLink.appendChild(oDropTriggerSpan);
		oDropTriggerTab.appendChild(oDropTriggerLink);
		oDropWrap.appendChild(oDropDiv);
		oDropTriggerTab.appendChild(oDropWrap);
		var oFirstRogue = YAHOO.util.Dom.getElementsByClassName(this.oConfig.sClassNavRogue, 'li', this.navBar)[0];
		if (oFirstRogue) {
			this.navBar.insertBefore(oDropTriggerTab, oFirstRogue);
			if (current) {
				this.navBar.insertBefore(current, oFirstRogue);
			}
		} else {
			this.navBar.appendChild(oDropTriggerTab);
			if (current) {
				this.navBar.appendChild(current);
			}
		}
		var sDropDivWidth = YAHOO.util.Dom.getStyle(oDropDiv, 'width');
		var iWidth = parseInt(sDropDivWidth, 10);
		var sWidth = (iWidth * iListCol) + 'px';
		var sWrapWidth = (iWidth * iListCol) + 4 + 'px';
		YAHOO.util.Dom.setStyle(oDropDiv, 'width', sWidth);
		YAHOO.util.Dom.setStyle(oDropWrap, 'width', sWrapWidth);
		if (YAHOO.util.Event.isIE) {
			var oDropIframe = document.createElement('iframe');
			oDropWrap.appendChild(oDropIframe);
			YAHOO.util.Dom.setStyle(oDropIframe, 'position', 'absolute');
			YAHOO.util.Dom.setStyle(oDropDiv, 'position', 'relative');
			YAHOO.util.Dom.setStyle(oDropDiv, 'z-index', '500');
			YAHOO.util.Dom.setStyle(oDropIframe, 'z-index', '499');
			YAHOO.util.Dom.setX(oDropIframe, YAHOO.util.Dom.getX(oDropDiv));
			YAHOO.util.Dom.setY(oDropIframe, YAHOO.util.Dom.getY(oDropDiv));
			YAHOO.util.Dom.setStyle(oDropIframe, 'width', oDropDiv.offsetWidth + 'px');
			YAHOO.util.Dom.setStyle(oDropIframe, 'height', oDropDiv.offsetHeight + 'px');
		}
		this.dropHeight = oDropDiv.offsetHeight;
		this.iLeft = YAHOO.util.Dom.getX(oDropWrap);
		this.iParLeft = YAHOO.util.Dom.getX(this.oConfig.sNavContainerId);
		YAHOO.util.Dom.setStyle(oDropWrap, 'overflow', 'hidden');
		YAHOO.util.Dom.setStyle(oDropWrap, 'height', '0');
		YAHOO.util.Dom.setStyle(oDropWrap, 'display', 'none');
		this.dropper = oDropWrap;
		this.dropLink = oDropTriggerLink;
		YAHOO.util.Event.on(this.dropLink, 'mousedown', this.toggleDropper, this, true);
		YAHOO.util.Event.on(document, 'click', this.onDOMEvent, this, true);
		if (navigator.userAgent.toLowerCase().indexOf('safari') !== -1) {
			var oBodyEl = document.getElementsByTagName('body')[0];
			YAHOO.util.Dom.removeClass(oBodyEl, 'notsafari');
		}
	};
	this.getCurrentXPos = function() {
		if (document.body && document.body.scrollLeft) {
			return document.body.scrollLeft;
		}
		if (document.documentElement && document.documentElement.scrollLeft) {
			return document.documentElement.scrollLeft;
		}
		if (window.pageXOffset) {
			return window.pageXOffset;
		}
		return 0;
	};
	this.toggleDropper = function(e) {
		this.isMouse = true;
		if (this.isActive) {
			this.hideDropper(e);
		} else {
			this.showDropper(e);
		}
		YAHOO.util.Event.stopEvent(e);
	};
	this.showDropper = function(e) {
		YAHOO.util.Dom.setStyle(this.dropper, 'display', 'block');
		var iRightWhitespace = 20;
		var iCParLeft = YAHOO.util.Dom.getX(this.oConfig.sNavContainerId);
		var iOrigLeft = (this.iLeft - this.iParLeft) + iCParLeft;
		var iScreenWidth = YAHOO.util.Dom.getViewportWidth();
		var iScreenOffset = this.getCurrentXPos();
		var iDropperWidth = this.dropper.offsetWidth;
		var test1 = iScreenOffset + iScreenWidth;
		var test2 = iOrigLeft + iDropperWidth + iRightWhitespace;
		if (test1 < test2) {
			var iX = (iScreenOffset + iScreenWidth)
					- (iDropperWidth + iRightWhitespace);
		} else {
			var iX = iOrigLeft;
		}
		YAHOO.util.Dom.setX(this.dropper, iX);
		if (navigator.userAgent.toLowerCase().indexOf('gecko') === -1) {
			var attributes = {
				height : {
					to : this.dropHeight
				}
			};
			var anim = new YAHOO.util.Anim(this.dropper, attributes, 0.3,
					YAHOO.util.Easing.backOut);
			anim.animate();
		} else {
			YAHOO.util.Dom.setStyle(this.dropper, 'height', this.dropHeight
					+ 'px');
		}
		this.isActive = true;
	};
	this.hideDropper = function(e) {
		if (navigator.userAgent.toLowerCase().indexOf('gecko') === -1) {
			var attributes = {
				height : {
					to : 0
				}
			};
			var anim = new YAHOO.util.Anim(this.dropper, attributes, 0.3,
					YAHOO.util.Easing.backOut);
			anim.animate();
			var thisLoser = this.dropper;
			anim.onComplete.subscribe(function() {
				YAHOO.util.Dom.setStyle(thisLoser, 'display', 'none');
			});
		} else {
			YAHOO.util.Dom.setStyle(this.dropper, 'height', '0');
			YAHOO.util.Dom.setStyle(this.dropper, 'display', 'none');
		}
		this.isActive = false;
		YAHOO.util.Event.stopEvent(e);
	};
	this.onDOMEvent = function(e) {
		var targetElement = YAHOO.util.Event.getTarget(e);
		if (this.isActive) {
			var bFlyout = false;
			while (targetElement
					&& targetElement.nodeName.toUpperCase() !== 'BODY') {
				if (targetElement === this.dropper
						|| targetElement === this.dropLink) {
					bFlyout = true;
					break;
				}
				targetElement = targetElement.parentNode;
			}
			if (!bFlyout) {
				this.hideDropper(e);
			}
		}
		if (this.isMouse) {
			YAHOO.util.Event.stopEvent(e);
		}
		this.isMouse = false;
	};
	return true;
};

Mackolik.widget.DTKNav.DropDown.prototype.changeLabelOnSelect = function() {
	YAHOO.util.Event.on(this.dropper, 'click', function(e) {
		var oTarget = YAHOO.util.Event.getTarget(e);
		//if (oTarget.nodeName.toLowerCase() != "a") {
		if (oTarget.parentNode.nodeName.toLowerCase() != "a") {
			return;
		}
		this.setLabel(oTarget.parentNode.innerHTML);
		this.hideDropper(e);
		
		/*
		Mackolik.oTicker.checkForUpdates("&sport="
				+ oTarget.getAttribute("href").split("#")[1].replace("sportid",	""));
				*/
	}, this, true);
}

Mackolik.widget.DTKNav.DropDown.prototype.setLabel = function(sLabel) {
	this.dropper.previousSibling.firstChild.innerHTML = sLabel;
}
Mackolik.widget.DTKNav.DropDown.prototype.setLabelByNumber = function(nNo) {
	this.dropper.previousSibling.firstChild.innerHTML = this.dropper.firstChild.firstChild.childNodes[nNo].firstChild.innerHTML;
}	

if (YAHOO.util.Event.isIE) {
	YAHOO.util.Event.on(window, "unload", function() {
		CollectGarbage();
	});
}

YAHOO.util.Event.onAvailable("yeug-ticker", function() {
	Mackolik.widget.Carousel.prototype.addPopout = function(oConfig) {
		if (window.opener) {
			YAHOO.util.Event.on(this.oPanel, "click", this.popin, this, true);
			return;
		}
	}
	Mackolik.widget.Carousel.prototype.popin = function(e) {
		var oTarget = YAHOO.util.Event.getTarget(e);
		if (oTarget.nodeName.toLowerCase() == "a") {
			YAHOO.util.Event.preventDefault(e);
			if (window.opener) {
				window.opener.location = oTarget.href;
			} else {
				window.open(oTarget.href);
			}
		}
	}
	Mackolik.oTicker = new Mackolik.widget.Carousel();
	Mackolik.oTicker.getData();
});

YAHOO.util.Event.onAvailable("yeug-ticker-wrapper", function() {
	YAHOO.util.Dom.get('yeug-ticker-wrapper').style.display = 'block';
});

YAHOO.util.Event.onAvailable("yeug-footer", function() {
	var a = YAHOO.util.Dom.getElementsByClassName('opta', 'a', document
			.getElementById("yeug-live"));
	for (var i = 0, j = a.length; i < j; i++) {
		YAHOO.util.Event.addListener(a[i], "click", function(e) {
			YAHOO.util.Event.stopEvent(e);
			Mackolik.optaWin(YAHOO.util.Event.getTarget(e));
		}, true);
	}
});

var oAutoConfig = {
	providerDelay : 30000,
	autoPlayDelay : 10000,
	buttonLabel : "başlat/dur",
	xmlAddress : "http://www325d.mackolik.com/ticker/defaultScript.aspx",
	siteName : "mackolik"
};

var oCarouselConfig = {
	buttonCont : 'yeug-ticker-wrapper',
	loop : 1,
	animDuration : 5
};

function changeTickerProvider(number) {
	Mackolik.oTicker.aProviders[Mackolik.oTicker.nCurrentProvider].oPanel.style.display = "none";
	Mackolik.oTicker.nCurrentProvider = number;
	Mackolik.oTicker.aProviders[Mackolik.oTicker.nCurrentProvider].oPanel.style.display = "";
}
//YAHOO.util.Event.onAvailable("yeug-ticker-wrapper", function() {

