jQuery.noConflict();
(function($, window, document, undefined){

$(document).ready(function(){

	
	var quotes = $('#quotes');
	if (quotes.length)
	{
		var h = 0;
		quotes.find('li').each(function(){
			h = Math.max(h, $(this).outerHeight());
		}).hide().filter(':eq(0)').show();

		quotes.height(h);

		window.setInterval(function(){
			var a = quotes.find('li:visible');
			var n = a.next();
			if (!n.length || !n.is('li'))
				n = quotes.find('li:eq(0)');
			a.fadeOut('slow');
			n.fadeIn('slow');
		}, 5500);
	}


	var $content = $('#content');


	$content.each(function(){
		$(this).data('fontSize', 12).append('<p class="fontSize"><a href="#" class="up">A<sup>+</sup></a> <a href="#" class="dn">A<sup>-</sup></a></p>');
	});
	$('#page').find('.fontSize').
		find('a.up').click(function(){
			fontSize(this.parentNode.parentNode, 1);
			return false;
		}).end().
		find('a.dn').click(function(){
			fontSize(this.parentNode.parentNode, -1);
			return false;
		});

	function fontSize(elem, delta)
	{
		elem = $(elem);
		var fs = parseInt(elem.css('fontSize')), fsb = elem.data('fontSize');
		fs += delta;
		if (fs < fsb - 4)
			fs = fsb - 4;
		if (fs > fsb + 4)
			fs = fsb + 4;
		elem.css('fontSize', fs + 'px');
	}


	if ($.fn.facebox)
	{
		$('#x').facebox({
			loadingImage : templateURL + 'img/facebox/loading.gif',
			closeImage   : templateURL + 'img/facebox/closelabel.gif'
		});

		function showLoginForm()
		{
			$('#login').find('input[name="redirect_to"]').val(this.href);
			$.facebox({ div: '#login' });
			return false;
		}

		if ($content.hasClass('content-papers'))
		{
			$content.find('h3 a, a.more').click(showLoginForm);
		}
		if ($content.hasClass('content-speaker'))
		{
			$content.find('.papers h3 a, .papers a.more').click(showLoginForm);
		}
	}


	if ($.browser.msie)
	{
		if ($.browser.version <= 6)
		{
			try {document.execCommand("BackgroundImageCache", false, true);} catch(err){};
			if (window['DD_belatedPNG'] !== undefined)
				DD_belatedPNG.fix('img');
		}

		$('#menuLeft').
			find('li.current-menu-ancestor').find('> ul, > a').addClass('active-ancestor').show().end().end().
			find('li.current-menu-item').find('> ul, > a').addClass('active-parent').show();

		quotes.
			find('span.q1').replaceWith('<img src="' + templateURL + 'img/icon/quote-1.gif"/> ').end().
			find('span.q2').replaceWith(' <img src="' + templateURL + 'img/icon/quote-2.gif"/>').end();
	}

});

})(jQuery, window, document);
