// 背景画像読み込みキャッシュ
try { 
	document.execCommand('BackgroundImageCache', false, true); 
} catch(e) {}


// ロールオーバー
var smartRollover = {
	config: function(){
		smartRollover.init('img');
		smartRollover.init('input');
	},

	init: function(tag) {
		var obj = document.getElementsByTagName(tag);
		if(typeof obj == 'undefined' || obj == null) return false;

		var preload = [];
		for(var i=0; i<obj.length; i++) {
			if(obj[i].className.indexOf('imgover') != -1){
				var src = obj[i].src;
				obj[i].ext = src.slice(src.length-4, src.length);
				obj[i].nimg = src;
				obj[i].oimg = src.replace(obj[i].ext, '_o'+obj[i].ext);

				preload[i] = new Image();
				preload[i].src = obj[i].himg;

				obj[i].onmouseover = function() {
					this.setAttribute('src', this.oimg);
				};
				obj[i].onmouseout = function() {
					this.setAttribute('src', this.nimg);
				};
			}
		}
	},

	addEvent: function(){
		try {
			window.addEventListener('load', smartRollover.config, false);
		} catch (e) {
			window.attachEvent('onload', smartRollover.config);
		}
	}
}
smartRollover.addEvent();


//インプット、デフォルト値の操作
var defaultCheck = {
	chkClass: 'defCheck',

	init: function(){
		var obj = document.getElementsByTagName('input');
		if(typeof obj == 'undefined' || obj == null) return false;

		for(var i=0; i<obj.length; i++){
			if(obj[i].type == 'text' && obj[i].className.indexOf(defaultCheck.chkClass) != -1){
				obj[i].onfocus = function(){
					if(this.value == this.defaultValue){
						this.value = '';
					}
				}
				obj[i].onblur = function(){
					if(this.value == ''){
						this.value = this.defaultValue;
					}
				}
			}
		}
	},

	addEvent: function(){
		try {
			window.addEventListener('load', defaultCheck.init, false);
		} catch (e) {
			window.attachEvent('onload', defaultCheck.init);
		}
	}
}
defaultCheck.addEvent();
