<? 
	//ini_set("memory_limit","40M");	// memory limit increased to handle 15M files

	session_start();
	
	require_once($_SERVER['DOCUMENT_ROOT']."/superdarn2008/scripts/dbConnect.php");
	$HEADER_LOC = "http://www.tiger.latrobe.edu.au/superdarn2008/subofabstract.php";
	
	function send_mail($emailaddress, $fromaddress, $emailsubject, $body, $attachments=false)
	{
	  $eol="\r\n";
	  $mime_boundary=md5(time());
		
	  # Common Headers
	  $headers .= 'From: SuperDARN 2008<'.$fromaddress.'>'.$eol;
	  $headers .= 'Reply-To: SuperDARN 2008<'.$fromaddress.'>'.$eol;
	  $headers .= 'Return-Path: SuperDARN 2008<'.$fromaddress.'>'.$eol;    // these two to set reply address
	  $headers .= "Message-ID: <".$now." TheSystem@".$_SERVER['SERVER_NAME'].">".$eol;
	  $headers .= "X-Mailer: PHP v".phpversion().$eol;          // These two to help avoid spam-filters
	
	  # Boundry for marking the split & Multitype Headers
	  $headers .= 'MIME-Version: 1.0'.$eol;
	  $headers .= "Content-Type: multipart/related; boundary=\"".$mime_boundary."\"".$eol;
	
	  $msg = "";     
	 
	  if ($attachments !== false)
	  {
	
	    for($i=0; $i < count($attachments); $i++)
	    {
	      if (is_file($attachments[$i]["file"]))
	      {  
	        # File for Attachment
	        $file_name = substr($attachments[$i]["file"], (strrpos($attachments[$i]["file"], "/")+1));
	       
	        $handle=fopen($attachments[$i]["file"], 'rb');
	        $f_contents=fread($handle, filesize($attachments[$i]["file"]));
	        $f_contents=chunk_split(base64_encode($f_contents));    //Encode The Data For Transition using base64_encode();
	        fclose($handle);
	       
	        # Attachment
	        $msg .= "--".$mime_boundary.$eol;
	        $msg .= "Content-Type: ".$attachments[$i]["content_type"]."; name=\"".$file_name."\"".$eol;
	        $msg .= "Content-Transfer-Encoding: base64".$eol;
	        $msg .= "Content-Disposition: attachment; filename=\"".$file_name."\"".$eol.$eol; // !! This line needs TWO end of lines !! IMPORTANT !!
	        $msg .= $f_contents.$eol.$eol;
	       
	      }
	    }
	  }
	 
	  # Setup for text OR html
	  $msg .= "Content-Type: multipart/alternative".$eol;
	 
	  # Text Version
	  $msg .= "--".$mime_boundary.$eol;
	  $msg .= "Content-Type: text/plain; charset=iso-8859-1".$eol;
	  $msg .= "Content-Transfer-Encoding: 8bit".$eol;
	  $msg .= strip_tags(str_replace("<br>", "\n", $body)).$eol.$eol;
	 
	  # HTML Version
	  $msg .= "--".$mime_boundary.$eol;
	  $msg .= "Content-Type: text/html; charset=iso-8859-1".$eol;
	  $msg .= "Content-Transfer-Encoding: 8bit".$eol;
	  $msg .= $body.$eol.$eol;
	 
	  # Finished
	  $msg .= "--".$mime_boundary."--".$eol.$eol;  // finish with two eol's for better security. see Injection.
	   
	  # SEND THE EMAIL
	  ini_set(sendmail_from,$fromaddress);  // the INI lines are to force the From Address to be used !
	  $mSent = mail($emailaddress, $emailsubject, $msg, $headers);
	  ini_restore(sendmail_from);
	  return $mSent;
	}
	
	
	function send_notif($file, $to, $subject, $msg)
	{
		# To Email Address
		$emailaddress = $to;
		
		# From Email Address
		$fromaddress = "webmaster_ee@latrobe.edu.au";
		
		# Message Subject
		$emailsubject = $subject;
		
		# Use relative paths to the attachments
		$attachments = Array(
		  Array("file"=>$file, "content_type"=>"application/pdf")
		);
		
		# Message Body
		$body = $msg;
		
		return send_mail($emailaddress, $fromaddress, $emailsubject, $body, $attachments);
	}

	
	/** *************************
	 ** 
	 **	THE ACTUAL PAGE BITS
	 ** 
	 ** ************************* */
	 
	if($_POST)
	{
		if( $_POST['PaperID'] != "" && $_POST['password'] != "" && $_FILES['submitfile']['size'] != 0 )
		{
			$msg = "";
			$title = "";
			$emailAddress = "";
			
			// Prepare POST data
			if(get_magic_quotes_gpc()) {
      	$cPaperID			= stripslashes(trim($_POST['PaperID']));
        $cPassword		= stripslashes(trim($_POST['password']));
        $cMAXFSIZE		= stripslashes(trim($_POST['MAX_FILE_SIZE']));
			} else {
      	$cPaperID		= trim($_POST['PaperID']);
        $cPassword	= trim($_POST['password']);
        $cMAXFSIZE	= trim($_POST['MAX_FILE_SIZE']);
			}
      
      $_SESSION['PaperID'] = $cPaperID;
      $_SESSION['Password'] = $cPassword;
      
			$db = connect_and_open("webuser", "sdarn08", "sDarn08");
		
			// First we check to see if the User is verified and has the correct details	
			$sql = sprintf("SELECT PaperID, Password, verified from PaperContact where PaperID = '%s' and Password = '%s' and verified = 1",
									mysql_real_escape_string($cPaperID, $db),
									mysql_real_escape_string($cPassword, $db) );
			
			
			//echo $sql."<br><br>";
			
			if(mysql_num_rows(run_query($sql, $db)) == 1)
			{
				// The user is GOOD - so now lets deal with the SUBMITTED FILE
				
				//	Does an abstract currently exist? 
				//	- YES --> Do you want to overwrite?
				//	- NO  --> Proceed to upload file.
				
				$sql = sprintf("SELECT PaperID, Submitted from PaperAbstract where PaperID = '%s' and Submitted = 1",
								mysql_real_escape_string($cPaperID, $db) );
				
				$qRes = run_query($sql, $db);
				$nRes = mysql_num_rows($qRes);
				
				mysql_free_result($qRes);
				/**
				 * 	CHECK RESULTS -> for above error checking.
				 *
				 **/
				if($nRes == 1)
				{
					$title = "Abstract Resubmission";
					$msg = "Your abstract has been resubmitted.";
					if($_SESSION['bAlreadySubmitted'] != 2) 
					{
						$_SESSION['bAlreadySubmitted'] = 1;
					}
				}
				else if($nRes > 1)
				{
					$title = "Error Submitting Abstract";
					$msg = "Please contact <a href=\"mailto:webmaster_ee@latrobe.edu.au?Subject=Abstract Submission ERR=2\">the DB Administrator</a> to resolve the error";
					$_SESSION['bAlreadySubmitted'] = 0;
				}
				else if($nRes == 0)
				{
					$msg = "File is good";		//dummy marker
					$_SESSION['bAlreadySubmitted'] = 0;
				}
								
					//- First lets check if the FILE is in the right FORMAT
					//-		this is not a guarantee that it is the right format,
					//-		as the file extension can be hacked by the client.
				$errEXT 			= $_FILES['submitfile']['name'];
				$errMIMETYPE 	= $_FILES['submitfile']['type'];
				
				//echo $errEXT . "<br>".$errMIMETYPE."<br>";
				
				$error = 0;
				
				
			/*	if(strstr($errEXT, ".pdf") == false || $errMIMETYPE !== "application/pdf" || $errMIMETYPE !== "application/octetstream" )
			//	if($errMIMETYPE !== "application/pdf" || $errMIMETYPE !== "application/octetstream" )
				{
					$msg = "File is not a <b><u>PDF</u></b> type.<br><br>";
					$error = 1;
				}
				*/
					//- Now lets check if the file size is within our specified LIMITS
				$errFSIZE = $FILES['submitfile']['size'];
				if($errFSIZE > $cMAXFSIZE)
				{
					$msg .= "File size must not exceed 5MB.<br><br>";
					$error = 1;					
				}

				//BASED ON THE PREVIOUS ERROR CHECKS WE PROCEED OR HALT EXECUTION
				if($error == 1)
				{
					$title = "ERROR SUBMITTING ABSTRACT";
					$msg .= "<a href=\"./subofabstract.php\">Click here to go back.</a>";
				}
				else if($_SESSION['bAlreadySubmitted'] == 1)
				{
					
					HTML_top();
					HTML_Confirm();
					HTML_bottom();
					
					exit();
				}
				else
				{
						//- Begin path construction and file renaming
					$uploadDir = $_SERVER['DOCUMENT_ROOT']."/superdarn2008/papers/";
					$uFile = pathinfo($_FILES['submitfile']['name']);
					$uploadFile = $uploadDir . $cPaperID . "." . $uFile['extension'];
					
						//- FINALLY... let's transfer the file to its appropriate position
					if($_FILES['submitfile']['error'] == UPLOAD_ERR_OK) 
					{
						if (move_uploaded_file($_FILES['submitfile']['tmp_name'], $uploadFile))	// the upload/copy bit of the transfer
						{
							//- We now modify the uploaded file's permissions
							if(!chmod($uploadFile, 0704))
							{
						  	$errMSG = "File permissions could not be modified on abstract submission file: " . $cPaperID;
						  
						  	// SEND EMAIL NOTIFYING ADMINISTRATOR
						  	$to = "J.Hura@latrobe.edu.au";
						  	$frm = "webmaster_ee@latrobe.edu.au";
						  	$sbj = "SD08 - File PERMISSIONS ERROR";
						  	
						  	send_mail($to, $frm, $sbj, $errMSG);
							}
						
							//- NEXT WE UPDATE THE DATABASE WITH THE FILENAME AND LOCATION    	
							$sql = sprintf("UPDATE PaperAbstract SET Submitted = '1', Filename = '%s', Location = '%s' WHERE PaperID = '%s'",
						  					mysql_real_escape_string($cPaperID . ".pdf", $db),
						   					mysql_real_escape_string("/superdarn2008/papers/", $db),
						   					mysql_real_escape_string($cPaperID, $db) );
						   					
							$qRes = run_query($sql, $db);
							
							if(mysql_affected_rows($db) == 0) 
							{
								if($_SESSION['bAlreadySubmitted'] > 2)
								{
									//There was an error inserting into the database, so essentially
									//this is equivalent to a failed upload, so we delete the moved file
									//as well as spitting out the DB error.
									$title = "UNEXPECTED DB ERROR!";
									$msg = "Type: " . mysql_error() . "<br>";
									unlink($uploadFile);
								}
								else
								{
									$sql = sprintf("SELECT Email from PaperContact where PaperID = '%s'",
														mysql_real_escape_string($cPaperID, $db) );
									
									$eRes = run_query($sql, $db);
									if(mysql_num_rows($eRes) == 1)
									{
										$row = mysql_fetch_array($eRes, MYSQL_ASSOC);
										$emailAddress = $row['Email'];
									}
									mysql_free_result($eRes);
									
									$title = "Abstract Successfully Re-Submitted";
									$msg = "File is valid, and was successfully re-submitted.<br><br>"
												."A copy of the re-submitted abstract has been sent to " . $emailAddress . "<br>";
									
									
									///////////////////////////////
									$emSBJ = "SD08 ABSTRACT RE-SUBMISSION (PAPER ID: " . $cPaperID . ")";
									$emMSG = "This message contains the Re-Submitted Abstract for Paper ID: " . $cPaperID . "\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";
									
									//send_notif($uploadFile, "J.Hura@latrobe.edu.au", $emSBJ, $emMSG);	//joe
									//send_notif($uploadFile, "M.Gentile@latrobe.edu.au", $emSBJ, $emMSG);	//mark
									send_notif($uploadFile, $emailAddress , $emSBJ, $emMSG);	//user
									send_notif($uploadFile, "colin.waters@newcastle.edu.au", $emSBJ, $emMSG); //colin
									send_notif($uploadFile, "A.Lennen@latrobe.edu.au", $emSBJ, $emMSG);	//alicia
								}
							}
							else
							{
								$sql = sprintf("SELECT Email from PaperContact where PaperID = '%s'",
													mysql_real_escape_string($cPaperID, $db) );
									
								$eRes = run_query($sql, $db);
								if(mysql_num_rows($eRes) == 1)
								{
									$row = mysql_fetch_array($eRes, MYSQL_ASSOC);
									$emailAddress = $row['Email'];
								}
								mysql_free_result($eRes);
									
								$title = "Abstract Successfully Uploaded";
								$msg = "File is valid, and was successfully uploaded.<br><br>"
											."A copy of the Submitted Abstract has been sent to " . $emailAddress . "<br>";

								///////////////////////////////
								
								$emSBJ = "SD08 ABSTRACT SUBMISSION (PAPER ID: " . $cPaperID . ")";
								$emMSG = "This message contains the uploaded abstract for Paper ID: " . $cPaperID . "\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";
								
								//send_notif($uploadFile, "J.Hura@latrobe.edu.au", $emSBJ, $emMSG);	//joe
								//send_notif($uploadFile, "M.Gentile@latrobe.edu.au", $emSBJ, $emMSG);	//mark
								send_notif($uploadFile, $emailAddress , $emSBJ, $emMSG);	//user
								send_notif($uploadFile, "colin.waters@newcastle.edu.au", $emSBJ, $emMSG); //colin
								send_notif($uploadFile, "A.Lennen@latrobe.edu.au", $emSBJ, $emMSG);	//alicia

							}
	
						}
						else 
						{
								$title = "Abstract Submission Error";
						    $msg = "Error uploading file. A message has been sent to the administrator to rectify this immediately.<br><br>"
						    				."<a href=\"./subofabstract.php\">Click here to go back.</a>";
						    
						    // SEND EMAIL NOTIFYING ADMINISTRATOR
						  	$to = "J.Hura@latrobe.edu.au";
						  	$frm = "webmaster@tiger.latrobe.edu.au";
						  	$sbj = "SD08 - Unable to MOVE uploaded File";
						  	$errMSG = "Error uploading: " . $uploadFile;
						  	
						  	send_mail($to, $frm, $sbj, $errMSG);
						}
					}
				}
			}
			else
			{
				$title = "Error with form input";
				$msg = "<b>Details do not match.</b><br>"
							."Please check your email and follow the verification process before submitting your abstract.<br><br>"
							."<a href=\"./subofabstract.php\">Click here to go back.</a>";
			}
			
			dcon_and_close($db);
			
			
			// Now spit out all the HTML
			HTML_top();
			HTML_form(false, $title, $msg);
			HTML_bottom();
			
			$_SESSION = array();
			session_destroy();
			unset($_POST);
			
		}
		else	/* THE REQUIRED FIELDS ARE MISSING */
		{
			HTML_top();
			$title = "Required Fields Missing";
			$msg = "Please check over all fields and ensure they are filled in correctly, and the attached PDF is not larger than 5MB.<br><br>"
						."<a href=\"./subofabstract.php\">Click here to go back.</a>";
			HTML_form(false, $title, $msg);
			HTML_bottom();
			unset($_POST);
		}
	}
	else if($_GET)
	{
		if(isset($_GET['resub']))
		{
			if($_GET['resub'] == 0)
			{
				unset($_GET); unset($_POST); unset($_FILES);
				$_SESSION = array();
				session_destroy();
				header("Location: " . $HEADER_LOC);
				exit();
			}
			else
			{
				$_SESSION['bAlreadySubmitted'] = 2;
				unset($_GET);
				header("Location: " . $HEADER_LOC);
				exit();
			}
		}
	}
	else
	{
		HTML_top();
		HTML_form(true);
		HTML_bottom();
	}

