var pageSelector = {
	init: function() {
		$('li.page a').each(function(index, elem) {
			var $this = $(elem);
			$this.removeClass('selected');
			if (elem.href == document.location.href) {
				$this.addClass('selected');	
				if ($this.parent().parent()[0].className == 'menu') {
					Cufon.replace($this, { fontFamily: 'Myriad Pro', hover:true });
				}
			}
		});
	}
}

function onAfter(curr, next, opts, fwd) {
	//get the height of the current slide
	var $ht = $(this).height();
	//set the container's height to that of the current slide
	$(this).parent().animate({height: $ht});
};

$(document).ready(function() {
		var $zoom = $('#zoom');
		if ($zoom[0]){
			$('#zoom').cycle({
				fx:    'zoom',
				sync:  false,
				delay: 1000,
				next:'#next',
				prev:'#prev'
			});
		}
		
		var $slogan = $('#slogan');
		if ($slogan[0]) {
			$slogan.cycle({
				fx:    'fade',
				sync:  false,
				delay: 1000,
				next:'#next',
				prev:'#prev'
			});			
		}
		
		var $slogan1 = $('#slogan1');
		if ($slogan1[0]) {
			$slogan1.cycle({
				fx:    'fade',
				sync:  false,
				delay: 1000,
				next:'#next',
				prev:'#prev'
			});
		}
		
		var $aside = $('.aside');
		if ($aside[0] && !$('#facebook-layouts')[0]) {
			$('#content').append($aside);
			$aside.slideDown();
		}
        
        var NullImg = new Image();
        NullImg.src = '/null.gif';
        previewBoxId = 'tooltip';
        $links = $('.tpl-preview');
        if ($links.length > 0 ) {
            $links.imgPreview({
                containerID:previewBoxId,
                considerBorders: true,
                srcAttr: 'data-img',
                preloadImages: false,
                imgSrcHide: '/null.gif',
				//minWidth: 430
          });
       }
	   
	   pageSelector.init();

	});	
