<?
	require_once($_SERVER['DOCUMENT_ROOT']."/superdarn2008/scripts/dbConnect.php");
	$HEADER_LOC = "http://www.tiger.latrobe.edu.au/superdarn2008/modpaper.php";

	session_start();
	
	// Get the session parameters
	$cPaperID = $_SESSION['pid'];
	$cPasswd = $_SESSION['pwd'];
	$sysLOG = "";
	$sysERR = 0;
	
	//echo $cPaperID . " <br> " . $cPasswd . " <br> ";
	
	function genRandomPassAndToken($string, $salt_length = 9)
	{
		//http://au2.php.net/manual/en/function.mysql-real-escape-string.php
		$salt = substr(md5(uniqid(rand(), true)), 0, $salt_length);

		return $salt . sha1($salt . $string);
	}

	function send_mail($to, $body, $subject, $fromaddress, $fromname)
	{
	  $eol="\r\n";
	  $mime_boundary=md5(time());
	
	  # Common Headers
	  $headers .= "From: ".$fromname."<".$fromaddress.">".$eol;
	  $headers .= "Reply-To: ".$fromname."<".$fromaddress.">".$eol;
	  $headers .= "Return-Path: ".$fromname."<".$fromaddress.">".$eol;    // these two to set reply address
	  $headers .= "Message-ID: <".time()."-".$fromaddress.">".$eol;
	  $headers .= "X-Mailer: PHP v".phpversion().$eol;          // These two to help avoid spam-filters
	
	  # Finished
	  $msg = $body;
	  
	  # SEND THE EMAIL
	  ini_set(sendmail_from,$fromaddress);  // the INI lines are to force the From Address to be used !
	  $mail_sent = mail($to, $subject, $msg, $headers);
	 
	  ini_restore(sendmail_from);
	 
	  return $mail_sent;
	}


	/** *********************************************
	  *	Process the call for papers form
	  *
	 ** ****************************************** */
	$errMSG = "";
	$errorFlag = 0;
	if($_POST)
	{
		if( isset($_POST['Given_Names']) && isset($_POST['Family_Name']) && isset($_POST['Email']) &&
				isset($_POST['Paper_Title']) && isset($_POST['presType']) && isset($_POST['Authors']) &&
				isset($_POST['Affiliations']) && isset($_POST['Different_Presentor']) )
		{
			//All fields were successfully filled in
			$errorFlag = 0;		

			//Let's begin to prepare the data for DB insertion
			if(get_magic_quotes_gpc()) {
				$gName			= stripslashes(trim($_POST['Given_Names']));
				$lName			= stripslashes(trim($_POST['Family_Name']));
				$email			= stripslashes(trim($_POST['Email']));
				$title			= stripslashes(trim($_POST['Paper_Title']));
				$presType		= stripslashes(trim($_POST['presType']));
				$authors		= stripslashes(trim($_POST['Authors']));
				$affil			= stripslashes(trim($_POST['Affiliations']));
				$presenter	= stripslashes(trim($_POST['Different_Presentor']));
			} else {
				$gName			= trim($_POST['Given_Names']);
				$lName			= trim($_POST['Family_Name']);
				$email			= trim($_POST['Email']);
				$title			= trim($_POST['Paper_Title']);
				$presType		= trim($_POST['presType']);
				$authors		= trim($_POST['Authors']);
				$affil			= trim($_POST['Affiliations']);
      	$presenter	= trim($_POST['Different_Presentor']);
      }
			$_POST = array(); unset($_POST);
			
			$modSYS = $_SESSION['modSYS'];
			
			if($modSYS == 0)
			{
				header("Location: $HEADER_LOC?e=1");
      	exit();
			}
			
			//Set Up OLD value VARS
			$oGNAME = "";
			$oLNAME = "";
			$oEMAIL = "";
			$oTITLE = "";
			$oPRESTYPE = "";
			$oAUTHORS = "";
			$oAFFIL = "";
			$oPRESENTER = "";

			//Validate data fields
			if(!preg_match("/^([a-z0-9._-](\+[a-z0-9])*)+@[a-z0-9.-]+\.[a-z]{2,6}$/i",$email))
			{
				$errorFlag = 1;
			}
			
			if($cPaperID == NULL || $cPasswd == NULL)
				$errorFlag = 1;
				

			//If submitted data is valid, let's continue and begin UPDATING ALL FIELDS
			if($errorFlag == 0)
			{
				$db = connect_and_open("webuser", "sdarn08", "sDarn08");
				
				//Check if session variables have transferred across and are still valid wrt the DB
				$sql = sprintf("SELECT * FROM PaperContact WHERE PaperID = '%s' and Password = '%s'",
									mysql_real_escape_string($cPaperID, $db),
									mysql_real_escape_string($cPasswd, $db) );

				//echo $sql."<br /><br />";
				
				$qRes = run_query($sql, $db);
				if(mysql_num_rows($qRes) == 1)
				{
					//PaperID and password have carried... let's now begin the updates....
					
					//First we preserve everything into temporary variables which will be 
					//emailed off at the end of this process.
					
						//- Use result set from PaperContact
					$row = mysql_fetch_array($qRes, MYSQL_ASSOC);
					
					$oGNAME = $row['GName'];
					$oLNAME = $row['LName'];
					$oEMAIL = $row['Email'];
					
					mysql_free_result($qRes);
					
					//- Create result set for PaperDetails
					$sql = sprintf("SELECT * FROM PaperDetails WHERE PaperID = '%s'",
								mysql_real_escape_string($cPaperID, $db) );
					$qRes = run_query($sql, $db);
					if(mysql_num_rows($qRes) == 1)
					{
						$row = mysql_fetch_array($qRes, MYSQL_ASSOC);
						$oPRESTYPE = $row['PresType'];
						$oAUTHORS = $row['Authors'];
						$oAFFIL = $row['Affiliations'];
						$oPRESENTER = $row['Presenter'];

					}
					else
					{
						$errorFlag = 1; //Conflict of records
					}
					
					mysql_free_result($qRes);
					
						//- Create result set for PaperTitle
					$sql = sprintf("SELECT * FROM PaperTitle WHERE PaperID = '%s'",
								mysql_real_escape_string($cPaperID, $db) );
					$qRes = run_query($sql, $db);
					if(mysql_num_rows($qRes) == 1)
					{
						$row = mysql_fetch_array($qRes, MYSQL_ASSOC);
						$oTITLE = $row['PTitle'];
					}
					else
					{
						$errorFlag = 1; //Conflict of records
					}
					mysql_free_result($qRes);
					
					// ^^^^^-> FINISHED PRESERVING ALL OLD FIELDS STORED IN DB
					//--
					// Now we begin by updating all the tables irrespective if 
					// they were changed or not.
					// We figure out what has been changed and inject that into
					// the update query.
					if($title !== $oTITLE)
					{
						$sql = sprintf("UPDATE PaperTitle SET PTitle = '%s' WHERE PaperID = '%s'",
											mysql_real_escape_string($title, $db),
											mysql_real_escape_string($cPaperID, $db) );
					//	echo $sql . "<br>";
						$qRes = run_query($sql, $db);
					}
					
					//- Preparing PaperDetails updates
					$sqlPRESTYPE = $sqlAUTHORS = $sqlAFFIL = $sqlPRESENTER = "";
					
					if($presType != $oPRESTYPE)
						$sqlPRESTYPE = $presType;
					else
						$sqlPRESTYPE = $oPRESTYPE;
						
					if($authors != $oAUTHORS	)
						$sqlAUTHORS = $authors;
					else
						$sqlAUTHORS = $oAUTHORS;
					
					if($affil != $oAFFIL)
						$sqlAFFIL = $affil;
					else
						$sqlAFFIL = $oAFFIL;
						
					if($presenter != $oPRESENTER)
					{
						if($presenter == "")
							$presenter = $gName . " " . $lName;

						$sqlPRESENTER = $presenter;
					}
					else
					{
						if($oPRESENTER == "")
							$oPRESENTER = $oGNAME . " " . $oLNAME;
						$sqlPRESENTER = $oPRESENTER;
					}
					$sql = sprintf("UPDATE PaperDetails SET PresType = '%s', Authors = '%s', Affiliations = '%s', Presenter = '%s' WHERE PaperID = '%s'",
										mysql_real_escape_string($sqlPRESTYPE, $db),
										mysql_real_escape_string($sqlAUTHORS, $db),
										mysql_real_escape_string($sqlAFFIL, $db),
										mysql_real_escape_string($sqlPRESENTER, $db),
										mysql_real_escape_string($cPaperID, $db) );
					//echo $sql . "<br>";
					$qRes = run_query($sql, $db);

					
					//- Preparing PaperContact updates
					//	- IF ANY OF THESE DETAILS CHANGE - NEW EMAILS ARE SENT OFF 
					//	- AND VERIFICATION PROCESS MUST BE RESTARTED TO ENSURE VALID
					//	- DETAILS OF THE NEW CONTACT PERSON 
					//	- -------------------------------------------------------------
					//	- HOWEVER - If the emails are the same - verification shouldn't
					//	- be required
					//	- -------------------------------------------------------------
					$sqlGNAME = $sqlLNAME = $sqlEMAIL = "";
					$bNewVerification = false;
					
					if($gName !== $oGNAME)
						$sqlGNAME = $gName;
					else
						$sqlGNAME = $oGNAME;
						
					if($lName !== $oLNAME)
						$sqlLNAME = $lName;
					else
						$sqlLNAME = $oLNAME;
						
					if($email !== $oEMAIL)
					{
						$sqlEMAIL = $email;
						$bNewVerification = true; //set redo verification process flag
					}
					else
					{
						$sqlEMAIL = $oEMAIL;
						$bNewVerification = false;
					}
					if($bNewVerification == true)
					{
						$sql = sprintf("UPDATE PaperContact SET GName = '%s', LName = '%s', Email = '%s', verified = 0 WHERE PaperID = '%s'",
											mysql_real_escape_string($sqlGNAME, $db),
											mysql_real_escape_string($sqlLNAME, $db),
											mysql_real_escape_string($sqlEMAIL, $db),
											mysql_real_escape_string($cPaperID, $db) );
					}
					else
					{
						$sql = sprintf("UPDATE PaperContact SET GName = '%s', LName = '%s', Email = '%s' WHERE PaperID = '%s'",
											mysql_real_escape_string($sqlGNAME, $db),
											mysql_real_escape_string($sqlLNAME, $db),
											mysql_real_escape_string($sqlEMAIL, $db),
											mysql_real_escape_string($cPaperID, $db) );
					}
					//echo $sql . "<br>";
					$qRes = run_query($sql, $db);
					
					/** ********************
					 ** NOW THAT WE HAVE UPDATED THE PAGE,
					 ** NOW WE MUST RE-DISPLAY IT
					 **
					 ** SO NOW WE --> RE-QUERY THE DB TO ENSURE ALLS WELL
					 **
					 **/
					$nPresType = $nAuthors = $nAffil = $nPresenter = $nSubmitted = $nGName = $nLName = $nEmail = $nVerified = "";
					$nPTitle = $nAbsSub = "";
					
					$sql = sprintf("SELECT * FROM PaperDetails WHERE PaperID = '%s'", mysql_real_escape_string($cPaperID, $db));
					$qRes = run_query($sql, $db);
					$nRes = mysql_num_rows($qRes);
					if($nRes > 1)
					{
						$errorFlag = 1;
						$errMSG = "Error - Non unique PaperID/Token";
					}
					else if($nRes == 0)
					{
						$errorFlag = 1;
						$errMSG = "Error - No such PaperID/Token.";
					}
					else if($nRes == 1)
					{
						$row = mysql_fetch_array($qRes, MYSQL_ASSOC);
						
						$nPresType = $row['PresType'];
						$nAuthors = $row['Authors'];
						$nAffil = $row['Affiliations'];
						$nPresenter = $row['Presenter'];
						$nSubmitted = $row['Submitted'];
					}
					
					mysql_free_result($qRes);
					
					$sql = sprintf("SELECT * FROM PaperContact WHERE PaperID = '%s'", mysql_real_escape_string($cPaperID, $db));
					$qRes = run_query($sql, $db);
					$nRes = mysql_num_rows($qRes);
					if($nRes > 1)
					{
						$errorFlag = 1;
						$errMSG = "Error - Non unique PaperID/Token";
					}
					else if($nRes == 0)
					{
						$errorFlag = 1;
						$errMSG = "Error - No such PaperID/Token.";
					}
					else if($nRes == 1)
					{
						$row = mysql_fetch_array($qRes, MYSQL_ASSOC);
						
						$nGName = $row['GName'];
						$nLName = $row['LName'];
						$nEmail = $row['Email'];
						$nVerified = $row['verified'];
					}
					mysql_free_result($qRes);
					
					$sql = sprintf("SELECT * FROM PaperTitle WHERE PaperID = '%s'", mysql_real_escape_string($cPaperID, $db));
					$qRes = run_query($sql, $db);
					$nRes = mysql_num_rows($qRes);
					if($nRes > 1)
					{
						$errorFlag = 1;
						$errMSG = "Error - Non unique PaperID/Token";
					}
					else if($nRes == 0)
					{
						$errorFlag = 1;
						$errMSG = "Error - No such PaperID/Token.";
					}
					else if($nRes == 1)
					{
						$row = mysql_fetch_array($qRes, MYSQL_ASSOC);
						
						$nPTitle = $row['PTitle'];
					}
					mysql_free_result($qRes);
					
					$sql = sprintf("SELECT * FROM PaperAbstract WHERE PaperID = '%s'", mysql_real_escape_string($cPaperID, $db));
					$qRes = run_query($sql, $db);
					$nRes = mysql_num_rows($qRes);
					if($nRes > 1)
					{
						$errorFlag = 1;
						$errMSG = "Error - Non unique PaperID/Token";
					}
					else if($nRes == 0)
					{
						$errorFlag = 1;
						$errMSG = "Error - No such PaperID/Token.";
					}
					else if($nRes == 1)
					{
						$row = mysql_fetch_array($qRes, MYSQL_ASSOC);
						
						$nAbsSub = $row['Submitted'];
					}
					mysql_free_result($qRes);

					//--////////////////////////////////
					//- ALL TABLES UPDATED SO LET'S CLOSE THE DB
					//--////////////////////////////////
					
					//Now Reprint all the information for the user
					// and email off to the relevant peoples.
					//send_mail($to, $body, $subject, $fromaddress, $fromname);
					($presType == "Poster") ? $txt = "POSTER Presented By:" : $txt = "ORAL Presentation by:";
					
					if($bNewVerification == true)
					{
						$_SESSION['modSYS'] = 2; // flag;
						// We resend a verification email to the new email address
						//	to confirm that the user is valid
						
						//- We re-generate a password and token similar to the fashion in which we 
						//	did in the call4papers processing.
						$c1 = genRandomPassAndToken($nEmail . $nPTitle);
						$c2 = genRandomPassAndToken($nPTitle . $nEmail);
						$nPaswd = substr($c1, 0, 6);	//Password  \\__ SIZE is SET
						$nToken = substr($c2, 0, 6);	//Token 		//   to 6 in DB
	
							//- Ensure the generated token is not replicated already
						$sql = sprintf("SELECT * FROM PaperContact WHERE Token = '%s'", mysql_real_escape_string($nToken) );
						//echo $sql."<br /><br />";
	
						while(mysql_num_rows(run_query($sql, $db)) > 0)
						{
							$c2 = genRandomPassAndToken($nPTitle . $nEmail . $nLName);
							$nToken = substr($c2, 0, 6);
							$sql = sprintf("SELECT * FROM PaperContact WHERE Token = '%s'", mysql_real_escape_string($cToken) );
							//echo $sql."<br /><br />";
						}
						
						$sql = sprintf("UPDATE PaperContact SET Password = '%s', Token = '%s' WHERE PaperID = '%s'",
											mysql_real_escape_string($nPaswd, $db),
											mysql_real_escape_string($nToken, $db),
											mysql_real_escape_string($cPaperID, $db) );
						//echo $sql."<br /><br />";
						$qRes = run_query($sql, $db);
						
						//DB Updated with new password and token for newly created Paper Contact
						// Now let's send them an email :)
						
						($nPresType == "Poster") ? $txt = "POSTER Presented By:" : $txt = "ORAL Presentation by:";
						($oPRESTYPE == "Poster") ? $txt2 = "POSTER Presented By:" : $txt2 = "ORAL Presentation by:";
					
						$emMSG = "Dear " . $nGName . " " . $nLName . ",\n\n"
								."The following presentation details have been UPDATED for the SuperDARN 2008 Annual Meeting.\n"
								."You have received this email because your details were submitted as an updated contact person\n"
								."by " . $oGNAME . " " . $oLNAME . " for the SuperDARN 2008 Paper (ID: " . $cPaperID . ").\n\n"
								."Contact Person Details:\n"
								."Given Names: \t" . $nGName ."\n"
								."Family Name: \t" . $nLName . "\n"
								."Email: \t\t" . $nEmail . "\n\n"
								."Paper Title Submission Details:\n"
								."PAPER ID: \t\t" . $cPaperID ."\n"
								."Title: \t\t" . $nPTitle ."\n"
								."Authors: \t\t" . $nAuthors ."\n"
								."Affiliations: \t" . $nAffil ."\n"
								. $txt . "\t" . $nPresenter . "\n\n"
								."To complete the verification process, please visit this URL:\n"
								."http://www.tiger.latrobe.edu.au/superdarn2008/verify.php?pid=" . $cPaperID . "&t=" . $nToken . "\n\n"
								."and enter the following PASSWORD where prompted: " . $nPaswd . "\n\n\n"
								."For your records, the PREVIOUS paper details were as follows:\n"
								."Contact Person Details:\n"
								."Given Names: \t" . $oGNAME ."\n"
								."Family Name: \t" . $oLNAME . "\n"
								."Email: \t\t" . $oEMAIL . "\n\n"
								."Paper Title Submission Details:\n"
								."PAPER ID: \t\t" . $cPaperID ."\n"
								."Title: \t\t" . $oTITLE ."\n"
								."Authors: \t\t" . $oAUTHORS ."\n"
								."Affiliations: \t" . $oAFFIL ."\n"
								. $txt2 . "\t" . $oPRESENTER . "\n\n\n"
								."Best Regards,\n\nThe SuperDARN 2008 Organising Committee.\n\n\n"
								."*************************************************\n"
								."This email has been sent on behalf of the SuperDARN 2008 Organising Committee.\n"
								."If you believe that this message has been sent in error, please contact webmaster_ee@latrobe.edu.au\n";
					
						/** **********************
						 ** **********************
						 EMAILS to:
						 		colin.waters@newcastle.edu.au - subject: UPDATED PAPER DETAILS - PID: $cPaperID
						 		A.Lennen@latrobe.edu.au				- subject: UPDATED PAPER DETAILS - PID: $cPaperID
						 
						 ** **********************
						 ** ********************** */
						$sbj 		= "SD08 MODIFIED PAPER DETAILS (PAPER ID: " . $cPaperID . ")";
						$frmem	= "webmaster_ee@latrobe.edu.au";
						$frmtit	=	"SuperDARN 2008";
						
						$mailFail = send_mail($nEmail,$emMSG, $sbj, $frmem, $frmtit);	//User
						//$mailFail &= send_mail("J.Hura@latrobe.edu.au",$emMSG, $sbj, $frmem, $frmtit);	// fake alicia
						//$mailFail &= send_mail("M.Gentile@latrobe.edu.au",$emMSG, $sbj, $frmem, $frmtit);		// fake colin
						$mailFail &= send_mail("colin.waters@newcastle.edu.au",$emMSG, $sbj, $frmem, $frmtit);	//Colin Waters
						$mailFail &= send_mail("A.Lennen@latrobe.edu.au",$emMSG, $sbj, $frmem, $frmtit);	//Alicia Lennen
						
						$modSYS = $_SESSION['modSYS'];
						
						HTML_top();
						HTML_Display($cPaperID, $nPTitle, $nGName, $nLName, $nEmail, $nVerified, $nPresType, $nAuthors, $nAffil, $nPresenter, $nSubmitted, $nAbsSub, $modSYS, $mailFail);
						HTML_bottom();
					}
					else
					{
						$_SESSION['modSYS'] = 1;	// flag
						// We send a verification email 
						($nPresType == "Poster") ? $txt = "POSTER Presented By:" : $txt = "ORAL Presentation by:";
						($oPRESTYPE == "Poster") ? $txt2 = "POSTER Presented By:" : $txt2 = "ORAL Presentation by:";
						$msg = "Dear " . $nGName . " " . $nLName . ",\n\n"
									."The following presentation details have been UPDATED for the SuperDARN 2008 Annual Meeting.\n\n"
									."Contact Person Details:\n"
									."Given Names: \t" . $nGName ."\n"
									."Family Name: \t" . $nLName . "\n"
									."Email: \t\t" . $nEmail . "\n\n"
									."Paper Title Submission Details:\n"
									."PAPER ID: \t\t" . $cPaperID ."\n"
									."Title: \t\t" . $nPTitle ."\n"
									."Authors: \t\t" . $nAuthors ."\n"
									."Affiliations: \t" . $nAffil ."\n"
									. $txt . "\t" . $nPresenter . "\n\n"
									."The PREVIOUS paper details were as follows:\n"
									."Contact Person Details:\n"
									."Given Names: \t" . $oGNAME ."\n"
									."Family Name: \t" . $oLNAME . "\n"
									."Email: \t\t" . $oEMAIL . "\n\n"
									."Paper Title Submission Details:\n"
									."PAPER ID: \t\t" . $cPaperID ."\n"
									."Title: \t\t" . $oTITLE ."\n"
									."Authors: \t\t" . $oAUTHORS ."\n"
									."Affiliations: \t" . $oAFFIL ."\n"
									. $txt2 . "\t" . $oPRESENTER . "\n\n\n"
									."Best Regards,\n\nThe SuperDARN 2008 Organising Committee.\n\n\n"
									."*************************************************\n"
									."This email has been sent on behalf of the SuperDARN 2008 Organising Committee.\n"
									."If you believe that this message has been sent in error, please contact webmaster_ee@latrobe.edu.au\n";
	
						/** **********************
						 ** **********************
						 EMAILS to:
						 		colin.waters@newcastle.edu.au - subject: UPDATED PAPER DETAILS - PID: $cPaperID
						 		A.Lennen@latrobe.edu.au				- subject: UPDATED PAPER DETAILS - PID: $cPaperID
						 
						 ** **********************
						 ** ********************** */
						$sbj 		= "SD08 MODIFIED PAPER DETAILS (PAPER ID: " . $cPaperID . ")";
						$frmem	= "webmaster@tiger.latrobe.edu.au";
						$frmtit	=	"SuperDARN 2008";
						
						$mailFail = send_mail($nEmail,$msg, $sbj, $frmem, $frmtit);	//User
						//$mailFail &= send_mail("J.Hura@latrobe.edu.au",$msg, $sbj, $frmem, $frmtit);	// fake alicia
						//$mailFail &= send_mail("M.Gentile@latrobe.edu.au",$msg, $sbj, $frmem, $frmtit);		// fake colin
						$mailFail &= send_mail("colin.waters@newcastle.edu.au",$emMSG, $sbj, $frmem, $frmtit);	//Colin Waters
						$mailFail &= send_mail("A.Lennen@latrobe.edu.au",$emMSG, $sbj, $frmem, $frmtit);	//Alicia Lennen
	
						HTML_top();
						//echo $msg;
						$modSYS = $_SESSION['modSYS'];
						HTML_Display($cPaperID, $nPTitle, $nGName, $nLName, $nEmail, $nVerified, $nPresType, $nAuthors, $nAffil, $nPresenter, $nSubmitted, $nAbsSub, $modSYS, $mailFail);
						
						HTML_bottom();
					}
					dcon_and_close($db);
				}
				else
				{
					$title = "Authentication Error";
					$msg = "Unable to confirm PaperID and/or Password and/or Current Contact Details";
					HTML_top();
					HTML_Disp_Error($title, $msg);
					HTML_bottom();
				}
      }
      else
      {
      	if($errorFlag == 1)
      	{
      		unset($_POST);
      		header("Location: $HEADER_LOC?e=1");
      		exit();
      	}
      }
    }
    else
    {
      	unset($_POST);
      	header("Location: $HEADER_LOC?e=1");
      	exit();
    }
		
	}
	else if($_GET)
	{
		if(isset($_GET['logout']) && $_GET['logout'] == 1)
		{
			$_SESSION = array();
			session_destroy();
			$_GET = array(); unset($_GET);
			header("Location: $HEADER_LOC");
		}
	}
	else
	{	/** ****************************************
			* NO SUBMIT - BRING UP ALL PAPER DETAILS
			*
			* ****************************************
		**/
		if($cPaperID != NULL || $cPasswd != NULL)
		{
			$db = connect_and_open("webuser", "sdarn08", "sDarn08");
		
			//Paper Details variables
			$sPresType = "";
			$sAuthors = "";
			$sAffil = "";
			$sPresenter = "";
			$sSubmitted = "";
			
			$sql = sprintf("SELECT * FROM PaperDetails WHERE PaperID = '%s'", mysql_real_escape_string($cPaperID, $db));
			$qRes = run_query($sql, $db);
			$nRes = mysql_num_rows($qRes);
			if($nRes > 1)
			{
				$errorFlag = 1;
				$errMSG = "Error - Non unique PaperID/Token";
			}
			else if($nRes == 0)
			{
				$errorFlag = 1;
				$errMSG = "Error - No such PaperID/Token.";
			}
			else if($nRes == 1)
			{
				$row = mysql_fetch_array($qRes, MYSQL_ASSOC);
				
				$sPresType = $row['PresType'];
				$sAuthors = $row['Authors'];
				$sAffil = $row['Affiliations'];
				$sPresenter = $row['Presenter'];
				$Submitted = $row['Submitted'];
			}
			mysql_free_result($qRes);
			
			//Paper Contact variables
			$sGName = "";
			$sLName = "";
			$sEmail = "";
			$sVerified = "";
			
			$sql = sprintf("SELECT * FROM PaperContact WHERE PaperID = '%s'", mysql_real_escape_string($cPaperID, $db));
			$qRes = run_query($sql, $db);
			$nRes = mysql_num_rows($qRes);
			if($nRes > 1)
			{
				$errorFlag = 1;
				$errMSG = "Error - Non unique PaperID/Token";
			}
			else if($nRes == 0)
			{
				$errorFlag = 1;
				$errMSG = "Error - No such PaperID/Token.";
			}
			else if($nRes == 1)
			{
				$row = mysql_fetch_array($qRes, MYSQL_ASSOC);
				
				$sGName = $row['GName'];
				$sLName = $row['LName'];
				$sEmail = $row['Email'];
				$sVerified = $row['verified'];
			}
			mysql_free_result($qRes);
			
			//Paper Title variables
			$sPTitle = "";
			
			$sql = sprintf("SELECT * FROM PaperTitle WHERE PaperID = '%s'", mysql_real_escape_string($cPaperID, $db));
			$qRes = run_query($sql, $db);
			$nRes = mysql_num_rows($qRes);
			if($nRes > 1)
			{
				$errorFlag = 1;
				$errMSG = "Error - Non unique PaperID/Token";
			}
			else if($nRes == 0)
			{
				$errorFlag = 1;
				$errMSG = "Error - No such PaperID/Token.";
			}
			else if($nRes == 1)
			{
				$row = mysql_fetch_array($qRes, MYSQL_ASSOC);
				
				$sPTitle = $row['PTitle'];
			}
			mysql_free_result($qRes);
			
			//Paper Abstract variables
			$sAbsSub = "";
			
			$sql = sprintf("SELECT * FROM PaperAbstract WHERE PaperID = '%s'", mysql_real_escape_string($cPaperID, $db));
			$qRes = run_query($sql, $db);
			$nRes = mysql_num_rows($qRes);
			if($nRes > 1)
			{
				$errorFlag = 1;
				$errMSG = "Error - Non unique PaperID/Token";
			}
			else if($nRes == 0)
			{
				$errorFlag = 1;
				$errMSG = "Error - No such PaperID/Token.";
			}
			else if($nRes == 1)
			{
				$row = mysql_fetch_array($qRes, MYSQL_ASSOC);
				
				$sAbsSub = $row['Submitted'];
			}
			mysql_free_result($qRes);
		
			// Clean up and close the DB
			dcon_and_close($db);
			
					
			// FINALLY THE HTML OUTPUT
			if($errorFlag == 1)
			{
				$title = "Errors were encountered when accessing: " . $cPaperID;
				HTML_top();
				HTML_Disp_Error($title, $errMSG);
				HTML_bottom();
				
				$_SESSION = array();
				session_destroy();
			}
			else
			{
				HTML_top();
			
				HTML_Display($cPaperID, $sPTitle, $sGName, $sLName, $sEmail, $sVerified, $sPresType, $sAuthors, $sAffil, $sPresenter, $Submitted, $sAbsSub);
				
				HTML_bottom();
			}
		}
		else
		{
			$title = "Unable to access this page";
			$msg = "Server is not responding to your request. Please ask nicely.";
			HTML_top();
			HTML_Disp_Error($title, $msg);
			HTML_bottom();
			
			$_SESSION = array();
			session_destroy();
		}
	}	//end else of not submit


	/**	********************************
	  *	THE TOP HTML STUFF
	  *
	  ** ***************************** */
	function HTML_top()
	{ ?>
		<html>
			<head>
				<title>SuperDARN 2008 - Modification of Presentation Title / Contact Details</title>
				<link rel="stylesheet" href="../assets/css/LTUtypespecs.css" type="text/css">
				
				<script type="text/javascript">
		      function errorCheck(thisform)
					{
						//create variables for script
						var sGName = -1;
						var sFName = -1;
						var sEmail = -1;
						var sPTitle = -1;
						var sAuthor = -1;
						var requiredFieldsErrorMessage = "";
						var alertMessage = "";
						
						//gather values of applicant's name
						sGName	= document.forms['modForm'].elements['Given_Names'].value;
						sFName	= document.forms['modForm'].elements['Family_Name'].value;
						sEmail	= document.forms['modForm'].elements['Email'].value;
						sEmail2	= document.forms['modForm'].elements['Email2'].value;
						sPTitle	= document.forms['modForm'].elements['Paper_Title'].value;
						sAuthor	= document.forms['modForm'].elements['Authors'].value;
						
												
						if (sGName == "") {
							requiredFieldsErrorMessage = requiredFieldsErrorMessage + "- Given Names must be entered\n";
						}
						if (sFName == "") {
							requiredFieldsErrorMessage = requiredFieldsErrorMessage + "- Family Name must be entered\n";
						}
						if (sEmail == "") {
							requiredFieldsErrorMessage = requiredFieldsErrorMessage + "- Email must be entered\n";
						}
						else if(!sEmail.match("^[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$") )
						{
							requiredFieldsErrorMessage = requiredFieldsErrorMessage + "- Email must be of valid formatting\n";
						}
						if (sEmail != sEmail2) {
							requiredFieldsErrorMessage = requiredFieldsErrorMessage + "- Email address must be confirmed\n";
						}
						if (sPTitle == "") {
							requiredFieldsErrorMessage = requiredFieldsErrorMessage + "- Paper Title must be entered\n";
						}
						if(checkRadio(document.forms['modForm'].elements['presType']) == null)
						{
							requiredFieldsErrorMessage = requiredFieldsErrorMessage + "- A Presentation type must be selected\n";
						}
						if (sAuthor == "") {
							requiredFieldsErrorMessage = requiredFieldsErrorMessage + "- Authors must be entered\n";
						}
						
						//Error message displays
						if (requiredFieldsErrorMessage)
						{
							if(requiredFieldsErrorMessage) {
								alertMessage = "Oops! There's a little trouble with the information you have provided.\n\n";
								alertMessage = alertMessage + "The following conditions must be met in order to procede:\n"
								alertMessage = alertMessage + requiredFieldsErrorMessage;
							}
		
							alert(alertMessage);
						}
						else {
							document.forms['modForm'].submit();
						}
					}
					
					function checkRadio(radBut)
					{
						var err = -1;
						for (var i=radBut.length-1; i > -1; i--) 
						{
							if (radBut[i].checked) {err = i; i = -1;}
						}
						
						if (err > -1) 
							return radBut[err].value;
						else 
							return null;
					}
	 			</script>
		</head>

		<body bgcolor="#FFFFFF" text="#333333" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" link="#DB0000" vlink="#666666" alink="#990000">

		<table name="mainarea" width="100%" bgcolor="#FFFFFF" border="0" cellspacing="0" cellpadding="0"><tr><td>

			<table width="100%" border="0" cellspacing="0" cellpadding="0">
			  <tr>
			    <td height="43" bgcolor="#FFFFFF" valign="top" align="left">
			          <table width="100%" border="0" cellspacing="0" cellpadding="0">
					        <tr>
					          <td bgcolor="#000000" width="150"><a href="http://www.newcastle.edu.au/school/math-physical-science/"><img src="../assets/images/logo_scitech_newcastle.gif" alt="Welcome to Newcastle University" border="0" width="147" height="38"></a></td>
					          <td bgcolor="#000000" width="99%"><img src="../assets/images/masthead_newcastle.gif" width="450" height="47" alt="School of Mathematical and Physical Sciences"></td>
					          <td valign="top" align="right" width="150"><a href="http://www.latrobe.edu.au"><img src="../assets/images/logo_latrobe.gif" width="150" height="47" border="0"></A></td>
					        </tr>
					      </table>
			    </td>
			  </tr>
			  <tr>
			    <td bgcolor="#FFFFFF" valign="top" align="left" height="99%">
			    	<table border="0" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF" width="100%">
			  			<tr>
			    			<td width="147" valign="top" align="center"> <img src="../assets/images/devices/spacer.gif" width="147" height="1">
			    			<br><br>

								<table width="137" border="0" cellpadding="2" align="center" cellspacing="0">
		   		    		<tr valign="top" align="left">
				       	    <td width="7"><img src="../assets/images/arrow_greydark.gif" width="7" height="10"></td>
		    		   	    <td width="118">
		       			    <p class="TextMidGreySmallBold"><a href="index.html" class="LinkRedSmallBold">Home</a></p></td>
		   	        	</tr>
		   	        	<tr valign="top" align="left">
										<td width="7"><img src="../assets/images/arrow_greydark.gif" width="7" height="10"></td>
										<td width="118">
										<p class="TextMidGreySmallBold"><a href="first.html" class="LinkRedSmallBold">Announcements</a></p></td>
		            	</tr>
		   	        	<tr valign="top" align="left">
										<td width="7"><img src="../assets/images/arrow_greydark.gif" width="7" height="10"></td>
										<td width="118">
										<p class="TextMidGreySmallBold"><a href="program.html" class="LinkRedSmallBold">Workshop Program</a></p></td>
		            	</tr>
		   	        	<tr valign="top" align="left">
										<td width="7"><img src="../assets/images/arrow_greydark.gif" width="7" height="10"></td>
										<td width="118">
										<p class="TextMidGreySmallBold"><a href="regoform.html" class="LinkRedSmallBold">Registration Form</a></p></td>
									</tr>
		            	<tr valign="top" align="left">
		       	 				<td width="7"><img src="../assets/images/arrow_greydark.gif" width="7" height="10"></td>
		       	 				<td width="118">
		        				<p class="TextMidGreySmallBold"><a href="organisers.html" class="LinkRedSmallBold">Conference Organisers</a></p></td>
		  	        	</tr>
		            	<tr valign="top" align="left">
		            		<td width="7"><img src="../assets/images/arrow_greydark.gif" width="7" height="10"></td>
		            		<td width="118">
		            		<p class="TextMidGreySmallBold"><a href="travelinfo.html" class="LinkRedSmallBold">Travel Information</a></p></td>
		            	</tr>
		            	<tr valign="top" align="left">
										<td width="7"><img src="../assets/images/arrow_greydark.gif" width="7" height="10"></td>
										<td width="118">
										<p class="TextMidGreySmallBold"><a href="contactus.html" class="LinkRedSmallBold">Contact Us</a></p></td>
									</tr>

								<td width="7" height="10"></td>
								<td width="118" height="10"></td>
				  		</tr>
				  	</table>

		     <!-- #EndLibraryItem -->
		      <table WIDTH="92%" BORDER="0">
		        <tr>
		         <td ALIGN="center"><span CLASS="TextDarkGreyMedium"><SPAN CLASS="TextDarkGreyMedium"><span CLASS="TextDarkGreyMedium"><SPAN CLASS="TextDarkGreySmall">
		         <span CLASS="TextDarkGreySmall"><SPAN CLASS="TextDarkGreySmall"><SPAN CLASS="TextDarkGreySmall">
		         <!-- #BeginLibraryItem "/Library/Contact%20SN&M.lbi" -->
		         <LINK REL="stylesheet" HREF="./assets/css/LTUtypespecs.css" TYPE="TEXT/CSS">
		         <SPAN CLASS="TextDarkGreyMedium"><SPAN CLASS="TextDarkGreyMedium"><SPAN CLASS="TextDarkGreyMedium">
		         <p>&nbsp;</p>
		         <SPAN CLASS="TextDarkGreySmall">
		         School of<BR>
		         Mathematical &<BR>
		         Physical Sciences<BR>
		         Newscastle University<BR>
		         NSW 2308 AUSTRALIA <BR>
		         Tel: +61 2 4921 5539<BR>
		         Fax: +61 2 4921 6898<BR>
		         </SPAN>
		         <A HREF="mailto:webmaster_ee@latrobe.edu.au" CLASS="LinkRedSmall">Email us </A></SPAN><BR>
		         </TD>
		       </TR>
		     </TABLE>
		      <br>
		          </td>
		          <td width="1" valign="bottom" background="./assets/images/line_dotted_v.gif" align="left"><img src="./assets/images/spacer_white10h.gif" width="1" height="10"></td>
		          <td width="10" valign="top" align="left"><img src="./assets/images/spacer.gif" width="10" height="1"></td>
		          <td width="99%" valign="top" align="left"> <img src="./assets/images/spacer.gif" width="1" height="1"><br>
		            <a name="top"></a>
		            <table width="98%" border="0" cellspacing="0" cellpadding="0">
		         </table>
		        <br>

		<!--- Main contents -->
		<table width="85%" cellpadding="0" cellspacing="0" border="0">
		<tr>
		<td><a href="http://superdarn.jhuapl.edu/"><IMG SRC="../images/sd_sm.gif" WIDTH=112 HEIGHT=129 BORDER=0 ALIGN="left" ALT="SuperDARN" HSPACE=10></a><a href="../index.html"><IMG SRC="../images/logo_5.jpg" WIDTH=128 HEIGHT=126 BORDER=0 ALIGN="right" ALT="TIGER" HSPACE=10></a>
		<center>
		<br>
<?
	}

	/**	********************************
	  *	THE BOTTOM HTML STUFF
	  *
	  ** ***************************** */
	function HTML_bottom()
	{ ?>
		<p>&nbsp;</p>
		<p>&nbsp;</p>


		<!-- Footer section -->
		            <span class="TextFootNotes">Content Approved by: Principal Investigator: Prof. P.L. Dyson<br>
		            Page maintained by: <a href="mailto:webmaster_ee@latrobe.edu.au">Webmaster</a><br>
		            Last Updated: 31th January, 2008</span>
					<span class=TextDarkGreyMedium></span>

		            <span class=TextFootNotes></span><span class="TextFootNotes"></span> <br><br>
		            <font size="1"><a href="#top" class="LinkRedSmall">return to top</a></font><br>
		          </td>

		  <tbody>
		  </tbody>
		  </table>

			    <p><br>
		            <span class="TextDarkGreySmallBold"><br>
		            </span>
		            </p>
		            <p>
		            <br>
		          </td>
		        </tr>
		      </table>
		    </td>
		  </tr>
		  <tr>
		   <td height="15" bgcolor="#FFFFFF" valign="bottom" align="left">&nbsp; </td>
		  </tr>
		</table>

		<table width="100%" border="0" cellspacing="0" cellpadding="0" height="17">
			<tr>
		    <td nowrap bgcolor="#000000" nowrap valign="middle" align="left">
		    	<form method="get" action="http://www.latrobe.edu.au/cgi-bin/htsearch">
				    	<a href="http://www.latrobe.edu.au/search" class="navtext">
							&nbsp;Search&nbsp;
							</a>
						</td>
				    <td nowrap bgcolor="#000000" nowrap valign="middle" align="left">
				    	&nbsp;<img src="./assets/images/nav_divider_off.gif" width="1" height="17" alt="">&nbsp;
						</td>
				    <td nowrap bgcolor="#000000" nowrap valign="middle" align="left">
							<input type="hidden" name="restrict" value="melkor.latrobe.edu.au/cs">
							<input type="text" name="words" value="Search Here" size="12" class="search" ONBLUR="if (value =='') {value = 'Search Here'}" ONFOCUS="if (value == 'Search Here') {value =''}">
						</td>
				    <td nowrap bgcolor="#000000" nowrap valign="middle" align="left">
				    	&nbsp;<img src="./assests/images/nav_divider_off.gif" width="1" height="17" alt="">&nbsp;
						</td>
				    <td nowrap bgcolor="#000000" nowrap valign="middle" align="left">
				    	<a href="http://www.latrobe.edu.au/contact" class="navtext">
							&nbsp;Contact LTU&nbsp;
							</a>
				    </td>
				    <td nowrap bgcolor="#000000" nowrap valign="middle" align="left">
				    	&nbsp;<img src="./assets/images/nav_divider_off.gif" width="1" height="17" alt="">&nbsp;
						</td>
				    <td nowrap bgcolor="#000000" nowrap valign="middle" align="left">
				    	<a href="http://www.latrobe.edu.au/sitemap/" class="navtext">
							&nbsp;Sitemap&nbsp;
							</a>
				    </td>
						<td bgcolor="#CCCCCC" nowrap valign="middle" align="left" width="99%">
					</form>
					<table border="0" cellspacing="0" cellpadding="0" height="17" width="100%">
						<tr>
							<td nowrap width="10" valign="middle" align="left"><img src="./assets/images/spacer.gif" width="10" height="1" alt=""></td>
							<td nowrap class="TextFootNotes" valign="middle" align="left"><a href="http://www.latrobe.edu.au/copyright/disclaimer.html"><span class="TextFootNotes" style="color: #666666 ; font-family: Verdana, Geneva, Tahoma, Arial; font-size: 10px; font-style: italic; text-decoration:none;">Copyright &copy; 2008 La Trobe University, Credits &amp; Disclaimer</span></a></td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
		<!-- End nav_bottom -->
		</body></html>
<?
	}
	

	/**	********************************
	  *	THE FORM AND MAIN ENTRY STUFF
	  *
	  ** ***************************** */
	
	function HTML_Display($cPaperID, $sPTitle, $sGName, $sLName, $sEmail, $sVerified, $sPresType, $sAuthors, $sAffil, $sPresenter, $sSubmitted, $sAbsSub, $modified = 0, $mailFail = false)
	{?>
			<font face="Arial,Times" size="+2">SuperDARN 2008 Annual Meeting</font><br>
			<font FACE="Arial,Times" SIZE="+1">Newcastle, NSW.   Australia, 1st &#150; 6th of June 2008</font><br>
			<font FACE="Arial,Times" SIZE="+3">Modification Form For Paper: <?= $cPaperID; ?></font>
			</center></td>
			</tr>
			<tr>
				<td align="center" class="TextDarkGreyMedium" width="90%"><h3><a href="<?= $SERVER['PHP_SELF']; ?>?logout=1"> LOG OUT </a></h3></td>
			</tr>
			</table>

			<SPAN class="TitlesSchitech">FIXED Details...</SPAN>
			<table VALIGN="middle" ALIGN="center" width="99%" cellspacing="1" cellpadding="1" border="0">
				<tr>
					<td class="TextDarkGreyMediumBold">&nbsp;</td>
					<td class="TextDarkGreyMedium" width="90%">&nbsp;</td>
				</tr>
				<tr>
					<td width="250" class="TextDarkGreyMediumBold">Paper ID:</td>
					<td width="346" class="TextGreySmall"><u><?= $cPaperID; ?></u></td>
				</tr>
				<tr>
					<td width="250" class="TextDarkGreyMediumBold">Details of last updated:</td>
					<td width="346" class="TextGreySmall"><u><?= $sSubmitted; ?></u></td>
				</tr>
				<tr>
					<td width="250" class="TextDarkGreyMediumBold">Abstract Submitted:</td>
					<td width="346" class="TextGreySmall"><? ($sAbsSub == 1) ? $a = "<u>Yes</u>" : $a = "<u>No</u>"; echo $a; ?></td>
				</tr>
				<tr>
					<td class="TextDarkGreyMediumBold">&nbsp;</td>
					<td class="TextDarkGreyMedium" width="90%">&nbsp;</td>
				</tr>
			</table>
			
			<SPAN class="TitlesSchitech">Modifiable Details...</SPAN>
			<? ($modified > 0) 	? $a = "<SPAN class=\"TitlesSchitech\"><font color=\"red\">Changes ACCEPTED</font></SPAN>"
															: $a = ""; 
					if($modified == 2) 
					{ $a .= "<br><SPAN class=\"TextDarkGreyMedium\"><font color=\"red\">As CONTACT EMAIL has changed - further modifications to the paper details can not be made until the "
							."NEW EMAIL address has been verified.</font></SPAN>";}
					echo $a; 
				?>
			<form action="<?= $_SERVER['PHP_SELF']; ?>" name="modForm" method="post" onSubmit="errorCheck(modForm); return false;">
				<table VALIGN="middle" ALIGN="center" width="99%" cellspacing="1" cellpadding="1" border="0">
					<tr>
						<td class="TextDarkGreyMediumBold">&nbsp;</td>
						<td class="TextDarkGreyMedium" width="90%">&nbsp;</td>
					</tr>
					<tr>
						<td width="157" class="TextDarkGreyMediumBold"><label for="Given_Names">
							<? ($errD==1) ? $a = "<font color=\"red\"><b>Given Names:</b></font>" : $a = "Given Names:"; echo $a; ?>
							</label></td>
						<td width="439" class="TextGreySmall"><input type="text" NAME="Given_Names" id="Given_Names" SIZE="40" value="<?= $sGName; ?>"></td>
					</tr>
					<tr>
						<td class="TextDarkGreyMediumBold"><label for="Family_Name">
							<? ($errD==1) ? $a = "<font color=\"red\"><b>Family Name:</b></font>" : $a = "Family Name:"; echo $a; ?>
							</label></td>
						<td class="TextDarkGreySmall"><input type="text" name="Family_Name" id="Family_Name" SIZE="40" value="<?= $sLName; ?>"></td>
					</tr>
					<tr>
						<td class="TextDarkGreyMediumBold">&nbsp;</td>
						<td class="TextDarkGreyMedium" width="90%">&nbsp;</td>
					</tr>
					<tr>
						<td class="TextDarkGreyMediumBold"><label for="Email">
							<? ($errD==1) ? $a = "<font color=\"red\"><b>Email:</b></font>" : $a = "Email:"; echo $a; ?>
							</label></td>
						<td class="TextDarkGreySmall"><input type="text" Name="Email" id="Email" size="60" value="<?= $sEmail; ?>"></td>
					</tr>
					<tr>
						<td class="TextDarkGreyMediumBold"><label for="Email2">
							<? ($errD==1) ? $a = "<font color=\"red\"><b>Confirm Email:</b></font>" : $a = "Confirm Email:"; echo $a; ?>
							</label></td>
						<td class="TextDarkGreySmall">
							<? ($sVerified == 1) ? $a = "<input type=\"text\" Name=\"Email2\" id=\"Email2\" size=\"60\" value=\"" . $sEmail . "\">" 
																	 : $a = "<input type=\"text\" Name=\"Email2\" id=\"Email2\" size=\"60\">"; echo $a; ?>
							</td>
					</tr>
					<tr>
						<td class="TextDarkGreyMediumBold">Email Verified:</td>
						<td class="TextDarkGreyMedium">
						<? ($sVerified == 1) ? $a = "Yes" : $a = "No"; echo "<b>".$a."</b>"; ?>
						</td>
					</tr>
					<tr>
						<td class="TextDarkGreyMediumBold">&nbsp;</td>
						<td class="TextDarkGreyMedium" width="90%">&nbsp;</td>
					</tr>
					<tr>
						<td class="TextDarkGreyMediumBold"><label for="Paper_Title">
							<? ($errD==1) ? $a = "<font color=\"red\"><b>Title:</b></font>" : $a = "Title:"; echo $a; ?>
							</label></td>
						<td class="TextDarkGreySmall"><input type="text" Name="Paper_Title" id="Paper_Title" size="60"  value="<?= $sPTitle; ?>"></td>
					</tr>
					<tr>
						<td class="TextDarkGreyMediumBold">&nbsp;</td>
						<td class="TextDarkGreyMedium" width="90%">&nbsp;</td>
					</tr>
					<tr>
						<td valign="TOP"><SPAN class="TextDarkGreyMediumBold"><label for="presTPres">
							<? ($errD==1) ? $a = "<font color=\"red\"><b>Oral:</b></font>" : $a = "Presentation:"; echo $a; ?>
							</label></SPAN></td>
						<td class="TextDarkGreySmall">
							<? ($sPresType == "Presentation") ? $b = "<input type=\"radio\" Name=\"presType\" Value=\"Presentation\" id=\"presTPres\" checked=\"checked\">"
																								: $b = "<input type=\"radio\" Name=\"presType\" Value=\"Presentation\" id=\"presTPres\">"; echo $b; ?>
						</td>
					</tr>
					<tr>
						<td valign="TOP"><SPAN class="TextDarkGreyMediumBold"><label for="presTPos">
							<? ($errD==1) ? $a = "<font color=\"red\"><b>Poster:</b></font>" : $a = "Poster:"; echo $a; ?>
							</label></SPAN></td>
						<td class="TextDarkGreyMedium">
							<? ($sPresType == "Poster") ? $b = "<input type=\"radio\" Name=\"presType\" Value=\"Poster\" id=\"presTPos\" checked=\"checked\">"
																					: $b = "<input type=\"radio\" Name=\"presType\" Value=\"Poster\" id=\"presTPos\">"; echo $b; ?>
						</td>
					</tr>
					<tr>
						<td class="TextDarkGreyMediumBold">&nbsp;</td>
						<td class="TextDarkGreyMedium" width="90%">&nbsp;</td>
					</tr>
					<tr>
						<td width="157" valign="top" class="TextDarkGreyMediumBold"><label for="Authors">
							<? ($errD==1) ? $a = "<font color=\"red\"><b>Authors:</b></font>" : $a = "Authors:"; echo $a; ?>
							</label></td>
						<td width="439" class="TextDarkGreyMedium"><textarea Name="Authors" id="Authors" rows="5" cols="70"><?= $sAuthors; ?></textarea></td>
					</tr>
					<tr>
						<td class="TextDarkGreyMediumBold">&nbsp;</td>
						<td class="TextDarkGreyMedium" width="90%">&nbsp;</td>
					</tr>
					<tr>
						<td width="157" valign="top" class="TextDarkGreyMediumBold"><label for="Affiliations">Affiliations:</label></td>
						<td width="439" class="TextDarkGreyMedium"><textarea Name="Affiliations" id="Affiliations" rows="5" cols="70"><?= $sAffil; ?></textarea></td>
					</tr>
					<tr>
						<td class="TextDarkGreyMediumBold">&nbsp;</td>
						<td class="TextDarkGreyMedium" width="90%">&nbsp;</td>
					</tr>
					<tr>
						<td width="157" valign="top" class="TextDarkGreyMediumBold"><label for="DiffPres">Person giving</label></td>
						<td class="TextDarkGreyMediumBold"><label for="DiffPres">Oral Presentation / Poster Presentation, if different from contact:</label><br><br>
						<?	$str = $sGName . " " . $sLName; ($str === $sPresenter) ? $a = "" : $a = $sPresenter; 
								echo "<textarea Name=\"Different_Presentor\" id=\"DiffPres\" rows=\"5\" cols=\"70\">" . $a . "</textarea></td>";						
						?>
					</tr>
						<td class="TextDarkGreyMediumBold">&nbsp;</td>
						<td class="TextDarkGreyMedium" width="90%">&nbsp;</td>
					</tr>
					</tr>
						<td class="TextDarkGreyMediumBold">&nbsp;</td>
						<?	if($modified == 1) { // no new email change - don't require verification
									echo "<td class=\"TextDarkGreyMedium\" width=\"90%\"><input type=\"submit\" value=\"Update Details\" name=\"modDetails\"></td>";
								} else if($modified == 2) { // email change - require verification
									echo "<td class=\"TextDarkGreyMedium\" width=\"90%\"><a href=\"" . $SERVER['PHP_SELF'] ."?logout=1\"> LOG OUT </a></td>";
								} else { 
									echo "<td class=\"TextDarkGreyMedium\" width=\"90%\"><input type=\"submit\" value=\"Update Details\" name=\"modDetails\"></td>";
								} ?>								
					</tr>
					</table>
				</form>
			
				<p class="TextDarkGreySmallBold">&nbsp;</p>
				</td></tr>
			</table>
<?	}

	function HTML_Disp_Error($title, $msg)
	{ ?>
		<font face="Arial,Times" size="+2">SuperDARN 2008 Annual Meeting</font><br>
		<font FACE="Arial,Times" SIZE="+1">Newcastle, NSW.   Australia, 1st &#150; 6th of June 2008</font><br>
		<font FACE="Arial,Times" SIZE="+3"><?= $title; ?> </font>
		</center></td>
		</tr>
		</table>
		<p>&nbsp;</p>
			
		<table VALIGN="middle" ALIGN="center" width="99%" cellspacing="1" cellpadding="1" border="0">
			<tr>
				<td class="TextDarkGreyMediumBold">&nbsp;</td>
				<td class="TextDarkGreyMedium" width="90%">&nbsp;</td>
			</tr>
			<tr>
				<td width="157" class="TextDarkGreyMediumBold">&nbsp;</Span></td>
				<td width="439" class="TextDarkGreyMedium"><?= $msg; ?></td>
			</tr>
			<tr>
				<td class="TextDarkGreyMediumBold">&nbsp;</Span></td>
				<td class="TextDarkGreyMedium">&nbsp;</td>
			</tr>
			<tr>
				<td class="TextDarkGreyMediumBold">&nbsp;</td>
				<td class="TextDarkGreyMedium" width="90%"><a href="index.html">Done.</a></td>
			</tr>
		</table>	<?
	}
?>