var G_OpenedMenuItem;

function submitForm(frm, msg)
{
  document.forms[frm]._outputMessage.value = msg;
  document.forms[frm].submit();
}

function openMenuItem(MenuItemID)
{
  // turn off prev menu Item
  if (G_OpenedMenuItem)
    G_OpenedMenuItem.style.display = 'none';

  var menuItem = document.getElementById(MenuItemID);
  if (menuItem)
  {
    menuItem.style.display = menuItem.style.display?'' : 'none';
  }
  G_OpenedMenuItem = menuItem;

  var today = new Date();
  var expires = new Date(today.getTime() + (56 * 86400000));
  var stringCookie = "OpenedMenuItem" + "=" +escape(MenuItemID) + ";expires=" + expires.toGMTString() + ";path=/";
  document.cookie = stringCookie;
}

function openPopUp(url, name)
{
  win=window.open(url, name,'scrollbars=yes,resizable=yes,width=640,height=480');
  win.focus();
}

function openPopUpSize(url, name, width, height)
{
    var w = width;
    var h = height;
    if (w > screen.availWidth-40) { w = screen.availWidth-40 }
    if (h > screen.availHeight-40) { h = screen.availHeight-40 }

  win=window.open(url, name,'scrollbars=yes,resizable=yes,top=0,left=0,width='+w+',height='+h);
  win.focus();
}

function openResortInfoDetail(url)
{
  var width = screen.availWidth-100;
  var height = screen.availHeight-100;

  win=window.open(url, 'resortInfoDetail','scrollbars=yes,resizable=yes,top=10,left=10,width='+width+',height='+height);
  win.focus();
}

function previewField(tmp_value)
{
  var width = screen.availWidth-300;
  var height = screen.availHeight-200;

  win=window.open('', 'preview','scrollbars=yes,resizable=yes,top=10,left=10,width='+width+',height='+height);
  win.focus();
  win.document.open()
  win.document.write('<html>');
  win.document.write('<body>');
  win.document.write('<form name=\"previewForm\" action=\"/WMOwners/web/previewPseudoCode.php\" method=\"post\">');
  win.document.write('<input type=\"hidden\" name=\"PreviewValue\" value=\"\">');
  win.document.write('</form>');
  win.document.write('</body>');
  win.document.write('</html>');
  win.document.close();

  win.document.forms['previewForm'].PreviewValue.value = tmp_value;
  win.document.forms['previewForm'].submit();
}

function onResortGroupChange(HTMLFormName)
{
  if(document.forms[HTMLFormName].rg.selectedIndex !=0 )
    document.forms[HTMLFormName].submit();
}

function onResortChange(HTMLFormName)
{
  if(document.forms[HTMLFormName].resort.selectedIndex !=0 )
    document.forms[HTMLFormName].submit();
}

function deleteAlbum(url)
{
  var ret;
  ret = confirm("This album and all pictures in it will be permanently deleted");
  if (ret)
    window.location.href=url;

}

function deleteReview(url)
{
  var ret;
  ret = confirm("This review will be permanently deleted");
  if (ret)
    window.location.href=url;

}

function deletePicture(url)
{
  var ret;
  ret = confirm("This picture will be permanently deleted");
  if (ret)
    window.location.href=url;
}

function openPage(url)
{
  window.location.href=url;
}