// Life StudioブログJavaScript関数


// -------------------------------------------------------------
// *** ユーザブログ表示
// ** サムネイル一覧
function disp_blogs(arg1, arg2){
	dat="&top="+arg1+"&cust_category="+arg2;
	sendRequest(req_res, dat, 'post', 'blog/disp_blogs.php', true, true);
}
// ** リスト一覧
function disp_blogs_usr(arg1, arg2){
	dat="&top="+arg1+"&user_name="+arg2;
	sendRequest(req_res, dat, 'post', 'blog/disp_blogs_usr.php', true, true);
}

function disp_blogs_usr2b(arg1, arg2){
	dat="&top="+arg1+"&user_name="+arg2;
	sendRequest(req_res, dat, 'post', 'blog/disp_blogs_usrT.php', true, true);
}
// append Jae-min Ryu(ajjo@chol.com) - 2009-05-08
function disp_blogs_staff_top(arg1){
	dat="&top="+arg1;
	sendRequest(req_res, dat, 'post', 'blog/disp_blogs_main.php', true, true);
}
// ** 編集
function edit_blog(arg1,arg2){
	author=document.getElementById('author').value;
	author=chgMessHalf(author);

	email=document.getElementById('email').value;
	email=chgMessHalf(email);

	if(author==""){
		alert("このブログを編集するためには、投稿時に入力したNAMEの入力が必要です。")
	}else if(email==""){
		alert("このブログを編集するためには、投稿時に入力したE-MAILの入力が必要です。");
	}else{
		dat="&action=edit&post="+arg1+"&cat="+arg2+"&author="+author+"&email="+email;
		sendRequest(req_res, dat, 'post', 'blog/wp-admin/edit-post-usr.php', true, true);
	}
}
// ** 編集／削除画面表示
function edit_post(cat,action,post){
	dat='&cat='+cat+'&action='+action+'&post='+post;
	sendRequest(req_res, dat, 'post', 'blog/wp-admin/edit-post.php', true, true);
}
// *** 編集ユーザ認証
function auth_user_edit(arg1, arg2, arg3){
	author=document.getElementById('author').value;
	author=chgMessHalf(author);

	email=document.getElementById('email').value;
	email=chgMessHalf(email);

	if(author==""){
		alert("このブログを編集するためには、投稿時に入力したNAMEの入力が必要です。")
	}else if(email==""){
		alert("このブログを編集するためには、投稿時に入力したE-MAILの入力が必要です。");
	}else{
		dat="&action=edit&referer="+location.host+"&author="+author+"&email="+email+"&status="+arg1+"&post="+arg2+"&cat="+arg3;
		sendRequest(auth_res_edit, dat, 'post', 'auth_user_edit.php', true, true);
	}
}
function auth_res_edit(oj){
	var res = oj.responseText;
	acc = res.split("/");
	document.getElementById('log').value=acc[0];
	document.getElementById('pwd').value=acc[1];
	document.loginform.submit();
}
// ** 新着一覧
function disp_new_blog(arg1, arg2){
	dat="&top="+arg1+"&cust_category="+arg2;
	sendRequest(req_res, dat, 'post', 'blog/disp_new_blog.php', true, true);
}
// ** ブログ記事表示
function disp_blog(arg){
	dat="p="+arg;
	sendRequest(req_res, dat, 'post', 'blog/', true, true);
}
// ** ブログ削除
function del_blog(arg1,arg2){
	author=document.getElementById('author').value;
	author=chgMessHalf(author);

	email=document.getElementById('email').value;
	email=chgMessHalf(email);

	if(author==""){
		alert("このブログを削除するためには、投稿時に入力したNAMEの入力が必要です。")
	}else if(email==""){
		alert("このブログを削除するためには、投稿時に入力したE-MAILの入力が必要です。");
	}else{
		dat="&action="+arg2+"&post="+arg1+"&author="+author+"&email="+email;
		sendRequest(req_res, dat, 'post', 'blog/wp-admin/edit-post-usr.php', true, true);
	}
}
// ** ブログ検索
function search_blogs(arg1, arg2, arg3){
	if(arg3==""){
		alert("検索キーが入力されていません。");
	}else{
		dat="?cust_category="+arg1+"&column="+arg2+"&key="+arg3;
	//	sendRequest(req_res, dat, 'post', 'blog/disp_blogs.php', true, true);
		location.href=dat;
	}
}
// ** ブログ検索(USER)
function search_blogs_usr(arg1, arg2, arg3){
	if(arg3==""){
		alert("検索キーが入力されていません。");
	}else{
		dat="&user_name="+arg1+"&column="+arg2+"&key="+arg3;
		sendRequest(req_res, dat, 'post', 'blog/disp_blogs_usr.php', true, true);
	}
}

// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function req_res(oj){
	var res = oj.responseText;
	document.getElementById("blog_list").innerHTML=res;
}
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++


// ** スタッフ一覧表示
function disp_staffs(){
	sendRequest(staff_res, '', 'post', 'blog/disp_staffs.php', true, true);
}

// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function staff_res(oj){
	var res = oj.responseText;
	document.getElementById("RIGHT_SIDE_IN_BLO_TOP").innerHTML=res;
}
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++


// *** 
function post(cat){
	arg='cat='+cat;
	sendRequest(req_res, arg, 'post', 'blog/wp-admin/post-new.php', true, true);
}


// *** NEWS最新ブログ表示
function disp_news(site_url){
	dat="&cust_category=news";
	sendRequest(news_res, dat, 'post', site_url+'/disp_new.php', true, true);
}
function disp_news_top(site_url){
	dat="&cust_category=news";
	sendRequest(news_res, dat, 'post', site_url+'/disp_new.php', true, true);
}
function news_res(oj){
	var res = oj.responseText;
	document.getElementById("news").innerHTML=res;
}
function disp_event(site_url){
	dat="&cust_category=event";
	sendRequest(event_res, dat, 'post', site_url+'/disp_new.php', true, true);
}
function disp_event_top(site_url){
	dat="&cust_category=event";
	sendRequest(event_res, dat, 'post', site_url+'/disp_new.php', true, true);
}
function event_res(oj){
	var res = oj.responseText;
	document.getElementById("event").innerHTML=res;
}


// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++


var blog_id;
// ** コメント投稿
function comment_post(arg, site_url){
	author=document.getElementById('author').value;
	author=chgMessHalf(author);

	email=document.getElementById('email').value;
	email=chgMessHalf(email);
	data=email.match(/^\S+@\S+\.\S+$/);

	comment=document.commentform.comment.value;
	comment_post_ID=document.commentform.comment_post_ID.value;
	redirect_to=document.commentform.redirect_to.value;

	if(document.commentform.author.value==""){
		alert("「NAME」を入力して下さい。");
	}else if(document.commentform.email.value==""){
		alert("「E-MAIL」を入力して下さい。");
	}else if(!data){
		alert("「E-MAIL」が不正な値です。");
	}else if(document.commentform.comment.value==""){
		alert("「COMMENT」を入力して下さい。");
	}else{
		blog_id=arg;
		dat='&author='+author+'&email='+email+'&comment='+comment;
		var arr=[];
		arr['author']=author;
		arr['email']=email;
		arr['comment']=comment;
		arr['comment_post_ID']=comment_post_ID;
		arr['redirect_to']=redirect_to;
		sendRequest(comment_res, arr, 'post', site_url+'/wp-comments-post.php', false, true);
	//	disp_blog(arg);
	}
}


// ** コメント編集
function edit_comment(arg1,arg2,arg3,arg4){
	author=document.getElementById('author').value;
	author=chgMessHalf(author);

	email=document.getElementById('email').value;
	email=chgMessHalf(email);

	if(author==""){
		alert("このコメントを編集するためには、投稿時に入力したNAMEの入力が必要です。")
	}else if(email==""){
		alert("このコメントを編集するためには、投稿時に入力したE-MAILの入力が必要です。");
	}else{
	//	dat="&post="+arg1+"&comm="+arg2+"&action="+arg3+"&cat="+arg4+"&author="+author+"&email="+email;
	//	sendRequest(req_res, dat, 'post', 'wp-admin/edit_comment.php', true, true);
		dat="?post="+arg1+"&comm="+arg2+"&action="+arg3+"&cat="+arg4+"&author="+author+"&email="+email;
		location.href='comment.php'+dat;
	}
}


function update_comment(){
	comment_content=encodeURI(document.getElementById('comment_content').value);
	action=document.getElementById('action').value;
	comm=document.getElementById('com_id').value;
	cat=document.getElementById('cat').value;

//	dat="&action="+action+"&comment_content="+comment_content+"&comm="+comm;
//	sendRequest(req_res, dat, 'post', 'blog/wp-admin/edit_comment.php', true, true);
	//decodeURI('<?=mb_convert_encoding($m,"SJIS")?>');
	dat="?action="+action+"&comment_content="+comment_content+"&comm="+comm+"&cat="+cat;
	location.href='comment.php'+dat;
}

