﻿
function previsual() {

	var imgCountMax = $("#fade img").size();
	// intializing 
	var imgCount = 0;
	$("#prefade").css("cursor","pointer");
	var strUA = "";
	strUA = navigator.userAgent.toLowerCase();

	if(imgCountMax !=1){
		$("#fade img").css({opacity:'0'});
		
		if(strUA.indexOf("msie 6") != -1){
			$("#prefade").prepend('<img src="http://www.meiji.ac.jp/cip/english/images/preslide_text.gif" width="768" height="330" style="float: none;width: 768px; height: 330px; z-index:1000; position:absolute;" />');
		} else {
			$("#prefade").prepend('<img src="http://www.meiji.ac.jp/cip/english/images/preslide_text.png" width="768" height="330" style="float: none;width: 768px; height: 330px; z-index:1000; position:absolute;" />');
		};
		
		$.timer(500, function(timer){
			$("#fade img:eq("+ imgCount +")").animate({opacity: 1},{
				duration: 3000, easing: "easeOutQuint",
				complete: function(){
					imgCount += 1;
					if (imgCount >= imgCountMax){
						timer.stop();
						var nowCount = imgCount -1;
						
						if(strUA.indexOf("msie") != -1){
						$("#prefade img").attr("src","images/preslide_text_white.gif").stop(true, true).animate({marginTop: +30, opacity: 0}, 500,function(){$("#prefade").empty();
						});
						} else {
						$("#prefade img").stop(true, true).animate({marginTop: +30, opacity: 0}, 500,function(){$("#prefade").empty();
						});
						};
						mainvisual();
					} else {
					$(this).animate({opacity: 1},500,function(){
						$(this).hide()
					});
					};
				}
			});
			timer.reset(3600);
			
			
			// for mainvisual 
			$('#prefade img').click(function() {
				imgCount = imgCountMax +1;
			});
	
		});
	} else {
		mainvisual();
	};

}


window.onload = function() {
	previsual();
}


