var	site_url = 'http://ebmarket.zenginkyo.or.jp';
var	ebm_admin_url = 'http://ebmarket.zenginkyo.or.jp';

var special_company_page_size = 10;
var special_company_pager_size = 9;
var company_search_page_size = 10;
var company_search_pager_size = 9;
var contents_search_page_size = 10;
var contents_search_pager_size = 9;
var lounge_reserve_page_size = 5;
var lounge_reserve_pager_size = 9;
var recent_new_days = 7;

var	industry_type_name = new Array(
	'農業,林業',
	'漁業',
	'鉱業,採石業,砂利採取業',
	'建設業', '機械製造業',
	'電気機器製造業',
	'自動車,同附属品製造業',
	'精密機器製造業',
	'その他製造業',
	'繊維工業',
	'印刷,同関連業',
	'化学工業', '鉄鋼業',
	'電気,ガス,熱供給,水道業',
	'情報通信業',
	'陸運業,水運業,その他運輸業',
	'卸売業',
	'小売業',
	'不動産業',
	'リース業,その他物品賃貸業',
	'宿泊業',
	'飲食サービス業',
	'生活関連サービス業',
	'娯楽業',
	'広告業',
	'その他学術研究,専門,技術サービス業',
	'医療,福祉業',
	'教育,学習支援業',
	'職業紹介,労働派遣業',
	'その他サービス業'
);

var area = new Array(
	{ 'name':'北海道エリア',	's':1,	'e':1  },
	{ 'name':'東北エリア',		's':2,	'e':7  },
	{ 'name':'北関東エリア',	's':8,	'e':10 },
	{ 'name':'南関東エリア',	's':11, 'e':14 },
	{ 'name':'甲信越エリア',	's':15, 'e':17 },
	{ 'name':'北陸エリア',		's':18, 'e':20 },
	{ 'name':'中部エリア',		's':21, 'e':24 },
	{ 'name':'近畿エリア',		's':25, 'e':30 },
	{ 'name':'中国エリア',		's':31, 'e':35 },
	{ 'name':'四国エリア',		's':36, 'e':39 },
	{ 'name':'九州エリア',		's':40, 'e':46 },
	{ 'name':'沖縄エリア',		's':47, 'e':47 }		
);

var	area_name = new Array(
	'全国',
	'北海道エリア', '東北エリア', '北関東エリア',
	'南関東エリア', '甲信越エリア', '北陸エリア',
	'中部エリア', '近畿エリア', '中国エリア',
	'四国エリア', '九州エリア', '沖縄エリア'
);
 
var	todofuken_name = new Array(
	'北海道',
	'青森県', '岩手県', '宮城県', '秋田県', '山形県', '福島県',
	'茨城県', '栃木県', '群馬県',
	'埼玉県', '千葉県', '東京都', '神奈川県',
	'新潟県', '山梨県', '長野県',
	'富山県', '石川県', '福井県',
	'三重県', '岐阜県', '静岡県', '愛知県',
	'滋賀県', '京都府', '大阪府', '兵庫県', '奈良県', '和歌山県',
	'鳥取県', '島根県', '岡山県', '広島県', '山口県',
	'徳島県', '香川県', '愛媛県', '高知県',
	'福岡県', '佐賀県', '長崎県', '熊本県', '大分県', '宮崎県', '鹿児島県',
	'沖縄県'
);

/**
 *
 * 画面に渡されたパラメータを返す
 *
 */
function ebm_getRequest() {

	if( location.search.length > 1 ) {
	
		var get = new Object();
		var ret = location.search.substr( 1 ).split( "&" );
		
		for ( var i = 0; i < ret.length; i++ ) {
		
			var r = ret[i].split( "=" );
      		get[r[0]] = r[1];
      		
      	}
      	
    	return get;
    	
    } else {
    
    	return false;
    	
    }

}

/**
 *
 * 検索結果にアクセスするのが初めてかの確認
 *
 */
function ebm_check_company_search_result() {

	var	c = $.cookie( 'ebm_check_company_search_result' );
	
	if ( c == null ) {
	
		return false;
		
	} 
	
	return true;
	
}


/**
 *
 * 検索時のアラートを表示する（検索時）
 *
 */
function ebm_check_company_search( id ) {
	
	var	search = '';
	
	for ( var i = 0; i < document.forms.length; i++ ) {
	
		if ( document.forms[i].id == id ) {
		
			for ( var j = 0; j < document.forms[i].elements.length; j++ ) {
				
				if ( document.forms[i].elements[j].type == 'checkbox' ) {
				
					if ( document.forms[i].elements[j].checked ) {
					
						search += '&' + document.forms[i].elements[j].name + '=' + document.forms[i].elements[j].value;
						
					}
					
				} else {
				
					search += '&' + document.forms[i].elements[j].name + '=' + utf.URLencode( document.forms[i].elements[j].value );

				}
	
			}
			
			break;
				
		}
	
	}
	
	var	url = site_url + '/company_search/result.html?' + search.substr( 1 );
	
	if ( !ebm_check_company_search_result() ) {
	
		url = site_url + '/attention/index.html?url=' + url;
		
		
	}
	
	document.location = url;
	
}

/**
 *
 * 検索時のアラートを表示する（検索時以外）
 *
 */
function ebm_check_company_search2( mode ) {
	
	var	url = '';
	
	switch ( mode ) {
	
		case 1 :
		
			url = site_url + '/special/index.html';
			break;
	}
	
	if ( !ebm_check_company_search_result() ) {
	
		url = site_url + '/attention/index.html?url=' + url;
		
		
	}
	
	document.location = url;
	
}

/**
 *
 * 検索結果アクセスに同意する
 *
 */
function ebm_accept_company_search_result() {

	$.cookie( 'ebm_check_company_search_result', '1', { path: '/', expires: 7 } );

}

/**
 *
 * 買いたい商品特集リストを表示する(トップ画面)
 *
 */
function ebm_show_top_special_company_list( id, limit ) {

	$( '#' + id ).empty();
        	
	$.ajax({
	
		dataType: 'json',
		data: {
            'service': 'top_special_company_list',
            'limit'  : limit
        },
        cache: false,
        url: ebm_admin_url + '/services/json',
        success: function (data) {
  
        	var	str = '';
        	
        	// 表示設定
			if (data.result[0].TopSetting.disp_flg == 0) {
			
				return;
				
			}
			
			str += '<div id="special">';
			str += '<div class="kt"><img src="index/kaitai_t.jpg" alt""/></div>';
			str += '<div id="special_inner">';
			str += '<h2><a href="javascript:ebm_check_company_search2(1)"><img src="index/kaitai_h2.jpg" alt="買いたい商品特集" title="買いたい商品特集"/></a></h2>';
			/*
			str += '<div id= "title" class="clearfix">';
			str += '<h2><img src="index/kaitai_h2.jpg" alt="買いたい商品特集" title="買いたい商品特集"/></h2>';
			str += '<p><a href="javascript:ebm_check_company_search2(1)"><img src="index/kaitai_detail.jpg" alt="全ての検索結果をみる" class="rollover" /></a></p>';
			str += '</div>';
			*/
			str += '<p><img src="index/kaitai_lead.jpg" alt="テーマに沿った商品・サービスを買いたい企業を紹介します。" /></p>';
			str += '<div id="theme">';
			str += '<div id="theme_inner">' + data.result[0].TopSetting.title + '</div>';
			str += '</div>';
			str += '<p id="explanation">' + data.result[0].TopSetting.fmt_description + '</p>';
			str += '<table class="link_table wordBreak">';	
			str += '<tr>';
			str += '<th class="link_table_th_01">登録日</th>';
			str += '<th class="link_table_th_02">企業名</th>';
			str += '<th class="link_table_th_03">業種</th>';
			str += '</tr>';
			
        	for ( i in data.result ) {
        	
        		if (i > 0) {
        		
        			str += '<tr>';
        			str += '<td class="link_table_td_01">' + formatDate(data.result[i].CompanyInfo.publish_dt.substr( 0, 10 )) + '</td>';
        			str += '<td class="link_table_td_02">';
        			str += '<a href="javascript:ebm_create_company_detail_window(' + data.result[i].CompanyInfo.company_id + ')">' + data.result[i].CompanyInfo.name + '</a>';
        			str += '</td>';
        			str += '<td class="link_table_td_03">' + data.result[i].CompanyInfo.fmt_industry_type + '</td>';
        			str += '</tr>';
        			
       			}
        	}
        	
        	str += '</table>';
        	str += '<p class="detail"><a href="javascript:ebm_check_company_search2(1)"><img src="index/kaitai_detail.jpg" alt="全ての検索結果を見る" class="rollover" /></a></p>';
			str += '</div>';
			str += '</div>';
        	
        	$( '#' + id ).append( str );
        	
        }
        	
	});
	
}

/**
 *
 * 買いたい商品特集リストを表示する
 *
 */
function ebm_show_special_company_list( id ) {

	$( '#' + id ).empty();
        	
	$.ajax({
	
		dataType: 'json',
		data: {
            'service': 'special_company_list',
            'pagesize' : special_company_page_size
        },
        cache: false,
        url: ebm_admin_url + '/services/json',
        success: function (data) {
          
        	var current_page = 0;
        	var	max_page_count = 0;
        
        	// 表示設定
			if (data.result[0].TopSetting.disp_flg == 0) {
			
				return;
				
			}
			
       		var	str = '';
       		var current_page   = '0';
       		var max_page_count = '0';
       		var	data_max_count = '0';
       		var show_index     = '0〜0件';
       		
	       	if ( data.result.length > 1 ) {
        	
        		current_page   = data.result[0].current_page_no;
        		max_page_count = data.result[0].max_page_count;
		  		data_max_count = data.result[0].data_max_count;
	 			show_index     = data.result[0].show_start_index + '〜' + data.result[0].show_end_index + '件';
         		
         		showPager( 'exp_pager', special_company_pager_size, max_page_count, current_page, 'ebm_special_company_select_page', '' );
	        
			}
        	
			str += '<p align="center"><img src="images/kaitai_lead.jpg" alt="テーマに沿った商品・サービスを買いたい企業を紹介します。" /></p>';
			str += '<div id="theme">';
			str += '<div id="theme_inner">' + data.result[0].TopSetting.title + '</div>';
			str += '</div>';
			str += '<p id="explanation">' + data.result[0].TopSetting.fmt_description + '</p>';			
			str += '<div class="search_title clearfix">';
			
	       	if ( data.result.length > 1 ) {
 			
				str += '<p class="searchNumber"> <span class="searchNumberAll">' + data_max_count + '</span>件中<span>' + show_index + '</span>を表示 </p>';
				
			}
			
			str += '</div>';
			
			str += '<table class="link_table wordBreak">';	
			str += '<tr>';
			str += '<th class="link_table_th_01">登録日</th>';
			str += '<th class="link_table_th_02">企業名</th>';
			str += '<th class="link_table_th_03">業種</th>';
			str += '</tr>';
			
        	for ( i in data.result ) {
        	
        		if (i > 0) {
        		
        			str += '<tr>';
        			str += '<td class="link_table_td_01">' + formatDate(data.result[i].CompanyInfo.publish_dt.substr( 0, 10 )) + '</td>';
        			str += '<td class="link_table_td_02">';
        			str += '<a href="javascript:ebm_create_company_detail_window(' + data.result[i].CompanyInfo.company_id + ')">' + data.result[i].CompanyInfo.name + '</a>';
        			str += '</td>';
        			str += '<td class="link_table_td_03">' + data.result[i].CompanyInfo.fmt_industry_type + '</td>';
        			str += '</tr>';
        			
       			}
        	}
        	
        	str += '</table>';
        	
        	$( '#' + id ).append( str );
        	
        }
        	
	});
	
}

/**
 *
 * 買いたい商品特集リストを表示する(ページ移動)
 *
 */

function ebm_special_company_select_page( pageno, detail_url ) {

	// ページ選択
	$.ajax({
	
		dataType: 'json',
		data: {
            'service' : 'special_company_select_page',
            'pageno'  : pageno
        },
        cache: false,
        url: ebm_admin_url + '/services/json',
        success: function (data) {
        
        	$( '#special_company_list' ).empty();
        	
        	var current_page = 0;
        	var	max_page_count = 0;
        
        	// 表示設定
			if (data.result[0].TopSetting.disp_flg == 0) {
			
				return;
				
			}
			
       		var	str = '';
       		var current_page   = '0';
       		var max_page_count = '0';
       		var	data_max_count = '0';
       		var show_index     = '0〜0件';
       		
	       	if ( data.result.length > 0 ) {
        	
        		current_page   = data.result[0].current_page_no;
        		max_page_count = data.result[0].max_page_count;
		  		data_max_count = data.result[0].data_max_count;
	 			show_index     = data.result[0].show_start_index + '〜' + data.result[0].show_end_index + '件';
         		
         		showPager( 'exp_pager', special_company_pager_size, max_page_count, current_page, 'ebm_special_company_select_page', '' );
	        
			}
        	
			str += '<p align="center"><img src="images/kaitai_lead.jpg" alt="テーマに沿った商品・サービスを買いたい企業を紹介します。" /></p>';
			str += '<div id="theme">';
			str += '<div id="theme_inner">' + data.result[0].TopSetting.title + '</div>';
			str += '</div>';
			str += '<p id="explanation">' + data.result[0].TopSetting.fmt_description + '</p>';			
			str += '<div class="search_title clearfix">';
			str += '<p class="searchNumber"> <span class="searchNumberAll">' + data_max_count + '</span>件中<span>' + show_index + '</span>を表示 </p>';
			str += '</div>';
			
			str += '<table class="link_table wordBreak">';	
			str += '<tr>';
			str += '<th class="link_table_th_01">登録日</th>';
			str += '<th class="link_table_th_02">企業名</th>';
			str += '<th class="link_table_th_03">業種</th>';
			str += '</tr>';
			
        	for ( i in data.result ) {
        	
        		if (i > 0) {
        		
        			str += '<tr>';
        			str += '<td class="link_table_td_01">' + formatDate(data.result[i].CompanyInfo.publish_dt.substr( 0, 10 )) + '</td>';
        			str += '<td class="link_table_td_02">';
        			str += '<a href="javascript:ebm_create_company_detail_window(' + data.result[i].CompanyInfo.company_id + ')">' + data.result[i].CompanyInfo.name + '</a>';
        			str += '</td>';
        			str += '<td class="link_table_td_03">' + data.result[i].CompanyInfo.fmt_industry_type + '</td>';
        			str += '</tr>';
        			
       			}
        	}
        	
        	str += '</table>';
        	
        	$( '#special_company_list' ).append( str );	        
	        $.scrollTo( '#PageTop', 10 );
       	
       }
        
	});
}

/**
 *
 * 最近掲載された企業リストを表示する
 *
 */