// ** コメント削除
function del_comment(arg1,arg2,arg3,arg4){
	author=document.getElementById('author').value;
	author=chgMessHalf(author);

	email=document.getElementById('email').value;
	email=chgMessHalf(email);

	if(author==""){
		alert("このコメントを削除するためには、投稿時に入力したNAMEの入力が必要です。")
	}else if(email==""){
		alert("このコメントを削除するためには、投稿時に入力したE-MAILの入力が必要です。");
	}else{
		dat="?post="+arg1+"&comm="+arg2+"&action="+arg3+"&cat="+arg4+"&author="+author+"&email="+email;
		location.href='comment.php'+dat;
	}

}

function comment_res(oj){
	var res = oj.responseText;
	err = res.indexOf("エラー");
	if(err>0) {
		res="<p id=\"err_msg\">"+res+"</p><p><a href='?p="+blog_id+"'>戻る</a></p>";
		document.getElementById("blog_list").innerHTML=res;
	}else{
		alert("コメントが投稿されました。\nありがとうございました。");
	//	disp_blog(blog_id);
		location.href="?p="+blog_id;
	}
}

function disp_blog(arg){
	dat="p="+arg;
	sendRequest(req_res, dat, 'post', 'blog/', true, true);
}

function comm_res(arg){
	disp_blog(arg);
}


// *** サムネイル用カテゴリのフォーム
function submit_form_thmb(){
	author=document.post.cust_name.value;
	author=chgMessHalf(author);

	email=document.post.cust_mail.value;
	email=chgMessHalf(email);
	data=email.match(/^\S+@\S+\.\S+$/); 

	if(document.post.cust_name.value==""){
		alert("「NAME」を入力して下さい。");
	}else if(document.post.cust_mail.value==""){
		alert("「E-MAIL」を入力して下さい。");
	}else if(!data){
		alert("「E-MAIL」の値が不正です。正しいメールアドレスを入力して下さい。");
	}else if(document.post.post_title.value==""){
		alert("「SUBJECT」を入力して下さい。");
	}else if(document.post.content.value==""){
		alert("「COMMENT」を入力して下さい。");
	}else if(document.post.cust_photo.value==""){
		alert("「PHOTO」を選択して下さい。");
	}else{
		document.post.cust_name.value=author;
		document.post.cust_mail.value=email;
		document.post.submit();
	}
}

// *** リスト用カテゴリのフォーム
function submit_form_list(){
	author=document.post.cust_name.value;
	author=chgMessHalf(author);

	email=document.post.cust_mail.value;
	email=chgMessHalf(email);
	data=email.match(/^\S+@\S+\.\S+$/); 

	if(document.post.cust_name.value==""){
		alert("「NAME」を入力して下さい。");
	}else if(document.post.cust_mail.value==""){
		alert("「E-MAIL」を入力して下さい。");
	}else if(!data){
		alert("「E-MAIL」の値が不正です。正しいメールアドレスを入力して下さい。");
	}else if(document.post.post_title.value==""){
		alert("「SUBJECT」を入力して下さい。");
	}else if(document.post.content.value==""){
		alert("「COMMENT」を入力して下さい。");
	}else{
		document.post.cust_name.value=author;
		document.post.cust_mail.value=email;
		document.post.submit();
	}
}


// *** ユーザ認証
function auth_user(){
	referer = "referer="+location.host;
	sendRequest(auth_res, referer, 'post', 'blog/auth_user.php', true, true);
}
function auth_res(oj){
	var res = oj.responseText;
	acc = res.split("/");
	document.loginform.log.value=acc[0];
	document.loginform.pwd.value=acc[1];
	document.loginform.submit();
}


// ------------------------------------------
var TimeOut         = 0;
var currentLayer    = null;
var currentitem     = null;
var currentLayerNum = 0;
var noClose         = 0;
var closeTimer      = null;
var layer;

function set_time(t){TimeOut=t; return false;}

