function smartRollover() {
	if(document.getElementsByTagName) {
		var images = document.getElementsByTagName("img");

		for(var i=0; i < images.length; i++) {
			if(images[i].getAttribute("src").match("_off."))
			{
				images[i].onmouseover = function() {
					this.setAttribute("src", this.getAttribute("src").replace("_off.", "_on."));
				}
				images[i].onmouseout = function() {
					this.setAttribute("src", this.getAttribute("src").replace("_on.", "_off."));
				}
			}
		}
	}
}

if(window.addEventListener) {
	window.addEventListener("load", smartRollover, false);
}
else if(window.attachEvent) {
	window.attachEvent("onload", smartRollover);
}

document.write('<link href="css/js_import.css" rel="stylesheet" type="text/css" />');

/*  common   */
j$(function(){
	var mainH = j$('#mainArea').height();
	var mainM = mainH / 2;
	j$('#contents').css("height", mainH);
	j$('#contents').css("min-height", mainH);
	j$('#mainArea').css("height", mainH);
	j$('#mainArea').css("margin-top", "-"+mainM+"px");
})


/*  IE6  */
function ie6JS(){
	mainH = j$('#mainArea').height();
	winHeight = j$(window).height();
	
	if (mainH >= winHeight){
		j$('#wrapper').css("height", mainH);
	} else {
		j$('#wrapper').css("height", winHeight);
	}
	
	j$(window).resize(function(){
	   	mainH = j$('#mainArea').height();
		winHeight = j$(window).height();
		if (mainH >= winHeight){
			j$('#wrapper').css("height", mainH);
		} else {
			j$('#wrapper').css("height", winHeight);
		}
	});

};


/*  top  */
function topJS(){
	setTimeout (function(){
	j$('#contents').css("width", "100%");
	j$('#contents').css("height", "100%");
	j$('#contents').css("min-height", "605px");
	j$('#mainArea').css("width", "960px");
	j$('#mainArea').css("height", "100%");
	j$('#mainArea').css("margin", "0 0 0 -480px");
	j$('#mainArea').css("left", "50%");
	j$('#mainArea').css("top", "0px");
	},10);
		
	j$("#topicsBtn").toggle(
		function () {
			j$('#regretArea').hide();
			j$(this).addClass('open');
			j$('#topicsArea').animate({bottom: '0'}, 700, 'easeOutElastic');
			j$('#topicsBtn img').hide();
		},
		function () {
			j$(this).removeClass('open');
			j$('#topicsArea').animate({bottom: '-104px'}, 700, 'easeOutElastic');
			j$('#topicsBtn img').show();
			setTimeout (function(){
				j$('#regretArea').show();
			},175);
		}

	);
	setTimeout (function(){
		j$('#topicsArea').animate({bottom: '-104px'}, 600, 'easeOutElastic');
		j$('#topicsBtn img').show();
	},1000);
};


/*  cm  */
function cmJS(){
	setTimeout(function(){j$('h1 img').animate({'marginLeft':'0','opacity':'1'},100);},1000);
	
	setTimeout(function(){j$('#cmBox').fadeIn(300)},1500);
	setTimeout(function(){j$('#thumbnailArea').animate({'marginRight':'0'},200, "swing")},1700);
	
	j$('.btn_cm1').click(function () {
		j$("#cmBox *").remove();
		j$("#cmBox").append('<object width="486" height="298"><param name="movie" value="http://www.youtube.com/v/cms3t16J41s?fs=1&amp;hl=ja_JP&amp;rel=0&amp;autoplay=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/cms3t16J41s?fs=1&amp;hl=ja_JP&amp;rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="486" height="298"></embed></object>');
	});
	j$('.btn_cm2').click(function () {
		j$("#cmBox *").remove();
		j$("#cmBox").append('<object width="486" height="298"><param name="movie" value="http://www.youtube.com/v/PC8FlnEJ3P8?fs=1&amp;hl=ja_JP&amp;rel=0&amp;autoplay=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/PC8FlnEJ3P8?fs=1&amp;hl=ja_JP&amp;rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="486" height="298"></embed></object>');
	});
}


