var myStat = function() {
this.put = function(ins){ this.cache=ins }
this.get = function(){ return this.cache }
}

var editstat = new myStat();

var cacheEditInPlace = function() {
this.cacheEdit=new Object();
this.put = function(elms,obj){ this.cacheEdit[elms]=obj }
this.chk = function(elms){
	if(this.cacheEdit[elms]){ return true } else { return false }
}
this.set = function(elms){
	//alert(this.cache[elms]);
	if(this.cacheEdit[elms]){
		this.cacheEdit[elms]._saveOrigText();
	}
}
this.delall = function(){
for (var i in this.cacheEdit) {
if($(i)){
this.del(i);
}
}
}
this.del = function(elms){
if(this.cacheEdit[elms]) {
this.cacheEdit[elms].removeEdit();
delete this.cacheEdit[elms];
}
}
}
var editfin = new cacheEditInPlace();
var cacheDraggables = function() {
this.cache=[];
this.put = function(elms){
var ab={
handle     : elms,
starteffect: function(element) { 
new Effect.Opacity(element, {duration:0.0, from:1.0, to:0.7}); 
},
endeffect  : function(element){ 
new Effect.Opacity(element, {duration:0.0, from:0.7, to:1.0}); 
},
revert :true
}
this.cache[elms]=new Draggable(elms, ab);
}
this.chk = function(elms){
	if(this.cache[elms]){ return true } else { return false }
}
this.del = function(elms){
if(this.cache[elms]) {
this.cache[elms].destroy();
delete this.cache[elms];
}
}
}
var drags = new cacheDraggables();
var cacheDroppables = function() {
this.cache=new Object();
this.put = function(elms){
//alert('cacheDroppables: '+elms);
if(elms == 'block0'){
Droppables.add(elms,
	{ accept: 'pages',
	onDrop: function( dragElement, dropElement, event ){
	chgContent(dragElement.id,'block');
	addpagetitle(dragElement);
	},
	hoverclass: 'drops'
	});
} else {
Droppables.add(elms,
	{ accept: 'pages',
	onDrop: function( dragElement, dropElement, event ){
	chgContent(dragElement.id,'block');
	addparts(dragElement);
	},
	hoverclass: 'drops'
	});
}
this.cache[elms]=1;
}
this.chk = function(elms){
	if(this.cache[elms]){ return true } else { return false }
}
this.delall=function(){
//alert('delall: '+this.cache.length);
for (var i in this.cache) {
//alert(i+': '+$(i));
if($(i)){
Droppables.remove(i);
Draggables.removeObserver(i);
delete this.cache[i];
}
}
}
this.del = function(elms){
if(this.cache[elms]) {
Droppables.remove(elms);
this.cache[elms]='';
}
}
}
var drops = new cacheDroppables();

