
/* Merged Plone Javascript file
 * This file is dynamically assembled from separate parts.
 * Some of these parts have 3rd party licenses or copyright information attached
 * Such information is valid for that section,
 * not for the entire composite file
 * originating files are separated by ----- filename.js -----
 */

/* ----- formsubmithelpers.js ----- */
function inputSubmitOnClick(event) {
    if (!event) var event = window.event; // IE compatibility

    if (hasClassName(this, 'submitting')) {
        return confirm(window.form_resubmit_message);
    } else {
        addClassName(this, 'submitting');
    }
    return true;
}

function registerSubmitHandler() {
    var nodes = cssQuery('input[type=submit]');
    for (var i=0; i<nodes.length; i++) {
        var node = nodes[i];
        if (!node.onclick) {
            node.onclick = inputSubmitOnClick;
        }
    }
}
registerPloneFunction(registerSubmitHandler);


/* ----- block_on_off.js ----- */
/**
 * WYSIWYG ContentsChange
 *
 * @param
 * @return
 **
function wysiwyg_template_change(){
    var temp = document.getElementById("templatename");
    var i = temp.selectedIndex;
    //TemplateData for IE
    var templatedata_ie = temp.options[i].name;
    //TemplateData for Firefox
    var templatedata_ff = temp.options[i].attributes[0].textContent;
    
    //var templatename2 = temp.options[i].form.templatename.id;
    var temp2 = document.getElementById("kupu-editor-main_content");
    //alert(templatedata);
    var divclass = temp2.childNodes[1].childNodes[3];
    var kupueditor = temp2.childNodes[1].childNodes[3].childNodes[5];
    //var kupueditor = document.getElementsByName("kupu-editor-iframe");
    var kupustyle = kupueditor.style;
    var htmleditor = document.getElementsByName("main_content");
    var htmlstyle = htmleditor[0].form.main_content.style;
    var sourceedit = switchSourceEdit();

    if (kupustyle.display == 'block' | kupustyle.display == '') divclass.className = "kupu-fulleditor kupu-sourcemode"; kupustyle.display = "none"; htmlstyle.display = "block";
    //alert(temp2.childNodes[1].childNodes[3].childNodes[5].innerHTML); kupu-fulleditor kupu-sourcemode
    if (templatedata_ie == undefined)
        temp.options[i].form.main_content.value = templatedata_ff;
        //kupueditor.focus();
    else 
        temp.options[i].form.main_content.value = templatedata_ie;
        
    if (kupustyle.display == 'none') divclass.className = "kupu-fulleditor"; htmlstyle.display = "none"; kupustyle.display = "block";


}**/

/**
 * Comment of StatusChange Setting
 * コメント情報をリクエストに付加して、ステータス変更処理に遷移するスクリプト
 *
 * @param
 * @return
 **/
function statusChangeWithComment(workflow)
{
    var comments = document.getElementById("status_comment");
    //var commentaa = comments.value;

    document.forms[1].action = './content_status_modify';
    document.forms[1].method = 'post';
    document.forms[1].id.value='edit_form';
    document.forms[1].name.value='edit_form';
    document.forms[1].comment.value=comments.value;
    document.forms[1].workflow_action.value=workflow;
    document.forms[1].submit();
    //var workflow_action = document.getElementById("workflow_action");
    //document.form.name = 'aai';
    //document.aa.id = 'ab';
    //document.forms[0].hidden.workflow_action.value=workflow.value;
    //document.forms[0].hidden.name='workflow_action';
    //document.forms[0].hidden.type='hidden';
    //document.forms[0].hidden.name='comment';
    //document.forms[0].hidden.type='hidden';
    //url = "./content_status_modify?workflow_action=" + workflow  + "&comment=" + comment.value;
    //location.href = url;
    //comment = this.contentarea.childNodes[9].value;
    //alert(comment.value);
    //tMenu = document.getElementById(tName).style; 
    //if (tMenu.display == 'none') tMenu.display = "block"; else tMenu.display = "none";
}

/*
*
* 外部URL登録で使用するCSV選択画面表示用スクリプト
*
*@param value URL
*
*/
function selectExportCsv(){
    tMenu = document.getElementById("selectbox_csv").style;
    if(tMenu.display == 'none') tMenu.display = "block"; else tMenu.display = "none";
}

/*
*
* 外部URL登録で使用するCSV出力用スクリプト
*
*@param value URL
*
*/
function exportCsv(value){
    window.location.href = value;
    tMenu = document.getElementById("selectbox_csv").style;
    if(tMenu.display == 'none') tMenu.display = "block"; else tMenu.display = "none";
}

/*
*
* ステータス変更時のコメント入力フォーム表示用スクリプト
*
*@param value URL
*
*/
function showCommentForm(status){
    //window.location.href = value;
    tMenu = document.getElementById("status_modify_edit_form").style;
    //if(tMenu.display == 'none') tMenu.display = "block"; else tMenu.display = "block";
    if(tMenu.display == 'none') tMenu.display = "block";
    //next_workflow_status = document.getElementById('workflow_action').value;
    //alert(workflow_action);
    tForm = document.getElementById("edit_form");
    tForm.workflow_action.value = status;
    //tForm.changebtn.value = status;
    //document.forms[2].workflow_action.value = status;
    //document.forms[2].changebutton.value = status;
    var aa;
}

/*
* リセットボタン（その他ニュース用）
*/
function otherSearchClear(other_start,other_end){
    other_start.value="";
    other_end.value="";
}
/*
* リセットボタン（プレスリリース用）
*/
function pressSearchClear(press_start,press_end,press_naiyou,nedofield){
    press_start.value="";
    press_end.value="";
    press_naiyou.value="";
    nedofield.value="100";
}
/*
* リセットボタン（記者会見用）
*/
function kaikenSearchClear(pressorder_start,pressorder_end,nedofield){
    pressorder_start.value="";
    pressorder_end.value="";
    nedofield.value="100";
}
/*
* リセットボタン（入札用）
*/
function nyusatsuSearchClear(nyusatsu_start,nyusatsu_end){
    nyusatsu_start.value="";
    nyusatsu_end.value="";
}
/*
* リセットボタン（公募用）
*/
function kouboSearchClear(koubojigyoday,releasedate_start,releasedate_end,koubo_status,nedofield,search_key_jigyounaiyou,search_key_taishosya){
    koubojigyoday.value="";
    releasedate_start.value="";
    releasedate_end.value="";
    koubo_status.value="";
    nedofield.value="100";
    search_key_jigyounaiyou.value="";
    search_key_taishosya.value="";
}
/*
* リセットボタン（イベント用）
*/
function eventsSearchClear(event_start,event_end,eventtype){
    event_start.value="";
    event_end.value="";
    eventtype.value="";
}
/*
* コメント400文字制限
*/
function limitChars(target,maxlength) {
    if ( target.value.length > maxlength ) {
        alert("「メッセージ」は400文字以内です。");
        target.value = target.value.substr(0,maxlength);
    }
    target.focus(); // BackSpace無効
}