/*  product  */
function productJS(){
	setTimeout(function(){ j$('h1 img').animate({'marginLeft':'0','opacity':'1'},100);},1000);
	
	setTimeout(function(){j$('#detail1').animate({'bottom':'0'},300, "swing")},1300);
	setTimeout(function(){j$('#detail2').animate({'bottom':'0'},300, "swing")},1400);
	setTimeout(function(){j$('#detail3').animate({'bottom':'0'},300, "swing")},1500);
	setTimeout(function(){j$('#detail4').animate({'bottom':'0'},300, "swing")},1600);
	
	if(!jQuery.support.opacity){
		if(!jQuery.support.style){
	        if (typeof document.documentElement.style.maxHeight != "undefined") {
				j$('.detailBox').hover(
					function() {
						j$('> .innerBox .product_detail',this).stop().animate({bottom: "-130px"}, 400, "easeOutBounce");
					},
					function() {
						j$('> .innerBox .product_detail',this).stop().animate({bottom: "-370px"}, 400, "easeOutBounce");
				});
			} else {
				j$('.detailBox').hover(
					function() {
						j$('> .innerBox .product_detail',this).stop().animate({bottom: "100px"}, 400, "easeOutBounce");
					},
					function() {
						j$('> .innerBox .product_detail',this).stop().animate({bottom: "-140px"}, 400, "easeOutBounce");
				});
	        };
		} else {
				j$('.detailBox').hover(
					function() {
						j$('> .innerBox .product_detail',this).stop().animate({bottom: "-130px"}, 400, "easeOutBounce");
					},
					function() {
						j$('> .innerBox .product_detail',this).stop().animate({bottom: "-370px"}, 400, "easeOutBounce");
				});
		}

	} else {
		j$('.detailBox').hover(
			function() {
				j$('> .innerBox .product_detail',this).stop().animate({bottom: "-130px"}, 400, "easeOutBounce");
			},
			function() {
				j$('> .innerBox .product_detail',this).stop().animate({bottom: "-370px"}, 400, "easeOutBounce");
			});
	}
}


/*  gadget  */
function imgJS(){
	if (j$('#img1').css('display')=='block') {
		j$('#img1').css("z-index", 10);
		j$('#img2').css("z-index", 20).fadeIn(300,function(){
				j$('#img1').fadeOut(300);
		});
	} else if (j$('#img2').css('display')=='block') {
		j$('#img2').css("z-index", 10);
		j$('#img3').css("z-index", 20).fadeIn(300,function(){
				j$('#img2').fadeOut(300);
		});
	} else if (j$('#img3').css('display')=='block') {
		j$('#img3').css("z-index", 10);
		j$('#img1').css("z-index", 20).fadeIn(300,function(){
				j$('#img3').fadeOut(300);
		});
	}
}

function gadgetJS(){
	setTimeout(function(){ j$('h1 img').animate({'marginLeft':'0','opacity':'1'},100)},1000);
	setTimeout(function(){ j$('#gadgetImgArea').animate({'marginTop':'79px'},300, "swing")},1500);
	setTimeout(function(){
		j$('#gadgetTextArea').animate({'marginTop':'0'},300, "swing");
		j$('#gadgetTextArea').css({'height':'auto'});
		j$('#appList li').animate({'paddingTop':'0'},350, "swing");
	},1500);
	
	setInterval('imgJS()', 5000);
}

function gadget2JS(){
	setTimeout(function(){ j$('h1 img').animate({'marginLeft':'0','opacity':'1'},100)},1000);
	setTimeout(function(){
		j$('#gadgetTextArea').animate({'paddingTop':'0'},300, "swing");
		j$('#appList li').animate({'paddingTop':'0'},400, "swing");
		j$('#gadgetTextArea').css({'height':'auto'});
	
	},1500);
	
	setInterval('imgJS()', 5000);
}


/* niketsu */
function niketsuJS(){
	setTimeout(function(){ j$('h1 img').animate({'marginLeft':'0','opacity':'1'},100)},1000);
	setTimeout(function() {
		j$('#movie1 img').animate({width: '242px',height: '201px','marginTop':'0','marginLeft':'0'},300, "easeOutElastic",function(){
			j$('#movie2 img').animate({width: '243px',height: '218px','marginTop':'0','marginLeft':'0'},300, "easeOutElastic",function(){
				j$('#movie3 img').animate({width: '231px',height: '218px','marginTop':'0','marginLeft':'0'},300, "easeOutElastic",function(){
					j$('#movie4 img').animate({width: '312px',height: '233px','marginTop':'0','marginLeft':'0'},300, "easeOutElastic",function(){
						j$('#movie5 img').animate({width: '259px',height: '250px','marginTop':'0','marginLeft':'0'},300, "easeOutElastic");
					});
				});
			});
		});
	},1500);
}


/* contact */
function contactJS(){
	setTimeout(function(){ j$('h1 img').animate({'marginLeft':'0','opacity':'1'},100);},1000);
}


/* download */
function downloadJS(){
	setTimeout(function(){ j$('h1 img').animate({'marginLeft':'0','opacity':'1'},100);},1000);
	setTimeout(function() {
		j$('.fLeft img').animate({width: '435px',height: '358px','marginTop':'0','marginLeft':'0'},100, function(){
			//j$('.fRight img').animate({width: '435px',height: '358px','marginTop':'0','marginLeft':'0'},100, function(){
					j$('#downLoadArea ul').fadeTo(500, 1);
			//});
		});
	},1500);
}

/* history */
function historyJS(){
	setTimeout(function(){ j$('h1 img').animate({'marginLeft':'0','opacity':'1'},100);},1000);
}


/* event */
function eventJS(){
	setTimeout(function(){ j$('h1 img').animate({'marginLeft':'0','opacity':'1'},100);},1000);
	setTimeout(function() {
		j$('#mainArea h2 img').animate({marginTop:0},400,'easeOutElastic');
	},1500);
}
