$(document).ready(function () {
	var eventID = null;
	var currentElement = null;
	function ToggleFeature() {
		var imgAlt = $(currentElement).find('img').attr("alt");
		var imgTitle = $(currentElement).find('a').attr("href");
		var imgDesc = $(currentElement).find('.block').html();
		var imgDescHeight = $(".homefeature").find('.block').height();
		if ($(currentElement).is(".active")) {
			return false
		} else {
			$('.homefeature .block').html("");
			$('.homefeature .block').animate({
				width: 'toggle'
			},
			500, function () {
				$(".homefeature .block").animate({
					width: 'toggle'
				},
				500);
				setTimeout(function () {
					$('.homefeature .block').html(imgDesc)
				},
				500);
				$(".homefeature img").attr({
					src: imgTitle,
					alt: imgAlt
				})
			})
		}
		$(".homefeaturelist ul li").removeClass('active');
		$(currentElement).addClass('active');
		return false
	}
	function CancelEvent() {
		currentElement = $(this);
		ToggleFeature();
		window.clearInterval(eventID)
	}
	$(".homefeature .desc").show();
	$(".homefeaturelist ul li:first").addClass('active');
	$(".homefeaturelist ul li").click(CancelEvent).hover(function () {
		$(this).addClass('hover')
	},
	function () {
		$(this).removeClass('hover')
	});
	var i = 0;
	var l = $('.homefeaturelist ul li');
	function doToggleFeature() {
		i++;
		if (i == l.length) {
			i = 0
		}
		currentElement = l[i];
		ToggleFeature()
	}
	eventID = window.setInterval(doToggleFeature, 5000);
	$('.poll').click(function () {
		$.get('/index.php/page/recordvote/ps_vote/' + escape($(this).attr('rel')) + '/pi_opinionpollid/' + parseInt($('#pollid').html()), function (response) {
			$('.response').html(response);
			$("#vote-buttons-container").fadeOut('fast');
			setCookie('cs_hasvoted', 'true', 1, '/')
		},
		'html')
	})
});
$(window).load(function () {
	$(".carousel1").show().jCarouselLite({
		btnNext: ".next",
		btnPrev: ".prev",
		scroll: 3,
		visible: 3
	});
	$(".carousel2").show().jCarouselLite({
		btnNext: ".next2",
		btnPrev: ".prev2",
		scroll: 3,
		visible: 3
	});
	$(".carousel3").show().jCarouselLite({
		btnNext: ".next3",
		btnPrev: ".prev3",
		scroll: 3,
		visible: 7,
		vertical: true
	})
});
