function trim(sString) 
{
	while (sString.substring(0,1) == ' ')
	{
		sString = sString.substring(1, sString.length);
	}
	while (sString.substring(sString.length-1, sString.length) == ' ')
	{
		sString = sString.substring(0,sString.length-1);
	}
	return sString;
}

function check_mail(email)
{	
	var re3 = /^\s*([a-zA-Z0-9\._\-]{1,100})@([a-zA-Z0-9\.\-_]){1,100}\.([a-zA-Z]{2,4})\s*$/gi;
     
    if (email.length>=0 && !email.match(re3)) 
	{
		return false;
	}
	
	return true;
}

function upload_form_validation()
{
	var error = "";
	
	if(document.getElementById('upfile_0').value=="") error = error + "-Select the file you want to upload\n";
	if(document.getElementById('fileTags').value=="") error = error + "-Add a short description for your file\n";	

	if(document.getElementById('terms').checked==false)
		error = error + "-You need to accept the terms of service\n";

	if(error != "")
	{
		alert(error);
		return false;
	}

	document.getElementById('myform').style.display="none";
	
	return uploadFiles();
}