function ebm_show_latest_publish_company_list( id, limit ) {

	$( '#' + id ).empty();
        	
	$.ajax({
	
		dataType: 'json',
		data: {
            'service': 'latest_publish_company_list',
            'limit'  : limit
        },
        cache: false,
        url: ebm_admin_url + '/services/json',
        success: function (data) {
 
        	var	str = '';
        	
        	for ( i in data.result ) {
        	
        		var buy_merchandise ='なし';
        		if (data.result[i].CompanyInfo.buy_merchandise.length > 0) {
        		
        			buy_merchandise='あり';
        		
        		}
        		        		
        		str += '<div class="result_wrapper">';
        		str += '<div class="result_inner">';
        		str += '<h3>';
        		str += '<a href="javascript:ebm_create_company_detail_window(' + data.result[i].CompanyInfo.company_id + ')">' + data.result[i].CompanyInfo.name + '</a>';
        		str += '</h3>';
        		str += '<ul class="clearfix">';
        		str += '<li class="day">' + formatDate(data.result[i].CompanyInfo.up_dt.substr( 0, 10 )) + '</li>'
        		str += '<li class="type">' + data.result[i].CompanyInfo.fmt_industry_type + '</li>'
        		str += '</ul>';
        		str += '<ul class="clearfix">';       		
        		str += '<li class="product">' + buy_merchandise + '</li>';
	       		str += '</ul>';
        		str += '<p>' + data.result[i].CompanyInfo.fmt_company_feature + '</p>'
        		str += '</div>';
        		str += '</div>';
        	}
        	
        	$( '#' + id ).append( str );
        	
        }
        	
	});
	
}

/**
 *
 * 企業情報詳細をウインドウを表示する
 *
 */
function ebm_create_company_detail_window( id ) {
	
	var	url = site_url + '/company_search/detail.html?id=' + id;
	
	if ( !ebm_check_company_search_result() ) {
	
		url = site_url + '/attention/index2.html?url=' + url;
		
	}
	
	window.open( url );
	
}

/**
 *
 * 企業情報詳細を表示する
 *
 */
function ebm_show_company_detail( id ) {

	$( '#ebm_f1' ).empty();	// 会社の特徴
	$( '#ebm_f2' ).empty();	// 会社名
	$( '#ebm_f3' ).empty();	// 業種分類
	$( '#ebm_f4' ).empty();	// URL
	$( '#ebm_f5' ).empty();	// 登録・更新年月日
	$( '#ebm_f6' ).empty();	// 連絡先
	$( '#ebm_f7' ).empty();	// 本社所在地
	$( '#ebm_f8' ).empty();	// 資本金
	$( '#ebm_f9' ).empty();	// 代表者名
	$( '#ebm_f10' ).empty();// 売りたい商品・サービスの内容
	$( '#ebm_f11' ).empty();// 売り込み先希望地域
	$( '#ebm_f12' ).empty();// 売り込み先希望業種
	$( '#ebm_f13' ).empty();// 買いたい商品・サービス
	$( '#ebm_f14' ).empty();// 登録ID
	$( '#ebm_f21' ).empty();// 連絡先
	$( '#ebm_f22' ).empty();// メールアドレス
	$( '#ebm_f24' ).empty();// 売りたい商品・サービスのセールスポイント
	$( '#ebm_f25' ).empty();// URLサムネイル
	
	$.ajax({
	
		dataType: 'json',
		data: {
            'service': 'company_info_detail',
            'id'     : id
        },
        cache: false,
        url: ebm_admin_url + '/services/json',
        success: function (data) {
        
         	if ( data.result == null ) {
        	
        		return false;
        		
        	}
        	 
	       	if ( data.result.CompanyInfo == undefined ) {
        	
        		return false;
        		
        	}
        	
        	document.title = '掲載企業「' + data.result.CompanyInfo.name + '」 | 「全銀e-ビジネスマーケット」';
        	
        	var	url = $.trim( data.result.CompanyInfo.url );
        	var img_url = $.trim( data.result.CompanyInfo.image_url );
        	
        	$( '#ebm_f1' ).append( data.result.CompanyInfo.fmt_company_feature );
        	$( '#ebm_f2' ).append( data.result.CompanyInfo.name );
        	$( '#ebm_f3' ).append( data.result.CompanyInfo.fmt_industry_type );
        	$( '#ebm_f4' ).append( '<a href="../jump/index.html?url=' + url + '" title="' + url + '">' + url + '</a>' );
        	$( '#ebm_f5' ).append( formatDate( data.result.CompanyInfo.up_dt.substr( 0, 10 ) ) );
        	$( '#ebm_f6' ).append( data.result.CompanyInfo.contact );
        	$( '#ebm_f7' ).append( data.result.CompanyInfo.headoffice_todofuken + data.result.CompanyInfo.headoffice_address );
        	$( '#ebm_f8' ).append( data.result.CompanyInfo.fmt_capital );
        	$( '#ebm_f9' ).append( data.result.CompanyInfo.rep_name );
        	$( '#ebm_f10' ).append( data.result.CompanyInfo.fmt_merchandise_feature );
        	$( '#ebm_f11' ).append( data.result.CompanyInfo.fmt_sales_area );
        	$( '#ebm_f12' ).append( data.result.CompanyInfo.fmt_sales_industry_type );
        	$( '#ebm_f13' ).append( data.result.CompanyInfo.fmt_buy_merchandise );
        	$( '#ebm_f14' ).append( '00A' + data.result.CompanyInfo.company_id );
         	$( '#ebm_f21' ).append( data.result.CompanyInfo.contact );
        	$( '#ebm_f22' ).append( '<a href="mailto:' + data.result.CompanyInfo.mailto_address + '">' + data.result.CompanyInfo.mailto_address + '</a>' );
        	$( '#ebm_f24' ).append( data.result.CompanyInfo.sales_point );
        	
        	if ( img_url == '' ) {
        		
        		$( '#ebm_f25' ).append( '<img src="images/dummyImg.jpg" alt="サムネイル" title="サムネイル" />' );
  				$( '#thumbnail' ).hide();			
      		
        	} else {
        	       		
       			var cap = 'http://pci-aios.heartrails-capture.com/170x130?' + img_url;        	
        		//var cap = 'http://capture.heartrails.com/medium?' + img_url;        	
          		$( '#ebm_f25' ).append( '<a href="../jump/index.html?url=' + url + '"><img title="サムネイル" src="' + cap + '" alt="サムネイル" width="170" height="130" /></a>' );
          		         		     		
        	}

			// 項目の表示/非表示
			var f1 = false;
			var f2 = false;
			var f3 = false;
			var f4 = false;
			
			if ( data.result.CompanyInfo.fmt_company_feature == '' )
			{
				$( '#disp_f1' ).hide();
				f1 = true;
			}
			
			if ( data.result.CompanyInfo.fmt_merchandise_feature == '' )
			{
				$( '#disp_f10' ).hide();
				f2 = true;
			}
			
			if ( data.result.CompanyInfo.sales_point == '' )
			{
				$( '#disp_f24' ).hide();
				f3 = true;
			}
			
			if ( data.result.CompanyInfo.fmt_sales_area == '' )
			{
				$( '#disp_f11' ).hide();
				f4 = true;
			}
			
			if ( f1 && f2 && f3 && f4 )
			{
				$( '#disp_f00' ).hide();
			}
			
			if ( data.result.CompanyInfo.fmt_sales_industry_type == '' )
			{
				$( '#disp_f12' ).hide();
			}
			
			if ( data.result.CompanyInfo.fmt_buy_merchandise == '' )
			{
				$( '#disp_f13' ).hide();
			}
			
        }      
        	
	});
	
}

/**
 *
 * 文言を表示する
 *
 */
function ebm_show_word( id, code ) {

	$( '#' + id ).empty();
	
	$.ajax({
	
		dataType: 'json',
		data: {
            'service': 'word',
            'code'   : code
        },
        cache: false,
        url: ebm_admin_url + '/services/json',
        success: function (data) {
        
        	$( '#' + id ).append( data.result.Word.word );
        	
        }      
        	
	});

}

/**
 *
 * 企業情報を検索する
 *
 */
