var POST = 0;
var MODIFY = 1;

function submit_check(f)
{
	if(set_icon(f,POST))
		return true;
	else { 
		return false;
	}
}

function document_check(f)
{
	if(f.isDocument.value != "")
		return true;
		
	// determine if this is a link or a file being submitted
	if (f.document.value != "")
	{	
		f.type.value = "none";
		return true;
	}
	else if ((f.link.value != "") && (f.link.value != "http://"))
	{	
		f.type.value = "Link";
		return true;
	}
	else
	{	
		alert("You have not uploaded a document or specified a link.");
		return false;
	}
}

function set_icon(f,action)
{ 
	var thefile;
	var splitstr;
	var xten;
	var thefile;
	
	thefile = f.document.value;

	if(f.document_delete != null)
	{
		if(f.document_delete.checked && thefile == "")
		{			
			//We're deleting the document, lets get out of here!
	 		f.icon.value =  "";
	 		thefile="";
	 		return true;
 		}
	}
		
		if(f.link.value != "") // Item is a link, set icon to html.gif
		{
			f.icon.value = "/publications/icons/html.gif";
			return true;
		}
		else if(thefile == "") // No (new) document, return true
		{
			return true;
		}
		else // New document, reset icon
		{

			if(thefile[thefile.length-1] == "/") 
			{ 
				thefile += "index.html"; 
			} 
			splitstr = thefile.split(".");
			xten = splitstr[splitstr.length - 1];
			xten = xten.toLowerCase();
			if(xten=="htm")  
			{ 
				xten = "html";
			} 
			if(xten=="jpeg")  
			{ 
				xten = "jpg"; 
			} 
			if(xten=="rtf")  
			{ 
				xten = "doc"; 
			} 
			if ((xten=="doc") || 
					(xten=="html") || 
					(xten=="pdf") || 
					(xten=="jpg") || 
					(xten=="gif") ||  
					(xten=="ppt") || 
					(xten=="pub") ||  
					(xten=="xls") || 
					(xten=="zip"))  
			{  
				f.icon.value = '/publications/icons/' + xten + '.gif'; 
				return true; 
			} 
			else 
			{ 
				alert('Sorry, files with extensions, .'+xten+', cannot be accepted\nAcceptable types are htm, html, doc, xls, pdf, jpeg, jpg, gif, rtf, ppt, pub or zip');
				thefile="";
				return false; 
			}
		}
	
	

}
