function setDefault() {
  if(confirm('Are you sure you want to revert to the Crescendo default text for this section? \nBy clicking OK, all customization for this section will be discarded.'))
    document.location = "gleg_mem_set_defaults.jsp";
}

function goUndo() {
  if(confirm('Are you sure you want to undo your last updates for this section? \nBy clicking OK, you will restore your previously saved text.'))
    document.location = "gleg_mem_undo.jsp";
}

function parentGoMain() {
  window.opener.document.location = "gleg_mem_main.jsp";
}

function confirmClose() {
  if(confirm('Are you sure you wish to exit the wizard?'))
    window.close();
}

function startWizard(url) {
  wW = 780;
  wH = 550;

  x = 10;
  y = 10;

  if(screen.height > 612) {
    wH = screen.height * 0.90;
  }

  if(wW < screen.width)
	x = (screen.width - wW) / 2; 

  params = 'height=' + wH + 
		   ',width=' + wW + 
		   ',left=' + x + 
		   ',top=' + y +
		   ',scrollbars=1';
  newWindow = window.open(url,'Wizard',params);	
  newWindow.focus();
  setInterval("checkForNewWindow()", 250);
}

function checkForNewWindow() {
  if (newWindow.closed) {
    document.location = "gleg_mem_main.jsp";
    clearInterval();
  }
  
}

function goNext() {
  document.WizForm.direction.value = "next";
  document.WizForm.func.value = "save";
  if(document.WizForm.textvalue)
	document.WizForm.textvalue.value = getEditorText();
  document.WizForm.submit();
}

function goBack() {
  document.WizForm.direction.value = "back";

  if(confirm('Click OK to save your changes or click Cancel to go back without saving.')) {
	document.WizForm.func.value = "save";
    if(document.WizForm.textvalue)
	  document.WizForm.textvalue.value = getEditorText();
  } else {
	document.WizForm.func.value = "nosave";
  }
  document.WizForm.submit();
}

function goExit() {
  document.WizForm.direction.value = "exit";

  if(confirm('Click OK to save your changes.')) {
    document.WizForm.func.value = "save";
    if(document.WizForm.textvalue)
      document.WizForm.textvalue.value = getEditorText();
  } else {
	document.WizForm.func.value = "nosave";
  }
  document.WizForm.submit();
}

function goPreview() {
  setEditor(getEditorText());
}

function goPublished(link) {
  //if(confirm('You must first save in order to see any changes you have made.\nWould you like to save your changes first?\nClick OK to save.')) {
  if(document.WizForm) {
    document.WizForm.direction.value = "publish";
    document.WizForm.func.value = "save";
    if(document.WizForm.textvalue)
      document.WizForm.textvalue.value = getEditorText();
    document.WizForm.submit();
  } else {
    window.open(link);
  }
  //} else {
  //  window.open(link);
  //}
}

function goDonorDescPreview() {
  out = document.getElementById('previewArea').innerHTML;
  sStoryTitle = document.WizForm.titleData.value;
  sStoryDescription = document.WizForm.descData.value;

  out = out.substring(0,out.indexOf('<!--StoryTitle-->')+17) + sStoryTitle + out.substring(out.indexOf('<!--/StoryTitle-->')); 
  out = out.substring(0,out.indexOf('<!--StoryDesc-->')+16) + sStoryDescription + out.substring(out.indexOf('<!--/StoryDesc-->'));
  out = out.substring(0,out.lastIndexOf('<!--StoryTitle-->')+17) + sStoryTitle + out.substring(out.lastIndexOf('<!--/StoryTitle-->')); 

  document.getElementById('previewArea').innerHTML = out;
}

function goPlainPreview() {
  document.getElementById('previewArea').innerHTML = document.WizForm.descData.value;
}

function goStory(storyID) {
  document.WizForm.direction.value = "Story";
  document.WizForm.storyNo.value = storyID;
  if(confirm('Click OK to save your changes.')) {
	document.WizForm.func.value = "save";
  } else {
	document.WizForm.func.value = "nosave";
  }
  document.WizForm.submit();
}

function doEditorHelp() {
  window.open("gleg_mem_wiz_help.jsp", "GiftLegacy", "status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,scrollbars=1,width=550,height=425");
}

function doSectionsHelp() {
  window.open("gleg_mem_gleg_news_secs_help.jsp", "GiftLegacy", "status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,scrollbars=1,width=550,height=425");
}
function doListHelp() {
  window.open("gleg_mem_gleg_list_help.jsp", "GiftLegacy", "status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,scrollbars=1,width=550,height=425");
}
function doSendMessageHelp() {
  window.open("gleg_mem_gleg_message_help.jsp", "GiftLegacy", "status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,scrollbars=1,width=550,height=425");
}

function changegleg(des,key) {
  destination = "Pic"+des;
  document[destination].src= "images/members/gleg_members_" + des + key;
}

function changeglaw(des,key) {
  destination = "Pic"+des;
  document[destination].src= "images/members/glaw_members_" + des + key;
}

function popup(url, title, height, width) {
  window.open(url, '', "status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,scrollbars=1,width=" + width + ",height=" + height);
}