function ebm_search_company( params, detail_url ) {

	var	keyword = '';
	var	keyword2 = '';
	var	advanced_keyword = 0;
	var	advanced_keyword2 = 0;
	
	var	s_industry_type = new Array( 30 );
	var	s_headoffice = new Array( 47 );
	var	s_headoffice_todofuken = '';
	
	var	b_industry_type = new Array( 30 );
	var	b_headoffice = new Array( 47 );
	var	b_headoffice_todofuken = '';	
	
	var	sale_keyword = '';
	var sale_keyword_chk = 0;
	
	var	buy_keyword = '';
	var buy_keyword_chk = 0;
	
	var search_type = 0;
	var search_type2 = 0;
	
	var	industry_type = new Array( 30 );
	var	headoffice_todofuken = '';	
	var search_keyword = '';
	var search_keyword_chk = 0;
	
	$('#sale_conditions').hide();
	$('#buy_conditions').hide();
	
	$( '#disp_s_it' ).hide();
	$( '#disp_s_ho' ).hide();
	$( '#disp_sale_txt' ).hide();
	$( '#disp_b_it' ).hide();
	$( '#disp_b_ho' ).hide();
	$( '#disp_buy_txt' ).hide();
	
	$( '#s_it' ).empty();
	$( '#s_ho' ).empty();
	$( '#s_sale_txt' ).empty();
	$( '#b_it' ).empty();
	$( '#b_ho' ).empty();
	$( '#b_sale_txt' ).empty();
	
	//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	// 検索タイプ(0:キーワードでの検索 1:売りたい 2:買いたい)
	//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	if ( params['select_tab1'] ) {
	
		if ( params['select_tab1'] == '1' ) {
		
			search_type = 1;
			
			if ( params['select_tab2'] == '1' ) {
			
				search_type2 = 1;
				
			} else if ( params['select_tab2'] == '2' ) {
			
				search_type2 = 2;
				
			} else if ( params['select_tab2'] == '3' ) {
			
				search_type2 = 3;
				
			}
			
		} else if ( params['select_tab1'] == '2' ) {
		
			search_type = 2;
			
			if ( params['select_tab2'] == '4' ) {
			
				search_type2 = 4;
				
			} else if ( params['select_tab2'] == '5' ) {
			
				search_type2 = 5;
				
			} else if ( params['select_tab2'] == '6' ) {
			
				search_type2 = 6;
				
			}
			
		}
		
		if ( params['search_all_conditions'] == '1' ) {
		
			search_type2 = 0;
			
		}
		
		$( '#searchval' ).append( '<input type="hidden" name="select_tab1" value="' + params['select_tab1'] + '"/>' );
		$( '#searchval' ).append( '<input type="hidden" name="select_tab2" value="' + params['select_tab2'] + '"/>' );
		$( '#searchval' ).append( '<input type="hidden" name="search_all_conditions" value="' + params['search_all_conditions'] + '"/>' );
	}	
	
	if ( search_type == 0 ) {
	
		//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		// キーワード
		//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		if ( params['searchtxt'] ) {
		
			keyword = utf.URLdecode( $.trim( params['searchtxt'] ) );
			$( '#searchtxt' ).val( keyword );
			
			if ( params['advanced_keyword'] ) {
			
				advanced_keyword = 1;
				$( '#searchval' ).append( '<input type="hidden" name="advanced_keyword" value="on"/>' );
					
			}	
		
			search_type2 = 98;
			
		}  else if ( params['searchtxt2'] ) {
		
			keyword2 = utf.URLdecode( $.trim( params['searchtxt2'] ) );
			$( '#searchtxt2' ).val( keyword2 );
			$( '#searchval' ).append( '<input type="hidden" name="searchtxt2" value="' + keyword2 + '"/>' );
			
			if ( params['advanced_keyword2'] ) {
			
				advanced_keyword2 = 1;
				$( '#searchval' ).append( '<input type="hidden" name="advanced_keyword2" value="on"/>' );
					
			}
		
			search_type2 = 99;
			
		}		
		
	} else {
	
		//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		// キーワード	
		//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		if ( params['searchtxt'] ) {
		
			keyword = utf.URLdecode( $.trim( params['searchtxt'] ) );
			$( '#searchtxt' ).val( keyword );
			
		}
	
		if ( params['keyword'] ) {
		
			keyword = utf.URLdecode( $.trim( params['keyword'] ) );
			$( '#searchtxt' ).val( keyword );
			
		}
	
		if ( params['keyword2'] ) {
		
			keyword2 = utf.URLdecode( $.trim( params['keyword2'] ) );
			$( '#searchtxt2' ).val( keyword2 );
			$( '#searchval' ).append( '<input type="hidden" name="searchtxt2" value="' + keyword2 + '"/>' );
			
		}
		
		//****************************************************************************
		// 売り
		//****************************************************************************
		
		//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		// 業種	
		//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		var	s_it_str = '';
		for ( var i = 1; i <= 30; i++ ) {
		
			var	itnm = 's_it_' + i;
			
			if ( params[itnm] ) {
			
				s_industry_type[(i - 1)] = 1;
				s_it_str += i + '.' + industry_type_name[(i - 1)] + '<br/>';
				
				$( '#searchval' ).append( '<input type="hidden" name="' + itnm + '" value="on"/>' );
				
			} else {
			
				s_industry_type[(i - 1)] = 0;
				
			}
			
		}
		
		//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		// 本社所在地
		//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		var	s_ho_str = '';
		if ( params['s_hoa_0'] ) {
		
			// 全国が選択されている場合
			s_headoffice_todofuken = '全国';
			s_ho_str = '全国';
						
			$( '#searchval' ).append( '<input type="hidden" name="s_hoa_0" value="on"/>' );
			
			for ( var i = 1; i <= 12; i++ ) {
			
				for ( var j = area[(i - 1)]['s']; j<= area[(i - 1)]['e']; j++ ) {
				
					$( '#searchval' ).append( '<input type="hidden" name="' + 's_ho_' + j + '" value="on"/>' );
					
				}
				
				$( '#searchval' ).append( '<input type="hidden" name="' + 's_hoa_' + i + '" value="on"/>' );
			}
			
		} else {
		
			for ( var i = 1; i <= 12; i++ ) {
			
				var	hoanm = 's_hoa_' + i;
				
				if ( params[hoanm] ) {
				
					s_ho_str += '/ ' + area[(i - 1)]['name'] + ' ';
					
					for ( var j = area[(i - 1)]['s']; j<= area[(i - 1)]['e']; j++ ) {
					
						s_headoffice[(j - 1)] = 1;
						$( '#searchval' ).append( '<input type="hidden" name="' + 's_ho_' + j + '" value="on"/>' );
						
					}
					
					$( '#searchval' ).append( '<input type="hidden" name="' + hoanm + '" value="on"/>' );
					
				} else {
				
					for ( var j = area[(i - 1)]['s']; j<= area[(i - 1)]['e']; j++ ) {
					
						var	honm = 's_ho_' + j;
						
						if ( params[honm] ) {

							s_headoffice[(j - 1)] = 1;
							s_ho_str += '/ ' + todofuken_name[(j - 1)] + ' ';
							
							$( '#searchval' ).append( '<input type="hidden" name="' + honm + '" value="on"/>' );
							
						} else {
						
							s_headoffice[(j - 1)] = 0;
							
						}
											
					}
				
				}
				
			}
			
			s_headoffice_todofuken = '';
			for ( var i = 1; i <= 47; i++ ) {
			
				if ( s_headoffice[(i - 1)] == 1 ) {
				
					s_headoffice_todofuken += '|' + todofuken_name[(i - 1)];
	
				}
			}
			
			if ( s_headoffice_todofuken != '' ) {
			
				s_headoffice_todofuken = s_headoffice_todofuken.substr( 1 );
			}
		
			if ( s_ho_str != '' ) {
				
				s_ho_str = s_ho_str.substr( 1 );
				
			}
			
		}
			
		//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		// 売りたいサービス...
		//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		if ( params['sale_txt'] ) {
		
			sale_keyword = utf.URLdecode( $.trim( params['sale_txt'] ) );				
			$( '#searchval' ).append( '<input type="hidden" name="sale_txt" value="' + sale_keyword + '"/>' );
			
		}
		
		if ( params['sale_txt_check'] ) {
		
			sale_keyword_chk = 1;
			$( '#searchval' ).append( '<input type="hidden" name="sale_txt_check" value="on"/>' );
				
		}	
		
		//****************************************************************************
		// 買い
		//****************************************************************************
		
		//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		// 業種	
		//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		var	b_it_str = '';
		for ( var i = 1; i <= 30; i++ ) {
		
			var	itnm = 'b_it_' + i;
			
			if ( params[itnm] ) {
			
				b_industry_type[(i - 1)] = 1;
				b_it_str += i + '.' + industry_type_name[(i - 1)] + '<br/>';
				
				$( '#searchval' ).append( '<input type="hidden" name="' + itnm + '" value="on"/>' );
				
			} else {
			
				b_industry_type[(i - 1)] = 0;
				
			}
			
		}
		
		//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		// 本社所在地
		//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		var	b_ho_str = '';
		if ( params['b_hoa_0'] ) {
		
			// 全国が選択されている場合
			b_headoffice_todofuken = '全国';
			b_ho_str = '全国';
			
			$( '#searchval' ).append( '<input type="hidden" name="b_hoa_0" value="on"/>' );
			
			for ( var i = 1; i <= 12; i++ ) {
			
				for ( var j = area[(i - 1)]['s']; j<= area[(i - 1)]['e']; j++ ) {
				
					$( '#searchval' ).append( '<input type="hidden" name="' + 'b_ho_' + j + '" value="on"/>' );
					
				}
			
				$( '#searchval' ).append( '<input type="hidden" name="' + 'b_hoa_' + i + '" value="on"/>' );
			}
			
		} else {
		
			for ( var i = 1; i <= 12; i++ ) {
			
				var	hoanm = 'b_hoa_' + i;
				
				if ( params[hoanm] ) {
				
					b_ho_str += '/ ' + area[(i - 1)]['name'] + ' ';
					
					for ( var j = area[(i - 1)]['s']; j<= area[(i - 1)]['e']; j++ ) {
					
						b_headoffice[(j - 1)] = 1;
						$( '#searchval' ).append( '<input type="hidden" name="' + 'b_ho_' + j + '" value="on"/>' );
						
					}
					
					$( '#searchval' ).append( '<input type="hidden" name="' + hoanm + '" value="on"/>' );
					
				} else {
				
					for ( var j = area[(i - 1)]['s']; j<= area[(i - 1)]['e']; j++ ) {
					
						var	honm = 'b_ho_' + j;
						
						if ( params[honm] ) {
						
							b_headoffice[(j - 1)] = 1;
							b_ho_str += '/ ' + todofuken_name[(j - 1)] + ' ';
							
							$( '#searchval' ).append( '<input type="hidden" name="' + honm + '" value="on"/>' );
							
						} else {
						
							b_headoffice[(j - 1)] = 0;
							
						}
											
					}
				
				}
				
			}
			
			b_headoffice_todofuken = '';
			for ( var i = 1; i <= 47; i++ ) {
			
				if ( b_headoffice[(i - 1)] == 1 ) {
				
					b_headoffice_todofuken += '|' + todofuken_name[(i - 1)];
	
				}
			}
			
			if ( b_headoffice_todofuken != '' ) {
			
				b_headoffice_todofuken = b_headoffice_todofuken.substr( 1 );
			}
		
			if ( b_ho_str != '' ) {
				
				b_ho_str = b_ho_str.substr( 1 );
				
			}
			
		}		
			
		//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		// 買いたいサービス...
		//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		if ( params['buy_txt'] ) {
		
			buy_keyword = utf.URLdecode( $.trim( params['buy_txt'] ) );				
			$( '#searchval' ).append( '<input type="hidden" name="buy_txt" value="' + buy_keyword + '"/>' );
			
		}
		
		if ( params['buy_txt_check'] ) {
		
			buy_keyword_chk = 1;
			$( '#searchval' ).append( '<input type="hidden" name="buy_txt_check" value="on"/>' );
				
		}	
	
		//****************************************************************************
		// 売りたい買いたいを表示
		//****************************************************************************
		if (search_type == 1) {
		
			$('#sale_conditions').show();
			
			switch (search_type2) {
			
				case 1 :
				
					$( '#s_it' ).append( s_it_str );		
					$( '#disp_s_it' ).show();
					break;
			
				case 2 :
				
					$( '#s_ho' ).append( s_ho_str );
					$( '#disp_s_ho' ).show();
					break;
			
				case 3 :
				
					$( '#s_sale_txt' ).append( sale_keyword );
					$( '#disp_sale_txt' ).show();
					break;
					
				default :
				
					$( '#s_it' ).append( s_it_str );
					$( '#s_ho' ).append( s_ho_str );
					$( '#s_sale_txt' ).append( sale_keyword );
					
					$( '#disp_s_it' ).show();
					$( '#disp_s_ho' ).show();
					$( '#disp_sale_txt' ).show();
					
					break;
			}
			
			for ( var i = 0; i < 30; i++ ) {
			
				industry_type[i] = s_industry_type[i];
				
			}
            
            headoffice_todofuken = s_headoffice_todofuken;
            search_keyword = sale_keyword;
            search_keyword_chk = sale_keyword_chk;
            
		} else if (search_type == 2) {
		
			$('#buy_conditions').show();
			
			switch (search_type2) {
			
				case 4 :
				
					$( '#b_it' ).append( b_it_str );
					$( '#disp_b_it' ).show();	
					break;
			
				case 5 :
				
					$( '#b_ho' ).append( b_ho_str );
					$( '#disp_b_ho' ).show();
					break;
			
				case 6 :
				
					$( '#b_buy_txt' ).append( buy_keyword );
					$( '#disp_buy_txt' ).show();
					break;
					
				default :
				
					$( '#b_it' ).append( b_it_str );
					$( '#b_ho' ).append( b_ho_str );
					$( '#b_buy_txt' ).append( buy_keyword );
					
					$( '#disp_b_it' ).show();
					$( '#disp_b_ho' ).show();
					$( '#disp_buy_txt' ).show();
					
					break;
			}
						
			for ( var i = 0; i < 30; i++ ) {
			
				industry_type[i] = b_industry_type[i];
				
			}
            
            headoffice_todofuken = b_headoffice_todofuken;
            search_keyword = buy_keyword;
            search_keyword_chk = buy_keyword_chk;
            
		}	
	}
	
	//-----------------------------------------------------------------------------
	// 検索
	//-----------------------------------------------------------------------------
	$.ajax({
	
		dataType: 'json',
		data: {
            'service' : 'search_company',
            'search_type' : search_type,
            'search_type2' : search_type2,
            'keyword' : keyword,
            'advanced_keyword' : advanced_keyword,
            'keyword2' : keyword2,
            'advanced_keyword2' : advanced_keyword2,
            'industry_type_01' : industry_type[0],
            'industry_type_02' : industry_type[1],
            'industry_type_03' : industry_type[2],
            'industry_type_04' : industry_type[3],
            'industry_type_05' : industry_type[4],
            'industry_type_06' : industry_type[5],
            'industry_type_07' : industry_type[6],
            'industry_type_08' : industry_type[7],
            'industry_type_09' : industry_type[8],
            'industry_type_10' : industry_type[9],
            'industry_type_11' : industry_type[10],
            'industry_type_12' : industry_type[11],
            'industry_type_13' : industry_type[12],
            'industry_type_14' : industry_type[13],
            'industry_type_15' : industry_type[14],
            'industry_type_16' : industry_type[15],
            'industry_type_17' : industry_type[16],
            'industry_type_18' : industry_type[17],
            'industry_type_19' : industry_type[18],
            'industry_type_20' : industry_type[19],
            'industry_type_21' : industry_type[20],
            'industry_type_22' : industry_type[21],
            'industry_type_23' : industry_type[22],
            'industry_type_24' : industry_type[23],
            'industry_type_25' : industry_type[24],
            'industry_type_26' : industry_type[25],
            'industry_type_27' : industry_type[26],
            'industry_type_28' : industry_type[27],
            'industry_type_29' : industry_type[28],
            'industry_type_30' : industry_type[29],
			'headoffice_todofuken' : headoffice_todofuken,
            'search_keyword' : search_keyword,
            'search_keyword_chk' : search_keyword_chk,
            'pagesize' : company_search_page_size
        },
        cache: false,
        url: ebm_admin_url + '/services/json',
        success: function (data) {
        
        	var current_page = 0;
        	var	max_page_count = 0;
 
 			$( '#data_max_count' ).empty();
 			$( '#show_index' ).empty();
        
         	$( '#result_list_area' ).empty();
        	
        	str = '';
        	
        	if ( data.result.length > 0 ) {
        	
        		current_page = data.result[0].current_page_no;
        		max_page_count = data.result[0].max_page_count;
        		
	  			$( '#data_max_count' ).append( data.result[0].data_max_count );
	 			$( '#show_index' ).append( data.result[0].show_start_index + '〜' + data.result[0].show_end_index + '件' );
   		
	        	for ( i in data.result ) {
	        		
	        		var	url = site_url + '/company_search/detail.html?id=' + data.result[i].CompanyInfo.company_id;
	        		
	        		str += '<div class="result_wrapper">';
	        		str += '<div class="result_inner">';
	        		
	        		str += '<div class="company_name">';
	        		str += '<h3><a href="' + url + '" title="' + data.result[i].CompanyInfo.name + '" target="_blank">' + data.result[i].CompanyInfo.name + '</a></h3>';
	        		
	        		if ( data.result[i].CompanyInfo.hit_type == '1' ) {
	        		
	        			str += '<p><img src="images/ico_hitcompany.gif" alt="掲載企業の登録企業から検索ヒットしました" width="122" height="30" title="掲載企業の登録企業から検索ヒットしました" /></p>';
	        		
	        		} else if ( data.result[i].CompanyInfo.hit_type == '2' ) {
	        		
	        			str += '<p><img src="images/ico_hitweb.gif" alt="掲載企業のウェブサイトから検索ヒットしました" width="122" height="30" title="掲載企業のウェブサイトから検索ヒットしました" /></p>';
	        		
	        		}
	        		
	        		str += '</div>';	        		
	        		str += '<dl class="clearfix">';
	        		str += '<dt><img src="images/tit_category.gif" alt="業務分類" title="業務分類" /></dt>';
	        		str += '<dd>' + data.result[i].CompanyInfo.fmt_industry_type + '</dd>';
	        		str += '<dt class="clear"><img src="images/tit_place.gif" alt="所在地" title="所在地" /></dt>';
	        		str += '<dd>' + data.result[i].CompanyInfo.headoffice_todofuken + data.result[i].CompanyInfo.headoffice_address + '</dd>';
	        		str += '</dl>';	        		
	        		str += '<p class="wordBreak pr">' + data.result[i].CompanyInfo.hit_company_feature + '</p>';
	        		str += '<table class="detail_table_01 clear">';
	        		str += '<tr>';
	        		str += '<td class="detail_table_01_td_01">売りたい商品・<br />サービスの内容</td>';
	        		str += '<td class="detail_table_01_td_02">' + data.result[i].CompanyInfo.hit_merchandise_feature + '</td>';
	        		str += '</tr>';
	        		str += '</table>';
	        		str += '<table class="detail_table_02">';
	        		str += '<tr>';
	        		str += '<td class="detail_table_02_td_01">買いたい商品・<br />サービスの内容</td>';
	        		str += '<td class="detail_table_02_td_02">' + data.result[i].CompanyInfo.hit_buy_merchandise + '</td>';
	        		str += '</tr>';
	        		str += '</table>';
	        		str += '</div>';
	        		str += '</div>';
	 
	        	}
	        	
        	
        		$( '#result_list_area' ).append( str );        	
        		showPager( 'exp_pager', company_search_pager_size, max_page_count, current_page, 'ebm_search_company_select_page', site_url + '/company_search/detail.html' );
	        
	        } else {
	        
	  			$( '#data_max_count' ).append( '0' );
	 			$( '#show_index' ).append( '0〜0' );
	        }

        }      
         	
	});       	
}

/**
 *
 * 企業情報を検索する(ページ移動)
 *
 */

