// image roll 
//------------------------------------
function imgRoll(obj,flag) {
	var pathsrc = obj.getAttribute("src");
	var path = pathsrc.slice(0,pathsrc.lastIndexOf("/")+1);
	var imgname = pathsrc.slice(pathsrc.lastIndexOf("/")+1,pathsrc.length);
	if(flag) {
		var imgname = imgname.replace(/_def/i,"_ovr");
	} else {
		var imgname = imgname.replace(/_ovr/i,"_def");
	}
	obj.setAttribute("src",path + imgname);
}


/* cookie operation
-----------------------------------------------------------------------------------------------------------------*/

function class_cookielib(){
	this.getCookie = getCookie;
	this.setCookie = setCookie;
	this.removeCookie = removeCookie;
	 
	var expireDate = new Date();
	expireDate.setFullYear(expireDate.getFullYear()+1);
	expireStr = "expires=" + expireDate.toUTCString();

	function getCookie(name){
		var gc=name+"=";
		var Cookie=document.cookie;
		if (Cookie.length>0) {
			var start=Cookie.indexOf(gc);
			if (start!=-1) {
				start+=gc.length;
				terminus=Cookie.indexOf(";",start);
				if (terminus==-1) terminus=Cookie.length;
				return unescape(Cookie.substring(start,terminus));
			}
		}
		return '';
	}
	function setCookie() {
		var key = arguments[0];
		var val = arguments[1];
		var path = (typeof(arguments[2]) != 'undefined' ? arguments[2] : '/');
		
		var exp = (typeof(arguments[3]) != 'undefined'  ? arguments[3] : expireStr);
		var sc = key + "=" + escape(val) + "; path=" + path + "; " + exp;
		document.cookie = sc;
	}
	function removeCookie(key,path) {
		if(!path){
			path = '/';
		}
		var rc = key + "=; path=" + path + "; expires=Thu, 1 Jan 1970 00:00:00 UTC";
		document.cookie = rc;
	}
}
var cookieObj = new class_cookielib();

/* メインウィンドウ用 */
function outputTextSizeCtrl(){
	if(document.layers){
		return;
	}
	document.write('<div class="textsize">');
	document.write('<img src="/common/images/head_size_txt.gif" width="30" height="22" alt="" title="文字サイズ"> ');
	if(txtsize_val) {
    document.write('<img src="/common/images/head_size_btn_l_cur.gif" width="37" height="20" alt="大" title="大"><a href="#" onmouseover="imgRoll(this.firstChild,1);" onmouseout="imgRoll(this.firstChild,0);" onclick="return changeTextSize(0);"><img src="/common/images/head_size_btn_s_def.gif" width="36" height="20" alt="小" title="小"></a>');
  } else {
		document.write('<a href="#" onmouseover="imgRoll(this.firstChild,1);" onmouseout="imgRoll(this.firstChild,0);" onclick="return changeTextSize(1);"><img src="/common/images/head_size_btn_l_def.gif" width="37" height="20" alt="大" title="大"></a><img src="/common/images/head_size_btn_s_cur.gif" width="36" height="20" alt="小" title="小">');
  }
	document.write('</div>');
}

/* サブウィン用 */
function outputTextSizeCtrlSub(){
	if(document.layers){
		return;
	}
	document.write('<div class="textsize">');
	document.write('<img src="/common/images/head_size_txt.gif" width="30" height="22" alt="" title="文字サイズ"> ');
	if(txtsize_val) {
    document.write('<img src="/common/images/head_size_btn_l_cur.gif" width="37" height="20" alt="大" title="大"><a href="#" onmouseover="imgRoll(this.firstChild,1);" onmouseout="imgRoll(this.firstChild,0);" onclick="return changeTextSize(0);"><img src="/common/images/head_size_btn_s_def.gif" width="36" height="20" alt="小" title="小"></a>');
  } else {
		document.write('<a href="#" onmouseover="imgRoll(this.firstChild,1);" onmouseout="imgRoll(this.firstChild,0);" onclick="return changeTextSize(1);"><img src="/common/images/head_size_btn_l_def.gif" width="37" height="20" alt="大" title="大"></a><img src="/common/images/head_size_btn_s_cur.gif" width="36" height="20" alt="小" title="小">');
  }
	document.write('</div>');
}


/* change text size
-----------------------------------------------------------------------------------------------------------------*/
var txtsize_val = 0;
var txtsize_css_size = new Array();
txtsize_css_size[0] = 'fsize_s';
txtsize_css_size[1] = 'fsize_l';

function setTextSize(){
	if(cookieObj.getCookie('txtsize') != ''){
		txtsize_val = 1 * cookieObj.getCookie('txtsize');
	}
	document.write('<link rel="stylesheet" href="/common/styles/'+ txtsize_css_size[txtsize_val] + '.css" type="text/css" media="screen,projection,print">');
}

function changeTextSize(num){
		cookieObj.setCookie('txtsize',num,'/');
		window.location.reload();
		return false;
}

/* subwin open
-----------------------------------------------------------------------------------------------------------------*/
function openWindow(strUrl,winName,winWidth,winHeight) {
	var features = 'toolbar=0,location=0,directories=0,status=0,menubar=1,scrollbars=1,resizable=1,width=' + winWidth + ',height=' + winHeight;
	winName = window.open(strUrl,winName,features);
	winName.focus();
}

/* normal link clicked
-----------------------------------------------------------------------------------------------------------------*/
function openLink(strUrl,winName) {
  winName = window.open(strUrl,winName);
  winName.focus();
}


