
/* Copyright (c) 2003 Timothy Sakharov, Alexander Sakharov */

function submit_f() {

  var itemText1;
  var itemVal1;
  var item2;
  var itemVal1;
  var item;
  var itemVal1;
  var res = 0;

  var ind = document.theForm.selectbox1.selectedIndex;
  if ( ind == -1 ) {
    alert("Colors not selected");
    return false;
  }

  itemText1 = document.theForm.selectbox1.options[ind].text;
  itemValue1 = document.theForm.selectbox1.options[ind].value;
  if ( itemValue1.charAt(0) == '-' ) {
    alert("Colors not selected");
    return false;
  }

  ind = document.theForm.selectbox2.selectedIndex;
  if ( ind == -1 ) {
    alert("Colors not selected");
    return false;
  }

  itemText2 = document.theForm.selectbox2.options[ind].text;
  itemValue2 = document.theForm.selectbox2.options[ind].value;
  if ( itemValue2.charAt(0) == '-' ) {
    alert("Colors not selected");
    return false;
  }

  ind = document.theForm.selectbox3.selectedIndex;
  if ( ind == -1 ) {
    alert("Colors not selected");
    return false;
  }

  itemText3 = document.theForm.selectbox3.options[ind].text;
  itemValue3 = document.theForm.selectbox3.options[ind].value;
  if ( itemValue3.charAt(0) == '-' ) {
    alert("Colors not selected");
    return false;
  }

  if ( itemValue1 == 'ro'
  || itemValue2 == 'ro'
  || itemValue3 == 'ro' )
    res += 1;
  if ( itemValue1 == 'yp'
  || itemValue2 == 'yp'
  || itemValue3 == 'yp' )
    res += 1;
  if ( itemValue1 == 'gb'
  || itemValue2 == 'gb'
  || itemValue3 == 'gb' )
    res += 1;

  if ( res == 3 ) {
     location.replace("http://sakharov.net/puzzle/cubesolved.html"); //?SOLUTION=" + itemText1 + "|" + itemText2 + "|" + itemText3);
  } else {
    alert("Incorrect!");
    /*
    document.theForm.selectbox1.options[0].selected = true;
    document.theForm.selectbox2.options[0].selected = true;
    document.theForm.selectbox3.options[0].selected = true;
    */
  }
}

function solution_f() {

    arr = solution.split('|');
    document.theForm.selectbox1.options[ind].text = arr[0];
    document.theForm.selectbox1.options[ind].value = arr[0];
    document.theForm.selectbox2.options[ind].text = arr[1];
    document.theForm.selectbox2.options[ind].value = arr[1];
    document.theForm.selectbox3.options[ind].text = arr[2];
    document.theForm.selectbox3.options[ind].value = arr[2];

}
