$(document).ready(function(){

	$('.boxlink').click(function(){
		document.location.href = $(this).find('span.more>a').attr('href');
	});

	$('div.heros').cycle({
		timeout:	6000,
		speed:		1000,
		pause:		1,
		sync:		1,
		before:		move_titles
	});
	
	$('div.inner ul').click(function(e){
		if ($(':animated').length) {
			return false;
		}
		else if($(e.target).is('li.passive')){
			first = 0;
			var idx = $('div.inner ul li').index(e.target);
			$('div.heros').cycle(idx);
			switch_em($('li.active'),$(e.target));
		}
		else if($(e.target).is('li.active')){
			document.location.href = $(this).find('li.active').attr('xhref');
		}
	});
	
	$('div.heros div').click(function(){
		document.location.href = $(this).find('img').attr('xhref');
	});

});

var first = 0;

function switch_em(out,inn) {
	out.switchClass('active','passive',500).find('span').fadeOut(200);
	inn.find('span').fadeIn(500);
	inn.switchClass('passive','active',500);
}

function move_titles() {
	if(first<1){
		first++;
		return;
	}
	var nobj = $('li.active').next();
	if(nobj.length == 0) nobj = $('div.inner ul li:first-child');
	switch_em($('li.active'),nobj);
}

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-1613320-6']);
_gaq.push(['_trackPageview']);
_gaq.push(['_trackPageLoadTime']);

(function() {
	var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
	ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
	var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

