﻿// inCMS module: list_type2
/*
$(function() {
	inCMS.initList();
	$('.list-type2 .listItem').mouseover(function() {
		inCMS.listItemOver(this);
	}).mouseout(function() {
		inCMS.listItemOut(this);
	}).each(function(){
		var href = $(this).find('h3 a').attr('href');
		if (href) {
			$(this).css('cursor', 'pointer')
				.click(function(){
					location.href = href;
			})
		}
	})
	$('.list-type2 #listControlLeft').click(function() {
		inCMS.listMoveLeft();
	}).mouseover(function() {
		$(this).addClass('hover');
	}).mouseout(function() {
		$(this).removeClass('hover');
	});
	$('.list-type2 #listControlRight').click(function() {
		inCMS.listMoveRight();
	}).mouseover(function() {
		$(this).addClass('hover');
	}).mouseout(function() {
		$(this).removeClass('hover');
	});
	$('.list-type2 .listItem a, .list-type2 .listItem img').each(function() {
		$(this).attr({ 'title': '', 'alt': '' });
	});
});

$(window).resize(function() {
	inCMS.initList();});

inCMS.initList = function() {
	var itemCount = $('.listItem').length;
	alert(itemCount);
	$('.list-type2 .listItem').eq(itemCount - 1).css('margin-right', '0');
	var width = itemCount * (235 + 18) - 18;
	$('.list-type2 .content').width(width);
	var viewWidth = 741;
	if (width > viewWidth) {
		$('.list-type2 #listControlRight').show();
	} else {
		$('.list-type2 #listControlLeft,.list-type2 #listControlRight').hide();
	}
}

inCMS.listMoveRight = function() {
	var width = $('.list-type2 .listItem').length * (235 + 18) - 18;
	var viewWidth = 741;
	var right = parseInt($('.list-type2 .content').css('right'));
	var offset = width - right - viewWidth;
	if (offset > viewWidth + 18) offset = viewWidth + 18;
	$('.list-type2 .content').animate({ right: (right + offset) + 'px' }, 500, function() {
	$('.list-type2 #listControlLeft').show();
	right = parseInt($('.list-type2 .content').css('right'));
	if (viewWidth + right == width) $('.list-type2 #listControlRight').hide();
	});
}
inCMS.listMoveLeft = function() {
	var width = $('.list-type2 .listItem').length * (235 + 18) - 18;
	var viewWidth = 741;
	var right = parseInt($('.list-type2 .content').css('right'));
	var offset = right;
	if (offset > viewWidth + 18) offset = viewWidth + 18;
	$('.list-type2 .content').animate({ right: (right - offset) + 'px' }, 500, function() {
		$('.list-type2 #listControlRight').show();
		right = parseInt($('.list-type2 .content').css('right'));
		if (right == 0) $('.list-type2 #listControlLeft').hide();
	});
}

inCMS.isListItemOver = new Array();

inCMS.listItemOver = function (o) {
	var n = $(o).attr('class').split('-')[1];
	inCMS.isListItemOver[n] = true;
	var timer = setTimeout('inCMS.listItemOverTimeout('+n+');',250);
}

inCMS.listItemOverTimeout = function (n) {
	if (inCMS.isListItemOver[n]) {
		var backGndActive = $('.list-type2 .listItem-' + n + ' > .background1');
		backGndActive.fadeIn(300);
	}
}

inCMS.listItemOut = function (o) {
	var n = $(o).attr('class').split('-')[1];
	inCMS.isListItemOver[n] = false;
	var timer = setTimeout('inCMS.listItemOutTimeout('+n+');',250);
}

inCMS.listItemOutTimeout = function (n) {
	if (!inCMS.isListItemOver[n]) {
		var backGndActive = $('.list-type2 .listItem-' + n + ' > .background1');
		backGndActive.fadeOut(300);
	}
}
*/