var CropImageManager = {
curCrop: null,
init: function() {
this.attachCropper();
},
onChange: function( e ) {
var vals = $F( Event.element( e ) ).split('|');
this.setImage( vals[0], vals[1], vals[2] ); 
},
setImage: function( imgSrc, w, h ) {
$( 'testImage' ).src = imgSrc;
$( 'testImage' ).width = w;
$( 'testImage' ).height = h;
this.attachCropper();
},
attachCropper: function() {
if( this.curCrop == null ) this.curCrop = new Cropper.Img( 'testImage', { onEndCrop: onEndCrop } );
else this.curCrop.reset();
},
removeCropper: function() {
//alert(this.curCrop);
if( this.curCrop != null ) {
this.curCrop.remove();
this.curCrop=null;
}
},
resetCropper: function() {
this.attachCropper();
},
restructCropper: function(x1,y1,x2,y2){
if( this.curCrop == null ) this.attachCropper();
this.curCrop.options.onloadCoords={ x1: x1, y1: y1, x2: x2, y2: y2 };
this.curCrop.reset();
this.curCrop.selArea.show();
this.curCrop.drawArea();
}
};
var SlideManager = {
curSlide: null,
init: function() {
//alert('SlideManager.init');
this.attachSlider();
},
attachSlider: function() {
//alert($('cropW').innerHTML);
if( this.curSlide == null ) {
this.curSlide =  new Control.Slider('resizeHandle','resizeTrack', { 
axis:'horizontal', 
range:$R(10,100), 
sliderValue:100,
alignX: -200,
onSlide: function(v) { scaleIt(v, parseInt($('cropW').innerHTML)); },
onChange: function(v) { saveChange(); }
});
}// else { this.curSlide.setEnabled(); }
},
removeSlider: function() {
if( this.curSlide != null ) {
this.curSlide.dispose();
this.curSlide=null;
}
},
resetSlide: function() {
this.attachSlide();
},
setDisabled: function(){
this.curSlide.setDisabled();
},
setEnabled: function(){
if(this.curSlide.alignX !=-200){
this.curSlide.alignX=-200;
}
this.curSlide.setEnabled();
}
};
hashHists.onHistChanged = function () {
var hash=document.location.hash==""? '#0':document.location.hash;
var nows=hash.substring(1,hash.length);
//alert(nows);
	aryPos=nows;
	eval(histAry[parseInt(nows)]);
};
function resetediter(docsrl){
if($('block'+docsrl) || $('cmm'+docsrl)){
//alert('resetediter');
drops.delall();
editfin.delall();
if($('block'+docsrl)){
drags.del('page_graph');
drags.del('page_link');
drags.del('page_attach');
drags.del('page_holi');
}
}
}
function openlogin(){
chgContent('login_form');
chgContent('addpart','block');
chgContent('addpage','block');
if(user.mid == 'h_maro'){
chgContent('openedit','none');
Event.stopObserving(window,'scroll',setaddparttop);
} else {
chgContent('openedit2','block');
chgContent('fileup2','block');
}
$('login_mid').focus();
}
function dologin(msg){
chgContent('loginbtn','none');
chgContent('login_form','none');
$('page_new').hide();
$('page_add').hide();
chgContent('loginname','block');
$('loginname').update('');
chgContent('addpart','block');
chgContent('addpage','block');
if(user.mid == 'h_maro'){
chgContent('openedit','none');
Event.stopObserving(window,'scroll',setaddparttop);
} else {
chgContent('openedit2','block');
chgContent('fileup2','block');
}
showsucerr(msg,1);
}
function gologin(form){
if(form.mid.value=='' || form.pass.value==''){
showsucerr('ユーザＩＤとパスワードを入力してください',1);
} else {
var loginscr='login("'+form.mid.value+'","'+form.pass.value+'","",'+(form.cookie.checked? 1:0)+')';
aryPos++;
if(histAry[aryPos] !='' && histAry[aryPos] !=loginscr){
histAry=histAry.slice(0,aryPos);
}
histAry[aryPos]=loginscr;
hashHists.setHist(aryPos);
//aryPos++;
//login(form.mid.value,form.pass.value,'',(form.cookie.checked? 1:0));
}
}
function login(mid,pass,uniq,cookie) {
//HistDriv.addFunction("login('"+mid+"','"+pass+"','"+uniq+"',"+(cookie? 1:0)+")");
chgContent('addpart','block');
chgContent('addpage','block');
if(user.mid == 'h_maro'){
chgContent('openedit','none');
Event.stopObserving(window,'scroll',setaddparttop);
} else {
chgContent('openedit2','block');
chgContent('fileup2','block');
}
chgContent('loginbtn','block');
chgContent('login_form','block');
chgContent('loginname','none');
//alert(cookie);
$('loginname').update('<img src="/nakamura2/rel/ajax-loader2.gif" width="16" height="16">送信中....');
//chgContent('openedit','none');
var url = '/seek/login.pl';
var myAjax = new Ajax.Request(url, {
method: 'post', 
parameters: 'mid='+mid+'&pass='+pass+'&uniq='+uniq+'&cookie='+cookie, 
onSuccess: function (originalRequest) {
//alert(originalRequest.responseText);
originalRequest.responseText.evalScripts();
},
onFailure: function (originalRequest) {
dologin('読み込みに失敗しました');
},
onException: function (originalRequest) {
dologin('読み込み中にエラーが発生しました');
}
});
}
function sendform(form,perls,query,nowait){
chgContent('addpart','block');
chgContent('addpage','block');
if(user.mid == 'h_maro'){
chgContent('openedit','none');
Event.stopObserving(window,'scroll',setaddparttop);
} else {
chgContent('openedit2','block');
chgContent('fileup2','block');
}
closesuccer();
if(!perls){
perls='estindex';
}
if(query ==undefined) query='';
if(!nowait){
showWaitBars();
}
//alert(query);
if(form.uniq){
form.uniq.value=user.uniq;
}
if(perls=='estindex' && (!query || !query.match(/^search/))){
if(serv.page){
query+=(query? '&':'')+'page='+serv.page;
} else if(serv.genre){
query+=(query? '&':'')+'genre='+serv.genre;
} else if(serv.cate){
query+=(query? '&':'')+'cate='+serv.cate;
}
}
var url = '/seek/'+perls+'.pl';
var pars = Form.serialize(form.id)+(query? '&'+query:'');
var myAjax = new Ajax.Updater(
'results',
url, 
{
method: 'post', 
parameters: pars, 
onSuccess: function (originalRequest) {
//hideWaitBars();
},
onFailure: failures,
onException: exceptions,
evalScripts: true
});
//evalScripts: true
}
function sendreq(form,perls,query,nowait){
chgContent('addpart','block');
chgContent('addpage','block');
if(user.mid == 'h_maro'){
chgContent('openedit','none');
} else {
chgContent('openedit2','block');
chgContent('fileup2','block');
}
Event.stopObserving(window,'scroll',setaddparttop);
closesuccer();
//waitwins();
if(form.uniq){
form.uniq.value=user.uniq;
}
var url = '/seek/'+perls+'.pl';
var pars = Form.serialize(form.id)+(query? '&'+query:'');
var myAjax = new Ajax.Request(
url, 
{
method: 'post', 
parameters: pars, 
onSuccess: function (originalRequest) {
closesuccer();
//alert(originalRequest.responseText);
originalRequest.responseText.evalScripts();
},
onFailure: failures,
onException: exceptions
});
}
function sendquery(perls,qstr,nohide){
chgContent('addpart','block');
chgContent('addpage','block');
if(user.mid == 'h_maro'){
chgContent('openedit','none');
Event.stopObserving(window,'scroll',setaddparttop);
} else {
chgContent('openedit2','block');
chgContent('fileup2','block');
}
closesuccer();
showWaitBars();
//alert(qstr);
var url = '/seek/'+perls+'.pl';
var pars = 'uniq='+user.uniq+(qstr? ('&'+qstr):'');
var myAjax = new Ajax.Request(
url, 
{
method: 'post', 
parameters: pars, 
onSuccess: function (originalRequest) {
if(!nohide){
hideWaitBars();
}
originalRequest.responseText.evalScripts();
},
onFailure: failures,
onException: function (a,exp) { exceptions(exp) }
});
}
function viewlink(perl,qstr,noer,divs){
	if(perl=='estindex'){
		var hist="openlink('"+perl+"','"+(qstr? qstr:'')+"',"+(noer? 1:0)+",'";
		hist +=(divs? divs:'')+"')";
		aryPos++;
		if(histAry[aryPos] !='' && histAry[aryPos] !=hist){
			histAry=histAry.slice(0,aryPos);
		}
		histAry[aryPos]=hist;
		hashHists.setHist(aryPos);
		//HistDriv.addFunction("viewlink("+hist+")");
	} else {
		openlink(perl,qstr,noer,divs);
	}
}
function openlink(perl,qstr,noer,divs){
editfin.delall();
drops.delall();
chgContent('addpart','block');
chgContent('addpage','block');
if(user.mid == 'h_maro'){
chgContent('openedit','none');
Event.stopObserving(window,'scroll',setaddparttop);
} else if(user.mid) {
chgContent('openedit2','none');
if(serv.page || serv.docsrl){
chgContent('fileup2','none');
}
}
chgContent('subtitles','block');
if(!noer){
closesuccer();
}
if(!divs){
divs='results';
}
if(perl !='estindex'){
showWaitBars();
} else {
showIndicator();
}
var url = '/seek/'+perl+'.pl';
var pars = 'uniq='+user.uniq+(qstr? ('&'+qstr):'');
var myAjax = new Ajax.Updater(
divs,
url, 
{
method: 'post', 
parameters: pars, 
onSuccess: function (originalRequest) {
//hideWaitBars();
//if(perl =='estindex'){
//hideIndicator();
//}
},
onFailure: failures,
onException: exceptions,
evalScripts: true
});
}
function inittmpl(tmpl){
if(confirm('テンプレート（'+tmpl+'）を初期化します。'+"\n"+'取り消しはできません。')){
showWaitBars();
//alert(query);
var url = '/seek/template.pl';
var pars = 'uniq='+user.uniq+'&del=1&tmplname='+tmpl;
var myAjax = new Ajax.Updater(
'results',
url, 
{
method: 'post', 
parameters: pars, 
onSuccess: function (originalRequest) {
hideWaitBars();
},
onFailure: failures,
onException: exceptions,
evalScripts: true
});

}
}
function searchedit(){
new Ajax.Updater(
'edit_list',
'/seek/searchedit.pl',
{
parameters: 'uniq='+user.uniq,
onFailure: function() { $('edit_list').update('読込みエラー'); },
onException: function(a,exp) { $('edit_list').update('解析エラー'); },
evalScripts: true
});
}
function showIndicator(){
var imgs = $(document.createElement('IMG'));
imgs.id = 'spinner';
imgs.setStyle({ width: '50px', height: '50px', position: 'absolute', zIndex: '500' });
imgs.src = '/nakamura2/rel/spinner.gif';
var body_tag = document.getElementsByTagName('body')[0];
body_tag.appendChild(imgs);
setcenter('spinner');
}
function hideIndicator(){
$('spinner').remove();
}
function sysfileup(form){
form.uniq.value=user.uniq;
form.submit();
}
function fileselector(form) {}
function closuploader() {
closewin('uploader');
}
function newpost(perl,qstr){
if(serv.genre){
qstr+=(qstr? '&':'')+'genre='+serv.genre;
} else if(serv.cate){
qstr+=(qstr? '&':'')+'cate='+serv.cate;
}
viewlink(perl,qstr);
}
function viewprev(form){
if(form.genre.options[form.genre.selectedIndex].value == ''){
alert('ジャンルが選択されていません');
} else if(form.cate.type=='select-one' && 
	form.cate.options[form.cate.selectedIndex].value == ''){
alert('カテゴリが選択されていません');
} else if(form.cate.value=='') {
alert('カテゴリの設定が異常です');
} else if(form.jtitle.value=='') {
alert('タイトルが未入力です');
} else if(form.jbody.value=='') {
alert('本文（詳細）が未入力です');
} else {
showWaiteBars();
form.uniq.value = user.uniq;
form.submit();
}
}
function appendopt(slct){
document.getElementById('q'+slct).innerHTML='';
var optary=new Array();
var firstopt, text;
firstopt = document.createElement("OPTION");
firstopt.setAttribute('value','');
if(slct=='genre'){
optary=genreary;
text = document.createTextNode('ジャンル');
firstopt.appendChild(text, null);
} else if(slct=='cate'){
optary=cateary;
text = document.createTextNode('カテゴリ');
firstopt.appendChild(text, null);
} else if(slct=='mid'){
optary=midary;
text = document.createTextNode('投稿者');
firstopt.appendChild(text, null);
}
document.getElementById('q'+slct).appendChild(firstopt, null);
var opt;
for (var i=0; i < optary.length; i++){
opt = document.createElement("OPTION");
opt.setAttribute('value',optary[i].val);
text = document.createTextNode(optary[i].jname);
opt.appendChild(text, null);
document.getElementById('q'+slct).appendChild(opt, null);
}
}
function drawscenario(scenario,divs,inp){
for(var i=0; i < scenario.length; i++){
if(scenario[i].name == 'sendbtn'){
var span=document.createElement("SPAN");
span.setAttribute('class','right');
span.setAttribute('style','width: 285px');
if(inp){
var input=document.createElement("INPUT");
input.setAttribute('name','save');
input.setAttribute('value',1);
input.setAttribute('type','hidden');
span.appendChild(input, null);
var btn=document.createElement("INPUT");
btn.setAttribute('value','送信');
btn.setAttribute('type','button');
btn.setAttribute('onclick',scenario[i].value+('scenario'));
span.appendChild(btn, null);
var lf = document.createTextNode(" | ");
document.getElementById(div).appendChild(lf, null);
var bak=document.createElement("INPUT");
bak.setAttribute('value','もどる');
bak.setAttribute('type','button');
bak.setAttribute('onclick',"drawscenario("+scenario+",'tbl',0)");
span.appendChild(bak, null);
} else {
var bak=document.createElement("INPUT");
bak.setAttribute('value','編集');
bak.setAttribute('type','button');
bak.setAttribute('onclick',"drawscenario("+scenario+",'tbl',1)");
span.appendChild(bak, null);
}
document.getElementById(div).appendChild(span, null);
} else {
var span=document.createElement("SPAN");
span.setAttribute('class','tdkei right');
span.setAttribute('style','font-family: monospace;width: 80px');
var text = document.createTextNode(scenario[i].jname);
span.appendChild(text, null);
document.getElementById(div).appendChild(span, null);
var lf = document.createTextNode("\n");
document.getElementById(div).appendChild(lf, null);
if(inp){
var input=document.createElement("INPUT");
input.setAttribute('name',scenario[i].name);
input.setAttribute('value',scenario[i].value);
if(scenario[i].name == 'srl'){
input.setAttribute('type','hidden');
} else {
input.setAttribute('type','text');
input.setAttribute('style','width: 200px');
}
document.getElementById(div).appendChild(input, null);
} else {
var text = document.createTextNode(scenario[i].value);
document.getElementById(div).appendChild(text, null);
}
}
var br=document.createElement("BR");
document.getElementById(div).appendChild(br, null);
}
}
function chgContent(QuestionID,nDsp) {
var disp=nDsp? nDsp:document.getElementById(QuestionID).style.display;
if(disp == "block") {
document.getElementById(QuestionID).style.display = "none";
} else {
document.getElementById(QuestionID).style.display = "block";
}
}
function failures (){
hideWaitBars();
showsucerr('読み込みに失敗しました',1);
}
function exceptions (exp){
hideWaitBars();
showsucerr('読み込み中にエラーが発生しました: '+exp,1);
}

