//コンテンツテーブル
var contentsTbl = new Array();
//0:ファイル名 1:ページ名 3:上位ページ
contentsTbl['index'] = new Array('index.html','ASA','');
//会社案内
contentsTbl['outline'] = new Array('cn_outline.html','会社案内','index');
contentsTbl['access'] = new Array('cn_access.html','アクセスマップ','index');
contentsTbl['torihikihou'] = new Array('cn_torihikihou.html','特定商取引法','index');
contentsTbl['jyohouhogo'] = new Array('cn_jyohouhogo.html','個人情報保護方針','index');
//業務案内
contentsTbl['cate_copy'] = new Array('cate_copy.html','コピー・複写','index');
contentsTbl['cate_data_io'] = new Array('cate_data_io.html','電子データ入出力','index');
contentsTbl['cate_del_fl'] = new Array('cate_del_fl.html','電子納品/ファイリング','index');
contentsTbl['cate_cad'] = new Array('cate_cad.html','ＣＡＤ','index');
contentsTbl['cate_book_bd'] = new Array('cate_book_bd.html','製本','index');
contentsTbl['cate_card'] = new Array('cate_card.html','名刺','index');
contentsTbl['cate_card_bc_sample'] = new Array('cate_card_bc_sample.html','オリジナル名刺','cate_card');
contentsTbl['cate_card_bc_OrderForm'] = new Array('cate_card_bc_OrderForm.html','名刺ご注文フォーム','cate_card');
contentsTbl['cate_design'] = new Array('cate_design.html','企画・デザイン・制作・加工','index');
contentsTbl['cate_web'] = new Array('cate_web.html','ホームページ制作','index');
contentsTbl['cate_others'] = new Array('cate_others.html','マイクロ撮影・パソコンデータ打込み・地図作成','index');
//その他
contentsTbl['usage'] = new Array('cn_usage.html','ご利用方法','index');
contentsTbl['inq_f'] = new Array('inq_f.html','お問合せフォーム','index');
contentsTbl['sitemap'] = new Array('sitemap.html','サイトマップ','index');


/* 画面表示処理--------------------------------------------- */
function init_OnLoad(pageNm) {

	// prototypeとの競合を避ける処置
	//$.noConflict();
	jQuery(document).ready(function($) {

		//ヘッダー
		$("#fr_header").ready(function(){
		$("#fr_header").load("fr_header.html");
		});
		
		//フッター
		$("#fr_footer").ready(function(){
		$("#fr_footer").load("fr_footer.html");
		});

		//サイドメニュー
		$("#fr_sidem").ready(function(){
		$("#fr_sidem").load("fr_sidem.html");
		});

		//パン屑リスト入れ替え
		$("#fr_blist").ready(function(){
		$("#fr_blist").html(set_blist2(pageNm));
		});

		//お知らせ取得処理
		get_news_xml();
		//プロフィール
		get_asa_prof_xml();
		//カテゴリーメニュー
		get_cate_xml();

		//トップページへ
		$(".pg_tp").ready(function(){
		$(".pg_tp").html('<div align="right" style="margin-bottom: 8px;"><a href="#">ページのトップへ</a></DIV>');
		});

		////////////////////////////
		// メニューの作成
		//  var $content = $("#furuya_article3 div.content");
		//  $abstract = $("<ul class='abstract-list'></ul>");
		//  $content.children("h2").each(function(index) {
		//    $("<li class='menu-item'>" + $(this).text() + "</li>").click(function() {
		//      $("#furuya_article3 li.menu-item").removeClass("selected").eq(index).addClass("selected");
		//      $content.hide().eq(index).fadeIn(2000);
		//    }).appendTo($abstract);
		//  });
		////////////////////////////
		////////////////////////////
		//  $("#furuya_article3 div#abstract").append($abstract);
		//  $content.hide().filter(":first").show();
		//  $("#furuya_article3 li.menu-item:first").addClass("selected");
		////////////////////////////
		// イベントハンドラの作成------------------------*
		$(".pg_tp").click(function() {
		$("html, body").animate({scrollTop : $("#pg_cap").offset().top}, 800);
		return false;
		});
		// イベントハンドラの作成------------------------*
		////////////////////////////
		//  // ストライプテーブル
		//  $("#stripe-num").change(function() {
		//    var stripe_num = $("#stripe-num").attr("value");
		//    $("#stripe tbody tr").removeClass("stripe-1 stripe-2 stripe-3 stripe-4 stripe-5");
		//    $("#stripe").stripeTable({pattern_num : parseInt(stripe_num)});
		//  });
		//  $("#stripe").stripeTable();
		////////////////////////////
		//jQueryでメニューを固定位置に追随させる------------------------*
		var name = "#categp_mu_scroll";
		var menuYloc = null;
		$(name).ready(function(){
			if ($(name).css("top") != null) {
				menuYloc = parseInt($(name).css("top").substring(0,$(name).css("top").indexOf("px")))
				$(window).scroll(function () { 
					offset = menuYloc+$(document).scrollTop()+"px";
					$(name).animate({top:offset},{duration:500,queue:false});
				});
			}
		});
		//jQueryでメニューを固定位置に追随させる------------------------*
		//prettyPhoto------------------------*
		//$(".sm_bx").ready(function(){
		//	//prettyPhoto----*
		//	$("a[rel^='prettyOverlay'],a[rel^='prettyPhoto']").prettyPhoto({
		//		animationSpeed: 'normal', /* fast/slow/normal */
		//		padding: 40, /* padding for each side of the picture */
		//		opacity: 0.35, /* Value betwee 0 and 1 */
		//		showTitle: true, /* true/false */
		//		allowresize: true /* true/false */
		//	});
		//	//prettyPhoto----*
		//});
		//prettyPhoto------------------------*

	});

}
/* 画面表示処理--------------------------------------------- */



