// dynamic parameter
function dp(parent,name,value){
	if(typeof(value) == "undefined"){
		return;
	}
	if(typeof(parent) == "undefined"){
		return;
	}
	if(typeof(parent[name]) != "undefined"){
		parent[name].value = value;
	}else{
		var elem = document.createElement("input");
		elem.setAttribute("type","hidden");
		elem.setAttribute("name",name);
		elem.setAttribute("value",value);
		parent.appendChild(elem);
	}
}

function go(mode,item,sort,page,search){
	if(typeof(document.base_form.MODE) != "undefined"){
		document.base_form.MODE.value=mode;
	}else{
		alert("NO MODE!");
	}
	
	if(typeof(document.base_form.PAGE_ITEM) != "undefined"){
		if(typeof(item) == "undefined"){
			document.base_form.PAGE_ITEM.value='';
		}else{
			document.base_form.PAGE_ITEM.value=item;
		}
	}
	
	if(typeof(document.base_form.SESSION_PAGE) != "undefined"){
		if(typeof(page) == "undefined"){
			document.base_form.SESSION_PAGE.value='';
		}else{
			document.base_form.SESSION_PAGE.value=page;
		}
	}
	
	if(typeof(document.base_form.SESSION_SEARCH) != "undefined"){
		if(typeof(search) == "undefined"){
			document.base_form.SESSION_SEARCH.value='';
		}else{
			document.base_form.SESSION_SEARCH.value=search;
		}
	}
	
	if(typeof(document.base_form.SESSION_SORT) != "undefined"){
		if(typeof(sort) == "undefined"){
			document.base_form.SESSION_SORT.value='';
		}else{
			document.base_form.SESSION_SORT.value=sort;
		}
	}
	
	document.base_form.submit();
}

function Del_Radio(f,radio) {
    var radio_len = f[radio].length;

    for(i=0; i<radio_len; i++) {
        f[radio][i].checked = false;
    }
}

function goSearch(mode,item,sort,page,search){
	if(typeof(document.search_form.MODE) != "undefined"){
		document.search_form.MODE.value=mode;
	}else{
		alert("NO MODE!");
	}	
	if(typeof(document.search_form.PAGE_ITEM) != "undefined"){
		if(typeof(item) == "undefined"){
			document.search_form.PAGE_ITEM.value='';
		}else{
			document.search_form.PAGE_ITEM.value=item;
		}
	}
	
	if(typeof(document.search_form.SESSION_PAGE) != "undefined"){
		if(typeof(page) == "undefined"){
			document.search_form.SESSION_PAGE.value='';
		}else{
			document.search_form.SESSION_PAGE.value=page;
		}
	}
	
	if(typeof(document.search_form.SESSION_SEARCH) != "undefined"){
		if(typeof(search) == "undefined"){
			document.search_form.SESSION_SEARCH.value='';
		}else{
			document.search_form.SESSION_SEARCH.value=search;
		}
	}
	
	if(typeof(document.search_form.SESSION_SORT) != "undefined"){
		if(typeof(sort) == "undefined"){
			document.search_form.SESSION_SORT.value='';
		}else{
			document.search_form.SESSION_SORT.value=sort;
		}
	}
	
	document.search_form.submit();
}

function goMember(mode,item,sort,page,search){
	if(typeof(document.search_form.MODE) != "undefined"){
		document.login_form.MODE.value=mode;
	}else{
		alert("NO MODE!");
	}	
	if(typeof(document.search_form.PAGE_ITEM) != "undefined"){
		if(typeof(item) == "undefined"){
			document.login_form.PAGE_ITEM.value='';
		}else{
			document.login_form.PAGE_ITEM.value=item;
		}
	}
	
	if(typeof(document.search_form.SESSION_PAGE) != "undefined"){
		if(typeof(page) == "undefined"){
			document.login_form.SESSION_PAGE.value='';
		}else{
			document.login_form.SESSION_PAGE.value=page;
		}
	}
	
	if(typeof(document.search_form.SESSION_SEARCH) != "undefined"){
		if(typeof(search) == "undefined"){
			document.login_form.SESSION_SEARCH.value='';
		}else{
			document.login_form.SESSION_SEARCH.value=search;
		}
	}
	
	if(typeof(document.search_form.SESSION_SORT) != "undefined"){
		if(typeof(sort) == "undefined"){
			document.login_form.SESSION_SORT.value='';
		}else{
			document.login_form.SESSION_SORT.value=sort;
		}
	}
	
	document.login_form.submit();
}

