function swap(thing, newImage) {
  thing.src="images/"+newImage;
  return true;
}

function checkEESSdups() {
  if (document.naver.which_review.selectedIndex == document.naver.compare_review.selectedIndex)
  { window.alert("Please select two different reviews for comparison!"); }
  else
  { window.open('servlet/EESScompare?p1='+document.naver.which_review.options[document.naver.which_review.selectedIndex].value+'&p2='+document.naver.compare_review.options[document.naver.compare_review.selectedIndex].value); }
}

function openExport(indx)
{
  window.open('servlet/exporter?indx='+document.naver.which_programme.options[document.naver.which_programme.selectedIndex].value,'_blank');
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
  var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
  if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}



function editBIR(todo, action) { 
	document.naver.todo.value=todo;
	//document.naver.action=action;
	//alert(document.naver.action);
	document.naver.submit();
}

function addFormat(what, type)
{
  if (type == 'link')
  {
    var yoo = window.prompt('Please enter the complete URL for this link.','http://');
    if (yoo != null && yoo != 'null' && yoo != 'undefined' && yoo != '')
    {
	var target = ' target="_blank"';
	var yes = window.confirm('Is this link an "internal link"?\n(Will this link point to a page within this site?)\n\nClick "OK" if this is an "internal link".');
	if (yes)
	{ target = ''; }
      var stuff = window.prompt('Please enter the text for this link.','');
      if (stuff != null && stuff != 'null' && stuff != 'undefined' && stuff != '')
        what.value = what.value + '<a href="' + yoo + '"' + target + '>'+stuff+'</a>';
    }
  }
  else if (type == 'email')
  {
    var yoo = window.prompt('Please enter the correct email address for this email link.','');
    if (yoo != null && yoo != 'null' && yoo != 'undefined' && yoo != '')
    {
	var stuff = window.prompt('Please enter the text for this email link.','');
      if (stuff != null && stuff != 'null' && stuff != 'undefined' && stuff != '')
        what.value = what.value + '<a href="mailto:' + yoo + '">'+stuff+'</a>';
    }
  }
  else if (type == 'blue')
  {
    var stuff = window.prompt('Please enter the text you would like to appear formatted.','');
    if (stuff != null && stuff != 'null' && stuff != 'undefined' && stuff != '')
    {
      stuff = '<span class="blue"><b>' + stuff + '</b></span>';

      what.value = what.value + stuff;    
    }
  }
  else
  {
    var stuff = window.prompt('Please enter the text you would like to appear formatted.','');
    if (stuff != null && stuff != 'null' && stuff != 'undefined' && stuff != '')
    {
      var add = '';
      for (i=0; i<type.length; i++)
        add += '<' + type.charAt(i) + '>';

	stuff = add + stuff;

	add = '';
	for (i=type.length-1; i>=0; i--)
        add += '</' + type.charAt(i) + '>';  

	stuff += add;

	what.value = what.value + stuff;    
    }
  }
}

function youSureMessage()
{
  var yes=window.confirm("Are you SURE you want to delete checked messages?");
  if (yes)
  {
    document.naver.todo.value='deletemsg';
    document.naver.submit();
  }
}

function youSureCompany()
{
  var yes=window.confirm("Are you SURE you want to delete this company?");
  if (yes)
  {
    var sure=window.confirm("Are you ABSOLUTELY SURE you want to delete this company?\n\nRemoving this company will PERMANENTLY delete EVERY\ndatabase record associated with it!");
    if (sure)
    {  
      document.naver.todo.value='deletethiscompany';
      document.naver.submit();
    }
  }
}

function youSureManual()
{
  var yes=window.confirm("Are you SURE you want to delete this output?");
  if (yes)
  {
    document.naver.todo.value='deletemanual';
    document.naver.submit();
  }
}

function youSureDelete(message,acto)
{
  var yes=window.confirm(message);
  if (yes)
  {
    document.naver.todo.value=acto;
    document.naver.submit();
  }
}

function youSureSpecific(message,acto,which)
{
  var yes=window.confirm(message);
  if (yes)
  {
    document.naver.todo.value=acto;
    document.naver.which_one.value=which;
    document.naver.submit();
  }
}

function alterPage()
{
  window.open('servlet/alterPage?p='+document.naver.which_one.options[document.naver.which_one.selectedIndex].value,'_blank'); 
}

function getValue(elementName){
	var el = document.getElementById(elementName);
	if(el)
		return el.value;
	return null;
}