/* パン屑リスト編集--------------------------------------------- */
function set_blist2(pageNm) {
	var w_html = "";

	try{

		if (pageNm == 'index') {
			return "";
			//return "&nbsp;";
		}

		var w_pageNm = contentsTbl[pageNm][2];
		var w_html_tbl = "";
		while (w_pageNm != '') {
			var w_tbl = "";
			w_tbl += "<DIV id=\"bl_" + w_pageNm + "\" style=\"background-color:#FFFFFF;border:#000000 solid 1px;color:#000000;float:left;padding:3px;margin-right:5px;\">"
			w_tbl += "<A href=\""+ contentsTbl[w_pageNm][0] +"\">"
			w_tbl += contentsTbl[w_pageNm][1]
			w_tbl += "</A>"
			w_tbl += "</DIV>";

			w_tbl += "<DIV style=\"background-color:#FFFFFF;color:#000000;float:left;padding:3px;margin-top:2px;font-size:85%;\">";
			w_tbl += ">>";
			w_tbl += "</DIV>";
			w_html_tbl = w_tbl + w_html_tbl;
			w_pageNm = contentsTbl[w_pageNm][2];
		}
		w_html += w_html_tbl;
		w_html += "<DIV id=\"bl_" + pageNm + "\" style=\"background-color:#000000;border:#000000 solid 1px;color:#ffffff;float:left;padding:3px;margin-right:5px;\">";
		w_html += contentsTbl[pageNm][1];
		w_html += "</DIV>";
		w_html += "<br style=\"clear:both;\" />";
	}catch( e ){
		alert( "init.js - " + e ); // バグの内容をダイアログで表示する
		alert( "init.js - pageNm= " + pageNm ); // バグの内容をダイアログで表示する
	}

	$("DIV#fr_blist").css("margin-top","10px");
	$("DIV#fr_blist").css("margin-bottom","10px");

	return w_html;
}
/* パン屑リスト編集--------------------------------------------- */

/* XML--------------------------------------------- */
// xmlファイル読み込み
function get_xml(nm,fl,parse_xml){
	$(nm).ready(function(){
		$.ajax({
			url:fl,
			type:'get',
			dataType:'xml',
			timeout:50000,
			error:error_func,
			success:parse_xml
		});
	});
}
function error_func(result) {
	//alert(result.responseText);
	alert("XML読込エラー");
}
/* XML--------------------------------------------- */
/* お知らせ取得処理--------------------------------------------- */
// xmlファイル読み込み
function get_news_xml(){
	get_xml("#oshirasebx","data/news.xml",parse_news_xml);
}
// xmlデータ解析
function parse_news_xml(xml,status){
	if(status!='success')return;
	$(xml).find('item').each(write_news_row);
	$("DIV.m_news").css("display","none");
}
/////////////////
// 1件分のデータをtable要素に追加
var news_display1 = "";
function write_news_row(){
	var key=$(this).find('key').text();
	var update=$(this).find('update').text();
	var yyyy = update.substring(0,4);
	var mm = update.substring(4,6);
	var dd = update.substring(6,8);
	var title=$(this).find('title').text();
	var message=$(this).find('message').text();
	var link=$(this).find('link').text();
	var display1=$(this).find('display1').text();

	var s_link_icon = "";
	if (link != "") {
		s_link_icon += "<A href=\""+link+"\" target=\"_blank\"><img alt=\"ホームページを表示する\" src=\"./img/icon_net.png\" width=\"17\" height=\"17\"></A>";
	}

	$('<LI id="l_news'+update+key+'" class="l_news" style="display:'+display1+';">'+
	'<DIV id="t_news'+update+key+'" class="t_news" style="cursor:pointer;font-size:120%;float: left;">'+
	'<A id=\'a_'+update+key+'\')">'+title+'('+mm+'/'+dd+')</A>'+
	'</DIV>'+
	'<DIV style="float: right;">'+s_link_icon+'</DIV>'+
	'<br />'+
	'<DIV id="m_news'+update+key+'" class="m_news" style="font-size:110%;line-height: 1.2em;padding-top: 2px;">'+
	'<P style="margin:15px;">'+message+'</P>'+
	'</DIV>'+
	'</LI>').appendTo('UL#news_tbl');

	if (news_display1 == "" && display1 != "none") {
		news_display1 = update+key;
	}

	$("#l_news"+update+key).hover(
		function(){
			// 対象オブジェクトに入った
			$("DIV#m_news"+update+key).fadeIn("normal");
			$("DIV#t_news"+update+key).css("font-weight","bold");
		},
		function(){
			$("DIV.m_news").css("display","none");
			$("DIV.t_news").css("font-weight","normal");
			// 対象オブジェクトから抜けた
		}
	);
}
/* お知らせ取得処理--------------------------------------------- */

