function makeShow(theElement)
{
document.getElementById(theElement).style.visibility="visible"
}

function makeHide(theElement)
{
document.getElementById(theElement).style.visibility="hidden"
}

var re = /^(\.sh)|(\.exe)|(\.php)|(\.sh)/;  // disallow these extensions
var dofilter=true;

function check_types() {
	if(dofilter==false)
		return true;
	with(document.forms[0])
	{
		for(i=0 ; i < elements.length ; i++)
		{
			if(elements[i].value.match(re))
			{
				alert('Sorry ' + elements[i].value + ' is not allowed');
				return false;
			}
		}
	}
	return true;
}

function postIt()
{
if(check_types() == false)
	{
		return false;
	}
	makeShow('demodiv');
	document.forms[0].submit();
}


function previewImage(fileInfo)
{
var filename = "";
//create the path to your local file
if (fileInfo == null) 
	{
	if (document.form.file != "")
		{
		filename = "file:///" + document.form.file.value;
		}
	}
	else
	{
	filename = fileInfo;
	}

//browser check then check if there is a value

browserName=navigator.appName; 

if (browserName=="Microsoft Internet Explorer")
{
if (filename == "") 
	{
	//if no value display message
	previewer.document.open();
	previewer.document.write("<html><head><style type='text/css'>body{font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #FFFFFF;}</style></head><body>");
	previewer.document.write("<b>Please select a file.</b><br><br>Only jpg, gif, png & bmp images can be previewed here but other files can be uploaded. </body><html>");
	previewer.document.close();
	}
	else
	{
	//if a value then work out file name minus path & file extension
	var shortfilename = filename.substring(filename.lastIndexOf("\\")+1);
	var fileExtension = filename.substring(filename.lastIndexOf(".")+1);
	//if extension is okay then display image else print message
	if (fileExtension == "jpg" || fileExtension == "JPG" || fileExtension == "jpeg" || fileExtension == "JPEG" || fileExtension == "gif" || fileExtension == "GIF" || fileExtension == "png" || fileExtension == "PNG" || fileExtension == "bmp" || fileExtension == "BMP")
		{
		previewer.document.open();
		previewer.document.write("<html><head><style type='text/css'>body{font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #FFFFFF; margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px;}</style></head><body>");
		previewer.document.write("<table align=center><b>" + shortfilename + "</b></div><br><img width='170' src='" + filename + "'></div></body><html>");
		previewer.document.close();
		}
		else
		{
		previewer.document.open();
		previewer.document.write("<html><head><style type='text/css'>body{font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #FFFFFF;}</style></head><body>");
		previewer.document.write("<b>" + shortfilename + "</b> cannot be previewed here, but you may still be able to upload this file.<br><br>Only jpg, gif, png & bmp images can be previewed but other files can be uploaded.</body><html>");
		previewer.document.close();
		}
	}
}
else
{
	previewer.document.open();
	previewer.document.write("<html><head><style type='text/css'>body{font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: #FFFFFF;}</style></head><body>");
	previewer.document.write("<b>Internet Explorer Only!</b><br><br>Sorry, but Image Preview will only work with Internet Explorer 5+. <br><br>However, you may still be able to upload this file.</body><html>");
	previewer.document.close();
}
}

