﻿function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

//*****     本文検索画面（page_lst） ******
//メニューを変更したとき
function c_m_id_body_lst(m){
	f= document.forms[0];

	location.href='01_page_lst.php' +
					'?m_id=' + m + 
					'&title=' + encodeURI(f.title.value) + 
					'&body=' + encodeURI(f.body.value) + 
					'&topics_kbn=' + encodeURI(f.topics_kbn.value) + 
					'&valid_kbn=' + encodeURI(f.valid_kbn.value) + 
					'&sort_order=' + encodeURI(f.sort_order.value) + 
					'&disp_cnt=' + encodeURI(f.disp_cnt.value);



}
//*****     本文検索画面（link_search） ******
//メニューを変更したとき
function c_m_id_search(f,m){
	var v;
	for(i=0; i<3;i++){
		if(f.valid_kbn[i].checked){
			v=f.valid_kbn[i].value;
		}
	}
	//location.href='link_search.php?m_id=' + m + '&title=' + encodeURI(f.title.value) + '&body=' + encodeURI(f.body.value) + '&valid_kbn=' + v;
}

//*****     本文検索画面（page_edt） ******
//メニューを変更したとき
function c_m_id_body_add(m){
	var v,f,tk,tak,ip,iText;

	f= document.forms[0];

	//var getDocument = document.getElementById("wysiwygbody").contentWindow.document;
	//var browserName = navigator.appName;
	// View Text for IE 	  	 

	//if(browserName == "Microsoft Internet Explorer") {
    	//iText = getDocument.body.innerText;
	//}else{
		// View Text for Mozilla/Netscape
 		//var html = getDocument.body.ownerDocument.createRange();
		//html.selectNodeContents(getDocument.body);
		//iText = html.toString();
	//}

	//本文
	iText = document.getElementById("wysiwygbody").contentWindow.document.body.innerHTML;

	//新着情報表示区分
	for(i=0; i<2;i++){
		if(f.topics_kbn[i].checked){
			tk=f.topics_kbn[i].value;
		}
	}

	//公開区分
	for(i=0; i<2;i++){
		if(f.valid_kbn[i].checked){
			v=f.valid_kbn[i].value;
		}
	}

	//リンク方法
	for(i=0; i<2;i++){
		if(f.target_kbn[i].checked){
			tak=f.target_kbn[i].value;
		}
	}

	//画像配置
	for(i=0; i<4;i++){
		if(f.image_position[i].checked){
			ip=f.image_position[i].value;
		}
	}

	location.href='01_page_edt.php?mode=insert' +
					'&m_id=' + m + 
					'&valid_kbn=' + v + 
					'&title_type=' + encodeURI(f.title_type.value) + 
					'&title=' + encodeURI(f.title.value) + 
					'&body=' + encodeURI(iText) + 
					'&page_kbn=' + encodeURI(f.page_kbn.value) + 
					'&br_kbn=' + encodeURI(f.br_kbn.value) + 
					'&topics_kbn=' + tk + 
					'&topics_message=' + encodeURI(f.topics_message.value) + 
					'&keyword=' + encodeURI(f.keyword.value) + 
					'&description=' + encodeURI(f.description.value) + 
					'&topics_date=' + encodeURI(f.topics_date.value) + 
					'&title_type=' + encodeURI(f.title_type.value) + 
					'&image_type=' + encodeURI(f.image_type.value) + 
					'&image_position=' + ip + 
					'&url=' + encodeURI(f.url.value) + 
					'&disp_width=' + encodeURI(f.disp_width.value) + 
					'&target_kbn=' + tak + 
					'&s_m_id=' + encodeURI(f.s_m_id.value) + 
					'&s_c_id=' + encodeURI(f.s_c_id.value) + 
					'&s_title=' + encodeURI(f.s_title.value) + 
					'&s_body=' + encodeURI(f.s_body.value) + 
					'&s_valid_kbn=' + encodeURI(f.s_valid_kbn.value);
}
//メニューを変更したとき
function c_m_id_body_edt(m,p){
	location.href='01_page_edt.php?mode=update&proc=4' +
					'&m_id=' + m + 
					'&p_id=' + p;
}
//メニューを変更したとき
function c_m_id_body_edt_old(m,p){
	var v,f,tk,tak,ip,iText;

	f= document.forms[0];

	//var getDocument = document.getElementById("wysiwygbody").contentWindow.document;
	//var browserName = navigator.appName;
	// View Text for IE 	  	 

	//if(browserName == "Microsoft Internet Explorer") {
    	//iText = getDocument.body.innerText;
	//}else{
		// View Text for Mozilla/Netscape
 		//var html = getDocument.body.ownerDocument.createRange();
		//html.selectNodeContents(getDocument.body);
		//iText = html.toString();
	//}

	//本文
	iText = document.getElementById("wysiwygbody").contentWindow.document.body.innerHTML;

alert(encodeURI(iText));
alert(encodeURI(f.title.value));

	//新着情報表示区分
	for(i=0; i<2;i++){
		if(f.topics_kbn[i].checked){
			tk=f.topics_kbn[i].value;
		}
	}

	//公開区分
	for(i=0; i<2;i++){
		if(f.valid_kbn[i].checked){
			v=f.valid_kbn[i].value;
		}
	}

	//リンク方法
	for(i=0; i<2;i++){
		if(f.target_kbn[i].checked){
			tak=f.target_kbn[i].value;
		}
	}

	//画像配置
	for(i=0; i<4;i++){
		if(f.image_position[i].checked){
			ip=f.image_position[i].value;
		}
	}

	location.href='01_page_edt.php?mode=update&proc=4' +
					'&m_id=' + m + 
					'&p_id=' + p + 
					'&valid_kbn=' + v + 
					'&title_type=' + encodeURI(f.title_type.value) + 
					'&title=' + encodeURI(f.title.value) + 
					'&body=' + encodeURI(iText) + 
					'&page_kbn=' + encodeURI(f.page_kbn.value) + 
					'&br_kbn=' + encodeURI(f.br_kbn.value) + 
					'&topics_kbn=' + tk + 
					'&topics_message=' + encodeURI(f.topics_message.value) + 
					'&keyword=' + encodeURI(f.keyword.value) + 
					'&description=' + encodeURI(f.description.value) + 
					'&topics_date=' + encodeURI(f.topics_date.value) + 
					'&title_type=' + encodeURI(f.title_type.value) + 
					'&image_type=' + encodeURI(f.image_type.value) + 
					'&image_width=' + encodeURI(f.image_width.value) + 
					'&image_position=' + ip + 
					'&url=' + encodeURI(f.url.value) + 
					'&disp_width=' + encodeURI(f.disp_width.value) + 
					'&target_kbn=' + tak + 
					'&s_m_id=' + encodeURI(f.s_m_id.value) + 
					'&s_c_id=' + encodeURI(f.s_c_id.value) + 
					'&s_title=' + encodeURI(f.s_title.value) + 
					'&s_body=' + encodeURI(f.s_body.value) + 
					'&s_valid_kbn=' + encodeURI(f.s_valid_kbn.value);
}

