// Workaround for .NET breaking on `clientID.startsWith`
Function.prototype.startsWith = function(){ return false; };


window.addEvent('domready',function() {
	// Stuff to do when the dom is ready.
	// Place the code here if this file is loaded in the <head>
	
    var tooltips = new Tips('.tooltips', {
	    className: 'tooltip',
	    showDelay: 200,
	    hideDelay: 300
    });
    var offerTips = new Tips('.offertooltips', {
        className: 'srOfferTips'
        }
        );
	
});

if ($('achievementNotification')) {
	var achievement = $('achievementNotification');
	
	achievement.getElement('.close').addEvent('click', function (e) {
		e.stop();
		achievement.dissolve();
	});
	
	(function () {
		achievement.reveal();
	}).delay(1000);
}

var profileLinks = $$('.opc');
profileLinks.each(function(el) {
	el.addEvent('click', function(e) {
		e.stop();
		var card = new PlayerCard({
			position: el.getPosition(),
			id: el.id
		});
		
		if ($type(card) != 'element') {
			var request = new Request({
				url: this.href,
				link: 'chain',
				onRequest: function() {
					card.setTitle('Loading');
					card.render();
				},
				onSuccess: function(response) {
					card.setTitle('Profile');
					card.setContent(response);
				}
			}).get();
		}
	});
});

if ($('tabsfx')) {
    var myTabs = new MooTabs('tabsfx', {tabSelector: 'ul.tabs li', panelSelector: 'div.tabContent', rememberTab: true});
}
