function n_displayDocuments()
{
     var url = 'modules.php?mod=membernews&pageno=0';
     displayText('maincontent',url);
}

function n_displayUsersPage(page)
{
     var form=document.getElementById('membernews_search');
     if (isEmpty(form.searchfield))
          {
          displayText('maincontent','modules.php?mod=membernews&req=displayall&pageno=' +page);
          }
     else
    	  {displayText('maincontent','modules.php?mod=membernews&req=search&pageno=' +page+'&searchfield='+encodeURIComponent(form.searchfield.value)); 
	  	  }
}
/*function n_addDocument()
{
     var url = 'modules.php?mod=adminpandp&req=add';
     displayText('maincontent',url);
}


function n_insertDocument()
{
     var form = document.getElementById('documentform');
     var docname = document.getElementById('myfile').value;
     if (docname =='')
          {
          alert('You must upload a file.');
          return false;
          }

     if ( ! n_validateDocumentForm(form))
          return false;

     var url = 'modules.php?mod=adminpandp&req=insert'+
               '&docname='+encodeURIComponent(docname)+
               '&title='+encodeURIComponent(form.title.value)+
               '&synopsis='+encodeURIComponent(form.synopsis.value)+
               '&description='+encodeURIComponent(form.description.value)+
               '&month='+encodeURIComponent(form.month.value)+
               '&year='+encodeURIComponent(form.year.value);
     ret = serverFunction(url);
alert(ret);
     var url = 'modules.php?mod=adminpandp';
     displayText('maincontent',url);
     return false;
}

function n_editDocument(docid)
{
     var url = 'modules.php?mod=adminpandp&req=edit&id='+docid;
     displayText('maincontent',url);
}

function n_updateDocument()
{
     var form = document.getElementById('documentform');

     if ( ! ap_validateDocumentForm(form))
          return false;

     var docname = document.getElementById('myfile').value;
//alert(docname + "*" + form.filename.value);

     var url = 'modules.php?mod=adminpandp&req=update'+
               '&docid='+encodeURIComponent(form.docid.value)+               
               '&docname='+encodeURIComponent(docname)+
               '&title='+encodeURIComponent(form.title.value)+
               '&synopsis='+encodeURIComponent(form.synopsis.value)+
               '&description='+encodeURIComponent(form.description.value)+
               '&month='+encodeURIComponent(form.month.value)+
               '&filename='+encodeURIComponent(form.filename.value)+
               '&year='+encodeURIComponent(form.year.value);
//alert(url);
     ret = serverFunction(url);
//alert(ret);
     var url = 'modules.php?mod=adminpandp';
     displayText('maincontent',url);
}


function n_deleteDocument(docid)
{
     if (confirm('Are you sure you want to delete this document?'))
          {
          var url = 'modules.php?mod=adminpandp&req=delete&id='+docid;
          serverFunction(url);
          var url = 'modules.php?mod=adminpandp';
          displayText('maincontent',url);
          }
     return false;
}


function n_archiveDocument(docid)
{
     if (confirm('Are you sure you want to archive this document?'))
          {
          var url = 'modules.php?mod=adminpandp&req=archive&id='+docid;
          serverFunction(url);
          var url = 'modules.php?mod=adminpandp';
          displayText('maincontent',url);
          }
     return false;
}


//function stopDocumentUpload(success,path,tmp) is in functions.js
*/
function n_validateDocumentForm(form)
{
     var error_message = "The following errors occurred:\n";
     var errors=0;
     if (isEmpty(form.title))
          {
          error_message = error_message + "\t\ntitle is missing";
          errors=1;
          }
     if (isEmpty(form.synopsis))
          {
          error_message = error_message + "\t\nsynopsis is missing";
          errors=1;
          }
     if (isEmpty(form.description))
          {
          error_message = error_message + "\t\ndescription is missing";
          errors=1;
          }
     if (isEmpty(form.month))
          {
          error_message = error_message + "\t\nmonth is missing";
          errors=1;
          }
     if (isEmpty(form.year))
          {
          error_message = error_message + "\t\nyear is missing";
          errors=1;
          }

/*
     if (docname != '0' && docname =='')
          {
          error_message = error_message + "\t\nYou must upload a document";
          errors=1;
          }
*/
     if (errors==1)
         {
	     alert(error_message);
		 return true;
		 }
     return false; 
}

function n_displayNewsStory(newsid)
{
     //in use
     var url='modules.php?mod=membernews&req=newsstory&newsid='+newsid;
     displayText('maincontent',url); 
}


function n_searchNewsStory()
{
     var form=document.getElementById('membernews_search');

     if (isEmpty(form.searchfield))
          {
          displayText('maincontent','modules.php?mod=membernews');
          }
     else
    	  { displayText('maincontent','modules.php?mod=membernews&req=search&searchfield='+encodeURIComponent(form.searchfield.value)); 
	  }   
     return false;

}
