var baseSURL = 'https://www.sakuranbo.co.jp';
var imgPlus = '_over';
function imgRollover(name) {
	if (!document.getElementById) return
	var src = document.getElementById(name).src;
	var suffix = src.substring(src.lastIndexOf('.'), src.length);
	var src_over = src.replace(suffix, imgPlus+suffix);
	document.getElementById(name).src = src_over;
}
function imgRollout(name) {
	if (!document.getElementById) return
	var src = document.getElementById(name).src;
	var suffix = src.substring(src.lastIndexOf('.'), src.length);
	var src_org = src.replace(imgPlus+suffix, suffix);
	document.getElementById(name).src = src_org;
}
function imgPreload() {
	if (!document.getElementById) return
	var imgPreLoad = new Array();
	var allimgs = document.getElementsByTagName('img');
	for (var i = 0; i < allimgs.length; i++) {		
		if (allimgs[i].className == 'rollover') {
			var src = allimgs[i].getAttribute('src');
			var suffix = src.substring(src.lastIndexOf('.'), src.length);
			imgPreLoad[i] = new Image();
			imgPreLoad[i].src = src.replace(suffix, imgPlus+suffix);
		}
	}
}
window.onload = imgPreload;

function showHomeImg() {
	var mdhm = window.location.search.substring(1);
	if(mdhm.match(/[^0-9]+/) || mdhm.length!=9){ mdhm = ""; }
	var hm;
	if (!mdhm) {
		var date	= new Date();
		var mon	= formatNum(2,date.getMonth() + 1);		var day	= formatNum(2,date.getDate());
		var hour	= formatNum(2,date.getHours());			var min	= formatNum(2,date.getMinutes());
		mdhm = 1 + mon + day + hour + min;				hm		= 1 + hour + min;
	} else {
		hm = 1 + mdhm.substring(5);
	}
	var image;	//5-10/11-17/18-4
	if (107011000 <= mdhm && mdhm < 109011000) {
		if (10500 <= hm && hm < 11100) {
			image = "home_summer_morning.jpg";
		} else if ((11800 <= hm && hm <= 12359) || (10000 <= hm && hm < 10500)) {
			image = "home_summer_night.jpg";
		} else {
			image = "home_summer_daytime.jpg";
		}
	} else if (109011000 <= mdhm && mdhm < 112011000) {
		if (10500 <= hm && hm < 11100) {
			image = "home_autumn_morning.jpg";
		} else if ((11800 <= hm && hm <= 12359) || (10000 <= hm && hm < 10500)) {
			image = "home_autumn_night.jpg";
		} else {
			image = "home_autumn_daytime.jpg";
		}
	} else if (112011000 <= mdhm || (101010000 <= mdhm && mdhm < 103011000)) {
		if (10500 <= hm && hm < 11100) {
			image = "home_winter_morning.jpg";
		} else if ((11800 <= hm && hm <= 12359) || (10000 <= hm && hm < 10500)) {
			image = "home_winter_night.jpg";
		} else {
			image = "home_winter_daytime.jpg";
		}
	} else {
		if (10500 <= hm && hm < 11100) {
			image = "home_spring_morning.jpg";
		} else if ((11800 <= hm && hm <= 12359) || (10000 <= hm && hm < 10500)) {
			image = "home_spring_night.jpg";
		} else {
			image = "home_spring_daytime.jpg";
		}
	}
	document.write("<img src=\"img/" + image + "\" width=\"950\" height=\"550\" alt=\"\" usemap=\"#Map\" />");
	document.write("<map name=\"Map\" id=\"Map\">");
	document.write("<area shape=\"rect\" coords=\"5,485,205,545\" href=\"pet/index.html\" alt=\"ボーの勝手に！？ペット大賞！\" />");
	document.write("</map>");
}
function showWallImg(name,no) {
	var html ='<img src="./img/' + no + '.jpg" alt="wall' + no + '" class="float-left" />\n';
    		html+='<ul id="download-sizelist">\n';
    		html+='	<li><a href="' + baseSURL + '/sayland/download/member/' + no + '_800.jpg" target="_blank">[800×600]</a></li>\n';
    		html+='	<li><a href="' + baseSURL + '/sayland/download/member/' + no + '_1024.jpg" target="_blank">[1024×768]</a></li>\n';
    		html+='	<li><a href="' + baseSURL + '/sayland/download/member/' + no + '_1280.jpg" target="_blank">[1280×1024]</a></li>\n';
    		html+='</ul>\n';
	outputHTML(name,html);
}
function showProfile(name) {
	if (!document.getElementById) return
	name = "profile-" + name;
	var html = document.getElementById(name);
	outputHTML("profile-chara",html.innerHTML);
}
function playMovie(mov_id){
	var so = new SWFObject("img/player.swf", "movie", "630", "475", "8", "#a7dae0");
		so.addVariable("mov_id",mov_id);
		so.write("library-play");
}
function outputHTML(name,html) {
	if (document.getElementById) {
		document.getElementById(name).innerHTML=html
	} else if (document.all) {
		document.all(name).innerHTML=html
	} else if (document.layers) {
		with(document.layers[name].document) {
			open();		write(html);	close();
		}
	}
}
function newwin(h,n,s) { window.open(h,n,s) }
function formatNum(keta, num) {
	var src = new String(num);
	var cnt = keta - src.length;
	if (cnt <= 0) return src;
	while (cnt-- > 0) src = "0" + src;
	return src;
}
