
// FOCUS INPUT
// INPUT要素がアクティブになった時に背景に色をつける
var colorful = new ColorfulInput;
	colorful.skip = ['submit'];
	colorful.skip = ['reset'];
	colorful.color['focus'] = '#F4F4F4';

function ColorfulInput() {
	this.skip= [];
	this.color = { 'blur': '', 'focus': '#F4F4F4' };

	this.set = function() {
		for (var i = 0; i < document.forms.length; i++) {
			for (var f = 0; f < document.forms[i].length; f++) {
				var elm = document.forms[i][f];
				if(!this._checkSkip(elm)) continue;
				this._setColor(elm, 'focus');
				this._setColor(elm, 'blur');
			}
		}
	}

	this._checkSkip = function(elm) {
		for(var i in this.skip) {
 			if(elm.type == this.skip[i]) return false;
		}
		return true;
	}

	this._setColor = function(elm, type) { 
		var color = this.color[type];
		var event = function() { elm.style.backgroundColor = color; };
		if(elm.addEventListener) {
			elm.addEventListener(type, event, false);
		}else if(elm.attachEvent) {
			elm.attachEvent('on'+type, event);
		}else{
			elm['on'+type] = event;
		}
	}
}


// IE ANCHOR BG CACHE
// IEの背景画像がキャッシュされない仕様を改善

var version = navigator.appVersion;
	version = version.substring(0,1);
var browser = navigator.appName;

if (browser =="Microsoft Internet Explorer"){
	try {
		document.execCommand("BackgroundImageCache", false, true);
	} catch(e) {}
}

// RESERVE SELECT BOX //

function updateCombo(){
	var combo1 = document.getElementById("combo1");
	var combo2 = document.getElementById("combo2");
	//  combo2.removeAttribute("disabled"); // didn't work
	combo2.disabled = false;
	for(i = combo2.childNodes.length-1;i >= 0;i--){
		combo2.removeChild(combo2.childNodes[i]);
	}

	today = new Date();
	mDate = today.getMonth() + 1;

	estm = mDate + 3;

	if($('#combo1').children(':selected').text() == "2010"){
		for(i=mDate;i<=12;i++){
			var selectBox = document.getElementById("combo2");
			var option = document.createElement('option');

			if(estm == i){
				option.setAttribute('selected','selected');
				option.setAttribute('value',i);
			}else{
				option.setAttribute('value',i);
			}

			option.appendChild(document.createTextNode(i));
			selectBox.appendChild(option);
		}
		var option = document.createElement('option');
		option.setAttribute('value','未定');
		option.appendChild(document.createTextNode('未定'));
		selectBox.appendChild(option);
	}else{
		for(n=1;n<=12;n++){
			var selectBox = document.getElementById("combo2");
			var option = document.createElement('option');

			if(estm == n){
				option.setAttribute('selected','selected');
				option.setAttribute('value',n);
			}else{
				option.setAttribute('value',n);
			}


			option.appendChild(document.createTextNode(n));
			selectBox.appendChild(option);
		}
		var option = document.createElement('option');
		option.setAttribute('value','未定');
		option.appendChild(document.createTextNode('未定'));
		selectBox.appendChild(option);
	}
	return true;
}

