/*
postData()
*/

/*画像合成プログラムからのデータ(ファイル名)を受け取って表示*/
function printResData(text_data){

    var gousei_image = document.getElementById('gouseiimage');
    gousei_image.innerHTML = '<img id="gouseiimg" src="' + gousei_dir + text_data + '">';

    openChildWindow();

    //合成画像のファイル名を配列に格納・imageDelete関数で使用
    gousei_src.push(text_data);

}


/*ウィンドウを開いて合成画像を表示*/
function openChildWindow(){

    var gousei_window = document.getElementById('gouseiwindow');
    gousei_window.style.visibility = 'visible';

}


/*ウィンドウの表示位置*/
function childWindowXY(e){

    var gousei_window = document.getElementById('gouseiwindow');
    gousei_window.style.left = e.clientX + 'px';
    gousei_window.style.top = e.clientY + 'px';

}


/*ウィンドウを閉じる*/
function closeChildWindow(){

    var gousei_window = document.getElementById('gouseiwindow');
    gousei_window.style.visibility = 'hidden';

}


/*データを画像合成プログラムに送る*/
function postData(e){

    // フォームに格納したファイル名を取得
    var hair_url = document.getElementById('hairform').value;
    var glasses_url = document.getElementById('glassesform').value;
    var eyebrows_left_url = document.getElementById('eyebrowslform').value;
    var eyebrows_right_url = document.getElementById('eyebrowsrform').value;
    var eyes_left_url = document.getElementById('eyeslform').value;
    var eyes_right_url = document.getElementById('eyesrform').value;
    var nose_url = document.getElementById('noseform').value;
    var mouth_url = document.getElementById('mouthform').value;
    var cheeks_left_url = document.getElementById('cheekslform').value;
    var cheeks_right_url = document.getElementById('cheeksrform').value;
    var outline_url = document.getElementById('outlineform').value;
    var backhair_url = document.getElementById('backhairform').value;
    var background_url = document.getElementById('backgroundform').value;

    // フォームに格納したオプションのチェックを取得
    var image_format = document.getElementById('formatform').value;
    var trimming_checked = document.getElementById('trimmingform').value;

    // フォームに格納したレイヤーの位置を取得
    var eyebrows_left_top = document.getElementById('eyebrowsltop').value;
    var eyebrows_left_left = document.getElementById('eyebrowslleft').value;
    var eyebrows_right_top = document.getElementById('eyebrowsrtop').value;
    var eyebrows_right_left = document.getElementById('eyebrowsrleft').value;
    var eyes_left_top = document.getElementById('eyesltop').value;
    var eyes_left_left = document.getElementById('eyeslleft').value;
    var eyes_right_top = document.getElementById('eyesrtop').value;
    var eyes_right_left = document.getElementById('eyesrleft').value;
    var cheeks_left_top = document.getElementById('cheeksltop').value;
    var cheeks_left_left = document.getElementById('cheekslleft').value;
    var cheeks_right_top = document.getElementById('cheeksrtop').value;
    var cheeks_right_left = document.getElementById('cheeksrleft').value;
    var nose_top = document.getElementById('nosetop').value;
    var nose_left = document.getElementById('noseleft').value;
    var mouth_top = document.getElementById('mouthtop').value;
    var mouth_left = document.getElementById('mouthleft').value;
    var glasses_top = document.getElementById('glassestop').value;
    var glasses_left = document.getElementById('glassesleft').value;


    // 合成ウィンドウの表示位置を指定する関数
    childWindowXY(e);

    var post_data;

    post_data = '&hair=' + encodeURIComponent(hair_url)
 + '&glasses=' + encodeURIComponent(glasses_url)
 + '&eyebrows_left=' + encodeURIComponent(eyebrows_left_url)
 + '&eyebrows_right=' + encodeURIComponent(eyebrows_right_url)
 + '&eyes_left=' + encodeURIComponent(eyes_left_url)
 + '&eyes_right=' + encodeURIComponent(eyes_right_url)
 + '&nose=' + encodeURIComponent(nose_url)
 + '&mouth=' + encodeURIComponent(mouth_url)
 + '&cheeks_left=' + encodeURIComponent(cheeks_left_url)
 + '&cheeks_right=' + encodeURIComponent(cheeks_right_url)
 + '&outline=' + encodeURIComponent(outline_url)
 + '&backhair=' + encodeURIComponent(backhair_url)
 + '&background=' + encodeURIComponent(background_url)
 + '&trimming=' + encodeURIComponent(trimming_checked)
 + '&format=' + encodeURIComponent(image_format)
 + '&eyebrows_left_top=' + encodeURIComponent(eyebrows_left_top)
 + '&eyebrows_left_left=' + encodeURIComponent(eyebrows_left_left)
 + '&eyebrows_right_top=' + encodeURIComponent(eyebrows_right_top)
 + '&eyebrows_right_left=' + encodeURIComponent(eyebrows_right_left)
 + '&eyes_left_top=' + encodeURIComponent(eyes_left_top)
 + '&eyes_left_left=' + encodeURIComponent(eyes_left_left)
 + '&eyes_right_top=' + encodeURIComponent(eyes_right_top)
 + '&eyes_right_left=' + encodeURIComponent(eyes_right_left)
 + '&cheeks_left_top=' + encodeURIComponent(cheeks_left_top)
 + '&cheeks_left_left=' + encodeURIComponent(cheeks_left_left)
 + '&cheeks_right_top=' + encodeURIComponent(cheeks_right_top)
 + '&cheeks_right_left=' + encodeURIComponent(cheeks_right_left)
 + '&nose_top=' + encodeURIComponent(nose_top)
 + '&nose_left=' + encodeURIComponent(nose_left)
 + '&mouth_top=' + encodeURIComponent(mouth_top)
 + '&mouth_left=' + encodeURIComponent(mouth_left)
 + '&glasses_top=' + encodeURIComponent(glasses_top)
 + '&glasses_left=' + encodeURIComponent(glasses_left);

    var target_url = 'gousei.php';

    httpPostRequest(target_url,post_data,printResData);

}