var timeOut = 5500;
var t;

$(function() {
	t = setTimeout('timedCount()', timeOut);
	$('#vntan li').hover(
		function() { // over
			if(navigator.userAgent.match(/^Mozilla\/5\.0 \(iPhone/i)){
			} else if(navigator.userAgent.match(/^Mozilla\/5\.0 \(iPad/i)){
			} else {
				clearTimeout(t);
				timedCount($(this).attr("id"));
	//			alert(tid);
			}
		},
		function() { // out
			if(navigator.userAgent.match(/^Mozilla\/5\.0 \(iPhone/i)){
			} else if(navigator.userAgent.match(/^Mozilla\/5\.0 \(iPad/i)){
			} else {
	//			var tid = $(this).attr("id");
	//alert(tid);
				t = setTimeout('timedCount()', timeOut);
			}
		});
	});

	function timedCount(cid) {
		var $nextImage;
		$('#mnmg li').each(function(i) {
			if ( cid ) {
				$(this).removeClass();
				if ( cid+"_p" == $(this).attr("id") ) {
					$(this).fadeIn("slow");
					$(this).addClass('dsp');
				} else {
					$(this).fadeOut("slow");
				}
			} else {
				if ($(this).hasClass('dsp')) {
					$(this).removeClass();
					$(this).fadeOut("slow");
					$nextImage = $(this).next();
					if ($nextImage.length == 0) {
						$nextImage = $('#mnmg li:first');
					}
				}
			}
		}); 
	if ( !cid ) {
		$nextImage.addClass('dsp');
		$nextImage.fadeIn("slow");
		t = setTimeout('timedCount()', timeOut);
	}
};