function ebm_search_company_select_page( pageno, detail_url ) {

	// ページ選択
	$.ajax({
	
		dataType: 'json',
		data: {
            'service' : 'search_company_select_page',
            'pageno'  : pageno
        },
        cache: false,
        url: ebm_admin_url + '/services/json',
        success: function (data) {
         
        	var current_page = 0;
        	
 			$( '#data_max_count' ).empty();
 			$( '#show_index' ).empty();
        
         	$( '#result_list_area' ).empty();
        	
        	str = '';
        	
        	if ( data.result.length > 0 ) {
        	
        		current_page = data.result[0].current_page_no;
        		max_page_count = data.result[0].max_page_count;
        		
	  			$( '#data_max_count' ).append( data.result[0].data_max_count );
	 			$( '#show_index' ).append( data.result[0].show_start_index + '〜' + data.result[0].show_end_index + '件' );
   		
	        	for ( i in data.result ) {
	        		
	        		var	url = detail_url + '?id=' + data.result[i].CompanyInfo.company_id;
	        		
	        		str += '<div class="result_wrapper">';
	        		str += '<div class="result_inner">';
	        		
	        		str += '<div class="company_name">';
	        		str += '<h3><a href="' + url + '" title="' + data.result[i].CompanyInfo.name + '" target="_blank">' + data.result[i].CompanyInfo.name + '</a></h3>';
	        		
	        		if ( data.result[i].CompanyInfo.hit_type == '1' ) {
	        		
	        			str += '<p><img src="images/ico_hitcompany.gif" alt="掲載企業の登録企業から検索ヒットしました" width="122" height="30" title="掲載企業の登録企業から検索ヒットしました" /></p>';
	        		
	        		} else if ( data.result[i].CompanyInfo.hit_type == '2' ) {
	        		
	        			str += '<p><img src="images/ico_hitweb.gif" alt="掲載企業のウェブサイトから検索ヒットしました" width="122" height="30" title="掲載企業のウェブサイトから検索ヒットしました" /></p>';
	        		
	        		}

	        		str += '</div>';	        		
	        		str += '<dl class="clearfix">';
	        		str += '<dt><img src="images/tit_category.gif" alt="業務分類" title="業務分類" /></dt>';
	        		str += '<dd>' + data.result[i].CompanyInfo.fmt_industry_type + '</dd>';
	        		str += '<dt class="clear"><img src="images/tit_place.gif" alt="所在地" title="所在地" /></dt>';
	        		str += '<dd>' + data.result[i].CompanyInfo.headoffice_todofuken + data.result[i].CompanyInfo.headoffice_address + '</dd>';
	        		str += '</dl>';	        		
	        		str += '<p class="wordBreak pr">' + data.result[i].CompanyInfo.hit_company_feature + '</p>';
	        		str += '<table class="detail_table_01 clear">';
	        		str += '<tr>';
	        		str += '<td class="detail_table_01_td_01">売りたい商品・<br />サービスの内容</td>';
	        		str += '<td class="detail_table_01_td_02">' + data.result[i].CompanyInfo.hit_merchandise_feature + '</td>';
	        		str += '</tr>';
	        		str += '</table>';
	        		str += '<table class="detail_table_02">';
	        		str += '<tr>';
	        		str += '<td class="detail_table_02_td_01">買いたい商品・<br />サービスの内容</td>';
	        		str += '<td class="detail_table_02_td_02">' + data.result[i].CompanyInfo.hit_buy_merchandise + '</td>';
	        		str += '</tr>';
	        		str += '</table>';
	        		str += '</div>';
	        		str += '</div>';
	 
	        	}
	        	
	        	$( '#result_list_area' ).append( str );       	
	        	showPager( 'exp_pager', company_search_pager_size, max_page_count, current_page, 'ebm_search_company_select_page', detail_url );

	        } else {
	        
	  			$( '#data_max_count' ).append( '0' );
	 			$( '#show_index' ).append( '0〜0' );
	        }
	        
	        $.scrollTo( '#PageTop', 10 );
       }
        
	});
}

 
/**
 *
 * 新着情報を表示する
 *
 */
function ebm_show_recent_news( id, limit ) {

	$( '#' + id ).empty();
        	
	$.ajax({
	
		dataType: 'json',
		data: {
            'service': 'contents_recent_news',
            'limit'  : limit,
            'new'    : recent_new_days
        },
        cache: false,
        url: ebm_admin_url + '/services/json',
        success: function (data) {
       	
        	var	str = '';
        	
        	for ( i in data.result ) {
        	
        		var	url = site_url + '/management_support/detail.html?id=' + data.result[i].Content.content_id;
	     		var cat1 = data.result[i].Content.fmt_genre_id_l1;
				var cat2 = data.result[i].Content.fmt_genre_id_l2;
				var cat3 = data.result[i].Content.fmt_genre_id_l3;
				
	    		if ( cat2 != null ) {
			
					cat1 += ' > ' + cat2;
				
				}
			
				if ( cat3 != null ) {
					
					cat1 += ' > ' + cat3;
				
				}
       		
        		str += '<div class="unitData">';
        		str += '<div class="unitDataLeft">' + formatDate( data.result[i].Content.publish_start_dt, false ) + '</div>';
        		str += '<div class="unitDataRight">';
        		str += '<dl class="dataList">';
        		str += '<dt><span>[カテゴリ]</span>' + cat1 + '</dt>';
        		str += '<dd>';
         		str += '<a href="' + url + '" target="_blank">' + data.result[i].Content.title + '</a>';
         		
         		if ( data.result[i].Content.new_flg == '1' ) {
         		
        			str += '<img src="index/new.jpg" alt="NEW" width="36" height="17" style="vertical-align:middle" title="new" />';

         		}
         		
        		str += '</dd>';
        		str += '</dl>';
        		str += '</div>';
        		str += '</div>';
 
        	}
        	
        	$( '#' + id ).append( str );
        	
        }
        	
	});
	
}

/**
 *
 * 経営支援情報詳細を表示する
 *
 */
function ebm_show_contents_detail( id ) {

	$( '#ebm_f1' ).empty();	// 大分類ジャンル
	$( '#ebm_f2' ).empty();	// 対象地域
	$( '#ebm_f3' ).empty();	// 情報提供者
	$( '#ebm_f4' ).empty();	// 情報掲載期間
	$( '#ebm_f5' ).empty();	// タイトル
	$( '#ebm_f6' ).empty();	// 本文
	$( '#ebm_f7' ).empty();	// 情報提供日
	$( '#ebm_f8' ).empty();	// 情報提供者
	$( '#ebm_f9' ).empty();	// 情報提供者
	$( '#ebm_f10' ).empty();// URL
	$( '#ebm_f11' ).empty();// 添付ファイル
	$( '#ebm_f12' ).empty();// URLサムネイル
	
	$.ajax({
	
		dataType: 'json',
		data: {
            'service': 'contents_detail',
            'id'     : id
        },
        cache: false,
        url: ebm_admin_url + '/services/json',
        success: function (data) {
        
        	if ( data.result == null ) {
        	
        		return false;
        		
        	}
        	 
        	if ( data.result.Content == undefined ) {
        	
        		return false;
        		
        	}
        	
        	var	url = $.trim( data.result.Content.url );
    		var cat1 = data.result.Content.fmt_genre_id_l1;
			var cat2 = data.result.Content.fmt_genre_id_l2;
			var cat3 = data.result.Content.fmt_genre_id_l3;
			
    		if ( cat2 != null ) {
		
				cat1 += ' > ' + cat2;
			
			}
		
			if ( cat3 != null ) {
				
				cat1 += ' > ' + cat3;
			
			}
	        		
   
        	$( '#ebm_f1' ).append( cat1 );
        	$( '#ebm_f2' ).append( data.result.Content.fmt_area );
        	$( '#ebm_f3' ).append( data.result.Content.informer );
        	$( '#ebm_f4' ).append( formatDate( data.result.Content.publish_start_dt, false ) );
        	$( '#ebm_f5' ).append( data.result.Content.title );
        	$( '#ebm_f6' ).append( data.result.Content.fmt_detail );
        	$( '#ebm_f7' ).append( formatDate( data.result.Content.publish_start_dt, false ) );
        	$( '#ebm_f8' ).append( data.result.Content.informer );
        	//$( '#ebm_f9' ).append( data.result.Content.informer );
        	
        	if ( url == '' ) {
        	
        		$( '#ebm_f10_title' ).empty();
          		$( '#ebm_f12' ).append( '<img src="images/thumbnail.jpg" alt="サムネイル" title="サムネイル" />' );         		     		
       		
        	} else {
        	
        		var cap = 'http://pci-aios.heartrails-capture.com/200x160?' + url; 
        		//var cap = 'http://capture.heartrails.com/medium?' + url;
        	
          		$( '#ebm_f10' ).append( '<dd><a href="../jump/index.html?url=' + url + '" title="' + url + '">' + url + '</a></dd>' );
          		$( '#ebm_f12' ).append( '<a href="../jump/index.html?url=' + url + '"><img title="サムネイル" src="' + cap + '" alt="サムネイル" width="159" height="196" /></a>' );         		     		

			}
			
			var pdf_str = '';
			var	pdf_cap = '';
			var	pdf_nam = '';
			var	pdf_siz = '';
			var	pdf_dwn = '';
			
			if ( (data.result.Content.pdf_name_1 == '') &&
			     (data.result.Content.pdf_name_2 == '') &&
			     (data.result.Content.pdf_name_3 == '') ) {
        	
        		$( '#ebm_f11_title' ).empty();
        		
			
			} else {
			
				if ( data.result.Content.pdf_name_1 != '' ) {
				
					pdf_cap = data.result.Content.pdf_caption_1;
					pdf_nam = data.result.Content.pdf_name_1;
					pdf_siz = parseInt( data.result.Content.pdf_size_1 );
					pdf_dwn = 'javascript:ebm_download_contents_pdf( ' + data.result.Content.content_id + ', 1 )';
					
					pdf_str += '<dd>';
					pdf_str += '<a href="' + pdf_dwn + '" title="' + pdf_cap + '">' + pdf_cap + '</a>';
					pdf_str += '<span>';
					pdf_str += '<a href="' + pdf_dwn + '" title="' + pdf_cap + 'PDF"><img src="../common/images/ico_pdf.gif" alt="PDF" /></a>';
					pdf_str += ' (PDF' + parseInt( pdf_siz / 1000 ) + 'KB)</span></dd>';
					
				}
				
				if ( data.result.Content.pdf_name_2 != '' ) {
				
					pdf_cap = data.result.Content.pdf_caption_2;
					pdf_nam = data.result.Content.pdf_name_2;
					pdf_siz = parseInt( data.result.Content.pdf_size_2 );
					pdf_dwn = 'javascript:ebm_download_contents_pdf( ' + data.result.Content.content_id + ', 2 )';
					
					pdf_str += '<dd>';
					pdf_str += '<a href="' + pdf_dwn + '" title="' + pdf_cap + '">' + pdf_cap + '</a>';
					pdf_str += '<span>';
					pdf_str += '<a href="' + pdf_dwn + '" title="' + pdf_cap + 'PDF"><img src="../common/images/ico_pdf.gif" alt="PDF" /></a>';
					pdf_str += ' (PDF' + parseInt( pdf_siz / 1000 ) + 'KB)</span></dd>';
					
				}
				
				if ( data.result.Content.pdf_name_3 != '' ) {
				
					pdf_cap = data.result.Content.pdf_caption_3;
					pdf_nam = data.result.Content.pdf_name_3;
					pdf_siz = parseInt( data.result.Content.pdf_size_3 );
					pdf_dwn = 'javascript:ebm_download_contents_pdf( ' + data.result.Content.content_id + ', 3 )';
				
					pdf_str += '<dd>';
					pdf_str += '<a href="' + pdf_dwn + '" title="' + pdf_cap + '">' + pdf_cap + '</a>';
					pdf_str += '<span>';
					pdf_str += '<a href="' + pdf_dwn + '" title="' + pdf_cap + 'PDF"><img src="../common/images/ico_pdf.gif" alt="PDF" /></a>';
					pdf_str += ' (PDF' + parseInt( pdf_siz / 1000 ) + 'KB)</span></dd>';
					
				}        	
	        	
	        	$( '#ebm_f11' ).append( pdf_str );
	        	
        	}
        	
        }      
        	
	});
	
}

/**
 *
 * コンテンツを検索する
 *
 */