function mopen(n) {
	var l  = document.getElementById("menu");
	var layer;

switch (n) {
	case "1":
		layer ="<ol class='page_menu_shop'>";
		layer +="<li><a href='../studio/index.html' class='onpage'>Point</a></li>";
		layer +="<li><a href='../studio/aoyama_interior.html'>Interior</a></li>";
		layer +="<li><a href='../studio/aoyama_board.html'>Board</a></li>";
		layer +="<li><a href='../studio/aoyama_map.html'>Map</a></li>";
		layer +="<li><a href='../best_photo/aoyama.html'>Best Photo</a></li>";
		layer +="</ol>";

		break;

	case "2":
		layer ="<ol class='page_menu_shop'>";
		layer +="<li><a href='../studio/tokorozawa_point.html' class='onpage'>Point</a></li>";
		layer +="<li><a href='../studio/tokorozawa_interior.html'>Interior</a></li>";
		layer +="<li><a href='../studio/tokorozawa_board.html'>Board</a></li>";
		layer +="<li><a href='../studio/tokorozawa_map.html'>Map</a></li>";
		layer +="<li><a href='../best_photo/tokorozawa.html'>Best Photo</a></li>";
		layer +="</ol>";
		break;

	case "3":
		layer ="<ol class='page_menu_shop'>";
		layer +="<li><a href='../studio/mito_point.html' class='onpage'>Point</a></li>";
		layer +="<li><a href='../studio/mito_interior.html'>Interior</a></li>";
		layer +="<li><a href='../studio/mito_board.html'>Board</a></li>";
		layer +="<li><a href='../studio/mito_map.html'>Map</a></li>";
		layer +="<li><a href='../best_photo/mito.html'>Best Photo</a></li>";
		layer +="</ol>";
		break;

	case "4":
		layer ="<ol class='page_menu_shop'>";
		layer +="<li><a href='../studio/nagoya_point.html' class='onpage'>Point</a></li>";
		layer +="<li><a href='../studio/nagoya_interior.html'>Interior</a></li>";
		layer +="<li><a href='../studio/nagoya_board.html'>Board</a></li>";
		layer +="<li><a href='../studio/nagoya_map.html'>Map</a></li>";
		layer +="<li><a href='../best_photo/nagoya.html'>Best Photo</a></li>";
		layer +="</ol>";
		break;

	case "5":
		layer ="<ol class='page_menu_shop'>";
		layer +="<li><a href='../studio/seijo_point.html' class='onpage'>Point</a></li>";
		layer +="<li><a href='../studio/seijo_interior.html'>Interior</a></li>";
		layer +="<li><a href='../studio/seijo_board.html'>Board</a></li>";
		layer +="<li><a href='../studio/seijo_map.html'>Map</a></li>";
		layer +="<li><a href='../best_photo/seijo.html'>Best Photo</a></li>";
		layer +="</ol>";
		break;

	case "6":
		layer ="<ol class='page_menu_shop'>";
		layer +="<li><a href='../studio/yokohama_point.html' class='onpage'>Point</a></li>";
		layer +="<li><a href='../studio/yokohama_interior.html'>Interior</a></li>";
		layer +="<li><a href='../studio/yokohama_board.html'>Board</a></li>";
		layer +="<li><a href='../studio/yokohama_map.html'>Map</a></li>";
		layer +="<li><a href='../best_photo/yokohama.html'>Best Photo</a></li>";
		layer +="</ol>";
		break;

	default:
		break;
}

	n=setTimeout(l.innerHTML=layer,10000);
	clearTimeout(n);

return false;

}






function mopen_anni(n) {
	var l  = document.getElementById("menu");
	var layer;

switch (n) {

	case "1":
		layer ="<ol class='page_menu_shop anniversary'>";
		layer +="<li><a href='index.html' class='onpage'>Point</a></li>";
		layer +="<li><a href='753_price.html'>price</a></li>";
		layer +="<li><a href='753_gallery.html'>Gallery</a></li>";
		layer +="</ol>";
		break;

	case "2":
		layer ="<ol class='page_menu_shop anniversary'>";
		layer +="<li><a href='20th_point.html' class='onpage'>Point</a></li>";
		layer +="<li><a href='20th_price.html'>price</a></li>";
		layer +="<li><a href='20th_gallery.html'>Gallery</a></li>";
		layer +="</ol>";
		break;

	case "3":
		layer ="<ol class='page_menu_shop anniversary'>";
		layer +="<li><a href='school_point.html' class='onpage'>Point</a></li>";
		layer +="<li><a href='school_gallery.html'>Gallery</a></li>";
		layer +="</ol>";
		break;

	default:
		break;
}

//    l.style.visibility='hidden';

	l.innerHTML = layer;

return false;

}