/** *************************
	*	
	*	THE HTML OUTPUT PAGES
	*
 ** ********************** */
 function HTML_Confirm()
	{ ?>
		<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">Re-Submission of Abstract</font>
		</center>
		</td>
		</tr>
		</table>
		<p>&nbsp;</p>
			
		<table 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;</td>
 				<td width="439" class="TextDarkGreyMedium">An asbtract has already been submitted for this paper. Do you wish to overwrite it?</td>
			</tr>
			<tr>
  			<td class="TextDarkGreyMediumBold">&nbsp;</td>
  			<td class="TextDarkGreyMedium">&nbsp;
  			</td>
			</tr>
			<tr>
  			<td class="TextDarkGreyMediumBold">&nbsp;</td>
  			<td class="TextDarkGreyMediumBold">
  				<table cellspacing="0" cellpadding="0" border="0">
						<tr>
    					<td align="center"><a href="<?= $_SERVER['PHP_SELF']; ?>?resub=0">No</a></td>
    					<td width="30">&nbsp;</td>
    					<td align="center"><a href="<?= $_SERVER['PHP_SELF']; ?>?resub=1">Yes</a></td>
						</tr>
					</table>	
  			</td>
			</tr>
			<tr>
  			<td class="TextDarkGreyMediumBold">&nbsp;</td>
  			<td class="TextDarkGreyMedium">&nbsp;
  			</td>
			</tr>
		</table>
<?}
	
	function HTML_top()
	{
?>
	<html>
		<head>
			<title>SuperDARN 2008 - Submission of Abstract</title>
			<link rel="stylesheet" href="../assets/css/LTUtypespecs.css" type="text/css">
			<link rel="stylesheet" href="./assets/css/LTUtypespecs.css" type="text/css">
			
			<script type="text/javascript">
					function errorCheck(thisform)
					{
						//create variables for script
						var sPaperID = -1;
						var sPASS = -1;
						var requiredFieldsErrorMessage = "";
						var alertMessage = "";
						
						//gather values of applicant's name
						sPaperID	= document.forms['abstract'].elements['PaperID'].value;
						sPASS	= document.forms['abstract'].elements['password'].value;
												
						if (sPaperID == "") {
							requiredFieldsErrorMessage = requiredFieldsErrorMessage + "- Paper ID must be entered\n";
						}
						if (sPASS == "") {
							requiredFieldsErrorMessage = requiredFieldsErrorMessage + "- Password must be entered\n";
						}
						
						//Error message displays
						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);
							return false;
						}
						else {
							//document.forms["abstract"].submit();
							return true;
						}
					}

	 			</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>
											<tr valign="top" align="left">
		            				<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" -->
			        
			         						<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>