function ebm_search_contents( mode, id, params, detail_url ) {

	$( '#' + id ).empty();
    
    var	cat_str = '';
    var	cat_id = '';
    var	gid = '';
    var	level = ''
    var	informer = '';
    var	keyword = '';
    var	year_f = '';
    var	month_f = '';
    var	day_f = '';
    var	year_t = '';
    var	month_t = '';
    var	day_t = '';
    var	area_str = '';
    var	area_a = new Array( 13 );
    
    if ( mode == 'search' ) {
    
    	$( '#searchval' ).empty();
    	$( '#disp_category' ).empty();
		$( '#disp_area' ).empty();
		$( '#disp_informer' ).empty();
		$( '#disp_dt' ).empty();
				
		//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		// カテゴリー
		//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		if ( params['id'] ) {
		
			gid   = params['id'];
			level = params['level'];
			
			$( '#id' ).val( gid );
			$( '#level' ).val( level );
			
			$.ajax({
						
				dataType: 'json',
				data: {
		            'service': 'genre_detail',
		            'id'     : gid
		        },
		        async: false,
		        cache: false,
		        url: ebm_admin_url + '/services/json',
		        success: function (data) {
		        
		        	if ( data.result.Genre.level == 1 ) {
		        	
		        		cat_str = data.result.Genre.name;
		        				        	
		        	} else if ( data.result.Genre.level == 2 ) {
		        	
		        		cat_str = data.result.Genre.p_genre_detail.Genre.name + '　>　' + data.result.Genre.name;
		        		
		        	} else if ( data.result.Genre.level == 3 ) {
		        	
		        		cat_str = data.result.Genre.pp_genre_detail.Genre.name + '　>　' + data.result.Genre.p_genre_detail.Genre.name + '　>　' + data.result.Genre.name;
		        		
		        	}
		        	
		        	
		        	var wk_str = '';
		        	for ( i in data.result.Genre.c_genre_list ) {
		        	
		        		var cnm = 'cat_' + data.result.Genre.c_genre_list[i].Genre.genre_id;
		        		if ( params[cnm] ) {
		        		
		        			wk_str += ',' + data.result.Genre.c_genre_list[i].Genre.name;
		        			cat_id += ':' + data.result.Genre.c_genre_list[i].Genre.genre_id
		        			
							$( '#searchval' ).append( '<input type="hidden" name="' + cnm + '" value="on"/>' );
			
		        		}
		        		
		        	}
		        	
		        	if ( wk_str != '' ) {
		        	
		        		cat_str += '　>　' + wk_str.substr( 1 );
		        		
		        	}
		        	
		        	$( '#disp_category' ).append( cat_str );
		        	
		        	
		        }
		        
			});
			
		} else {
		
			$( '#disp_category' ).append( '全てのカテゴリー' );
			
		}		
		
		//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		// 地域
		//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		for ( var i = 0; i <= 12; i++ ) {
		
			var	anm = 'area_' + i;
			if ( params[anm] ) {
			
				area_a[i] = 1;
				area_str += '「' + area_name[i] + '」';
				
				$( '#searchval' ).append( '<input type="hidden" name="' + anm + '" value="on"/>' );
				
			} else {
			
				area_a[i] = 0;
			}
		}
		
		$( '#disp_area' ).append( area_str );
		 	
		if ( area_str == '' ) {
		
			$( '#title_area' ).hide();
			
		} else {
		
			$( '#title_area' ).show();
			
		}
   
		//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		// 情報提供者
		//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		if ( params['informer'] ) {
		
			informer = utf.URLdecode( $.trim( params['informer'] ) );
			$( '#disp_informer' ).text( informer );
			
			$( '#searchval' ).append( '<input type="hidden" name="informer" value="' + informer + '"/>' );
			
		}
		
 		if ( informer == '' ) {
		
			$( '#title_informer' ).hide();
			
		} else {
		
			$( '#title_informer' ).show();
			
		}
    
		//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		// キーワード
		//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		if ( params['keyword'] ) {
		
			keyword = utf.URLdecode( $.trim( params['keyword'] ) );
			$( '#keyword' ).val( keyword );
			
		}
  		
		if ( keyword != '' )	{
		
			$( '#disp_keyword' ).text( keyword );
			$( '#title_keyword' ).show();
			
		} else {
		
			$( '#title_keyword' ).hide();
		
		}	
  
		//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		// 掲載日(From)
		//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		var	from_dt = '';
		if ( params['year_f'] ) {
		
			year_f = utf.URLdecode( $.trim( params['year_f'] ) );
			
			if ( year_f != '' ) {
			
				from_dt += year_f + '年';
				$( '#searchval' ).append( '<input type="hidden" name="year_f" value="' + year_f + '"/>' );
				
			}			
			
		}
		
		if ( params['month_f'] ) {
		
			month_f = utf.URLdecode( $.trim( params['month_f'] ) );
			
			if ( month_f != '' ) {
			
				from_dt += month_f + '月';
				$( '#searchval' ).append( '<input type="hidden" name="month_f" value="' + month_f + '"/>' );
				
			}			
			
		}
		
		if ( params['day_f'] ) {
		
			day_f = utf.URLdecode( $.trim( params['day_f'] ) );
			
			if ( day_f != '' ) {
			
				from_dt += day_f + '日';
				$( '#searchval' ).append( '<input type="hidden" name="day_f" value="' + day_f + '"/>' );
				
			}			
			
		}
    
		//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		// 掲載日(To)
		//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		var	to_dt = '';
		if ( params['year_t'] ) {
		
			year_t = utf.URLdecode( $.trim( params['year_t'] ) );
			
			if ( year_t != '' ) {
			
				to_dt += year_t + '年';
				$( '#searchval' ).append( '<input type="hidden" name="year_t" value="' + year_t + '"/>' );
				
			}			
			
		}
		
		if ( params['month_t'] ) {
		
			month_t = utf.URLdecode( $.trim( params['month_t'] ) );
			
			if ( month_t != '' ) {
			
				to_dt += month_t + '月';
				$( '#searchval' ).append( '<input type="hidden" name="month_t" value="' + month_t + '"/>' );
				
			}			
			
		}
		
		if ( params['day_t'] ) {
		
			day_t = utf.URLdecode( $.trim( params['day_t'] ) );
			
			if ( day_t != '' ) {
			
				to_dt += day_t + '日';
				$( '#searchval' ).append( '<input type="hidden" name="day_t" value="' + day_t + '"/>' );
				
			}			
			
		}
		
		if ( (from_dt != '') || (to_dt != '') )	{
		
			$( '#disp_dt' ).text( from_dt + '〜' + to_dt );
			$( '#title_dt' ).show();
			
		} else {
		
			$( '#title_dt' ).hide();
		
		}	
    
    }
    
	$.ajax({
	
		dataType: 'json',
		data: {
            'service'     : 'search_contents',
            'mode'        : mode,
            'genre_id'    : gid,
            'genre_level' : level,
            'c_genre_id'  : cat_id.substr( 1 ),
            'area_00'     : area_a[0],
            'area_01'     : area_a[1],
            'area_02'     : area_a[2],
            'area_03'     : area_a[3],
            'area_04'     : area_a[4],
            'area_05'     : area_a[5],
            'area_06'     : area_a[6],
            'area_07'     : area_a[7],
            'area_08'     : area_a[8],
            'area_09'     : area_a[9],
            'area_10'     : area_a[10],
            'area_11'     : area_a[11],
            'area_12'     : area_a[12],
            'informer'    : informer,
            'keyword'     : keyword,
            'from_year'   : year_f,
            'from_month'  : month_f,
            'from_day'    : day_f,
            'to_year'     : year_t,
            'to_month'    : month_t,
            'to_day'      : day_t,
            'pagesize'    : contents_search_page_size
        },
        cache: false,
        url: ebm_admin_url + '/services/json',
        success: function (data) {
       	
         	var current_page = 0;
        	var	max_page_count = 0;
        	
 			$( '#data_max_count' ).empty();
 			$( '#show_index' ).empty();
        
       		var	str = '';
  
         	if ( data.result.length > 0 ) {
        	
        		current_page = data.result[0].current_page_no;
        		max_page_count = data.result[0].max_page_count;
        		
	  			$( '#data_max_count' ).append( data.result[0].data_max_count );
	 			$( '#show_index' ).append( data.result[0].show_start_index + '〜' + data.result[0].show_end_index + '件' );
   		
		       	for ( i in data.result ) {
	        	
	        		var	url  = site_url + '/management_support/detail.html' + '?id=' + data.result[i].Content.content_id;
	        		var cat1 = data.result[i].Content.fmt_genre_id_l1;
	        		var cat2 = data.result[i].Content.fmt_genre_id_l2;
	        		var cat3 = data.result[i].Content.fmt_genre_id_l3;
	        		
	        		var cat_url = site_url + '/management_support/result.html' + '?id=' + data.result[i].Content.genre_id_l1;
	        		
	        		str += '<div class="unitData">';
	        		str += '<div class="unitDataLeft">' + formatDate( data.result[i].Content.publish_start_dt, false ) + '</div>';
	        		str += '<div class="unitDataRight">';
	        		str += '<dl>';
	        		str += '<dt><span>[情報提供者]</span>' + data.result[i].Content.informer + '</dt>';
	        		str += '<dd>';
	        		str += '<a href="' + url + '" target="_blank" title="' + data.result[i].Content.title + '">';
	        		str += '<span style="cursor:pointer;">' + data.result[i].Content.title + '</span>';
	        		str += '</a>';
	        		str += '</dd>';
	        		str += '<dd class="unitDataCategory">';
	        		str += '<span>[カテゴリ]</span>';
	        		str += '<a href="' + cat_url + '" title="' + cat1 + '">' + cat1 + '</a>';
	        		
	        		if ( cat2 != null ) {
	        		
	        			var cat_url = site_url + '/management_support/result.html' + '?id=' + data.result[i].Content.genre_id_l2;
	        			str += ' > ' + '<a href="' + cat_url + '" title="' + cat2 + '">' + cat2 + '</a>';
	        			
	        		}
	        		
	        		if ( cat3 != null ) {
	        		
	        			var cat_url = site_url + '/management_support/result.html' + '?id=' + data.result[i].Content.genre_id_l3;
	        			str += ' > ' + '<a href="' + cat_url + '" title="' + cat3 + '">' + cat3 + '</a>';
	        			
	        		}
	        		
	        		str += '</dd>';
	        		str += '</dl>';
	        		str += '</div>';
	        		str += '</div>';
	 
	        	}
        	
	        	
	        	showPager( 'exp_pager', contents_search_pager_size, max_page_count, current_page, 'ebm_search_contents_select_page', site_url + '/management_support/detail.html' );
 
	        } else {
	        
	  			$( '#data_max_count' ).append( '0' );
	 			$( '#show_index' ).append( '0〜0' );
	        }
        	
        	$( '#' + id ).append( str );
        	
        }
        	
	});

}


/**
 *
 * 経営支援情報を検索する(ページ移動)
 *
 */

function ebm_search_contents_select_page( pageno, detail_url ) {

	$( '#contents_list' ).empty();
        	
	// ページ選択
	$.ajax({
	
		dataType: 'json',
		data: {
            'service' : 'search_contents_select_page',
            'pageno'  : pageno
        },
        cache: false,
        url: ebm_admin_url + '/services/json',
        success: function (data) {
         
        	var current_page = 0;
        	
 			$( '#data_max_count' ).empty();
 			$( '#show_index' ).empty();
        
       		var	str = '';
        	
         	if ( data.result.length > 0 ) {
        	
        		current_page = data.result[0].current_page_no;
        		max_page_count = data.result[0].max_page_count;
        		
	  			$( '#data_max_count' ).append( data.result[0].data_max_count );
	 			$( '#show_index' ).append( data.result[0].show_start_index + '〜' + data.result[0].show_end_index + '件' );
   		
		       	for ( i in data.result ) {
	        	
	        		var	url  = site_url + '/management_support/detail.html' + '?id=' + data.result[i].Content.content_id;
	        		var cat1 = data.result[i].Content.fmt_genre_id_l1;
	        		var cat2 = data.result[i].Content.fmt_genre_id_l2;
	        		var cat3 = data.result[i].Content.fmt_genre_id_l3;
	        		
	        		var cat_url = site_url + '/management_support/result.html' + '?id=' + data.result[i].Content.genre_id_l1;
	        		
	        		str += '<div class="unitData">';
	        		str += '<div class="unitDataLeft">' + formatDate( data.result[i].Content.publish_start_dt, false ) + '</div>';
	        		str += '<div class="unitDataRight">';
	        		str += '<dl>';
	        		str += '<dt><span>[情報提供者]</span>' + data.result[i].Content.informer + '</dt>';
	        		str += '<dd><a href="' + url + '" target="_blank" title="' + data.result[i].Content.title + '">';
	        		str += '<span>' + data.result[i].Content.title + '</span>';
	        		str += '</a></dd>';
	        		str += '<dd class="unitDataCategory"><span>[カテゴリ]</span>';
	        		str += '<a href="' + cat_url + '" title="' + cat1 + '">' + cat1 + '</a>';
	        		
	        		if ( cat2 != null ) {
	        		
	        			var cat_url = site_url + '/management_support/result.html' + '?id=' + data.result[i].Content.genre_id_l2;
	        			str += ' > ' + '<a href="' + cat_url + '" title="' + cat2 + '">' + cat2 + '</a>';
	        			
	        		}
	        		
	        		if ( cat3 != null ) {
	        		
	        			var cat_url = site_url + '/management_support/result.html' + '?id=' + data.result[i].Content.genre_id_l3;
	        			str += ' > ' + '<a href="' + cat_url + '" title="' + cat3 + '">' + cat3 + '</a>';
	        			
	        		}
	        		
	        		str += '</dd>';
	        		str += '</dl>';
	        		str += '</div>';
	        		str += '</div>';
	 
	        	}
        	
	        	
	        	showPager( 'exp_pager', contents_search_pager_size, max_page_count, current_page, 'ebm_search_contents_select_page', detail_url );

	        } else {
	        
	  			$( '#data_max_count' ).append( '0' );
	 			$( '#show_index' ).append( '0〜0' );
	        }
        	
        	$( '#contents_list' ).append( str );
        	$.scrollTo( '#PageTop', 10 );
        	
        }
        
	});
}

/**
 *
 * 経営支援情報のカテゴリーナビを表示する
 *
 */
function ebm_create_category_navi( id ) {

	var navi_str = '';
	var flag = {};
	
	$( '#' + id ).empty();

	$.ajax({
	
		dataType: 'json',
		data: {
            'service': 'get_genre_list'
        },
        cache: false,
        url: ebm_admin_url + '/services/json',
        success: function (data) {
        
			navi_str += '<ul>';
			navi_str += '<li class="oya_CA"><a href="result.html">全てのカテゴリ検索</a></li>';
	
       		for ( i in data.result ) {
        	
        		var	cat_id = 'category_' + data.result[i].Genre.genre_id;
        		
        		flag[cat_id] = true;
        		
        		navi_str += '<li class="oya_CA">';
 		        navi_str += '<a href="result.html?id=' + data.result[i].Genre.genre_id + "&level=1" + '">' + data.result[i].Genre.name + '</a>';
        		navi_str += '<ul class="wordBreak">';
        		
        		for ( j in data.result[i].Genre.level2 ) {
  
	      			navi_str += '<li>';
  		        	navi_str += '<p><a href="result.html?id=' + data.result[i].Genre.level2[j].Genre.genre_id + "&level=2" + '">' + data.result[i].Genre.level2[j].Genre.name + '</a></p>';
					navi_str += '<ul class="child_CA">';
					
	        		for ( c in data.result[i].Genre.level2[j].Genre.level3 ) {
	        		
 		        		navi_str += '<li><a href="result.html?id=' + data.result[i].Genre.level2[j].Genre.level3[c].Genre.genre_id + "&level=3" + '">' + data.result[i].Genre.level2[j].Genre.level3[c].Genre.name + '</a></li>';
	        		}
					
					navi_str += '</ul>';
	        		navi_str += '</li">';
	      		
	      		}
        		
        		navi_str += '</ul>';
        		navi_str += '</li">';
        		        		
        	}
        	
			navi_str += '</ul>';
			
			$( '#' + id ).append( navi_str );
			
       }
        
	});
		
}

/**
 *
 * 新着リンクを表示する
 *
 */
function ebm_show_recent_link( id, limit ) {

	$( '#' + id ).empty();
        	
	$.ajax({
	
		dataType: 'json',
		data: {
            'service': 'link_recent_link',
            'limit'  : limit
        },
        cache: false,
        url: ebm_admin_url + '/services/json',
        success: function (data) {
       	
        	var	str = '';
      	
        	str += '<tr>';
        	str += '<th class="link_table_th_01">掲載日</th>';
        	str += '<th class="link_table_th_02">リンク先</th>';
        	str += '<th class="link_table_th_03">リンク集</th>';
        	str += '<th class="link_table_th_04">内容・URL</th>';
        	str += '</tr>';
       	
	       	for ( i in data.result ) {
    	
	    		var	url = $.trim( data.result[i].Link.url );
	    		
	    		if ( (i % 2) == 0 ) {

		        	str += '<tr>';
		        	str += '<td class="link_table_td_01">' + formatDate( data.result[i].Link.up_dt.substr( 0, 10 ), false ) + '</td>';
		        	str += '<td class="link_table_td_02">' + data.result[i].Link.title + '</td>';
		        	str += '<td class="link_table_td_03">' + data.result[i].Link.fmt_link_collection_name + '</td>';
		        	str += '<td class="link_table_td_04">' + data.result[i].Link.description;
		        	str += '<br/><span><a href="../jump/index.html?url=' + url + '" title="' + url + '">' + url + '</a></span>';
		        	str += '</td>';
		        	str += '</tr>';
	    		
	    		} else {
	    		
		        	str += '<tr>';
		        	str += '<td class="link_table_td_05">' + formatDate( data.result[i].Link.up_dt.substr( 0, 10 ), false ) + '</td>';
		        	str += '<td class="link_table_td_06">' + data.result[i].Link.title + '</td>';
		        	str += '<td class="link_table_td_07">' + data.result[i].Link.fmt_link_collection_name + '</td>';
		        	str += '<td class="link_table_td_08">' + data.result[i].Link.description;
		        	str += '<br/><span><a href="../jump/index.html?url=' + url + '" title="' + url + '">' + url + '</a></span>';
		        	str += '</td>';
		        	str += '</tr>';
	    		
	    		}

    		}
    	
       		$( '#' + id ).append( str );
        	
        }
        	
	});
	
}

/**
 *
 * リンク集を表示する
 *
 */
function ebm_show_link_collection( id ) {

	$( '#' + id ).empty();
        	
	$.ajax({
	
		dataType: 'json',
		data: {
            'service'  : 'search_link_collection',
            'genre_id' : '',
            'mode'     : 'all'
        },
        async: false,
        cache: false,
        url: ebm_admin_url + '/services/json',
        success: function (data) {
       	
        	var	str = '';
      	
	       	for ( i in data.result ) {
    	   
    			str += '<div class="link_h2_box">';
 	    		str += '<a name="' + data.result[i].LinkCollection.collection_id + '"></a>';
	   			str += '<h3>' + data.result[i].LinkCollection.title + '</h3>';
    			
    			for ( j in data.result[i].LinkCollection.link_list ) {
    			
    				var	url = $.trim( data.result[i].LinkCollection.link_list[j].Link.url );
    				
	    			str += '<div class="link_h3_box">';
	    			str += '<h4>';
	    			str += '<a href="../jump/index.html?url=' + url + '" title="' + url + '">';
	    			str += data.result[i].LinkCollection.link_list[j].Link.title;
	    			str += '</a>';
	    			str += '</h4>';
	    			str += '<p>' + data.result[i].LinkCollection.link_list[j].Link.description + '</p>';
	    			str += '</p>';
	    			str += '</div>';

    			}

    			str += '</div>';

    			

    		}
    	
       		$( '#' + id ).append( str );
        	
        }
        	
	});
	
}

