/**
 * 画像反転処理
 *
 */
///mouseover
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


///windowopen
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
/**
 * 子ウインドウ起動
 *
 */
function OpenChild( url, width, height, name ) {
    
    option = "scrollbars=yes,resizable=yes,directories=no,location=no,menubar=no";
    //option = option + "width=" + width + ",height=" + height;
    
	if( width ) {

		if( window.screen.width > width ) {
			
			option += ", left=" + (window.screen.width - width) / 2;
		
		} else {
			
			width = window.screen.width;
		}
		
		option += ", width=" + width;
	}
	if( height ) {
		
		if( window.screen.height > height ) {

			option += ", top=" + (window.screen.height - height) / 2;
		
		} else {
			
			height = window.screen.height;
		}
		
		option += ", height=" + height;
	}
	
    child = window.open( url, name, option );
    
    child.focus();
}
/**
 * 親ウインドウを更新して閉じる
 *
 */
function refreshClose() {

	if( (!!window.opener) && (window.opener.closed == false) ) {

		window.opener.location.reload();
	}
	
	window.close();
}
/**
 * 実行確認
 *
 */
function checkAction() {
	
	if( window.confirm("実行してもよろしいですか？") ) {
    	
		return true;
        
    } else {

        return false;
    }
}
/**
 * 再検索
 * 
 */
function re_search() {

	document.search_form.page_no.value='1';
	document.search_form.submit();
}
/**
 * フォームのリセット
 *
 */
function resetForm() {

	form = document.search_form;
	
    for( i=0; i<form.elements.length; i++ ) {

		if( form.elements[i].type == "checkbox" || form.elements[i].type=="radio" ) {

			form.elements[i].checked =false;
		
		} else if( form.elements[i].type == "text" || form.elements[i].type=="select-one" || form.elements[i].type=="password" ) {
		
			form.elements[i].value  = "";
		}
    }
}
/*
 * 検索フォームの本日設定
 */
function setToday( myForm, input1name, input2name ) {

	date = new Date();

	year = date.getYear();

	if( year < 2000 ) year += 1900;

	start_year  = myForm.elements[input1name + "[Y]"];
	start_month = myForm.elements[input1name + "[m]"];
	start_day   = myForm.elements[input1name + "[d]"];
	
	start_year.value  = year;
	start_month.value = date.getMonth() + 1;
	start_day.value   = date.getDate();
	
	if( input2name != "" ) {

		end_year  = myForm.elements[input2name + "[Y]"];
		end_month = myForm.elements[input2name + "[m]"];
		end_day   = myForm.elements[input2name + "[d]"];
		
		end_year.value  = year;
		end_month.value = date.getMonth() + 1;
		end_day.value   = date.getDate();
	}
}
/*
 * 検索フォームの本日設定
 */
function copyDate( myForm, input1name, input2name ) {
	
	start_year_value  = myForm.elements[input1name+'[Y]'].value;
	start_month_value = myForm.elements[input1name+'[m]'].value;
	start_day_value   = myForm.elements[input1name+'[d]'].value;
	
	
	stop_year_count  = myForm.elements[input2name+'[Y]'].length
	stop_month_count = myForm.elements[input2name+'[m]'].length
	stop_day_count   = myForm.elements[input2name+'[d]'].length
	
	for( count=0; count<stop_year_count; count++ ) {
		
		if( start_year_value == myForm.elements[input2name+'[Y]'][count].value ) {

			myForm.elements[input2name+'[Y]'][count].selected = true;
			break;
		}
	}
	
	for( count=0; count<stop_month_count; count++ ) {
		
		if( start_month_value == myForm.elements[input2name+'[m]'][count].value ) {

			myForm.elements[input2name+'[m]'][count].selected = true;
			break;
		}
	}
	
	for( count=0; count<stop_day_count; count++ ) {
		
		if( start_day_value == myForm.elements[input2name+'[d]'][count].value ) {

			myForm.elements[input2name+'[d]'][count].selected = true;
			break;
		}
	}
}
/*
 * 検索フォームの日付クリア
 */
function clearDate( myForm, input1name, input2name ) {
	
	if( input1name != "" ) {

		//
		start_year  = myForm.elements[input1name + "[Y]"];
		start_month = myForm.elements[input1name + "[m]"];
		start_day   = myForm.elements[input1name + "[d]"];
	
		//
		if( start_year ) {
		
			start_year.value  = "";
			start_month.value = "";
			start_day.value   = "";
		}
	}
	
	if( input2name != "" ) {

		//
		end_year  = myForm.elements[input2name + "[Y]"];
		end_month = myForm.elements[input2name + "[m]"];
		end_day   = myForm.elements[input2name + "[d]"];
		
		//
		if( end_year ) {

			end_year.value  = "";
			end_month.value = "";
			end_day.value   = "";
		}
	}
}
/**
 * 左サイドメニュー関連処理
 * 
 */