//データを削除しようとしたとき
function DelDataConfirm(){
  var f;
  f= document.forms[0];
  if(f.proc[1].checked){
	return confirm('データを削除してもよろしいですか？');
  }
  return true;
}

//データを削除しようとしたとき
function DelPageConfirm(){
  var f;
  f= document.forms[0];
  if(typeof f.proc[1]=='undefined'){
	  if(viewTextMode=='1'){
		alert('ページ内容を「HTMLタグの表示」モードで編集しています。「HTMLタグの表示」ボタンをクリックしてから処理を行ってください。');
	   	return false;
	  }
  }else{
    if(f.proc[1].checked){
  		return confirm('データを削除してもよろしいですか？');
	}else if(f.proc[2].checked){
		return confirm('このページをコピーして、新しいページを作成しますか？');
    }else{
		if(viewTextMode=='1'){
			alert('ページ内容を「HTMLタグの表示」モードで編集しています。「HTMLタグの表示」ボタンをクリックしてから処理を行ってください。');
		   	return false;
		}
    }
  }
  return true;
}
//データを削除しようとしたとき
function DelDataConfirm_old(f){
  if(f.proc[1].checked){
  	if(confirm('データを削除してもよろしいですか？')){
    	f.submit();
    }else{
    	return false;
    }
  }
  f.submit();
}
//処理を実行しようとしたとき
function ExecConfirm(){
  var f;
  f= document.forms[0];
  if(confirm('処理を実行してもよろしいですか？')){
    f.submit();
  }else{
  	return false;
  }
}
//処理を実行しようとしたとき
function ExecConfirm2(){
  var f;
  f= document.forms[1];
  if(confirm('処理を実行してもよろしいですか？')){
    f.submit();
  }else{
  	return false;
  }
}

//*****     問合せ管理（inq_edt） ******
function SendAskConfirm(f){
  	if(f.proc[1].checked){
		alert('処理に「削除」を選択している場合は、メールの返信ができません。');
		return false;
	}
	if(f.replay_to.value==''){
		alert('メールの宛先を入力してください。');
		return false;
	}
  	if(confirm('「' + f.replay_to.value + '」宛にメールを送信してもよろしいですか？')){
  		if(f.replay_kbn[0].checked){
		   	if(confirm('既にメールを送信していますが、送信しますか？')){
				Dialog.info("<center><br>送信中です。<br><br>しばらくお待ちください。</center>",{width:250,height:100,showProgress:true} );
		    	f.submit();
		    }else{
		    	return false;
		    }
  		}else{
			Dialog.info("<center><br>送信中です。<br><br>しばらくお待ちください。</center>",{width:250,height:100,showProgress:true} );
  			f.submit();
  		}
    }else{
    	return false;
    }
}
//*****     並び替え設定（sort_lst） ******
//ページ区分を変更したとき
function c_page_kbn_sort_lst(f,m){
	location.href='01_sort_lst.php?page_kbn=' + f.page_kbn.value;
}

//*****     並び替え設定（sort_lst） ******
//メニューを変更したとき
function c_m_id_sort_lst(f,m){
	location.href='01_sort_lst.php?m_id=' + m + '&page_kbn=' + f.page_kbn.value;
}