/**
 *
 * カテゴリーに紐づくリンク集を表示する
 *
 */
function ebm_show_category_link_collection( id, params ) {

	$( '#' + id ).empty();
    
    var genre_id = '';
    if ( params['id'] ) {
    
    	genre_id = params['id'];
    	
    }
    	
	$.ajax({
	
		dataType: 'json',
		data: {
            'service'  : 'search_link_collection',
            'genre_id' : genre_id,
            'mode'     : 'search'
        },
        cache: false,
        url: ebm_admin_url + '/services/json',
        success: function (data) {
       	
        	var	str = '<ul>';
      	
	       	for ( i in data.result ) {
    	   
    	   		var url = site_url + '/link/index.html#' + data.result[i].LinkCollection.collection_id
    			str += '<li>';
    			str += '<a href="' + url + '" title="' + data.result[i].LinkCollection.title + '">'
    			str += data.result[i].LinkCollection.title;
    			str += '</a>';
    			str += '</li>';
 
    		}
    	
    		str += '</ul>';
      		$( '#' + id ).append( str );
        	
        }
        	
	});
	
}

/**
 *
 * ビジネスラウンジナビを表示する
 *
 */
function ebm_show_lounge_navi( id ) {

	$( '#' + id ).empty();
	
	$.ajax({
	
		dataType: 'json',
		data: {
            'service' : 'get_lounge_list',
            'status'  : 0
        },
        cache: false,
        url: ebm_admin_url + '/services/json',
        success: function (data) {
        
			var	str = '<ul>';
        
			for ( i in data.result ) {
			
				var	url  = site_url + '/lounge/book/detail.html?id=' + data.result[i].Lounge.lounge_id;
				 
				str += '<li>';
				str += '<a href="' + url + '" title="' + data.result[i].Lounge.name + '">';
				str += data.result[i].Lounge.name;
				str += '</a>';
				str += '</li>';
				
			}
			
			str += '</ul>';
			$( '#' + id ).append( str );
			    	
        }
        
	});
		
}

/**
 *
 * ビジネスラウンジの予約状況を表示する
 *
 */
function ebm_show_lounge_reserve( id ) {

	$( '#' + id ).empty();
        	
	$.ajax({
	
		dataType: 'json',
		data: {
            'service': 'get_lounge_list',
            'status'  : 1
        },
        cache: false,
        url: ebm_admin_url + '/services/json',
        success: function (data) {
       	
        	var	str = '';
     	
        	str += '<tr>';
        	str += '<th class="lounge_table_01_th_01">ラウンジ</th>';
        	str += '<th class="lounge_table_01_th_02">予約状況</th>';
        	str += '</tr>';
 
	       	for ( i in data.result ) {
    	
				var	url  = site_url + '/lounge/book/detail.html?id=' + data.result[i].Lounge.lounge_id;
	    		
	    		if ( (i % 2) == 0 ) {

		        	str += '<tr>';
		        	str += '<td class="lounge_table_01_td_01">';
					str += '<a href="' + url + '" title="' + data.result[i].Lounge.name + '">';
					str += data.result[i].Lounge.name;
		        	str += '</a>';
		        	str += '</td>';
		        	str += '<td class="lounge_table_01_td_02">';
		        	str += '<span>' + data.result[i].Lounge.reserve_count + '</span>件';
		        	str += '</td>';
		        	str += '</tr>';
	    		
	    		} else {
	    		
		        	str += '<tr>';
		        	str += '<td class="lounge_table_01_td_03">';
					str += '<a href="' + url + '" title="' + data.result[i].Lounge.name + '">';
					str += data.result[i].Lounge.name;
		        	str += '</a>';
		        	str += '</td>';
		        	str += '<td class="lounge_table_01_td_04">';
		        	str += '<span>' + data.result[i].Lounge.reserve_count + '</span>件';
		        	str += '</td>';
		        	str += '</tr>';
	    		
	    		}

    		}
    	
       		$( '#' + id ).append( str );
        	
        }
        	
	});
	
}

/**
 *
 * ビジネスラウンジ詳細を表示する
 *
 */
function ebm_show_lounge_detail( id ) {

	$( '#ebm_f1' ).empty();	// ラウンジ名称
	
	$.ajax({
	
		dataType: 'json',
		data: {
            'service': 'lounge_detail',
            'id'     : id
        },
        cache: false,
        url: ebm_admin_url + '/services/json',
        success: function (data) {
        
        	if ( data.result == null ) {
        	
        		return false;
        		
        	}

        	if ( data.result.Lounge == undefined ) {
        	
        		return false;
        		
        	}
        	
        	$( '#ebm_f1' ).append( data.result.Lounge.name );
         	
        }      
        	
	});
	
}

/**
 *
 * ビジネスラウンジの予約一覧を表示する
 *
 */
function ebm_show_reserve_list( name, id ) {

	$( '#' + name ).empty();
        	
	$.ajax({
	
		dataType: 'json',
		data: {
            'service'  : 'get_lounge_reserve_list',
            'id'       : id,
            'pagesize' : lounge_reserve_page_size
        },
        cache: false,
        url: ebm_admin_url + '/services/json',
        success: function (data) {
                	
	     	var current_page = 0;
	    	var	max_page_count = 0;
	    	
	       	var	str = '';
     	
      		str += '<tr>';
        	str += '<th colspan="2">予約状況</th>';
        	str += '</tr>';

			if ( data.result.length > 0 ) {
        	
        		current_page = data.result[0].current_page_no;
        		max_page_count = data.result[0].max_page_count;
        		
		       	for ( i in data.result ) {
	  	
		    		if ( (i % 2) == 0 ) {
	
			        	str += '<tr>';
			        	str += '<td class="lounge_detail_table_02_td_01">';
						str += formatDate( data.result[i].LoungeReserve.reserve_dt, false );
			        	str += '</td>';
			        	str += '<td class="lounge_detail_table_02_td_02">';
			        	
			        	for ( j in data.result[i].LoungeReserve.time_list ) {
			        	
			        		var	list = data.result[i].LoungeReserve.time_list[j];
			        		
			        		str += '<span>' + list.LoungeReserve.start_tm + '　～　' + list.LoungeReserve.end_tm + '</span>';
			        	
			        	}
			        	
			        	str += '</td>';
			        	str += '</tr>';
		    		
		    		} else {
		    		
			        	str += '<tr>';
			        	str += '<td class="lounge_detail_table_02_td_03">';
						str += formatDate( data.result[i].LoungeReserve.reserve_dt, false );
			        	str += '</td>';
			        	str += '<td class="lounge_detail_table_02_td_04">';
			        	
			        	for ( j in data.result[i].LoungeReserve.time_list ) {
			        	
			        		var	list = data.result[i].LoungeReserve.time_list[j];
			        		
			        		str += '<span>' + list.LoungeReserve.start_tm + '　～　' + list.LoungeReserve.end_tm + '</span>';
			        	
			        	}
			        	
			        	str += '</td>';
			        	str += '</tr>';
		    		
		    		}
	
	    		}
    		
	        	showPager( 'exp_pager', lounge_reserve_pager_size, max_page_count, current_page, 'ebm_show_reserve_select_page', '' );
    		}
    		
     		$( '#' + name ).append( str );
        	
        }
        	
	});
	
}

/**
 *
 * ビジネスラウンジの予約一覧を表示する(ページ移動)
 *
 */

function ebm_show_reserve_select_page( pageno, detail_url ) {

    $( '#reserve_list' ).empty();
    
	// ページ選択
	$.ajax({
	
		dataType: 'json',
		data: {
            'service' : 'lounge_reserve_select_page',
            'pageno'  : pageno
        },
        cache: false,
        url: ebm_admin_url + '/services/json',
        success: function (data) {
         
	     	var current_page = 0;
	    	var	max_page_count = 0;
	    	
	       	var	str = '';
     	
      		str += '<tr>';
        	str += '<th colspan="2">予約状況</th>';
        	str += '</tr>';

			if ( data.result.length > 0 ) {
        	
        		current_page = data.result[0].current_page_no;
        		max_page_count = data.result[0].max_page_count;
        		
		       	for ( i in data.result ) {
	  	
		    		if ( (i % 2) == 0 ) {
	
			        	str += '<tr>';
			        	str += '<td class="lounge_detail_table_02_td_01">';
						str += formatDate( data.result[i].LoungeReserve.reserve_dt, false );
			        	str += '</td>';
			        	str += '<td class="lounge_detail_table_02_td_02">';
			        	
			        	for ( j in data.result[i].LoungeReserve.time_list ) {
			        	
			        		var	list = data.result[i].LoungeReserve.time_list[j];
			        		
			        		str += '<span>' + list.LoungeReserve.start_tm + '　～　' + list.LoungeReserve.end_tm + '</span>';
			        	
			        	}
			        	
			        	str += '</td>';
			        	str += '</tr>';
		    		
		    		} else {
		    		
			        	str += '<tr>';
			        	str += '<td class="lounge_detail_table_02_td_03">';
						str += formatDate( data.result[i].LoungeReserve.reserve_dt, false );
			        	str += '</td>';
			        	str += '<td class="lounge_detail_table_02_td_04">';
			        	
			        	for ( j in data.result[i].LoungeReserve.time_list ) {
			        	
			        		var	list = data.result[i].LoungeReserve.time_list[j];
			        		
			        		str += '<span>' + list.LoungeReserve.start_tm + '　～　' + list.LoungeReserve.end_tm + '</span>';
			        	
			        	}
			        	
			        	str += '</td>';
			        	str += '</tr>';
		    		
		    		}
	
	    		}
    		
	        	showPager( 'exp_pager', lounge_reserve_pager_size, max_page_count, current_page, 'ebm_show_reserve_select_page', '' );
    		}
    		
     		$( '#reserve_list' ).append( str );
        	
       }
        
	});
}

/**
 *
 * ビジネスラウンジ宣伝ページを表示する
 *
 */
function ebm_show_lounge_ad( id ) {

	$( '#' + id ).empty();
	
	$.ajax({
	
		dataType: 'json',
		data: {
            'service' : 'get_lounge_ad'
        },
        cache: false,
        url: ebm_admin_url + '/services/json',
        success: function (data) {
        
       		$( '#' + id ).append( data.result.LoungeAd.ad_content );
        	
        }
        
	});
		
}

/**
 *
 * ビジネスラウンジお知らせを表示する
 *
 */
function ebm_show_lounge_information( id ) {

	$( '#' + id ).empty();
	
	$.ajax({
	
		dataType: 'json',
		data: {
            'service' : 'get_lounge_information'
        },
        cache: false,
        url: ebm_admin_url + '/services/json',
        success: function (data) {
        
       		$( '#' + id ).append( data.result.Word.word );
        	
        }
        
	});
		
}

/**
 *
 * ご利用規約を表示する
 *
 */
function ebm_show_regulation( id ) {

	$( '#' + id ).empty();
	
	$.ajax({
	
		dataType: 'json',
		data: {
            'service' : 'get_regulation'
        },
        cache: false,
        url: ebm_admin_url + '/services/json',
        success: function (data) {
        
        	$( '#' + id ).append( data.result.Word.word );
        	
        }
        
	});
		
}

/**
 *
 * お知らせを表示する
 *
 */
function ebm_show_information( id ) {

	$( '#' + id ).empty();
	
	$.ajax({
	
		dataType: 'json',
		data: {
            'service' : 'get_information'
        },
        cache: false,
        url: ebm_admin_url + '/services/json',
        success: function (data) {
        
        	$( '#' + id ).append( data.result.Word.word );
        	
        }
        
	});
		
}

/**
 *
 * 各種アラートを表示する
 *
 * 1: 検索時のアラート
 * 2: 申込書ダウンロード時のアラート
 * 3: 変更届ダウンロード時のアラート
 * 4: 掲載継続届けダウンロード時のアラート
 * 5: 掲載中止届けダウンロード時のアラート
 *
 */
function ebm_show_alert( no ) {

	var	code = '';
	var	word = '';

	switch ( no ) {
	
		case 1 :
		
			code = '2000000001';
			break;
	
		case 2 :
		
			code = '2000000002';
			break;
	
		case 3 :
		
			code = '2000000003';
			break;
	
		case 4 :
		
			code = '2000000004';
			break;
	
		case 5 :
		
			code = '2000000005';
			break;
			
	}
	
	$.ajax({
	
		dataType: 'json',
		data: {
            'service' : 'word',
            'code'    : code
        },
        async: false,
        cache: false,
        url: ebm_admin_url + '/services/json',
        success: function (data) {
        
			word = data.result.Word.word;
			      	
        }
        
	});
	
	return confirm( word );
	
}

/**
 *
 * バナーを表示する
 *
 */
function ebm_show_banner( id ) {

	$( '#' + id ).empty();
	
	$.ajax({
	
		dataType: 'json',
		data: {
            'service' : 'get_banner'
        },
        cache: false,
        url: ebm_admin_url + '/services/json',
        success: function (data) {
        
			var	str = '';
 			
			for ( i in data.result ) {
			
				var	jump_url = site_url + '/jump/index.html';
				var	url  = data.result[i].Banner.url;
				var	name = data.result[i].Banner.name;
				 
				str += '<p class="bnr">';
				str += '<a href="' + jump_url + '?url=' + url + '" title="' + url + '">';
				str += '<img width="210" height="45" src="' + ebm_admin_url + '/services/banner/' + data.result[i].Banner.banner_id + '" alt="' + name + '" width="210" height="89" title="' + name + '" />';
				str += '</a>';
				str += '</p>';
				
			}
			
			$( '#' + id ).append( str );
			    	
        }
        
	});
		
}

/**
 *
 * コンテンツのPDFをダウンロードする
 *
 */
function ebm_download_contents_pdf( id, no ) {

	location.href = ebm_admin_url + '/services/download/subact:contents?id=' + id + '&no=' + no;
 	//var w = window.open( ebm_admin_url + '/services/download/subact:contents?id=' + id + '&no=' + no, '', '' );
	//w.focus();
	
}

/**
 *
 * 日付を整形する
 *
 */
function formatDate( date_str, yoff ) {

	if ( date_str.length == 10 ) {
	
		var	y = date_str.substr( 0, 4 );
		var m = date_str.substr( 5, 2 );
		var d = date_str.substr( 8, 2 );

		if ( yoff ) {
		
			return parseInt( m, 10 ) + '月' + parseInt( d, 10 ) + '日';

		} else {
		
			return parseInt( y, 10 ) + '年' + parseInt( m, 10 ) + '月' + parseInt( d, 10 ) + '日';

		}
		
	} else {
	
		return date_str;
		
	}
	
}