/**
 * 
 * 
 */
function load_search_form() {

	var url = '?module=PartnerInformation&action=dispSearchForm';

	var params;

	new Ajax.Updater(
		{ success : 'id_disp_search_form' },
		url,
		{
			asynchronous   : true,
			requestHeaders : ["Content-Type", "application/x-www-form-urlencoded; charset=Shift_JIS"],
			postBody       : params,
			onLoading : disp_loading,
			onFailure : disp_error,
			evalScripts : true
		}
	);
}
/**
 * 画面読込時の左サイドメニュー制御
 * 
 */
function load_side_menu() {

	// クッキー保持期間：2日
	cookie_manager = new CookieManager();

	if ( cookie_manager != null && cookie_manager != "" ) {

		change_disp_sub_menu( 'ul_id_1', cookie_manager.getCookie("keep_ul_id_1") );
		change_disp_sub_menu( 'ul_id_2', cookie_manager.getCookie("keep_ul_id_2") );
		change_disp_sub_menu( 'ul_id_3', cookie_manager.getCookie("keep_ul_id_3") );
		change_disp_sub_menu( 'ul_id_4', cookie_manager.getCookie("keep_ul_id_4") );
		change_disp_sub_menu( 'ul_id_5', cookie_manager.getCookie("keep_ul_id_5") );
		change_disp_sub_menu( 'ul_id_6', cookie_manager.getCookie("keep_ul_id_6") );
		change_disp_sub_menu( 'ul_id_7', cookie_manager.getCookie("keep_ul_id_7") );
		change_disp_sub_menu( 'ul_id_8', cookie_manager.getCookie("keep_ul_id_8") );
		change_disp_sub_menu( 'ul_id_9', cookie_manager.getCookie("keep_ul_id_9") );
		change_disp_sub_menu( 'ul_id_10', cookie_manager.getCookie("keep_ul_id_10") );
		change_disp_sub_menu( 'ul_id_11', cookie_manager.getCookie("keep_ul_id_11") );
		change_disp_sub_menu( 'ul_id_12', cookie_manager.getCookie("keep_ul_id_12") );
		change_disp_sub_menu( 'ul_id_13', cookie_manager.getCookie("keep_ul_id_13") );
		change_disp_sub_menu( 'ul_id_14', cookie_manager.getCookie("keep_ul_id_14") );
		change_disp_sub_menu( 'ul_id_15', cookie_manager.getCookie("keep_ul_id_15") );
		change_disp_sub_menu( 'ul_id_16', cookie_manager.getCookie("keep_ul_id_16") );
		change_disp_sub_menu( 'ul_id_17', cookie_manager.getCookie("keep_ul_id_17") );
		change_disp_sub_menu( 'ul_id_18', cookie_manager.getCookie("keep_ul_id_18") );
		change_disp_sub_menu( 'ul_id_19', cookie_manager.getCookie("keep_ul_id_19") );
		change_disp_sub_menu( 'ul_id_20', cookie_manager.getCookie("keep_ul_id_20") );
		change_disp_sub_menu( 'ul_id_21', cookie_manager.getCookie("keep_ul_id_21") );
		change_disp_sub_menu( 'ul_id_22', cookie_manager.getCookie("keep_ul_id_22") );
		change_disp_sub_menu( 'ul_id_23', cookie_manager.getCookie("keep_ul_id_23") );
		change_disp_sub_menu( 'ul_id_24', cookie_manager.getCookie("keep_ul_id_24") );
		change_disp_sub_menu( 'ul_id_25', cookie_manager.getCookie("keep_ul_id_25") );
		change_disp_sub_menu( 'ul_id_26', cookie_manager.getCookie("keep_ul_id_26") );
		change_disp_sub_menu( 'ul_id_27', cookie_manager.getCookie("keep_ul_id_27") );
		change_disp_sub_menu( 'ul_id_28', cookie_manager.getCookie("keep_ul_id_28") );
		change_disp_sub_menu( 'ul_id_29', cookie_manager.getCookie("keep_ul_id_29") );
		change_disp_sub_menu( 'ul_id_30', cookie_manager.getCookie("keep_ul_id_30") );
		change_disp_sub_menu( 'ul_id_31', cookie_manager.getCookie("keep_ul_id_31") );
		change_disp_sub_menu( 'ul_id_32', cookie_manager.getCookie("keep_ul_id_32") );
		change_disp_sub_menu( 'ul_id_33', cookie_manager.getCookie("keep_ul_id_33") );
		change_disp_sub_menu( 'ul_id_34', cookie_manager.getCookie("keep_ul_id_34") );
		change_disp_sub_menu( 'ul_id_35', cookie_manager.getCookie("keep_ul_id_35") );
		change_disp_sub_menu( 'ul_id_36', cookie_manager.getCookie("keep_ul_id_36") );
		change_disp_sub_menu( 'ul_id_37', cookie_manager.getCookie("keep_ul_id_37") );
		change_disp_sub_menu( 'ul_id_38', cookie_manager.getCookie("keep_ul_id_38") );
		change_disp_sub_menu( 'ul_id_39', cookie_manager.getCookie("keep_ul_id_39") );
		change_disp_sub_menu( 'ul_id_40', cookie_manager.getCookie("keep_ul_id_40") );
		change_disp_sub_menu( 'ul_id_41', cookie_manager.getCookie("keep_ul_id_41") );
		change_disp_sub_menu( 'ul_id_42', cookie_manager.getCookie("keep_ul_id_42") );
		change_disp_sub_menu( 'ul_id_43', cookie_manager.getCookie("keep_ul_id_43") );
		change_disp_sub_menu( 'ul_id_44', cookie_manager.getCookie("keep_ul_id_44") );
		change_disp_sub_menu( 'ul_id_45', cookie_manager.getCookie("keep_ul_id_45") );
		change_disp_sub_menu( 'ul_id_46', cookie_manager.getCookie("keep_ul_id_46") );
		change_disp_sub_menu( 'ul_id_47', cookie_manager.getCookie("keep_ul_id_47") );
		change_disp_sub_menu( 'ul_id_48', cookie_manager.getCookie("keep_ul_id_48") );
		change_disp_sub_menu( 'ul_id_49', cookie_manager.getCookie("keep_ul_id_49") );
		change_disp_sub_menu( 'ul_id_50', cookie_manager.getCookie("keep_ul_id_50") );

		change_disp_sub_menu( 'ul_id_101', cookie_manager.getCookie("keep_ul_id_101") );

		//
		change_disp_sub_menu( 'ul_id_kakaku_search', cookie_manager.getCookie("keep_ul_id_kakaku_search") );
		change_disp_sub_menu( 'ul_id_support', cookie_manager.getCookie("keep_ul_id_support") );
		change_disp_sub_menu( 'ul_id_request', cookie_manager.getCookie("keep_ul_id_request") );
		change_disp_sub_menu( 'ul_id_obc_staff', cookie_manager.getCookie("keep_ul_id_obc_staff") );
		change_disp_sub_menu( 'ul_id_user_common', cookie_manager.getCookie("keep_ul_id_user_common") );

		//
		cookie_manager.setCookie( 'is_cookie', '1' );
	}
}
/**
 * 左サイドメニュー開閉制御
 * 
 */
