
/*
	Standards Compliant Rollover Script
	Author : Daniel Nolan
	http://www.bleedingego.co.uk/webdev.php
*/

//var gsRoot = "http://localhost/xxx";
//var gsIndexFile = "index.html";
var gsRoot = "http://www.vague-project.co.jp/10days/";
var gsIndexFile = "index.html";
var gsTags = ['img', 'input'];

function initRollovers() {
	if (!document.getElementById) return
	
	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = null;
	var aInput = null;
	var sRoot = location.href;

	if (gsRoot != "") sRoot = sRoot.replace(gsRoot,"");
	sRoot = sRoot.replace("http://","").replace("https://","");
	sRoot = sRoot.substring(sRoot.indexOf('/') + 1, sRoot.length);
	if (sRoot == gsIndexFile) sRoot = "";

	for (var i = 0; i < gsTags.length; i++) {
		aImages = document.getElementsByTagName(gsTags[i]);
		for (var j = 0; j < aImages.length; j++) {
			if (aImages[j].className == 'imgover') {
				var src = aImages[j].getAttribute('src');
				var ftype = src.substring(src.lastIndexOf('.'), src.length);
				var hsrc = src.replace(ftype, '_on'+ftype);

				if (aImages[j].id.indexOf('imgover_') >= 0) {
					var sImageName = aImages[j].id.replace("imgover_","");

					if ((sImageName != '' && sRoot.indexOf(sImageName) >= 0)
					 || ( sImageName == '' && sRoot.indexOf(sImageName) == 0 && location.href == gsRoot + "/")
					 || ( sImageName == '' && sRoot.indexOf(sImageName) == 0 && location.href == gsRoot + "/" + gsIndexFile)
					 ) {
						aImages[j].src = hsrc;
					}
				}

				aImages[j].setAttribute('hsrc', hsrc);
				
				aPreLoad[j] = new Image();
				aPreLoad[j].src = hsrc;
				
				aImages[j].onmouseover = function() {
					sTempSrc = this.getAttribute('src');
					this.setAttribute('src', this.getAttribute('hsrc'));
				}	
				
				aImages[j].onmouseout = function() {
					if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_on'+ftype, ftype);
					this.setAttribute('src', sTempSrc);
				}
			}
		}
	}
}

window.onload = initRollovers;