/**
 *
 * ページャーを表示する
 *
 */
function showPager( id, shownum, maxpage, pageno, callback, detail_url ) {

	var	c;
	var	sp;
	var	ep;
	var	prv = pageno - 1;
	var	nxt = pageno + 1;
	
	if ( (shownum % 2) == 0 ) {
	
		c = shownum / 2;
	
	} else {
	
		c = parseInt( shownum / 2 ) + 1;
		
	}
	
	if ( maxpage <= shownum ) {
	
		sp = 1;
		ep = maxpage;
	
	} else {
	
	
		if ( (pageno >= 1) && (pageno <= c) ) {
		
			sp = 1;
			ep = shownum;
		
		} else if ( (pageno + (c - 1)) == maxpage ) {
		
			sp = pageno - (c -1);
			ep = maxpage;
		
		} else if ( (pageno + (c - 1)) > maxpage ) {
		
			sp = maxpage - (shownum - 1);
			ep = maxpage;
			
		} else {
		
			sp = pageno - (c - 1);
			ep = sp + (shownum - 1);
		
		}
	
	}
	
	if ( ep > maxpage ) {
	
		ep = maxpage;
		
	}
	
	if ( prv < 1 ) {
	
		prv = 1;
		
	}
	
	if ( nxt > maxpage ) {
	
		nxt = maxpage;
		
	}
	
	$( '#' + id ).empty();

	if ( maxpage <=1 )
	{
		str = '';
		str += '<ul class="pagenate clearfix">';
		str += '<li style="border-style:none;">' + maxpage + '</li>';
		str += '</ul>';
	}
	else
	{
		var	prev_link = callback + "(" + prv + ", '" + detail_url + "')";
		var	next_link = callback + "(" + nxt + ", '" + detail_url + "')";
		
		str = '';
		str += '<ul class="pagenate clearfix">';
		
		if (pageno > 1)
		{
			str += '<li class="pagenatePrevious">';
			str += '<a href="javascript:' + prev_link + '" title="&lt;&lt; 前のページ">&lt;&lt; 前のページ</a>';
			str += '</li>';
		}
				
		for ( var i = sp; i <= ep; i++ ) {
		
			if ( i == pageno ) {
			
				str += '<li>' + i + '</li>';
				
			} else {
			
				var	page_link = callback + "(" + i + ", '" + detail_url + "')";
				str += '<li>';
				str += '<a href="javascript:' + page_link + '" title="' + i + '">' + i + '</a>';
				str += '</li>';
				
			}
			
		}
		
		if (pageno < maxpage)
		{
			str += '<li class="pagenateNext">';
			str += '<a href="javascript:' + next_link + '" title="次のページ &gt;&gt;">次のページ &gt;&gt;</a>';
			str += '</li>';
		}
		
		str += '</ul>';
	}
	
	$( '#' + id ).append( str );

}

/**
 *
 * 企業検索画面のチェックボックス処理
 *
 */
function ebm_company_search_checkbox() {

	// 北海道
	$('#s_hoa_1').click(function () {
	$('#s_ho_1').attr('checked', this.checked);
	});
	$('#b_hoa_1').click(function () {
	$('#b_ho_1').attr('checked', this.checked);
	});
	$('#s_ho_1').click(function () {
	$('#s_hoa_1').attr('checked', this.checked);
	});
	$('#b_ho_1').click(function () {
	$('#b_hoa_1').attr('checked', this.checked);
	});
	
	// 東北エリア
	$('#s_hoa_2').click(function () {
	$('#s_ho_2,#s_ho_3,#s_ho_4,#s_ho_5,#s_ho_6,#s_ho_7').attr('checked', this.checked);
	});
	$('#b_hoa_2').click(function () {
	$('#b_ho_2,#b_ho_3,#b_ho_4,#b_ho_5,#b_ho_6,#b_ho_7').attr('checked', this.checked);
	});
	
	$('input,label').click(function () {
	if( $( '#s_ho_2' ).is( ':checked' ) && $( '#s_ho_3' ).is( ':checked' ) && $( '#s_ho_4' ).is( ':checked' ) && $( '#s_ho_5' ).is( ':checked' ) && $( '#s_ho_6' ).is( ':checked' ) && $( '#s_ho_7' ).is( ':checked' )) {
	$('#s_hoa_2').attr('checked','true');
	}
	else if( $( '#s_ho_2' ).is( ':not(:checked)' ) || $( '#s_ho_3' ).is( ':not(:checked)' ) || $( '#s_ho_4' ).is( ':not(:checked)' ) || $( '#s_ho_5' ).is( ':not(:checked)' ) || $( '#s_ho_6' ).is( ':not(:checked)' ) || $( '#s_ho_7' ).is( ':not(:checked)' )) {
	$('#s_hoa_2').attr('checked','');
	}
	});
	
	$('input,label').click(function () {
	if( $( '#b_ho_2' ).is( ':checked' ) && $( '#b_ho_3' ).is( ':checked' ) && $( '#b_ho_4' ).is( ':checked' ) && $( '#b_ho_5' ).is( ':checked' ) && $( '#b_ho_6' ).is( ':checked' ) && $( '#b_ho_7' ).is( ':checked' )) {
	$('#b_hoa_2').attr('checked','true');
	}
	else if( $( '#b_ho_2' ).is( ':not(:checked)' ) || $( '#b_ho_3' ).is( ':not(:checked)' ) || $( '#b_ho_4' ).is( ':not(:checked)' ) || $( '#b_ho_5' ).is( ':not(:checked)' ) || $( '#b_ho_6' ).is( ':not(:checked)' ) || $( '#b_ho_7' ).is( ':not(:checked)' )) {
	$('#b_hoa_2').attr('checked','');
	}
	});

	// 北関東エリア
	$('#s_hoa_3').click(function () {
	$('#s_ho_8,#s_ho_9,#s_ho_10').attr('checked', this.checked);
	});
	$('#b_hoa_3').click(function () {
	$('#b_ho_8,#b_ho_9,#b_ho_10').attr('checked', this.checked);
	});
	
	$('input,label').click(function () {
	if( $( '#s_ho_8' ).is( ':checked' ) && $( '#s_ho_9' ).is( ':checked' ) && $( '#s_ho_10' ).is( ':checked' )) {
	$('#s_hoa_3').attr('checked','true');
	}
	else if( $( '#s_ho_8' ).is( ':not(:checked)' ) || $( '#s_ho_9' ).is( ':not(:checked)' ) || $( '#s_ho_10' ).is( ':not(:checked)' )) {
	$('#s_hoa_3').attr('checked','');
	}
	});
	
	$('input,label').click(function () {
	if( $( '#b_ho_8' ).is( ':checked' ) && $( '#b_ho_9' ).is( ':checked' ) && $( '#b_ho_10' ).is( ':checked' )) {
	$('#b_hoa_3').attr('checked','true');
	}
	else if( $( '#b_ho_8' ).is( ':not(:checked)' ) || $( '#b_ho_9' ).is( ':not(:checked)' ) || $( '#b_ho_10' ).is( ':not(:checked)' )) {
	$('#b_hoa_3').attr('checked','');
	}
	});
	
	// 南関東エリア
	$('#s_hoa_4').click(function () {
	$('#s_ho_11,#s_ho_12,#s_ho_13,#s_ho_14').attr('checked', this.checked);
	});
	$('#b_hoa_4').click(function () {
	$('#b_ho_11,#b_ho_12,#b_ho_13,#b_ho_14').attr('checked', this.checked);
	});
	
	$('input,label').click(function () {
	if( $( '#s_ho_11' ).is( ':checked' ) && $( '#s_ho_12' ).is( ':checked' ) && $( '#s_ho_13' ).is( ':checked' ) && $( '#s_ho_14' ).is( ':checked' )) {
	$('#s_hoa_4').attr('checked','true');
	}
	else if( $( '#s_ho_11' ).is( ':not(:checked)' ) || $( '#s_ho_12' ).is( ':not(:checked)' ) || $( '#s_ho_13' ).is( ':not(:checked)' ) || $( '#s_ho_14' ).is( ':not(:checked)' )) {
	$('#s_hoa_4').attr('checked','');
	}
	});
	
	$('input,label').click(function () {
	if( $( '#b_ho_11' ).is( ':checked' ) && $( '#b_ho_12' ).is( ':checked' ) && $( '#b_ho_13' ).is( ':checked' ) && $( '#b_ho_14' ).is( ':checked' )) {
	$('#b_hoa_4').attr('checked','true');
	}
	else if( $( '#b_ho_11' ).is( ':not(:checked)' ) || $( '#b_ho_12' ).is( ':not(:checked)' ) || $( '#b_ho_13' ).is( ':not(:checked)' ) || $( '#b_ho_14' ).is( ':not(:checked)' )) {
	$('#b_hoa_4').attr('checked','');
	}
	});
	
	// 甲信越エリア
	$('#s_hoa_5').click(function () {
	$('#s_ho_15,#s_ho_16,#s_ho_17').attr('checked', this.checked);
	});
	$('#b_hoa_5').click(function () {
	$('#b_ho_15,#b_ho_16,#b_ho_17').attr('checked', this.checked);
	});
	
	$('input,label').click(function () {
	if( $( '#s_ho_15' ).is( ':checked' ) && $( '#s_ho_16' ).is( ':checked' ) && $( '#s_ho_17' ).is( ':checked' )) {
	$('#s_hoa_5').attr('checked','true');
	}
	else if( $( '#s_ho_15' ).is( ':not(:checked)' ) || $( '#s_ho_16' ).is( ':not(:checked)' ) || $( '#s_ho_17' ).is( ':not(:checked)' )) {
	$('#s_hoa_5').attr('checked','');
	}
	});
	
	$('input,label').click(function () {
	if( $( '#b_ho_15' ).is( ':checked' ) && $( '#b_ho_16' ).is( ':checked' ) && $( '#b_ho_17' ).is( ':checked' )) {
	$('#b_hoa_5').attr('checked','true');
	}
	else if( $( '#b_ho_15' ).is( ':not(:checked)' ) || $( '#b_ho_16' ).is( ':not(:checked)' ) || $( '#b_ho_17' ).is( ':not(:checked)' )) {
	$('#b_hoa_5').attr('checked','');
	}
	});
	
	// 北陸エリア
	$('#s_hoa_6').click(function () {
	$('#s_ho_18,#s_ho_19,#s_ho_20').attr('checked', this.checked);
	});
	$('#b_hoa_6').click(function () {
	$('#b_ho_18,#b_ho_19,#b_ho_20').attr('checked', this.checked);
	});
	
	$('input,label').click(function () {
	if( $( '#s_ho_18' ).is( ':checked' ) && $( '#s_ho_19' ).is( ':checked' ) && $( '#s_ho_20' ).is( ':checked' )) {
	$('#s_hoa_6').attr('checked','true');
	}
	else if( $( '#s_ho_18' ).is( ':not(:checked)' ) || $( '#s_ho_19' ).is( ':not(:checked)' ) || $( '#s_ho_20' ).is( ':not(:checked)' )) {
	$('#s_hoa_6').attr('checked','');
	}
	});
	
	$('input,label').click(function () {
	if( $( '#b_ho_18' ).is( ':checked' ) && $( '#b_ho_19' ).is( ':checked' ) && $( '#b_ho_20' ).is( ':checked' )) {
	$('#b_hoa_6').attr('checked','true');
	}
	else if( $( '#b_ho_18' ).is( ':not(:checked)' ) || $( '#b_ho_19' ).is( ':not(:checked)' ) || $( '#b_ho_20' ).is( ':not(:checked)' )) {
	$('#b_hoa_6').attr('checked','');
	}
	});
	
	// 中部エリア
	$('#s_hoa_7').click(function () {
	$('#s_ho_21,#s_ho_22,#s_ho_23,#s_ho_24').attr('checked', this.checked);
	});
	$('#b_hoa_7').click(function () {
	$('#b_ho_21,#b_ho_22,#b_ho_23,#b_ho_24').attr('checked', this.checked);
	});
	
	$('input,label').click(function () {
	if( $( '#s_ho_21' ).is( ':checked' ) && $( '#s_ho_22' ).is( ':checked' ) && $( '#s_ho_23' ).is( ':checked' ) && $( '#s_ho_24' ).is( ':checked' )) {
	$('#s_hoa_7').attr('checked','true');
	}
	else if( $( '#s_ho_21' ).is( ':not(:checked)' ) || $( '#s_ho_22' ).is( ':not(:checked)' ) || $( '#s_ho_23' ).is( ':not(:checked)' ) || $( '#s_ho_24' ).is( ':not(:checked)' )) {
	$('#s_hoa_7').attr('checked','');
	}
	});
	
	$('input,label').click(function () {
	if( $( '#b_ho_21' ).is( ':checked' ) && $( '#b_ho_22' ).is( ':checked' ) && $( '#b_ho_23' ).is( ':checked' ) && $( '#b_ho_24' ).is( ':checked' )) {
	$('#b_hoa_7').attr('checked','true');
	}
	else if( $( '#b_ho_21' ).is( ':not(:checked)' ) || $( '#b_ho_22' ).is( ':not(:checked)' ) || $( '#b_ho_23' ).is( ':not(:checked)' ) || $( '#b_ho_24' ).is( ':not(:checked)' )) {
	$('#b_hoa_7').attr('checked','');
	}
	});
	
	// 近畿エリア
	$('#s_hoa_8').click(function () {
	$('#s_ho_25,#s_ho_26,#s_ho_27,#s_ho_28,#s_ho_29,#s_ho_30').attr('checked', this.checked);
	});
	$('#b_hoa_8').click(function () {
	$('#b_ho_25,#b_ho_26,#b_ho_27,#b_ho_28,#b_ho_29,#b_ho_30').attr('checked', this.checked);
	});
	
	$('input,label').click(function () {
	if( $( '#s_ho_25' ).is( ':checked' ) && $( '#s_ho_26' ).is( ':checked' ) && $( '#s_ho_27' ).is( ':checked' ) && $( '#s_ho_28' ).is( ':checked' ) && $( '#s_ho_29' ).is( ':checked' ) && $( '#s_ho_30' ).is( ':checked' )) {
	$('#s_hoa_8').attr('checked','true');
	}
	else if( $( '#s_ho_25' ).is( ':not(:checked)' ) || $( '#s_ho_26' ).is( ':not(:checked)' ) || $( '#s_ho_27' ).is( ':not(:checked)' ) || $( '#s_ho_28' ).is( ':not(:checked)' ) || $( '#s_ho_29' ).is( ':not(:checked)' ) || $( '#s_ho_30' ).is( ':not(:checked)' )) {
	$('#s_hoa_8').attr('checked','');
	}
	});
	
	$('input,label').click(function () {
	if( $( '#b_ho_25' ).is( ':checked' ) && $( '#b_ho_26' ).is( ':checked' ) && $( '#b_ho_27' ).is( ':checked' ) && $( '#b_ho_28' ).is( ':checked' ) && $( '#b_ho_29' ).is( ':checked' ) && $( '#b_ho_30' ).is( ':checked' )) {
	$('#b_hoa_8').attr('checked','true');
	}
	else if( $( '#b_ho_25' ).is( ':not(:checked)' ) || $( '#b_ho_26' ).is( ':not(:checked)' ) || $( '#b_ho_27' ).is( ':not(:checked)' ) || $( '#b_ho_28' ).is( ':not(:checked)' ) || $( '#b_ho_29' ).is( ':not(:checked)' ) || $( '#b_ho_30' ).is( ':not(:checked)' )) {
	$('#b_hoa_8').attr('checked','');
	}
	});
	
	// 中国エリア
	$('#s_hoa_9').click(function () {
	$('#s_ho_31,#s_ho_32,#s_ho_33,#s_ho_34,#s_ho_35').attr('checked', this.checked);
	});
	$('#b_hoa_9').click(function () {
	$('#b_ho_31,#b_ho_32,#b_ho_33,#b_ho_34,#b_ho_35').attr('checked', this.checked);
	});
	
	$('input,label').click(function () {
	if( $( '#s_ho_31' ).is( ':checked' ) && $( '#s_ho_32' ).is( ':checked' ) && $( '#s_ho_33' ).is( ':checked' ) && $( '#s_ho_34' ).is( ':checked' ) && $( '#s_ho_35' ).is( ':checked' )) {
	$('#s_hoa_9').attr('checked','true');
	}
	else if( $( '#s_ho_31' ).is( ':not(:checked)' ) || $( '#s_ho_32' ).is( ':not(:checked)' ) || $( '#s_ho_33' ).is( ':not(:checked)' ) || $( '#s_ho_34' ).is( ':not(:checked)' ) || $( '#s_ho_35' ).is( ':not(:checked)' )) {
	$('#s_hoa_9').attr('checked','');
	}
	});
	
	$('input,label').click(function () {
	if( $( '#b_ho_31' ).is( ':checked' ) && $( '#b_ho_32' ).is( ':checked' ) && $( '#b_ho_33' ).is( ':checked' ) && $( '#b_ho_34' ).is( ':checked' ) && $( '#b_ho_35' ).is( ':checked' )) {
	$('#b_hoa_9').attr('checked','true');
	}
	else if( $( '#b_ho_31' ).is( ':not(:checked)' ) || $( '#b_ho_32' ).is( ':not(:checked)' ) || $( '#b_ho_33' ).is( ':not(:checked)' ) || $( '#b_ho_34' ).is( ':not(:checked)' ) || $( '#b_ho_35' ).is( ':not(:checked)' )) {
	$('#b_hoa_9').attr('checked','');
	}
	});
	
	// 四国エリア
	$('#s_hoa_10').click(function () {
	$('#s_ho_36,#s_ho_37,#s_ho_38,#s_ho_39').attr('checked', this.checked);
	});
	$('#b_hoa_10').click(function () {
	$('#b_ho_36,#b_ho_37,#b_ho_38,#b_ho_39').attr('checked', this.checked);
	});
	
	$('input,label').click(function () {
	if( $( '#s_ho_36' ).is( ':checked' ) && $( '#s_ho_37' ).is( ':checked' ) && $( '#s_ho_38' ).is( ':checked' ) && $( '#s_ho_39' ).is( ':checked' )) {
	$('#s_hoa_10').attr('checked','true');
	}
	else if( $( '#s_ho_36' ).is( ':not(:checked)' ) || $( '#s_ho_37' ).is( ':not(:checked)' ) || $( '#s_ho_38' ).is( ':not(:checked)' ) || $( '#s_ho_39' ).is( ':not(:checked)' )) {
	$('#s_hoa_10').attr('checked','');
	}
	});
	
	$('input,label').click(function () {
	if( $( '#b_ho_36' ).is( ':checked' ) && $( '#b_ho_37' ).is( ':checked' ) && $( '#b_ho_38' ).is( ':checked' ) && $( '#b_ho_39' ).is( ':checked' )) {
	$('#b_hoa_10').attr('checked','true');
	}
	else if( $( '#b_ho_36' ).is( ':not(:checked)' ) || $( '#b_ho_37' ).is( ':not(:checked)' ) || $( '#b_ho_38' ).is( ':not(:checked)' ) || $( '#b_ho_39' ).is( ':not(:checked)' )) {
	$('#b_hoa_10').attr('checked','');
	}
	});
	
	// 九州エリア
	$('#s_hoa_11').click(function () {
	$('#s_ho_40,#s_ho_41,#s_ho_42,#s_ho_43,#s_ho_44,#s_ho_45,#s_ho_46').attr('checked', this.checked);
	});
	$('#b_hoa_11').click(function () {
	$('#b_ho_40,#b_ho_41,#b_ho_42,#b_ho_43,#b_ho_44,#b_ho_45,#b_ho_46').attr('checked', this.checked);
	});
	
	$('input,label').click(function () {
	if( $( '#s_ho_40' ).is( ':checked' ) && $( '#s_ho_41' ).is( ':checked' ) && $( '#s_ho_42' ).is( ':checked' ) && $( '#s_ho_43' ).is( ':checked' ) && $( '#s_ho_44' ).is( ':checked' ) && $( '#s_ho_45' ).is( ':checked' ) && $( '#s_ho_46' ).is( ':checked' )) {
	$('#s_hoa_11').attr('checked','true');
	}
	else if( $( '#s_ho_40' ).is( ':not(:checked)' ) || $( '#s_ho_41' ).is( ':not(:checked)' ) || $( '#s_ho_42' ).is( ':not(:checked)' ) || $( '#s_ho_43' ).is( ':not(:checked)' ) || $( '#s_ho_44' ).is( ':not(:checked)' ) || $( '#s_ho_45' ).is( ':not(:checked)' ) || $( '#s_ho_46' ).is( ':not(:checked)' )) {
	$('#s_hoa_11').attr('checked','');
	}
	});
	
	$('input,label').click(function () {
	if( $( '#b_ho_40' ).is( ':checked' ) && $( '#b_ho_41' ).is( ':checked' ) && $( '#b_ho_42' ).is( ':checked' ) && $( '#b_ho_43' ).is( ':checked' ) && $( '#b_ho_44' ).is( ':checked' ) && $( '#b_ho_45' ).is( ':checked' ) && $( '#b_ho_46' ).is( ':checked' )) {
	$('#b_hoa_11').attr('checked','true');
	}
	else if( $( '#b_ho_40' ).is( ':not(:checked)' ) || $( '#b_ho_41' ).is( ':not(:checked)' ) || $( '#b_ho_42' ).is( ':not(:checked)' ) || $( '#b_ho_43' ).is( ':not(:checked)' ) || $( '#b_ho_44' ).is( ':not(:checked)' ) || $( '#b_ho_45' ).is( ':not(:checked)' ) || $( '#b_ho_46' ).is( ':not(:checked)' )) {
	$('#b_hoa_11').attr('checked','');
	}
	});
	
	// 沖縄エリア
	$('#s_hoa_12').click(function () {
	$('#s_ho_47').attr('checked', this.checked);
	});
	$('#b_hoa_12').click(function () {
	$('#b_ho_47').attr('checked', this.checked);
	});
	$('#s_ho_47').click(function () {
	$('#s_hoa_12').attr('checked', this.checked);
	});
	$('#b_ho_47').click(function () {
	$('#b_hoa_12').attr('checked', this.checked);
	});
	
	// 全国
   	$('#s_hoa_0,#b_hoa_0').click(function () {
	$(this).parents('div.place_box').find(':checkbox').attr('checked', this.checked);
	});
	
	$('input,label').click(function () {
	if( $( '#s_hoa_0' ).parents('div.place_box').find(':checkbox:not(#category_03_01):checked').length == 59){
	$('#s_hoa_0').attr('checked','true');
	}
	else if( $( '#s_hoa_0' ).parents('div.place_box').find(':checkbox:not(#s_hoa_0)').is( ':not(:checked)' )) {
	$('#s_hoa_0').attr('checked','');
	}
	});
	
	$('input,label').click(function () {
	if( $( '#b_hoa_0' ).parents('div.place_box').find(':checkbox:not(#b_hoa_0):checked').length == 59){
	$('#b_hoa_0').attr('checked','true');
	}
	else if( $( '#b_hoa_0' ).parents('div.place_box').find(':checkbox:not(#b_hoa_0)').is( ':not(:checked)' )) {
	$('#b_hoa_0').attr('checked','');
	}
	});
	
	// 「設定条件をクリア」ボタン
	$('.allcheck').click(function() {
	$(":checkbox").each( function(){ $(this).removeAttr("checked"); } );
	});
	
}