function change_disp_sub_menu( target_ul_id, keep_status ){

	obj = document.getElementById( target_ul_id );

	if ( obj == null ) return false;


	// クッキー保持期間：2日
	cookie_manager = new CookieManager();

	if ( cookie_manager != null && (cookie_manager.getCookie("is_cookie") == null || cookie_manager.getCookie("is_cookie") == 'null') ) {

		next_status = 'none';

	} else {

		// 対象部分の表示状態
		now_status = obj.style.display;

		// 前の開閉状態から左サイドメニューを制御
		if ( keep_status != null ) {

			if ( keep_status == 'disp' ) {

				next_status = '';

			} else if ( keep_status == 'no_disp' ) {

				next_status = 'none';
			}
	
		// 表示、非表示制御
		} else {

			if ( now_status == 'none' ) {

				next_status = '';

			} else {

				next_status = 'none';
			}
		}
	}

	document.getElementById( target_ul_id ).style.display = next_status;

	// サイドメニューの背景色変更
	target_span_id = 'side_menu_' + target_ul_id.replace( 'ul_id_', '' );

	if ( next_status == '' ) {

		document.getElementById(target_span_id).className = 'markOn';

	} else {

		document.getElementById(target_span_id).className = 'mark';
	}

	set_side_menu( target_ul_id );
}
/**
 * クッキーに左サイドメニューの状態をセット
 * 
 */
