﻿function uranai_open ( n ) {

  switch ( n ) {

    case "シンプル派" :

      img = "simple";
      script = "何事にも動じないあなたは、あきの来ないスタンダードなリングがおすすめ";

      break;

    case "スタイリッシュ派" :

      img = "stylish"; 
      script = "シンプルの中にも存在感を求めているあなたは、都会なリングがおすすめ";

      break;

    case "キュート派" :

      img = "cute";
      script = "ロマンチックな夢をもつあなたはハッピーモチーフのリングがおすすめ";

      break;

    case "個性派" :

      img = "unique";
      script = "感性のするどいあなたはアートなカタチのリングがおすすめ";

      break;

  }

  if ( document.all )
    Doc = document.all( "uranai" );

  else if ( document.getElementById )
    Doc = document.getElementById( "uranai" );

  photo = "";

  for ( i = 0; i < 1; i++ ) {

    photo += "<ul>\n";

    for ( j = 0; j < 1; j++ ) {

      photo += '<li><img src="./img/uranai_img_' + img + '_01.jpg" width="140" height="90" /></li>';

    }
    for ( j = 0; j < 1; j++ ) {

      photo += '<li><img src="./img/uranai_img_' + img + '_02.jpg" width="140" height="90" /></li>';

    }
    for ( j = 0; j < 1; j++ ) {

      photo += '<li><img src="./img/uranai_img_' + img + '_03.jpg" width="140" height="90" /></li>';

    }

    photo += "</ul>\n";

  }

  Doc.innerHTML = '<p class="uranai_title_' + img + '">あなたは' + n + '</p>\n<p class="uranai_script_' + img + '">' + script + '</p>\n' + photo + '<p class="uranai_back">\n<a href="javascript: uranai_close();">戻る</a></p>';

}

function uranai_submit () {

  resultArr = new Array ( "シンプル派", "スタイリッシュ派", "キュート派", "個性派" );

  num = 1;
  flag = 0;

  for ( i = 1; i < 16; i++ ) {

    if ( document.all )
      Doc = document.all( "value_" + i );

    else if ( document.getElementById )
      Doc = document.getElementById( "value_" + i );

    Doc = eval ( "document.form.value_" + i );

    if ( i > 2 ) {

      if ( !Doc[ 0 ].checked && !Doc[ 1 ].checked ) {

        alert ( "Q" + i + "は入力してください。" );
        flag = 1;
        break;

      }

      else if ( Doc[ 0 ].checked )
        num += 2;

    }

    else
      num += Doc.value;

  }

  if ( flag == 0 ) {

    num += "";
    num = eval ( "Math.sqrt(" + num + ")" ) + "";
    num = eval ( "Math.round ((" + num.slice ( -1 ) + " - 0 )/ 10 * 4)" ) - 0; 

    if ( document.all )
      Doc = document.all( "uranai" );

    else if ( document.getElementById )
      Doc = document.getElementById( "uranai" );

    Doc.style.position = "absolute";
    Doc.style.zIndex = 9999;
    Doc.style.left ="50%";
    Doc.style.top = "50%";
    Doc.style.marginLeft = -350 + "px";
    Doc.style.marginTop = -50 + "px";
    Doc.style.width = 500 + "px";
    Doc.style.backgroundColor = "#FFE3F4";

    h = 0;
    ACTION = setInterval ( "uranai_action ( '" + resultArr[ num ] + "' )", 50 );

  }

}

function uranai_close () {

  if ( document.all ) {

    document.all( "uranai" ).innerHTML = "";
    document.all( "uranai" ).style.height = 0 + "px";

  }

  else if ( document.getElementById ) {

    document.getElementById( "uranai" ).innerHTML = "";
    document.getElementById( "uranai" ).style.height = 0 + "px";

  }

}

function uranai_action ( n ) {

  if ( document.all )
    Doc = document.all( "uranai" );

  else if ( document.getElementById )
    Doc = document.getElementById( "uranai" );

  h+=20;

  if ( h < 330 )
    Doc.style.height = h + "px";

  else {

    clearInterval ( ACTION );
    setTimeout ( "uranai_open ( '" + n + "' )", 900 );

  }

}