function setcate(form) {
var elms=form.genre;
document.getElementById('cateslct').innerHTML='';
opt = document.createElement("OPTION");
opt.setAttribute('value','');
text = document.createTextNode('選択');
opt.appendChild(text, null);
document.getElementById('cateslct').appendChild(opt);
for(var i=0;i<cateary.length;i++){
if(elms.options[elms.selectedIndex].value !='members'){
if(cateary[i].val == 'graffiti' || cateary[i].val == 'profile'){
continue;
}
}
if(elms.options[elms.selectedIndex].value=='jobs'){
//if(cateary[i].val == 'memo'){
//continue;
//}
} else if(elms.options[elms.selectedIndex].value=='client'){
if(cateary[i].val != 'memo'){
continue;
}
}
opt = document.createElement("OPTION");
opt.setAttribute('value',cateary[i].val);
if(elms.options[elms.selectedIndex].value=='client'){
opt.setAttribute('selected',true);
}
text = document.createTextNode(cateary[i].jname);
opt.appendChild(text, null);
document.getElementById('cateslct').appendChild(opt);
}
chgContent('job0','block');
chgContent('job1','block');
chgContent('job2','block');
chgContent('prof0','block');
chgContent('prof1','block');
chgContent('prof2','block');
chgContent('prof4','block');
if(elms.options[elms.selectedIndex].value =='client'){
chgContent('prof3','none');
document.getElementById('hombun').innerHTML='概要';
document.getElementById('ttls').innerHTML='クライアント名';
} else {
chgContent('prof3','block');
}
}
function setform(form) {
var gnr=form.genre;
if(gnr.options[gnr.selectedIndex].value==''){
alert('ジャンルを先に選択してください');
return false;
}
var ctg=form.cate;
if(gnr.options[gnr.selectedIndex].value=='jobs'){
document.getElementById('photo').innerHTML='ファイル';
chgContent('prof0','block');
if(ctg.options[ctg.selectedIndex].value=='schedule'){
chgContent('job0','none');
chgContent('job1','none');
chgContent('job2','none');
//chgContent('prof0','block');
chgContent('prof1','none');
document.getElementById('ttls').innerHTML='プロジェクト名';
document.getElementById('hombun').innerHTML='詳細';
} else {
chgContent('job0','block');
chgContent('job1','block');
chgContent('job2','block');
//chgContent('prof0','block');
chgContent('prof1','block');
document.getElementById('ttls').innerHTML='タイトル';
document.getElementById('hombun').innerHTML='本文';
}
} else if(gnr.options[gnr.selectedIndex].value =='members'){
chgContent('job0','block');
chgContent('job1','block');
chgContent('job2','block');
if(ctg.options[ctg.selectedIndex].value=='profile'){
chgContent('prof0','none');
chgContent('prof1','none');
chgContent('prof3','none');
chgContent('prof4','block');
document.getElementById('ttls').innerHTML='なまえ';
document.getElementById('hombun').innerHTML='自己紹介・コメント';
document.getElementById('photo').innerHTML='写真';
} else if(ctg.options[ctg.selectedIndex].value=='graffiti'){
chgContent('prof4','none');
} else {
chgContent('prof0','block');
chgContent('prof1','block');
chgContent('prof3','block');
chgContent('prof4','block');
document.getElementById('ttls').innerHTML='タイトル';
document.getElementById('hombun').innerHTML='本文';
document.getElementById('photo').innerHTML='ファイル';
}
} else {
document.getElementById('photo').innerHTML='ファイル';
}
}
function sendmids(form){
if(form.uniq){
form.uniq.value=user.uniq;
}
$('indicator').style.color='#000';
$('indicator').update('送信中....');
$('indicator').style.background='transparent url(/nakamura2/rel/ajax-loader.gif) no-repeat center left';
$('indicator').style.paddingLeft='20px';
chgContent('indicator','none');
var url = '/seek/userconf.pl';
var myAjax = new Ajax.Request(url, {
method: 'post', 
parameters: Form.serialize(form.id), 
onSuccess: function (originalRequest) {
//alert(originalRequest.responseText);
originalRequest.responseText.evalScripts();
},
onFailure: function (originalRequest) {
$('indicator').style.paddingLeft='0';
$('indicator').style.background='transparent';
$('indicator').style.color='#903';
$('indicator').update('読み込みに失敗しました');
},
onException: function (originalRequest) {
$('indicator').style.paddingLeft='0';
$('indicator').style.background='transparent';
$('indicator').style.color='#903';
$('indicator').update('読み込み中にエラーが発生しました');
}
});

}
function setmids(form,srl,mid,cls,mpay,ena) {
var m=new ASYOUJS.Modal(false,{ contents: modalcontents });
m.open();
var opt;
$('setmidbody').style.fontSize='85%';
if(srl=='new'){
$('setmidhead').update('新規登録');
chgContent('newmail','none');
chgContent('othdy','block');
chgContent('passinit','block');
for (var i=0;i < uclsary.length; i++) {
opt = document.createElement("OPTION");
opt.setAttribute('value',uclsary[i].value);
text = document.createTextNode(uclsary[i].title);
opt.appendChild(text, null);
$('ucls').appendChild(opt);
}
opt = document.createElement("OPTION");
opt.setAttribute('value',1);
text = document.createTextNode('新規登録');
opt.appendChild(text, null);
$('umpay').appendChild(opt);
} else {
$('setmidhead').update(mid+'の更新');
var form=document.forms['setmidbody'];
form.srl.value=srl;
form.umid.value=mid;
chgContent('newmail','block');
chgContent('othdy','none');
var slct=0;
for (var i=0;i < uclsary.length; i++) {
opt = document.createElement("OPTION");
opt.setAttribute('value',uclsary[i].value);
if(cls==uclsary[i].value){
opt.setAttribute('selected','selected');
}
text = document.createTextNode(uclsary[i].title);
opt.appendChild(text, null);
document.getElementById('ucls').appendChild(opt);
}
opt = document.createElement("OPTION");
opt.setAttribute('value',0);
text = document.createTextNode('変更なし');
opt.appendChild(text, null);
document.getElementById('umpay').appendChild(opt);
opt = document.createElement("OPTION");
opt.setAttribute('value',1);
text = document.createTextNode('１年延長');
opt.appendChild(text, null);
document.getElementById('umpay').appendChild(opt);
opt = document.createElement("OPTION");
opt.setAttribute('value',2);
text = document.createTextNode('２年延長');
opt.appendChild(text, null);
document.getElementById('umpay').appendChild(opt);
opt = document.createElement("OPTION");
opt.setAttribute('value',3);
text = document.createTextNode('３年延長');
opt.appendChild(text, null);
document.getElementById('umpay').appendChild(opt);
opt = document.createElement("OPTION");
opt.setAttribute('value',19000000);
text = document.createTextNode('無期限に変更');
opt.appendChild(text, null);
$('umpay').appendChild(opt);
form.uena.selectedIndex=ena? 0:1;
opt = document.createElement("OPTION");
opt.setAttribute('value',0);
if(!ena){
opt.setAttribute('selected','selected');
}
text = document.createTextNode('停止');
opt.appendChild(text, null);
$('uena').appendChild(opt);
}
}
function closewin(div) {
hidewoverlay();
chgContent(div,'block');
document.getElementById(div).style.zIndex=1;
//document.getElementById(div).style.position='absolute';
//var head=div+'head';
//document.getElementById(head).innerHTML='';
}
function viewpop(perls,qstr){
hideWaitBars();
document.getElementById('popup').style.display='block';
document.getElementById('popup').style.width='280px';
document.getElementById('popup').style.height='22em';
document.getElementById('popup').style.zIndex=600;
//document.getElementById('popup').style.position='absolute';
//document.getElementById('popup').style.left=(pageWidth()/2-140)+'px';
document.getElementById('popup').style.top=(posTop()+100)+'px';
document.getElementById('popuphead').innerHTML='';
document.getElementById('popupbody').innerHTML='';
document.getElementById('popupbody').style.height='19.8em';
showoverlay();
viewlink(perls,qstr,0,'popupbody');
}
function viewmain(perls,qstr){
hidewoverlay();
document.getElementById('popup').style.display='none';
document.getElementById('popuphead').innerHTML='';
document.getElementById('popupbody').innerHTML='';
document.getElementById('popup').style.zIndex=1;
if(perls){
viewlink(perls,qstr);
}
}
function filedel(form,perls){
//alert(form.delfile.value);
sendquery(perls,'file='+form.delfile.value);
}
function showWaitBars(){
var title, midashi,submbtn, inp, news;
ASYOUJS.Modal.close();
m=new ASYOUJS.Modal(false,{
contents: '<span class="r0">&#160;<'+'/span>\
<span class="alerthead" style="width: 148px"><'+'/span>\
<span class="r1">&#160;<'+'/span><br class="clear">\
<p class="body" style="width: 146px">\
<b>送信中....<'+'/b><br class="clear">\
<span class="waitBar" id="viewbar"><'+'/span><br class="clear"><'+'/p>\
<span class="r2">&#160;<'+'/span><div class="alertfoot" style="width: 148px">&#160;<'+'/div><span class="r3">&#160;<'+'/span><br class="clear">'
});  
m.open();
$('modal_container').style.width='180px';
initWaitBars();
}
function hideWaitBars(){
if($('viewbar')){
myWaitBars.stops();
}
ASYOUJS.Modal.close();
}
function setcenter(div){
var pw=pageWidth();
var ph=pageHeight();
var boxelm=$(div).getDimensions();
document.getElementById(div).style.position='absolute';
document.getElementById(div).style.left=Math.floor((pw - boxelm.width)/2)+'px';
document.getElementById(div).style.top=Math.floor((posTop() + (ph - boxelm.height)/2))+'px';
}
function open_edit(){
//$('page_new').style.display='inline';
//$('page_add').style.display='inline';
if($('subtitles').style.display !='none'){
showsucerr('各種設定中は投稿ができません',1);
return;
}
var block=0;
chgContent('addpage','none');
if(user.mid == 'h_maro'){
chgContent('openedit','block');
} else {
chgContent('openedit2','block');
}
if($('block0')){
$('block0').style.border='1px solid #f00';
if(Element.empty('block0')){
$('block0').style.height='1em';
}
} else {
var newdiv='<div id="block0" style="border: 1px solid #f00; height: 1em"><'+'/div>';
new Insertion.Top('results', newdiv);
}
if(user.mid == 'h_maro'){
if($('page_new').style.display !='none'){ drags.put('page_new'); }
if(serv.page){
if($('page_add').style.display !='none'){ drags.put('page_add'); }
if($('page_re').style.display !='none'){ drags.put('page_re'); }
if($('page_cmm').style.display !='none'){ drags.put('page_cmm'); }
if($('page_quest').style.display !='none'){ drags.put('page_quest'); }
if($('page_hand').style.display !='none'){ drags.put('page_hand'); }
} else {
if($('page_cmm')){
drags.del('page_cmm');
$('page_cmm').hide();
}
if($('page_quest')){
drags.del('page_quest');
$('page_quest').hide();
}
if($('page_add')){
drags.del('page_add');
$('page_add').hide();
}
if($('page_re')){
drags.del('page_re');
$('page_re').hide();
}
if($('page_hand')){
drags.del('page_hand');
$('page_hand').hide();
}
}
}
drops.delall();
drops.put('block0');
//Droppables.add('block0',
//　　{ accept: 'pages',
//　　　onDrop: function( dragElement, dropElement, event ){
//	chgContent(dragElement.id,'block');
//	addpagetitle(dragElement);
//	},//
//　　　hoverclass: 'drops'
//　　});
if(user.mid == 'h_maro'){
chgContent('addpart','block');
Event.stopObserving(window,'scroll',setaddparttop);
}
}
function open_edit2(){
var jtitle='<input type="text" name="jtitle" id="focus" style="width: 200px">';
ASYOUJS.Modal.close();
var m=new ASYOUJS.Modal(false,{
contents: '<span class="r0">&#160;<'+'/span>\
<span class="alerthead"><'+'/span>\
<span class="r1">&#160;<'+'/span><br class="clear">\
<div class="body">\
<p id="alerttext" style="margin: 0; padding: 0; line-height: 140%"><b>新規投稿<'+'/b><br class="clear">タイトルを設定してください<'+'/p>\
<form action="javascripy:void(0)" id="alert_form" method="post">\
<span id="alertdtn"><input type="hidden" name="new" value="1">\
<input type="hidden" name="docsrl" value="-1">\
<input type="hidden" name="uniq">\
<input type="hidden" name="save" value="1">\
<input type="hidden" name="elms" value="page_new">\
<input type="button" onclick="makepage(this.form,1)" value="送信"><'+'/span>\
<'+'/form><'+'/div>\
<span class="r2">&#160;<'+'/span><div class="alertfoot">&#160;<'+'/div><span class="r3">&#160;<'+'/span><br class="clear">\
<div class="alertclose" id="alert_close" onclick="ASYOUJS.Modal.close()"> <'+'/div>'
});
m.open();
if(jtitle){
new Insertion.Top('alert_form', jtitle);
if($('focus')){ $('focus').focus(); }
}
}
function open_file2() {
ASYOUJS.Modal.close();
var m=new ASYOUJS.Modal(false,{
contents: '<span class="r0">&#160;<'+'/span>\
<span class="alerthead"><'+'/span>\
<span class="r1">&#160;<'+'/span><br class="clear">\
<div class="body">\
<p id="alerttext" style="margin: 0; padding: 0; line-height: 140%"><b>アップロード<'+'/b><br class="clear">ファイルを選択してください<'+'/p>\
<span id="nowloading2"></span>\
<form action="/seek/upload.pl?uniq='+user.uniq+'&docsrl='+docsrl+'" class="right" id="alert2_form" method="post" target="imgupfrm" enctype="multipart/form-data"><input type="file" onchange="setpart2(this.form)" name="upfile">\
<input type="hidden" name="save" value="1"><'+'/form><'+'/div>\
<span class="r2">&#160;<'+'/span><div class="alertfoot">&#160;<'+'/div><span class="r3">&#160;<'+'/span><br class="clear">\
<div class="alertclose" id="alert_close" onclick="ASYOUJS.Modal.close()"> <'+'/div>\
<iframe id="imgupfrm" name="imgupfrm" style="width: 1px; height: 1px; visibility: hidden"></iframe>'
});
m.open();
}
function open_comment2(){
var jtitle='<input type="text" name="jtitle" id="focus" style="width: 200px">';
ASYOUJS.Modal.close();
var m=new ASYOUJS.Modal(false,{
contents: '<span class="r0">&#160;<'+'/span>\
<span class="alerthead"><'+'/span>\
<span class="r1">&#160;<'+'/span><br class="clear">\
<div class="body">\
<p id="alerttext" style="margin: 0; padding: 0; line-height: 140%"><b>コメント投稿<'+'/b><br class="clear">タイトルを設定してください<'+'/p>\
<form action="javascripy:void(0)" id="alert_form" method="post">\
<span id="alertdtn"><input type="hidden" name="new" value="1">\
<input type="hidden" name="docsrl" value="-1">\
<input type="hidden" name="uniq">\
<input type="hidden" name="save" value="1">\
<input type="hidden" name="elms" value="page_cmm">\
<input type="hidden" name="cate" value="comment">\
<input type="hidden" name="reno" value="'+serv.page+'">\
<input type="button" onclick="makepage(this.form,1)" value="送信"><'+'/span>\
<'+'/form><'+'/div>\
<span class="r2">&#160;<'+'/span><div class="alertfoot">&#160;<'+'/div><span class="r3">&#160;<'+'/span><br class="clear">\
<div class="alertclose" id="alert_close" onclick="ASYOUJS.Modal.close()"> <'+'/div>'
});
m.open();
if(jtitle){
new Insertion.Top('alert_form', jtitle);
if($('focus')){ $('focus').focus(); }
}
}
function close_edit(){
chgContent('addpage','block');
if(user.mid == 'h_maro'){
chgContent('openedit','none');
} else {
chgContent('openedit2','none');
if(serv.page || serv.docsrl){
chgContent('fileup2','none');
}
}
//alert('block0 check');
//if($('block0')) {
drops.delall();
//Droppables.remove('block0');
//}
//alert('page_cmm check');
if(user.mid == 'h_maro'){
if($('page_cmm')) drags.del('page_cmm');
//alert('page_quest check');
if($('page_quest')) drags.del('page_quest');
//alert('page_add check');
if($('page_add')) drags.del('page_add');
//alert('page_re check');
if($('page_re')) drags.del('page_re');
//alert('page_hand check');
if($('page_hand')) drags.del('page_hand');
//alert('page_new check');
if($('page_new')) drags.del('page_new');
}
if(serv.page && $('block0')){
$('block0').style.border='transparent';
if($('block0') && Element.empty('block0')){
$('block0').style.height=0;
}
} else if($('block0')) {
$('block0').remove();
}
}
function closeeditwin(icon){
ASYOUJS.Modal.close();
$(icon).style.display='inline';
open_edit();
}
function closeupwin(icon){
ASYOUJS.Modal.close();
$(icon).style.display='inline';
}
function addpagetitle(dragElement) {
var title, midashi,submbtn, inp, news, cmd, jtitle;
if(dragElement.id=='page_add'){
title='本文追加';
inp='<input type="hidden" name="page" value="'+serv.page+'">';
if(serv.subpage){
inp+='<input type="hidden" name="subpage" value="'+serv.subpage+'">';
		} else {
inp+='<input type="hidden" name="subpage" value="0">';
		}
inp+='<input type="hidden" name="column" value="-1">';
midashi='見出しを設定してください';
news=0;
cmd='makepage';
jtitle='<input type="text" name="jtitle" id="focus" style="width: 200px">';
} else {
if(dragElement.id=='page_new'){
title='新規投稿';
inp='<input type="hidden" name="new" value="1">';
inp+='<input type="hidden" name="docsrl" value="-1">';
news=1;
cmd='makepage';
jtitle='<input type="text" name="jtitle" id="focus" style="width: 200px">';
} else if(dragElement.id=='page_re'){
title='返信';
inp='<input type="hidden" name="reno" value="'+serv.page+'">';
inp+='<input type="hidden" name="docsrl" value="-1">';
news=1;
cmd='makeresponce';
jtitle='<span id="nowloading"><img src="/nakamura2/rel/ajax-loader.gif" style="width: 16px; height: 16px">タイトルをロード中....</span>';
} else if(dragElement.id=='page_cmm'){
title='コメント投稿';
inp='<input type="hidden" name="cate" value="comment">';
inp+='<input type="hidden" name="docsrl" value="-1">';
inp+='<input type="hidden" name="reno" value="'+serv.page+'">';
news=1;
cmd='makepage';
jtitle='<input type="text" name="jtitle" id="focus" style="width: 200px">';
} else if(dragElement.id=='page_quest'){
title='質問';
inp='<input type="hidden" name="cate" value="question">';
inp+='<input type="hidden" name="docsrl" value="-1">';
inp+='<input type="hidden" name="reno" value="'+serv.page+'">';
news=1;
cmd='makeresponce';
jtitle='<input type="text" name="jtitle" id="focus" style="width: 200px">';
} else if(dragElement.id=='page_hand'){
title='手をあげる';
inp='<input type="hidden" name="uri" value="'+serv.docsrl+'">';
news=1;
cmd='makepick';
}
if(dragElement.id=='page_hand'){
midashi='タイトルを設定してください';
} else {
midashi='タイトルを設定してください';
}
}
ASYOUJS.Modal.close();
var m;
if(dragElement.id=='page_hand'){
} else {
m=new ASYOUJS.Modal(false,{
contents: '<span class="r0">&#160;<'+'/span>\
<span class="alerthead"><'+'/span>\
<span class="r1">&#160;<'+'/span><br class="clear">\
<div class="body">\
<p id="alerttext" style="margin: 0; padding: 0; line-height: 140%"><b>'+title+'<'+'/b><br class="clear">'+midashi+'<'+'/p>\
<form action="javascripy:void(0)" id="alert_form" method="post">\
<span id="alertdtn">'+inp+'<input type="hidden" name="uniq">\
<input type="hidden" name="save" value="1">\
<input type="hidden" name="elms" value="'+dragElement.id+'">\
<input type="button" onclick="'+cmd+'(this.form,'+news+')" value="送信"><'+'/span>\
<'+'/form><'+'/div>\
<span class="r2">&#160;<'+'/span><div class="alertfoot">&#160;<'+'/div><span class="r3">&#160;<'+'/span><br class="clear">\
<div class="alertclose" id="alert_close" onclick="closeeditwin(\''+dragElement.id+'\')"> <'+'/div>'
});
}
m.open();
if(jtitle){
new Insertion.Top('alert_form', jtitle);
if($('focus')){ $('focus').focus(); }
else {
new Ajax.updater('nowloading','/seek/getretitle.pl',{
parameters: 'uniq='+user.uniq+'&reno='+serv.docsrl, 
onFailure: function() { $('nowloading').update('読込みに失敗しました') },
onException: function() { $('nowloading').update('読込みにエラーが発生しました') },
evalScripts: true
});
}
}
}
function graphicwin(docsrl, all){
ASYOUJS.Modal.close();
var urls='/seek/loadimgs.pl';
var param='uniq='+user.uniq+'&docsrl='+docsrl+(all? '&all=1':'');
var m = new ASYOUJS.Modal(false,{
	width: 800,
	height: 512,
	contents: function(){
		new Ajax.Request( urls,{  
			method: 'post', 
			parameters: param, 
			onComplete: function(request){
				$('modal_container').update(request.responseText);
				$('modal_container').setStyle({'height':''});
				$('modal_container').setStyle({'padding':'10px'});
$('modal_container').setStyle({'backgroundColor': '#fff'});
$('modal_container').setStyle({'border':'1px solid #000'});
			}.bind(this),
			evalScripts: true
		});  
		return '<img src="/nakamura2/rel/spinner.gif" width="50" height="50">';  
	}
});  
m.open();
}
function closeimgedit() {
CropImageManager.removeCropper();
if(SlideManager.curSlide){
SlideManager.removeSlider();
}
var dim=$('modal_container').getDimensions();
var divx=Math.floor((dim.width - 52)/2)+'px';
var divy=Math.floor((dim.height - 68)/2)+'px';
var div=document.createElement('DIV');
div.setAttribute("id","closeIndi");
$('modal_container').appendChild(div);
new Effect.Opacity('closeIndi', {duration:2.0, from:1.0, to:0.3}); 
$('closeIndi').style.height='66px';
$('closeIndi').style.width='50px';
$('closeIndi').style.padding='10px';
$('closeIndi').style.backgroundColor='#fff';
$('closeIndi').style.textAlign='center';
$('closeIndi').style.border='1px solid #000';
$('closeIndi').style.position='absolute';
$('closeIndi').style.left=divx;
$('closeIndi').style.top=divy;
$('closeIndi').style.zIndex='1200';
$('closeIndi').update('<img src="/nakamura2/rel/spinner.gif" width="50" height="50"><br><img src="/nakamura2/rel/shori.gif" width="50" height="16">');
var clsInt=setTimeout('closeImgsEdit()',2000);
}
function closeImgsEdit() {
ASYOUJS.Modal.close();
$('modal_container').setStyle({'backgroundColor': 'transparent'});
$('modal_container').setStyle({'border':'none'});
$('modal_container').setStyle({'padding':'0'});
}
function recenter(){
var imgDim=$('testImage').getDimensions();
$('testWrap').setStyle({'height': (imgDim.height+20)+'px'});
$('testWrap').setStyle({'width': (imgDim.width+20)+'px'});
var ph = pageHeight()? pageHeight():240;
var elmh=$('modal_container').getHeight();
if(elmh > ph){
$('modal_container').setStyle({'height': (ph-50)+'px'});
$('testWrap').setStyle({'height': (ph - 140)+'px'});
$('testWrap').setStyle({'width': (imgDim.width+20)+'px'});
$('testWrap').setStyle({'overflow': 'hidden'});
}
//setcenter('modal_container');
//alert('CropImageManager');
CropImageManager.init();
//SlideManager.init();
//initSlider();
setCoords(1);
}
function setCoords(init){
if(parseInt($('cropX').innerHTML) || parseInt($('cropY').innerHTML) || 
	parseInt($( 'cropW' ).innerHTML) != parseInt($('testImage').width) || 
	parseInt($( 'cropH' ).innerHTML) != parseInt($('testImage').height)){
var x1=parseInt($( 'cropX' ).innerHTML);
var y1=parseInt($( 'cropY' ).innerHTML);
var x2=x1+parseInt($( 'cropW' ).innerHTML);
var y2=y1+parseInt($( 'cropH' ).innerHTML);
CropImageManager.restructCropper(x1,y1,x2,y2);
} else if(!init) {
CropImageManager.attachCropper();
}
$('changed').value=0;
}
function onEndCrop( coords, dimensions ) {
if(CropImageManager.curCrop){
if(parseInt($('cropX').innerHTML) != parseInt(coords.x1) || 
	parseInt($('cropY').innerHTML) != parseInt(coords.y1) || 
	parseInt($( 'cropW' ).innerHTML) != parseInt(dimensions.width) || 
	parseInt($( 'cropH' ).innerHTML) != parseInt(dimensions.height)){
$( 'cropX' ).update(coords.x1);
$( 'cropY' ).update(coords.y1);
$( 'cropW' ).update(dimensions.width);
$( 'cropH' ).update(dimensions.height);
$('changed').value=1;
}
}
}
function scaleIt(v, originalWidth) {
//var scalePhoto = $('resizeImage');
var scalePhoto = $('theImage');
v = originalWidth * (v/100);
scalePhoto.style.width = Math.floor(v) + 'px';
$('resizeW').update(Math.floor(v));
}
function saveChange() {
//var theWidth = $('resizeImage').style.width;
var theWidth = $('theImage').style.width;
theWidth = theWidth.substring(0,(theWidth.length-2));
}
function goscale(){
CropImageManager.removeCropper();
$('resizeW').update($( 'cropW' ).innerHTML);
//alert(SlideManager.curSlide);
if(!SlideManager.curSlide){
SlideManager.init();
} else {
SlideManager.setEnabled();
}
chgContent('scale_set','none');
chgContent('prev_set','block');
$('testWrap').hide();
$('resizeImage').setStyle({'width': $( 'cropW' ).innerHTML+'px'});
$('resizeImage').setStyle({'height': $( 'cropH' ).innerHTML+'px'});
$('resizeImage').show();
var ph = pageHeight()? pageHeight():240;
if(parseInt($( 'cropH' ).innerHTML) > ph){
$('modal_container').setStyle({'height': (ph-50)+'px'});
$('resizeImage').setStyle({'height': (ph - 120)+'px'});
//$('wrapwin').setStyle({'width': (imgDim.width+42)+'px'});
$('resizeImage').setStyle({'overflow-y': 'scroll'});
}
if(!parseInt($('cropX').innerHTML) && !parseInt($('cropY').innerHTML) && 
	parseInt($( 'cropW' ).innerHTML) == parseInt($('testImage').width) && 
	parseInt($( 'cropH' ).innerHTML) == parseInt($('testImage').height)){
//alert($('testImage').src);
$('theImage').src=$('testImage').src;
} else if($('changed').value){
var imgtag='/seek/imgload.pl'+$('img_fsrl').value;
imgtag +='.jpg?uniq='+user.uniq+'&cropX='+$( 'cropX' ).innerHTML;
imgtag +='&cropY='+$('cropY').innerHTML+'&cropW='+$( 'cropW' ).innerHTML;
imgtag +='&cropH='+$('cropH').innerHTML;
//alert(imgtag);
$('theImage').src=imgtag;
}
}
function gotriming(){
chgContent('scale_set','block');
chgContent('prev_set','none');
SlideManager.removeSlider();
setCoords();
$('testWrap').show();
$('resizeImage').hide();
}
function docropping(docsrl){
var urls='/seek/setimgs.pl';
var param='uniq='+user.uniq+'&docsrl='+docsrl;
param +='&cropX='+$( 'cropX' ).innerHTML+'&cropY='+$('cropY').innerHTML;
param +='&cropW='+$( 'cropW' ).innerHTML+'&cropH='+$('cropH').innerHTML;
param +='&resizeW='+$( 'resizeW' ).innerHTML;
param +='&border='+($( 'imgborder' ).checked? 'ccc':'0');
$('nowloading3').update('<img src="/nakamura2/rel/ajax-loader.gif" style="width: 16px; height: 16px">イメージファイルを設定中....');
$('alert_close').hide();
editfin.del('jdesc_cmd'+docsrl);
new Ajax.Request(urls,{
	method: 'post', 
	parameters: param, 
	onComplete: function(request){  
		request.responseText.evalScripts();
		setcaptionedit(docsrl);
	},
	onFailure: function(){
setcaptionedit(docsrl);
		$('nowloading3').update('読込みに失敗しました');
		$('alert_close').show();
	},
	onException: function(a,r){
setcaptionedit(docsrl);
		$('nowloading3').update('読込み解析に失敗しました:'+r);
		$('alert_close').show();
	}
});
}
function inserts_prevbtn(docsrl,div){
var prevbtn='<div class="right" id="formbtndiv"><input type="button" value="プレビュー" id="doprev"> | <input type="button" value="キャンセル"id="docancel'+docsrl+'"> | <input type="button" value="編集中リストから削除"id="dopagedel'+docsrl+'">';
if(docsrl < 2000000000){
prevbtn+=' | <input type="button" value="掲載中の記事も削除"id="confirmdel'+docsrl+'"></div>';
}
editset(1,docsrl)
editstat.put(0);
new Insertion.Bottom('block'+docsrl, prevbtn);
$('doprev').observe('click',
	function(e) { insert_savebtn(docsrl) });
$('docancel'+docsrl).observe('click',
	function(e) { dobackpage(docsrl) });
$('dopagedel'+docsrl).observe('click',
	function(e) {
		resetediter(docsrl);
		editstat.put(1);
		sendquery('estpost','del=1&docsrl='+docsrl)
	});
if($('confirmdel'+docsrl)){
$('confirmdel'+docsrl).observe('click',
	function(e) {
		if(confirm('公開中の「'+$('jtitle_cmd'+docsrl).innerHTML+'」も含めて、編集中の記事を削除します。'+"\n"+'取り消しはできません。')){
			resetediter(docsrl);
			confirmalldel(docsrl);
		}
	});
}
}
function confirmalldel(docsrl){
editstat.put(1);
sendquery('estpost','del=2&docsrl='+docsrl)
}
function insert_savebtn(docsrl){
$('subtitles').update($('jtitle_cmd'+docsrl).innerHTML+'のプレビュー');
$('subtitles').show();
editab_btn(0);
$('block'+docsrl).setStyle({ 'border': 'none' });
$('formbtndiv').remove();
chgContent('creats'+docsrl,'block');
var prevbtn='<div class="right" id="formsavediv"><input type="checkbox" value="1" id="doldate'+docsrl+'">更新日を本日にする<input type="button" value="公開" id="dosave'+docsrl+'"> | <input type="button" value="編集にもどる"id="docancel'+docsrl+'"></div>';
editset(0,docsrl);
editstat.put(1);
new Insertion.Bottom('block'+docsrl, prevbtn);
$('dosave'+docsrl).observe('click',
	function(e) {
resetediter(docsrl);
sendquery('estpost','docsrl='+docsrl+'&release=1&vtop='+$('doldate'+docsrl).checked);
});
$('docancel'+docsrl).observe('click',
	function(e) {
		$('formsavediv').remove();
		editpage(docsrl,0);
		seteditor(docsrl);
	});
}
function seteditor(docsrl){
$('doexte'+docsrl).show();
//var obj=$('results');
//for(var i=0;i<obj.childNodes.length;i++){
//var divid=obj.childNodes[i].id;
//if(obj.childNodes[i].nodeType==1 && divid.substr(0,5)=='block'){
//var tmpblock=divid.substr(5,divid.length-5);
//$('editab'+tmpblock).hide();
//}
//}
inserts_prevbtn(docsrl);
editab_btn(0);
}
function setcomment(docsrl){
var prevbtn='<div class="right" id="formbtndiv"><input type="button" value="プレビュー" id="doprev"> | <input type="button" value="キャンセル"id="doCommcancel'+docsrl+'">';
if(user.uniq){
prevbtn+=' | <input type="button" value="編集中リストから削除"id="doCommdel'+docsrl+'">';
}
if(docsrl < 2000000000){
var mpass=user.uniq? 'hidden':'text';;
prevbtn+=' | <input type="'+mpass+'" id="mpass'+docsrl+'"><input type="button" value="掲載中のコメントも削除"id="confirmComm'+docsrl+'"></div>';
}
editstat.put(0);
editab_btn(0);
new Insertion.Bottom('cmm'+docsrl, prevbtn);
$('doprev').observe('click',
	function(e) { insert_saveComm(docsrl) });
$('doCommcancel'+docsrl).observe('click',
	function(e) { dobackComm(docsrl) });
if($('doCommdel'+docsrl)){
$('doCommdel'+docsrl).observe('click',
	function(e) {
		resetediter(docsrl);
		sendquery('estpost','del=1&docsrl='+docsrl)
	});
}
if($('confirmComm'+docsrl)){
$('confirmComm'+docsrl).observe('click',
	function(e) {
		if(confirm('公開中の「'+$('jtitle_cmd'+docsrl).innerHTML+'」も含めて、編集中のコメントを削除します。'+"\n"+'取り消しはできません。')){
			var mpass=$('mpass'+docsrl).value;
			resetediter(docsrl);
			confirmallComm(docsrl,mpass);
		}
	});
}
}
function confirmallComm(docsrl,mpass){
//alert(mpass);
editstat.put(1);
sendquery('estpost','del=2&docsrl='+docsrl+'&mpass='+encodeURIComponent(mpass));
}
function insert_saveComm(docsrl){
$('subtitles').update($('jtitle_cmd'+docsrl).innerHTML+'のプレビュー');
$('subtitles').show();
editab_btn(0);
$('cmm'+docsrl).setStyle({ 'border': 'none' });
$('formbtndiv').remove();
//chgContent('creats'+docsrl,'block');
var prevbtn='<div class="right" id="formsavediv">';
prevbtn+='<input type="'+(user.uniq? 'hidden':'text')+'" ';
prevbtn+='id="mpass'+docsrl+'">';
prevbtn+='<input type="checkbox" value="1" id="doldate'+docsrl;
prevbtn+='">更新日を本日にする<input type="button" value="公開" ';
prevbtn+='id="doCommsave'+docsrl+'"> | ';
prevbtn+='<input type="button" value="編集にもどる"id="doCommEdit';
prevbtn+=docsrl+'"></div>';
//editset(0,docsrl);
editstat.put(1);
new Insertion.Bottom('cmm'+docsrl, prevbtn);
$('doCommsave'+docsrl).observe('click',
	function(e) {
resetediter(docsrl);
sendquery('estpost','docsrl='+docsrl+'&release=1&vtop='+$('doldate'+docsrl).checked+'&mpass='+$('mpass'+docsrl).value);
});
$('doCommEdit'+docsrl).observe('click',
	function(e) {
		$('formsavediv').remove();
		editComm(docsrl,0);
		setcomment(docsrl);
	});
}
function editComm(docsrl,script,mpass){
$('subtitles').update($('jtitle_cmd'+docsrl).innerHTML+'の編集');
$('subtitles').show();
$('cmm'+docsrl).setStyle({ 'border': '1px solid Orange' });
if(script){
editfin.delall();
drops.delall();
sendquery('geteditor','docsrl='+docsrl+(mpass? ('&mpass='+$('mpass'+docsrl).value):''));
}
}
function editpage(docsrl,script){
$('subtitles').update($('jtitle_cmd'+docsrl).innerHTML+'の編集');
$('subtitles').show();
$('block'+docsrl).setStyle({ 'border': '1px solid Orange' });
if(script){
editfin.delall();
drops.delall();
sendquery('geteditor','docsrl='+docsrl);
}
}
function editset(num,docs){
if(num){
if($('imgview_cmd'+docs)) {
$('imgview_cmd'+docs).show();
}
if($('hr'+docs)) {
var text='<input id="delhr'+docs+'" class="right" type="button" value="削" onclick="delparts('+docs+',\'hr\')">';
new Insertion.Before('hr'+docs, text);
}
if($('mfile'+docs)) {
var text='<input type="button" value="削" onclick="delparts('+docs+',\'mfile\')"id="delmfile'+docs+'" class="right">';
new Insertion.Top('mfile'+docs, text);
}
if($('lurl'+docs)) {
var text='<input id="delurl'+docs+'" class="right" type="button" value="削" onclick="delparts('+docs+',\'lurl\')">';
new Insertion.Top('lurl'+docs, text);
}
} else {
if($('imgview_cmd'+docs)) $('imgview_cmd'+docs).hide();
if($('delhr'+docs)) $('delhr'+docs).remove();
if($('delmfile'+docs)) $('delmfile'+docs).remove();
if($('delurl'+docs)) $('delurl'+docs).remove();
}
}
function editab_btn(num){
if($$('p.editab')){
var regex=new RegExp("([0-9]+)$");
$$('p.editab').each(function(editab) {
editab.id.replace(regex,"");
var docs=RegExp.$1;
if($('mid'+docs).value==user.mid) {
if(num){ $(editab.id).show(); } else { $(editab.id).hide(); }
} else { $(editab.id).hide(); }
});
}
}
function dobackComm(docsrl){
var comm='';
if(user.uniq){
comm='編集中の内容はサーバに保存されていますが、'+"\n"+'１週間以内に編集を完了しない場合には'+"\n"+'保存内容を削除します。';
} else {
comm='保存内容は削除します。';
}
if(confirm('編集モードを終了します。'+"\n"+comm)){
$('subtitles').update('');
$('subtitles').hide();
resetediter(docsrl);
editstat.put(1);
chgContent('addpart','block');
chgContent('addpage','block');
if(user.mid == 'h_maro'){
chgContent('openedit','none');
Event.stopObserving(window,'scroll',setaddparttop);
} else {
chgContent('openedit2','none');
if(serv.page || serv.docsrl){
chgContent('fileup2','none');
}
}
var qstr='';
if(parseInt(serv.page)){
qstr='page='+serv.page;
if(parseInt(serv.subpage)){
qstr +='_'+serv.subpage;
}
} else if(serv.genre) {
qstr='genre='+serv.genre;
if(serv.cate){
qstr +='&cate='+serv.cate;
}
} else if(serv.cate) {
qstr='cate='+serv.cate;
}
viewlink('estindex',qstr);
}
}
function dobackpage(docsrl){
if(confirm('編集モードを終了します。'+"\n"+'編集中の内容はサーバに保存されていますが、'+"\n"+'１週間以内に編集を完了しない場合には'+"\n"+'保存内容を削除します。')){
$('subtitles').update('');
$('subtitles').hide();
resetediter(docsrl);
editstat.put(1);
chgContent('addpart','block');
chgContent('addpage','block');
if(user.mid == 'h_maro'){
chgContent('openedit','none');
Event.stopObserving(window,'scroll',setaddparttop);
} else {
chgContent('openedit2','none');
if(serv.page || serv.docsrl){
chgContent('fileup2','none');
}
}
var qstr='';
if(parseInt(serv.page)){
qstr='page='+serv.page;
if(parseInt(serv.subpage)){
qstr +='_'+serv.subpage;
}
} else if(serv.genre) {
qstr='genre='+serv.genre;
if(serv.cate){
qstr +='&cate='+serv.cate;
}
} else if(serv.cate) {
qstr='cate='+serv.cate;
}
viewlink('estindex',qstr);
}
}
function chgalign(select,docsrl){
var urls='/seek/estpost.pl';
var param='save=1&uniq='+user.uniq+'&align='+select.options[select.selectedIndex].value+'&docsrl='+docsrl;
$('nowloading4_'+docsrl).show();
$('nowloading4_'+docsrl).update('<img src="/nakamura2/rel/ajax-loader.gif" style="width: 16px; height: 16px">イメージの配置を設定中....');
new Ajax.Request(urls,{
	method: 'post', 
	parameters: param, 
	onComplete: function(request){
		request.responseText.evalScripts();
	},
	onFailure: function(){
		$('nowloading4_'+docsrl).update('読込みに失敗しました');
	},
	onException: function(){
		$('nowloading4_'+docsrl).update('読込み解析に失敗しました');
	}
});
}
function delparts(docsrl,elms){
if(!$(elms+docsrl)){
return false;
}
if(elms=='imgframe' || elms=='mfile'){
var item=elms=='imgframe'? 'イメージ':'添付';
var addcoment='';
if(elms=='imgframe'){
addcoment='とキャプション';
}
if(confirm(item+'ファイル'+addcoment+'を削除します。'+"\n"+'取り消しはできません。')){
if(elms=='imgframe'){
editfin.del('jdesc_cmd'+docsrl);
}
sendquery('filedel','item=files&docsrl='+docsrl);
}
} else {
var item=elms=='lurl'? '関連リンク':'罫線';
if(elms=='lurl') { elms='urls'; } else { elms='vhr' }
if(confirm(item+'を削除します。'+"\n"+'取り消しはできません。')){
sendquery('estpost',elms+'=0&docsrl='+docsrl);
}
}
}
function makepage(form,news){
if(form.uniq){
form.uniq.value=user.uniq;
}
var url = '/seek/makeblock.pl';
var pars = Form.serialize(form.id);
var myAjax = new Ajax.Request(
url, 
{
method: 'post', 
parameters: pars, 
onSuccess: function (originalRequest) {
drops.delall();
//Droppables.remove('block0');
originalRequest.responseText.evalScripts();
},
onFailure: function (originalRequest) {
drops.delall();
$(form.elms.value).show();
//Droppables.remove('block0');
if($('block0') && !Element.empty('block0')){
$('block0').style.border='transparent';
} else if($('block0')) {
$('block0').remove();
}
failures();
},
onException: function (ar,exp) {
drops.delall();
$(form.elms.value).show();
if($('block0') && !Element.empty('block0')){
$('block0').style.border='transparent';
} else if($('block0')) {
$('block0').remove();
}
exceptions(exp);
}
});
}
function addparts(dragElement){
ASYOUJS.Modal.close();
var title, midashi;
var names='';
if(dragElement.id=='page_graph' || dragElement.id=='page_attach'){
if(dragElement.id=='page_graph'){
title='イメージファイルの追加';
midashi='ファイルを選択してください';
} else if(dragElement.id=='page_attach'){
title='添付ファイルの追加';
midashi='ファイルを選択してください';
}
$(dragElement.id).hide();
var m=new ASYOUJS.Modal(false,{
contents: '<span class="r0">&#160;<'+'/span>\
<span class="alerthead"><'+'/span>\
<span class="r1">&#160;<'+'/span><br class="clear">\
<div class="body">\
<p id="alerttext" style="margin: 0; padding: 0; line-height: 140%"><b>'+title+'<'+'/b><br class="clear">'+midashi+'<'+'/p>\
<span id="nowloading2"></span>\
<form action="/seek/imgup.pl?uniq='+user.uniq+'&docsrl='+docsrl+'&elms='+dragElement.id+'" class="right" id="alert2_form" method="post" target="imgupfrm" enctype="multipart/form-data"><input type="file" onchange="setpart(this.form,\''+dragElement.id+'\')" name="upfile">\
<input type="hidden" name="save" value="1"><'+'/form><'+'/div>\
<span class="r2">&#160;<'+'/span><div class="alertfoot">&#160;<'+'/div><span class="r3">&#160;<'+'/span><br class="clear">\
<div class="alertclose" id="alert_close" onclick="closeupwin(\''+dragElement.id+'\')"> <'+'/div>\
<iframe id="imgupfrm" name="imgupfrm" style="width: 1px; height: 1px; visibility: hidden"></iframe>'
});
m.open();
} else {
if(dragElement.id=='page_holi'){
title='文末罫線の設定';
midashi='文末に罫線を設定しますか？';
forms='<input type="hidden" name="vhr" value="1">';
} else if(dragElement.id=='page_link'){
title='関連リンクの設定';
midashi='リンク先の実在性を検証します';
forms='<input type="text" name="urls" style="width: 160px">';
}
$(dragElement.id).hide();
var m=new ASYOUJS.Modal(false,{
contents: '<span class="r0">&#160;<'+'/span>\
<span class="alerthead"><'+'/span>\
<span class="r1">&#160;<'+'/span><br class="clear">\
<div class="body">\
<p id="alerttext" style="margin: 0; padding: 0; line-height: 140%"><b>'+title+'<'+'/b><br class="clear">'+midashi+'<'+'/p>\
<span id="nowloading2"></span>\
<form action="javascript:void(0)" class="right" id="alert2_form" method="post">'+forms+'<input type="button" onclick="setpart(this.form,\''+dragElement.id+'\')" value="送信"><input type="hidden" name="uniq">\
<input type="hidden" name="docsrl" value="'+docsrl+'">\
<input type="hidden" name="save" value="1"><'+'/form><'+'/div>\
<span class="r2">&#160;<'+'/span><div class="alertfoot">&#160;<'+'/div><span class="r3">&#160;<'+'/span><br class="clear">\
<div class="alertclose" id="alert_close" onclick="closeupwin(\''+dragElement.id+'\')"> <'+'/div>'
});
m.open();
}
}
function setpart(form,dragElement){
var sending;
if(dragElement=='page_graph'){
sending='<img src="/nakamura2/rel/ajax-loader.gif" style="width: 16px; height: 16px">イメージファイルを送信中....';
} else if(dragElement=='page_attach'){
sending='<img src="/nakamura2/rel/ajax-loader.gif" style="width: 16px; height: 16px">添付ファイルを送信中....';
form.action='/seek/fileup.pl?uniq='+user.uniq+'&docsrl='+docsrl+'&elms='+dragElement;
} else if(dragElement=='page_holi'){
sending='<img src="/nakamura2/rel/ajax-loader.gif" style="width: 16px; height: 16px">文末罫線を設定中....';
} else if(dragElement=='page_link'){
sending='<img src="/nakamura2/rel/ajax-loader.gif" style="width: 16px; height: 16px">リンク先をチェック中....';
}
//alert('dragElement/form.docsrl.value: '+dragElement+'/'+form.docsrl.value);
$('nowloading2').update(sending);
if(dragElement=='page_graph' || dragElement=='page_attach'){
form.submit();
} else {
form.uniq.value=user.uniq;
var url = '/seek/estpost.pl';
var pars = Form.serialize(form.id)+'elms='+dragElement;
var myAjax = new Ajax.Request(
url, 
{
method: 'post', 
parameters: pars, 
onSuccess: function (originalRequest) {
originalRequest.responseText.evalScripts();
},
onFailure: function (originalRequest) {
$(dragElement).show();
$('nowloading2').update('読み込みに失敗しました');
},
onException: function (originalRequest) {
$(dragElement).show();
$('nowloading2').update('読み込み中にエラーが発生しました');
}
});
}
}
function setpart2(form){
var sending='<img src="/nakamura2/rel/ajax-loader.gif" style="width: 16px; height: 16px">ファイルを送信中....';
$('nowloading2').update(sending);
form.submit();
}
function setmfiles(docsrl,msg,succ){
ASYOUJS.Modal.close();
if($('lurl'+docsrl)){
new Insertion.After('lurl'+docsrl, msg);
} else {
new Insertion.After('jbody_cmd'+docsrl, msg);
}
drags.del('page_graph');;
$('page_graph').hide();
chgContent('addpart','none');
//setaddparttop();
Event.observe(window,'scroll',setaddparttop);
showsucerr(succ,0);
}
function setaddparttop(){
$('addpart').setStyle({'top':(posTop()+100)+'px'});
}
function setimgfiles(docsrl,msg){
new Insertion.Before('jbody_cmd'+docsrl, msg);
var text='<div class="imgview" id="imgview_cmd'+docsrl+'"><span id="nowloading4_'+docsrl+'"></span><select name="" onchange="chgalign(this,'+docsrl+')">\
<option value="4">左寄せ</option>\
<option value="5">右寄せ</option>\
<option value="6">センター</option>\
</select><input id="ediimg'+docsrl+'" class="imgdel" type="button" value="編" onclick="graphicwin('+docsrl+',1)">\
<input id="delimg'+docsrl+'" class="imgdel" type="button" value="削" onclick="delparts('+docsrl+',\'imgframe\')"></div>';
new Insertion.Bottom('imgframe'+docsrl, text);
setcaptionedit(docsrl);
chgContent('addpart','none');
Event.observe(window,'scroll',setaddparttop);
drags.del('page_attach');
$('page_attach').hide();
var text2='<input type="button" value="サイズを変更する" onclick="graphicwin('+docsrl+')" style="width: 18ex"> | ';
text2 +='<input type="button" value="そのまま使用する" onclick="ASYOUJS.Modal.close()" style="width: 18ex">';
$('nowloading2').update(text2);
$('nowloading2').style.textAlign='center';
$('alerttext').update('<b>アップロード完了<'+'/b><br class="clear">イメージファイルがセットされました');
$('alert2_form').hide();
$('alert_close').hide();
}
function setcaptionedit(docsrl){
if(!editfin.chk('jdesc_cmd'+docsrl) && 
	$('jdesc_cmd'+docsrl)){
$('jdesc_cmd'+docsrl).editInPlace({
	empty_text: 'キャプションを入力',
	more_data: {
		'uniq': user.uniq,
		'docsrl': docsrl,
		'save': 1
	},
	select_text: true
});
}
}
function getcal(date){
EditInPlace.defaults['save_url'] = '/seek/estpost.pl';
EditInPlace.defaults['chk_func'] = 'editstat.get()';
EditInPlace.defaults['save_on_enter'] = false;
EditInPlace.defaults['allcancel_btn'] = 'doprev';
if(!date){
var dt=new Date;
var yy = dt.getYear();
if (yy < 2000) yy += 1900;
var mm = dt.getMonth() + 1;
if (mm < 10) mm = '0'+mm;
var dd = dt.getDate();
if (dd < 10) dd = '0'+dd;
date=''+yy+mm+dd;
}
$('calender').update('<img src="/nakamura2/rel/progress_circle2.gif" width="32" height="32" style="margin: 50px auto">');
var myAjax = new Ajax.Updater('calender','/seek/getcal.pl', {
method: 'post', 
parameters: 'date='+date+(user.uniq? '&uniq='+user.uniq:''),
onSuccess: function (originalRequest) {
},
onFailure: function (originalRequest) {
$('calender').update('読み込みに失敗しました');
},
onException: function (originalRequest) {
$('calender').update('読み込み中にエラーが発生しました');
},
evalScripts: true
});
}
function pageWidth() {
return window.innerWidth != null? window.innerWidth : document.documentElement && document.documentElement.clientWidth ?       document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;
}
function pageHeight() {
return  window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ?  document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null;
}
function posLeft() {
return typeof window.pageXOffset != 'undefined' ? window.pageXOffset :document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body != null && document.body.scrollLeft ? document.body.scrollLeft : 0;}
function posTop() {
return typeof window.pageYOffset != 'undefined' ?  window.pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body != null && document.body.scrollTop ? document.body.scrollTop : 0;
}