/**
 *
 * 企業検索画面のタブ選択１
 *
 */
function ebm_company_search_select_tab1( tabno ) {

	$('#select_tab1').val(tabno);
	
}

/**
 *
 * 企業検索画面のタブ選択２
 *
 */
function ebm_company_search_select_tab2( tabno ) {

	$('#select_tab2').val(tabno);
	$('#search_all_conditions').val('0');
	
	switch ( tabno ) {
	
		case 1 :
		case 2 :
		case 3 :
		
			$('#select_tab1').val('1');
			break;
			
		case 4 :
		case 5 :
		case 6 :
		
			$('#select_tab1').val('2');
			break;
			
	}
	
}

/**
 *
 * 企業検索画面のすべての条件で検索
 *
 */
function ebm_company_search_all_conditions() {

	$('#search_all_conditions').val('1');
	$('#keyword').val($('#searchtxt').val());
	$('#keyword2').val($('#searchtxt2').val());
	
}


/**********************************************************
/ Tools
/**********************************************************
/**
 *
 * 文字エンコード/デコード
 *
 */
utf = new function()
{
    this.unpackUTF16 = function(_str)
    {
        var i, utf16=[];
        for (i=0; i<_str.length; i++) utf16[i] = _str.charCodeAt(i);
        return utf16;
    }
    
    this.unpackChar = function(_str) 
    {
    	var utf16 = this.unpackUTF16(_str);
    	var i,n, tmp = [];
    	for (n=i=0; i<utf16.length; i++) {
    		if (utf16[i]<=0xff) tmp[n++] = utf16[i];
    		else {
    			tmp[n++] = utf16[i] >> 8;
    			tmp[n++] = utf16[i] &  0xff;
    		}	
    	}
    	return tmp;
    }
    
    this.packChar  =
    this.packUTF16 = function(_utf16)
    {
        var i, str = "";
        for (i in _utf16) str += String.fromCharCode(_utf16[i]);
        return str;
    }

    this.unpackUTF8 = function(_str)
    {
       return this.toUTF8( this.unpackUTF16(_str) );
    }

    this.packUTF8 = function(_utf8)
    {
        return this.packUTF16( this.toUTF16(_utf8) );
    }
    
    this.toUTF8 = function(_utf16)
    {
        var utf8 = [];
        var idx = 0;
        var i, j, c;
        for (i=0; i<_utf16.length; i++)
        {
            c = _utf16[i];
            if (c <= 0x7f) utf8[idx++] = c;
            else if (c <= 0x7ff)
            {
                utf8[idx++] = 0xc0 | (c >>> 6 );
                utf8[idx++] = 0x80 | (c & 0x3f);
            }
            else if (c <= 0xffff)
            {
                utf8[idx++] = 0xe0 | (c >>> 12 );
                utf8[idx++] = 0x80 | ((c >>> 6 ) & 0x3f);
                utf8[idx++] = 0x80 | (c & 0x3f);
            }
            else
            {
                j = 4;
                while (c >> (6*j)) j++;
                utf8[idx++] = ((0xff00 >>> j) & 0xff) | (c >>> (6*--j) );
                while (j--) 
                utf8[idx++] = 0x80 | ((c >>> (6*j)) & 0x3f);
            }
        }
        return utf8;
    }
    
    this.toUTF16 = function(_utf8)
    {
        var utf16 = [];
        var idx = 0;
        var i,s;
        for (i=0; i<_utf8.length; i++, idx++)
        {
            if (_utf8[i] <= 0x7f) utf16[idx] = _utf8[i];
            else 
            {
                if ( (_utf8[i]>>5) == 0x6)
                {
                    utf16[idx] = ( (_utf8[i] & 0x1f) << 6 )
                                 | ( _utf8[++i] & 0x3f );
                }
                else if ( (_utf8[i]>>4) == 0xe)
                {
                    utf16[idx] = ( (_utf8[i] & 0xf) << 12 )
                                 | ( (_utf8[++i] & 0x3f) << 6 )
                                 | ( _utf8[++i] & 0x3f );
                }
                else
                {
                    s = 1;
                    while (_utf8[i] & (0x20 >>> s) ) s++;
                    utf16[idx] = _utf8[i] & (0x1f >>> s);
                    while (s-->=0) utf16[idx] = (utf16[idx] << 6) ^ (_utf8[++i] & 0x3f);
                }
            }
        }
        return utf16;
    }
    
    this.URLencode = function(_str)
    {
        return _str.replace(/([^a-zA-Z0-9_\-\.])/g, function(_tmp, _c)
            { 
                if (_c == "\x20") return "+";
                var tmp = utf.toUTF8( [_c.charCodeAt(0)] );
                var c = "";
                for (var i in tmp)
                {
                    i = tmp[i].toString(16);
                    if (i.length == 1) i = "0"+ i;
                    c += "%"+ i;
                }
                return c;
            } );
    }

    this.URLdecode = function(_dat)
    {
        _dat = _dat.replace(/\+/g, "\x20");
        _dat = _dat.replace( /%([a-fA-F0-9][a-fA-F0-9])/g, 
                function(_tmp, _hex){ return String.fromCharCode( parseInt(_hex, 16) ) } );
        return this.packChar( this.toUTF16( this.unpackUTF16(_dat) ) );
    }
}

/**
 *
 * 日付チェック
 *
 */
function chkDate( y, m ,d, false_msg ) {

	if ( y.match(/[^0-9]/g) || m.match(/[^0-9]/g) || d.match(/[^0-9]/g) ) {
		
		alert( false_msg );
		return false;
		
	}
	
	var year  = parseInt( y );
	var month = parseInt( m );
	var day   = parseInt( d );

    if( year >= 0 && month <= 12 && day >= 1 && day <= 31 ) {
    
    	switch ( month ) {
    	
    		case 2 :
    		
   				if ( ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0) ) {
   				
	     			if ( day > 29 ) {
	    			
				 		alert( false_msg );
				    	return false;
				    	
	   				}
   				
   				} else {
   				
	     			if ( day > 28	 ) {
	    			
				 		alert( false_msg );
				    	return false;
				    	
	   				}
	   				
   				}
   				
   				break;
    			
    		case 4 :
    		case 6 :
    		case 9 :
    		case 11 :
    		
    			if ( day > 30 ) {
    			
			 		alert( false_msg );
			    	return false;
			    	
   				}
   				
    			break;
    	}
    	
    } else {
    
		alert( false_msg );
    	return false;
    	
    }
    
    return true;
    
}

