function printResults(URL) {
   day = new Date();
   id = day.getTime();
   eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=0,height=0,left = 640,top = 400');");
}



if (document.images)
    {
      preload_image = new Image(60,60); 
      preload_image.src="/img/yes.gif"; 
    }


function Enable( name, val ) {
      var buttons = document.getElementsByName( name );
      for ( var i = 0; i < buttons.length; i++ ) {
         buttons[ i ].disabled = val;
      }
   }
  
   function disableRadioGrp(name)
   {
      var btns = document.getElementsByName(name);
      for(b in btns)
      {
            btns[b].disabled = true;
      }
   }
   
   function disableRadioButton(name,num)
   {
      var btns = document.getElementsByName(name);
      btns[num].disabled = true;
   }
   
   function disable(name,num) {
      var rb = document.getElementsByName(name);
      rb[num].disabled = true;
      // alert('MVW');
      return;
   }

function checkAnswer(CURL,QID,NUM,CID) {
   $.ajax({
      url: CURL + "/checkAnswer.php?QID=" + QID + "&NUM=" + NUM + "&CID=" + CID,
      type: 'POST',
      error: function (xhr, status) {
         alert("Error!  Message: " + status);
      },
      success: function (data) {
         $('#r_' + NUM).html(data);
      }
   });
}

function checkAnswer2(QID,NUM) {
   $.ajax({
      url: "checkAnswer.php?QID=" + QID + "&NUM=" + NUM,
      type: 'POST',
      error: function (xhr, status) {
         alert("Error!  Message: " + status);
      },
      success: function (data) {
         $('#r_' + NUM).html(data);
         if (QID = "q5") {
            resetForm(5);
         }
      }
   });
}

/*
function getTracklist(MIXID) {
   $.ajax({
      url: "/mixes/getTracklist.php?mix=" + MIXID,
      type: 'GET',
      error: function (xhr, status) {
         alert("Error!  Message: " + status);
      },
      success: function (data) {
         $('#tracklist_' + MIXID).html(data);
      }
   });
}
*/

function optionChanged(optNum) {
   // alert('Option changed');
   var selectNo = "q5_" + optNum;
   var thisSelect = document.getElementById(selectNo);
   
   var selectedOption = thisSelect.selectedIndex;
   var selected_text = thisSelect.options[selectedOption].text;
   // alert(selected_text);
   
   for (i=1; i<11; i++) 
   {
      if (i == optNum) {
         // alert('Not modifying option' + optNum);
         continue;
      }
      
      else {
         var thisID = "q5_" + i;
         // alert('About to change select ' + thisID);
         var selector = document.getElementById(thisID);
         selector.options[selectedOption].disabled=true;
      }
   }
}

function resetForm(qNo) {
   for (i=1; i<11; i++) 
   {
      var thisID = "q5_" + i;
      var selector = document.getElementById(thisID);
      
      for (j=1; j<selector.length; j++) {
         selector.options[j].disabled=false;
      }
      selector.options[0].selected=true;
   }
   
   setTimeout('resetCheckButton();',450);
   
   
   
   
}

function resetCheckButton() {
   var refill = document.getElementById("r_0");
   refill.innerHTML = '<img src="/img/maybe.gif" onClick="javascript: checkAnswer2(\'q5\',0);"  />';
}



function moveUp(){
/* var usedList = document.f1.IdxUsed; */
var usedList = document.getElementById("updownlist");
var i = usedList.selectedIndex;
var txt = usedList.options[i - 1].text
var val = usedList.options[i - 1].value
usedList.options[i - 1].text = usedList.options[i].text;
usedList.options[i - 1].value = usedList.options[i].value;
usedList.options[i].text = txt;
usedList.options[i].value = val;
usedList.selectedIndex = i - 1;
}

function moveDown(){
/* var usedList = document.f1.IdxUsed; */
var usedList = document.getElementById("updownlist");
var i = usedList.selectedIndex;
var txt = usedList.options[i + 1].text
var val = usedList.options[i + 1].value
usedList.options[i + 1].text = usedList.options[i].text;
usedList.options[i + 1].value = usedList.options[i].value;
usedList.options[i].text = txt;
usedList.options[i].value = val;
usedList.selectedIndex = i + 1;
}