<?	
	}

	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: 18th October, 2007
				  							</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>
									</p>
	  						</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>
<?
	}

	function HTML_form($form = true, $title = "", $msg = "")
	{
		if($form == true) {?>
			<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>
			<?	if($_SESSION['bAlreadySubmitted'] == 2) {
						$a = "<font face=\"Arial,Times\" size=\"+3\">Re-Submission of Abstract</font>"; }
					else {
						$a = "<font face=\"Arial,Times\" size=\"+3\">Submission of Abstract</font>"; }
					echo $a; ?>
			</center>
			</td>
			</tr>
			</table>
			<p>&nbsp;</p>

			<form name="abstract" method="post" enctype="multipart/form-data" action="<?= $_SERVER['PHP_SELF']; ?>" onSubmit="return errorCheck(abstract);">
				<table 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="PaperID">Paper ID: </label></td>
	 					<td width="439" class="TextDarkGreyMedium">
	 					<?	if($_SESSION['bAlreadySubmitted'] == 2) {
	 								$a = "<input type=\"text\" name=\"PaperID\" id=\"PaperID\" size=\"40\" value=\" " . $_SESSION['PaperID'] . "\">"; }
	 							else {
	 								$a = "<input type=\"text\" name=\"PaperID\" id=\"PaperID\" size=\"40\">"; }
	 							echo $a; ?>
	 					</td>
						</tr>
					<tr>
	   				<td class="TextDarkGreyMediumBold"><label for="password">Password: </label></td>
	   				<td class="textdarkgreymedium">
	   				<?	if($_SESSION['bAlreadySubmitted'] == 2) {
	   							$a = "<input type=\"password\" name=\"password\" id=\"password\" size=\"40\" value=\"". $_SESSION['Password'] . "\">"; }
	   						else {
	   							$a = "<input type=\"password\" name=\"password\" id=\"password\" size=\"40\">"; }
	   						echo $a; ?>
	   				</td>
					</tr>
					<tr>
	   				<td class="TextDarkGreyMediumBold"><label for="submitfile">File: </label></td>
	   				<td class="TextDarkGreyMedium">
	   					<input type="hidden" name="MAX_FILE_SIZE" value="5120000">
	   					<input type="file" id="submitfile" name="submitfile" size="60" accept="application/*">
	   				</td>
					</tr>
					<tr>
	   				<td class="TextDarkGreyMediumBold"></td>
	   				<td class="TextDarkGreyMedium"><br>
							<span class="TextDarkGreySmall">
								Full Abstracts are due before the <b>9th of May, 2008</b> and must be sent using the following 
								<a href="forms/Abstract_template.rtf">Submission of Abstract Template</a> format.</span></p>
								<p><span class="TextDarkGreySmall">Below is list of guidelines that should be followed.</p>
	        				<OL>
									<LI>File must be in <b><u>PDF</u></b> format.</LI>
									<LI>File size <b><u>MUST NOT</u></b> exceed 5MB.</LI>
									<LI>Maximum of 1 page including figures, text in single column.</LI>
									<LI>Font size 12, Times New Roman or nearest equivalent.</LI>
									<LI>Left margin 2.5cm, right margin 2.5cm, top 2.5cm, bottom 2.5cm.</LI>
									<LI>Title to be in boldface, fontsize 14, Times New Roman, lower case.</LI>
									<LI>Author(s) Times New Roman size 12, Bold.</LI>
									<LI>Affiliation(s) showing full postal address and Email if available, Times New Roman 12, Bold.</LI>
									<LI>Main text in single column, diagrams can be included in main text or at the end of the abstract.</LI>
									<LI>Literature should be referenced by numbers in square brackets, eg., &#91;2&#93; throughout the text.</LI>
								</OL>
	       			</SPAN>
							<br>
						</td>
					</tr>
					<tr>
	   				<td class="TextDarkGreyMediumBold"></td>
	   				<td class="TextDarkGreyMedium">
							<table cellspacing="0" cellpadding="0" border="0">
								<tr>
	    						<td align="center"><input type="Submit" name="submit" value="Submit File"></td>
	    						<td width="30">&nbsp;</td>
	    						<td align="center"><input type="Reset"></td>
								</tr>
								<tr><td colspan="3">&nbsp;</td></tr>
								<tr>
									<td colspan="3">
										<span class="TextDarkGreySmall">
											If you have problems with the abstract submission, please contact the <a href="mailto:webmaster_ee@latrobe.edu.au">
											webmaster</a> quoting your Paper ID.
										</span>
									</td>
								</tr>
							</table>
						</td>
					</tr>
				</table>
			</form> <?
		}
		else { ?>
			<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 width="99%" cellspacing="1" cellpadding="1" border="0">
				<tr>
					<td class="TextDarkGreyMediumBold">&nbsp;</td>
					<td class="TextDarkGreyMedium" width="90%">&nbsp;</td>
				</tr>
				<tr>
					<td class="TextDarkGreyMediumBold">&nbsp;</td>
					<td class="TextDarkGreyMedium" width="90%"><h3><?= $msg; ?></h3><br><br>
						<a href="index.html">Done.</a>
					</td>
				</tr>
			</table> <?
		}
	}
?>