/*
* @version : 1.1.1
* @update : 2011-08-04
* @author: บริษัท อีมีเดีย จำกัด
* @comment : CIMB Website
*/

var timerWhatNew;
function RoateWhatNew(idx, setTimer) {
	clearTimeout(timerWhatNew);

	idx = parseInt(idx||0);

	if (parseInt(idx) >= $("div#Container div.WhatNew div.Content ul li").length ) idx = 0;
	var elm = ''+(idx+1);

	$("div#Container div.WhatNew div[id^='what_new-']").filter(":visible").not("#what_new-"+elm).fadeOut("fast", function(){

		$("div#Container div.WhatNew ul li").removeClass("active");
		$("div#Container div.WhatNew ul li#nav-what_new-"+elm).addClass("active");
		$("div#Container div.WhatNew div#what_new-"+elm).fadeIn("fast");
	});

	if (setTimer==true) {
		timerWhatNew = setTimeout('RoateWhatNew("'+(idx+1)+'", true)', 5000);
	}
}


$(document).ready(function() {

	if ( $("div#Container div.WhatNew ul li").length > 0 ) {
		$("div#Container div.WhatNew div.Content > ul > li > span").each(function(){
			if ( $(this).height() > 20) { // Double Line
				$(this).parent().addClass("double");
			}
		});

		$("div#Container div.WhatNew ul li").mouseover(function() {
			if ( !$(this).hasClass("active") ) {
				RoateWhatNew($(this).index(), false);
			}
		});

		$("div#Container div.WhatNew ul li").mouseleave(function() {
			if ( $(this).hasClass("active") ) {
				RoateWhatNew($(this).index(), true);
			}
		});

		RoateWhatNew(0, true);
	}

});

