var lastin  = "";

function abortReply(subject)
{
  document.replypost.subject.value = subject;
  document.replypost.message.innerHTML = '';
  fadeOut('reply');
}

function messagePreview(formname)
{
  
}

function submitTest(thisform)
{
  if (!thisform.eid.value) { alert("Please select the emulator!"); return false; }
  if (!thisform.version.value) { alert("Please specify the emulator version!"); return false; }
  if (!thisform.rating.value) { alert("Please choose a rating!"); return false; }
  if (confirm("Are you sure the test information you are about to submit is correct?")) { return true; }
  else { alert("Submission aborted!"); return false; }
}

function limitText(limitField, limitNum) {
    if (limitField.value.length > limitNum) {
        limitField.value = limitField.value.substring(0, limitNum);
    } 
}

function changeOptionText(id,newtext)
{
    $(id).options[x.selectedIndex].text = newtext;
}

function fadeIn(fademe)
{
  new Effect.Appear(fademe, {duration:.3});
}

function fadeOut(fademe)
{
  new Effect.Fade(fademe, {duration:.3});
}

function toggle_list(fadeout,fadein) 
{
  if ($('menu_'+fadein)) 
  {
    $('menu_'+fadein).className = 'active';
    $('menu_'+fadeout).className = '';
  }
  fadeOut(fadeout);
  setTimeout('fadeIn(\''+fadein+'\')',400);
}

function toggle_div(fadein)
{
  if (lastin == '') fadeIn(fadein)
  else if (fadein != lastin) toggle_list(lastin,fadein)
  lastin = fadein;
}

function showScreenshot(img,title,width,height)
{
  width = width * 1;
  height = height * 1;
  pagewidth = width+35;
  pageheight = height+45;
  windowheight = document.viewport.getDimensions().height;
  imagetop = ((windowheight - height) / 2) - 25;
  if (imagetop < 0) imagetop = 0;
  $('screenshot').style.top = imagetop+"px";
  $('screenshot').innerHTML = "<h2 class=\"subtitle\" style=\'width: "+pagewidth+"px; height: "+pageheight+"px;\' onclick=\'hideScreenshot()\'>"+title+"<br><span id=\'loading\' style=\'width: "+width+"px; height: "+height+"px;\'><img id=\"screenshot_img\" style=\'width: "+width+"px; height: "+height+"px; display: none;\'src=\'\' onload=\'fadeIn(\"screenshot_img\")\'></span>Click anywhere in this popup to close!</h2>";
  $('dimpage').style.display = "block";
  fadeIn('screenshot');
  $('screenshot_img').src = img;
}

function hideScreenshot()
{
  fadeOut('dimpage');
  fadeOut('screenshot');
}