function set_side_menu( target_ul_id ) {

	// クッキー保持期間：2日
	cookie_manager = new CookieManager();

	keep_key = 'keep_' + target_ul_id;
	
	if ( document.getElementById( target_ul_id ).style.display == 'none' ) {

		cookie_manager.setCookie( keep_key, 'no_disp' );

	} else {

		cookie_manager.setCookie( keep_key, 'disp' );
	}
}
/**
* ユーザー側検索関連
* ※検索項目の表示/非表示切り替え
* ※keep_statusはオンロード時のみ
*
*/
function change_style_display_by_id( target_id, keep_status ) {

	obj = document.getElementById( target_id );

	img_obj = document.getElementById( 'search_area_status' );

	if ( obj != null ) {

		now_status = obj.style.display;

		//
		next_status = '';
		if ( now_status == '' ) next_status='none';

		if ( keep_status != null && keep_status == 'disp') {

			next_status = '';

		} else if ( keep_status != null && keep_status == 'no_disp') {

			next_status = 'none';

		} else if ( keep_status != null ) {

			next_status = '';
		}

		if ( next_status == 'none' ) {

			img_obj.src='img/common/btn_open_shut_f2.gif';
			obj.style.display = next_status;

			if ( document.getElementById('id_img_searchList_bottom') != false ) document.getElementById('id_img_searchList_bottom').style.display='none';

		} else {

			img_obj.src='img/common/btn_open_shut.gif';
			obj.style.display = next_status;

			if ( document.getElementById('id_img_searchList_bottom') != false ) document.getElementById('id_img_searchList_bottom').style.display='';
		}

		// クッキー保持期間：2日
		cookie_manager = new CookieManager();

		next_keep_status = 'no_disp';
		if ( next_status == '' ) next_keep_status = 'disp';

		cookie_manager.setCookie( 'keep_menu_open_status', next_keep_status );
	}
}
/**
 * 
 * 
 */
function load_search_area_status() {

	// クッキー保持期間：2日
	cookie_manager = new CookieManager();

	if ( cookie_manager != null && cookie_manager != "" ) {

		// メニューの開閉状態
		change_style_display_by_id( 'serch_form_area', cookie_manager.getCookie("keep_menu_open_status") );
	}
}
/**
 * 
 * 
 */
function change_sort_type( target_name, change_value ) {

	document.getElementsByName(target_name)[0].value = change_value;
}
/**
 * 検索結果エリア読込
 *
 */
function load_search_info( info_kind, sort_pattern ) {

	var page_no_value = 1;
	var cate1_sort_value = 'ASC';
	var cate2_sort_value = 'ASC';

	var form_id = 'form_id_' + info_kind;
	var form = document.getElementById(form_id);

	var is_from_top = '';

	
	if ( form != null && form.page_no != null ) {

		page_no_value = form.page_no.value;

	} else if ( document.getElementsByName('page_no') != null ) {
		
		page_no_value = document.getElementsByName('page_no')[0].value;
	}

	if ( document.getElementsByName('cate1_sort_type') != null && document.getElementsByName('cate1_sort_type')[0] != null) cate1_sort_value = document.getElementsByName('cate1_sort_type')[0].value;
	if ( document.getElementsByName('cate2_sort_type') != null && document.getElementsByName('cate2_sort_type')[0] != null) cate2_sort_value = document.getElementsByName('cate2_sort_type')[0].value;

	if ( document.getElementById('id_from_top') != null && document.getElementById('id_from_top').value != null) is_from_top = '1';

	var target_area_id = 'search_result_' + info_kind;

	var params = '';

	var url = '?module=PartnerInformation&action=searchList&InfoKind=' + info_kind +'&sort_pattern=' + sort_pattern;
	url = url + '&page_no=' + page_no_value;
	url = url + '&cate1_sort_type=' + cate1_sort_value;
	url = url + '&cate2_sort_type=' + cate2_sort_value;
	url = url + '&from_top=' + is_from_top;

	new Ajax.Updater(
		{ success : target_area_id },
		url,
		{
			asynchronous   : true,
			requestHeaders : ["Content-Type", "application/x-www-form-urlencoded; charset=Shift_JIS"],
			postBody       : params,
			onLoading : disp_loading,
			onFailure : disp_error,
			evalScripts : true
		}
	);
}
/**
 * 
 * 
 */
function disp_loading() {}
/**
 * 
 * 
 */
function disp_error() {}
