function trimAll(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 postcontentForm_Validator(postcontentForm)
{
	//File
 if (trimAll(postcontentForm.tbxtitle.value) == "" )
 {
 alert("Please enter \"College Name / Training Institute Name / Consultancy / Exam Paper Title / Job Title\" field.");
 postcontentForm.tbxtitle.focus();
 return (false);
 }	
		//File
 if (trimAll(postcontentForm.tareaabout.value) == "" )
 {
 alert("Please enter \"About the College / Institute / Consultancy / Job Description\" field.");
 postcontentForm.tareaabout.focus();
 return (false);
 }
 
 if (trimAll(postcontentForm.tareaaddress.value) == "" )
 {
 alert("Please enter \"Address\" field.");
 postcontentForm.tareaaddress.focus();
 return (false);
 }
 
 //Mobile
 if (trimAll(postcontentForm.tbxphone.value) == "" )
 {
 alert("Please enter \"Phone no\" field.");
 postcontentForm.tbxphone.focus();
 return (false);
 }
 
 var checkOK = "0123456789";
 var checkStr = postcontentForm.tbxphone.value;
 var allValid = true;
 var validGroups = true;
 for (i = 0; i < checkStr.length; i++)
 {
 ch = checkStr.charAt(i);
 for (j = 0; j < checkOK.length; j++)
 if (ch == checkOK.charAt(j))
 break;
 if (j == checkOK.length)
 {
 allValid = false;
 break;
 }
 }
 if (!allValid)
 {
 alert("Please enter only digit in the \"Phone no\" field.");
 postcontentForm.tbxphone.focus();
 return (false);
 }


//E-Mail
if (trimAll(postcontentForm.tbxemail.value) == "" )
{
alert("Please enter \"E-Mail\" field.");
postcontentForm.tbxemail.focus();
return (false);
}
var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890_.@ \t\r\n\f";
var checkStr = postcontentForm.tbxemail.value;
var allValid = true;
var validGroups = true;
for (i = 0; i < checkStr.length; i++)
{
ch = checkStr.charAt(i);
for (j = 0; j < checkOK.length; j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length)
{
allValid = false;
break;
}
if (checkStr.indexOf('@') == -1 || checkStr.indexOf('.') == -1 )
{
allValid = false;
break;
}
}
if (!allValid)
{
alert("Please enter a valid id in the \"E-Mail \" field.");
postcontentForm.tbxemail.focus();
return (false);
}

  if (trimAll(postcontentForm.tbxwebsite.value) == "" )
 {
 alert("Please enter \"Website address\" field.");
 postcontentForm.tbxwebsite.focus();
 return (false);
 }
 if (trimAll(postcontentForm.fileupload.value) != "" )
 {
	 var path = postcontentForm.fileupload.value.toLowerCase();
	 
	 var fileextension = path.substr(path.length-3,path.length);

	 if(fileextension=="doc" ||fileextension=="DOC")
	 {}
	 else
	 {
		 alert("Invalid file format.");
		 postcontentForm.fileupload.focus();
		 return (false);
	 }
 }
 
return (true);
}