/* 会社情報取得処理--------------------------------------------- */
// xmlファイル読み込み
function get_asa_prof_xml(){
	get_xml(".asa_prof","data/asa_prof.xml",parse_asa_prof_xml);
}
// xmlデータ解析
function parse_asa_prof_xml(xml,status){
	if(status!='success')return;
	$(xml).find('item').each(write_asa_prof_row);
}
function write_asa_prof_row(){
	var key=$(this).find('key').text();
	var name_ca=$(this).find('name_ca').text();
	var name=$(this).find('name').text();
	var zip_ca=$(this).find('zip_ca').text();
	var zip=$(this).find('zip').text();
	var address_ca=$(this).find('address_ca').text();
	var address=$(this).find('address').text();
	var tel_ca=$(this).find('tel_ca').text();
	var tel=$(this).find('tel').text();
	var fax_ca=$(this).find('fax_ca').text();
	var fax=$(this).find('fax').text();
	var mail_ca=$(this).find('mail_ca').text();
	var mail=$(this).find('mail').text();
	var mail_to=$(this).find('mail_to').text();
	var holiday_ca=$(this).find('holiday_ca').text();
	var holiday=$(this).find('holiday').text();
	$('.name').html(name);
	$('.zip_ca').html(zip_ca);
	$('.zip').html(zip);
	$('.address_ca').html(address_ca);
	$('.address').html(address);
	$('.tel_ca').html(tel_ca);
	$('.tel').html(tel);
	$('.fax_ca').html(fax_ca);
	$('.fax').html(fax);
	$('.mail_ca').html(mail_ca);
	$('.mail').html(mail);
	$('.mail_to').html(mail_to);
	$('.holiday_ca').html(holiday_ca);
	$('.holiday').html(holiday);
}
/* 会社情報取得処理--------------------------------------------- */

/* カテゴリー取得処理--------------------------------------------- */
// xmlファイル読み込み
function get_cate_xml(){
	get_xml("#categ_bd","data/category.xml",parse_cate_xml);
}
// xmlデータ解析
function parse_cate_xml(xml,status){
	if(status!='success')return;
	$(xml).find('item').each(write_cate_row);
}
/////////////////
// 1件分のデータをtable要素に追加
var c_work = "";
var w_href = "";
function write_cate_row(){

	var key=$(this).find('key').text();
	var name=$(this).find('name').text();
	var href=$(this).find('href').text();
	var show=$(this).find('show').text();

	c_work = "";
	w_href = href;
	$(this).find('c_item').each(write_cate_row1);

	$('<LI class="categ_li">'+
	'<DIV class="categ" id="'+ key +'"><A href=' + href + '>' + name + '</A></DIV>'+
	c_work +
	'</LI>').appendTo('UL#categ_tbl');

}
function write_cate_row1(){
	var c_key=$(this).find('c_key').text();
	var c_name=$(this).find('c_name').text();
	var c_lname=$(this).find('c_lname').text();
	c_work += '<DIV class="categ_c" id="'+ c_key +'"><A href="' + w_href + c_lname + '">' + c_name + '</A></DIV>';

}
/* カテゴリー取得処理--------------------------------------------- */
/* ヒントの表示--------------------------------------------- */
function f_showHint(hintId, event, bool){
	var style = document.getElementById(hintId).style;
	if(document.all){
		style.left = event.x + document.body.scrollLeft + 10;
		style.top  = event.y + document.body.scrollTop + 0;
	} else {
		style.left = event.x + 10;
		style.top  = event.y + 0;
	}
	style.display = (bool ? "block" : "none");
}
/* ヒントの表示--------------------------------------------- */