//*****     画像の消去 ******
function del_image(m,id){
    if(confirm('画像を削除してもよろしいですか？')){
    	location.href='image_delete.php?m=' + m + '&id=' + id;
    }
}

//*****    リンク先画面の検索 　******
function link_search(){
    window.open('link_search.php','','dependent=yes,width=750,height=880,top=0,left=0,scrollbars=yes,status=yes');
}
//*****    リンク先画面の選択 　******
function link_select(address){
  window.opener.document.form.url.value=address;
  window.close();
}
//*****    画像選択 　******
function seturl(url){
	window.opener.document.trigger.imageurl.value=url;
	window.close();
}

//*****    本文のモードチェック 　******
function CheckMode(){
  if(viewTextMode=='1'){
	alert('本文が「TEXT」モードで編集しています。登録するには「HTML」モードに変更してください');
   	return false;
  }

}
//*****    カレンダー画面の表示 　******
function open_calendar(d,m){
    window.open('calendar.php?d='+d+'&m='+m,'','dependent=yes,width=230,height=300,scrollbars=no,status=no');
}
//*****    日付選択 　******
function set_date(d,m){
	switch(m){
		case '1':
			window.opener.document.form.topics_date.value=d;
	　　	break;
		case '2':
			window.opener.document.form.from_date.value=d;
	　　	break;
		case '3':
			window.opener.document.form.to_date.value=d;
	　　	break;
		default:
			break;
	}
	window.close();
}
function image_open(){
    window.open('index.php','','dependent=yes,width=750,height=750,top=0,left=0,scrollbars=yes,status=yes');
}

//*****    IPアドレスの検索 　******
function ip_search_olf(ip){
	var url;
	url='ip_search.php?ip=' + ip;
    window.open(url,'','dependent=yes,width=400,height=100,top=0,left=0,scrollbars=no,status=no');
}
function ip_search(event,ip){
	var host_name;
	var leftPos;
	var TopPos;

    //IE用
    if(window.ActiveXObject){
        try {
            //MSXML2以降用
            var httpObj = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                //旧MSXML用
                var httpObj = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e2) {
                var httpObj = null;
            }
         }
    } else if(window.XMLHttpRequest){
        //IE以外のXMLHttpRequestオブジェクト実装ブラウザ用
        var httpObj = new XMLHttpRequest();
    } else {
        var httpObj = null;
    }

	var url = "ip_search.php?ip=" + ip;
	httpObj.open("GET",url, true);

	httpObj.onreadystatechange = function(){
	    if(httpObj.readyState == 4){
	        host_name =httpObj.responseText;

			var obj = document.getElementById('host_name');
			var obj2 = document.getElementById('host_name_content');
			obj2.innerHTML = host_name;
			obj.style.display = 'block';
			var st = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
			if(navigator.userAgent.toLowerCase().indexOf('safari')>=0)st=0; 

			if(leftPos<0)leftPos = 0;
			obj.style.left = leftPos + 'px';
			obj.style.top = TopPos - obj.offsetHeight -15 + st + 'px';
	    }
	}
	leftPos = event.clientX;
	TopPos = event.clientY;
	httpObj.send(null);

}
function hideHostName()
{
	document.getElementById('host_name').style.display = 'none';
}


function PopupBanner(e,id){
	var obj = document.getElementById(id);
	obj.style.display = 'block';

	if(navigator.userAgent.toLowerCase().indexOf('firefox')>=0){
		obj.style.left = 270;
	}else{
		obj.style.left = 250;
	}

}

function OffPopupBanner(id){
	document.getElementById(id).style.display='none';
}

function disp_help(e,msg){
	var obj = document.getElementById('help');
	var obj2 = document.getElementById('help_content');
	obj2.innerHTML = msg;
	obj.style.display = 'block';
	var st = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
	if(navigator.userAgent.toLowerCase().indexOf('safari')>=0)st=0; 
	var leftPos = e.clientX;
	if(leftPos<0)leftPos = 0;
	obj.style.left = leftPos + 'px';
	obj.style.top = e.clientY - obj.offsetHeight -15 + st + 'px';
}
function disp_help_left(e,msg){
	var obj = document.getElementById('help');
	var obj2 = document.getElementById('help_content');
	obj2.innerHTML = msg;
	obj.style.display = 'block';
	var st = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
	if(navigator.userAgent.toLowerCase().indexOf('safari')>=0)st=0; 
	var leftPos = e.clientX;
	if(leftPos<0)leftPos = 0;
	obj.style.left = leftPos -100 + 'px';
	obj.style.top = e.clientY - obj.offsetHeight -15 + st + 'px';
}
function hide_help()
{
	document.getElementById('help').style.display = 'none';	
}
//*****    カレンダー画面の表示 　******
function open_color(m){
    window.open('select_font_color.php?m='+m,'','dependent=yes,width=210,height=165,scrollbars=0,status=0,location=0');
}
/* ---------------------------------------------------------------------- *\
  Function    : selectColor()
  Description : Selects the color and inserts it into the WYSIWYG
\* ---------------------------------------------------------------------- */

