// テーブルカラーチェンジ

function table_row(){
	tables = document.getElementsByTagName("table");
	for (i=0; i<tables.length; i++){
		if ( tables[i].className != "none" && tables[i].className != "mceLayout" ){
			for (ii=0; ii<tables[i].tBodies[0].rows.length; ii++){
				if ( tables[i].className != "mod-del" && tables[i].tBodies[0].rows.length >= 2 ){
					tables[i].tBodies[0].rows[ii].onmouseover=function(){this.className="over"};
				}
				if ( ii%2 ){
					tables[i].tBodies[0].rows[ii].className="gray";
					tables[i].tBodies[0].rows[ii].onmouseout=function(){this.className="gray"};
				}else{
					tables[i].tBodies[0].rows[ii].className="white";
					tables[i].tBodies[0].rows[ii].onmouseout=function(){this.className="white"};
				}
			}
		}
	}
}

// フォントサイズ
function changeFontSize(size) {
	var fontSizeSet = ['100%','140%','180%'];
	if ( size == 'N' ){
		if ( size = getCookie('fontsize') ){
			if ( isNaN(size) ){
				size = 0;
			}
		}else{
			size = 0;
		}
	}else{
		setCookie('fontsize',size);
	}
	document.getElementById('main').style.fontSize = fontSizeSet[size];
	if ( size == 0 ){
		document.getElementById('fontS').className = "fontS-select";
		document.getElementById('fontM').className = null;
		document.getElementById('fontL').className = null;
	}else if ( size == 1 ){
		document.getElementById('fontS').className = null;
		document.getElementById('fontM').className = "fontM-select";
		document.getElementById('fontL').className = null;
	}else if ( size == 2 ){
		document.getElementById('fontS').className = null;
		document.getElementById('fontM').className = null;
		document.getElementById('fontL').className = "fontL-select";
	}
}

function setCookie(Data,Value){
	life = new Date();
	life.setTime(life.getTime() + 24*60*60*1000*30);
	document.cookie = Data + "=" + escape(Value) + "; path=/; expires=" + life.toGMTString();

}

function getCookie(Data){
	var cookieArray = document.cookie.split("; ");
	for ( i=0; i<cookieArray.length; i++ ){
		var aCrumb = cookieArray[i].split("=");
		if ( Data == aCrumb[0] ){
			return unescape(aCrumb[1]);
		}
	}
	return null;
}

// ロールオーバー
function initRollOvers() {
	if (!document.getElementById){
		return;
	}
	
	var preLoads = new Array();
	var allImages = document.getElementsByTagName('img');

	for (var i = 0; i < allImages.length; i++) {		
		if (allImages[i].getAttribute("src").match("__off")) {
			var src = allImages[i].getAttribute('src');
			var oSrc = src.replace("__off", "__on");

			//-- スワップ元、スワップ先画像の登録
			allImages[i].setAttribute('pSrc', src);
			allImages[i].setAttribute('oSrc', oSrc);

			//-- イメージのプリロード
			preLoads[i] = new Image();
			preLoads[i].src = oSrc;

			//-- イベントの設定
			allImages[i].onmouseover = function() {
				this.setAttribute('src', this.getAttribute('oSrc'));
			};
			allImages[i].onmouseout = function() {
				this.setAttribute('src', this.getAttribute('pSrc'));
			};
		}
	}
}

function addOnload(func){
	if ( typeof window.addEventListener != "undefined" ){
		window.addEventListener( "load", func, false );
	}else if ( typeof window.attachEvent != "undefined" ) {
		window.attachEvent( "onload", func );
	}else{
		if ( window.onload !== null ){
			var oldOnload = window.onload;
			window.onload = function ( e ) {
				oldOnload( e );
				window[func]();
			};
		}else{
			window.onload = func;
		}
	}
}
addOnload(initRollOvers);

// SoftScroll
var scrj = 1;
function softScrollBack() {

	var scdist  = document.body.scrollTop  || document.documentElement.scrollTop;

	if(scrj<50 && scdist) {
      scdist = (scdist>2) ? Math.ceil(scdist*.2) : 1;
      scrj++;
      scrollBy(0,-scdist);
      setTimeout("softScrollBack()",20);
   } else {
      scrollTo(0,0);
      scrj = 1;
   }
}

// ダミーボタンクリック
function submitForm(i){
	document.getElementById(i).click();
}