// charactor big or small
// Sence MacIE5
var brw_p = navigator.platform.charAt(0);
var brw_v = navigator.appVersion.charAt(0);
if( brw_p == "M" && navigator.appVersion.charAt(22) == "5") brw_v = 5;
var brw_n = navigator.appName.charAt(0);
if(window.opera) brw_n="O";
var isMacIE5 = false;
if( brw_p == "M"){
	if(document.getElementById){
		if(brw_n == "M" || brw_n == "O"){
			isMacIE5 = true;
		}
	}
}

// load CSS
var cookieName = "z_style";
var defaultSize = 0;
var saveDates = 14;


// lazy loading for the MacIE5
var cData = loadCookie(cookieName);
if(cData == false){
	saveCookie(cookieName,defaultSize,saveDates);
} else {
	defaultSize = parseInt(cData);
}
if(defaultSize==0){
	document.writeln("<link rel='alternate stylesheet' title='large' type='text/css' media='screen,print' href='/css/large.css' />");	// index:1
}else if(defaultSize==1){
	document.writeln("<link rel='stylesheet' title='large' type='text/css' media='screen,print' href='/css/large.css' />");	// index:1
}

function iniSet(){
	// nothing to do.
}

function clickSet(param){
	if(param == "up"){
		defaultSize = 1;
	}else{
		defaultSize = 0;
	}
	saveCookie(cookieName,defaultSize,saveDates);
	
	if(isMacIE5 == true){
		location.reload();
	}else{
		setActiveStyle();
	}
}


window.unload = function() {
	saveCookie(cookieName,defaultSize,saveDates);
}


//----------------------------------------------------

function setActiveStyle(){
	if(defaultSize == 1){
		document.getElementsByTagName("link")[0].disabled = false;
	} else {
		document.getElementsByTagName("link")[0].disabled = true;
	}
}


// *** secure flag not support *** comment by yasumura 2005.01.28

function saveCookie(arg1,arg2,arg3){ //arg1=dataname arg2=data arg3=expiration days
	if(arg1 && (arg2 >= 0)){
		if(arg3){
			xDay = new Date;
			xDay.setDate(xDay.getDate() + eval(arg3));
			xDay = xDay.toGMTString();
			_exp = ";expires=" + xDay;
		}
		else _exp ="";
		document.cookie = escape(arg1) + "=" + escape(arg2) + _exp + ";path=/;";
	}
}

function loadCookie(arg){ //arg=dataname
	if(arg){
		cookieData = document.cookie + ";" ;
		arg = escape(arg);
		startPoint1 = cookieData.indexOf(arg);
		startPoint2 = cookieData.indexOf("=",startPoint1) +1;
		endPoint = cookieData.indexOf(";",startPoint1);
		if(startPoint2 < endPoint && startPoint1 > -1 &&startPoint2-startPoint1 == arg.length+1){
			cookieData = cookieData.substring(startPoint2,endPoint);
			cookieData = unescape(cookieData);
			return cookieData
		}
	}
	return false
}

function deleteCookie(arg){ //arg=dataname
	if(arg){
		arg = escape(arg);
		yDay = new Date;
		yDay.setHours(yDay.getHours() - 1); 
		yDay = yDay.toGMTString(); 
		document.cookie = arg + "=xxx" + ";expires=" + yDay;
	}
}

// change Ruby
var rubi_elements;
var cookieRubyName = "ruby_status";
var rubyStatus = 0;
var rubyDates = 14;

var cRubyData = loadCookie(cookieRubyName);
if(cRubyData){
	rubyStatus = parseInt(cRubyData);
} else {
	saveCookie(cookieRubyName,rubyStatus,rubyDates);
}

//ルビ表示切り替え
function changerubi() {
	ruby_elements = $$('span.ruby');
	for (var i =0; i < ruby_elements.length; i ++){
		Element.toggle(ruby_elements[i]);
	}

	if(rubyStatus){
		rubyStatus = 0;
	} else {
		rubyStatus = 1;
	}

	saveCookie(cookieRubyName,rubyStatus,rubyDates);
}
    
//初期化 最初は非表示にする
function start() {
	if(rubyStatus == 0){
		ruby_elements = $$('span.ruby');
		for (var i =0; i < ruby_elements.length; i ++){
			Element.hide(ruby_elements[i]);
		}
	}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0 
  window.open(theURL,winName,features); 
} 