function mclosetime() {
  closeTimer = window.setTimeout(mclose, TimeOut);
}

function mcancelclosetime() {
  if(closeTimer) {
    window.clearTimeout(closeTimer);
    closeTimer = null;
  }
}

function mclose() {
  if(currentLayer && noClose!=1)   {
    currentLayer.style.visibility='hidden';
    currentLayerNum = 0;
    currentLayer = null;
    currentitem = null;
  } else {
    noClose = 0;
  }
  currentLayer = null;
  currentitem = null;
}

function openImageSizedWindow(src){
    // 画像をロードしてサイズを取得
    var i = new Image(); i.src = src;

	img_width	=i.width;
	img_height	=i.height;

    // 画像のサイズに合った空ウィンドウを開く
    var pop_win = window.open(
                      "",
                      "_blank",
                      "width="+img_width+",height="+img_height+",scrollbars=yes,resizable=yes"
                  );
    // 空ウィンドウに画像を出力するためのHTML
    pop_win.window.document.open();
    pop_win.window.document.write(
     '<html>'
    +'<head><title>'+i.alt+'</title></head>'
    +'<body style="margin:0;padding:0;border:0;">'
    +'<a href="javascript:window.close();">'
    +'<img src="'+i.src+'" border="0" alt="" />'
    +'</a>'
    +'</body>'
    +'</html>'
    );
    pop_win.window.document.close();
}

// *** 全角を半角に変換
function chgMessHalf(messIn){

//  messIn = document.chgForm.messIn.value;
  messOut = "";

  //半角カナ用
  for(i=0; i<halfArr.length; i++){
    reg = new RegExp(fullArr[i],"g"); 
    messIn = messIn.replace(reg, halfArr[i]);
  }

  for(i=0; i<messIn.length; i++){
    oneStr = messIn.charAt(i);
    num = full.indexOf(oneStr,0);
    oneStr = num >= 0 ? half.charAt(num) : oneStr;
    messOut += oneStr;
  }

  //改行コード削除
  kaigyo();

//	document.chgForm.messOut.value = messOut;
  return messOut;
}//end chgMessHalf



//文字定義
half = "0123456789";
half += "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
half += "abcdefghijklmnopqrstuvwxyz";
half += "-+_@., ";
halfArr = new Array("ヴ","ガ","ギ","グ","ゲ","ゴ","ザ","ジ","ズ","ゼ","ゾ","ダ","ヂ","ヅ","デ","ド","バ","ビ","ブ","ベ","ボ","パ","ピ","プ","ペ","ポ");

full = "０１２３４５６７８９";
full += "ＡＢＣＤＥＦＧＨＩＪＫＬＭＮＯＰＱＲＳＴＵＶＷＸＹＺ";
full += "ａｂｃｄｅｆｇｈｉｊｋｌｍｎｏｐｑｒｓｔｕｖｗｘｙｚ";
full += "－＋＿＠．，　";
fullArr = new Array("ｳﾞ","ｶﾞ","ｷﾞ","ｸﾞ","ｹﾞ","ｺﾞ","ｻﾞ","ｼﾞ","ｽﾞ","ｾﾞ","ｿﾞ","ﾀﾞ","ﾁﾞ","ﾂﾞ","ﾃﾞ","ﾄﾞ","ﾊﾞ","ﾋﾞ","ﾌﾞ","ﾍﾞ","ﾎﾞ","ﾊﾟ","ﾋﾟ","ﾌﾟ","ﾍﾟ","ﾎﾟ");


function kaigyo(){

  while(messOut.indexOf("\r",0) >= 0 || messOut.indexOf("\n",0) >= 0){
    messOut = messOut.replace("\r","");
    messOut = messOut.replace("\n","");
  }

}//end kaigyo

// flash movie play
function jiyugaokaPoint() {
	var _object_ = "";
	_object_ += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="600" height="400" align="middle">';
	_object_ += '<param name="movie" value="final.swf" />';
	_object_ += '<param name="quality" value="high" />';
	_object_ += '<param name="wmode" value="transparent" />';
	_object_ += '<param name="bgcolor" value="#ffffff" />';
	_object_ += '<embed src="final.swf" quality="high" wmode="transparent" bgcolor="#ffffff" width="600" height="400" align="middle" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	_object_ += '</object>';
	document.getElementById('jiyugaoka-point').innerHTML = _object_;
}