function CheckFormA()
{
	var strError = "";
	
	if(document.Form1.name.value == "" || trim(document.Form1.name.value) == true)
		strError += "-  Name is a mandatory field. \n";
		
	if(document.Form1.email.value == "" || trim(document.Form1.email.value) == true)
		strError += "-  Email is a mandatory field. \n";
	else if (CheckEmail(document.Form1.email.value) != true)
		strError += "-  Invalid Email address. \n";
		
	if(document.Form1.contact.value == "" || trim(document.Form1.contact.value) == true)
		strError += "-  Contact No. is a mandatory field. \n";
		
	if(document.Form1.comments.value == "" || trim(document.Form1.comments.value) == true)
		strError += "-  Comments is a mandatory field. \n";
	
	if(strError != "")
	{
		alert(strError);
		return false;
	}
	
	return true;
}



function CheckFormB()
{
	var strError = "";

	if(document.Form1.company.value == "" || trim(document.Form1.company.value) == true)
		strError += "-  Company is a mandatory field. \n";
	
	if(document.Form1.name.value == "" || trim(document.Form1.name.value) == true)
		strError += "-  Name is a mandatory field. \n";

	if(document.Form1.designation.value == "" || trim(document.Form1.designation.value) == true)
		strError += "-  Designation is a mandatory field. \n";

	if(document.Form1.contact.value == "" || trim(document.Form1.contact.value) == true)
		strError += "-  Contact No. is a mandatory field. \n";
		
	if(document.Form1.email.value == "" || trim(document.Form1.email.value) == true)
		strError += "-  Email is a mandatory field. \n";
	else if (CheckEmail(document.Form1.email.value) != true)
		strError += "-  Invalid Email address. \n";
		
	if(document.Form1.description.value == "" || trim(document.Form1.description.value) == true)
		strError += "-  Description is a mandatory field. \n";

	if(document.Form1.attachment != null)
	{
		if(document.Form1.attachment.value != "")
		{
			 if(!IsCorrectUploadFile("pdf,doc,docx,xls,xlsx,ppt,pptx", document.Form1.attachment))
				strError += "-  Invalid Attachment File format.\n";
		}
		else
		{
			strError += "-  Attachment is a mandatory field.\n";
		}
	}
	
	if(strError != "")
	{
		alert(strError);
		return false;
	}
	
	return true;
}


function CheckFormC()
{
	var strError = "";

	if(document.Form1.category.value == "" || trim(document.Form1.category.value) == true)
		strError += "-  Job Category is a mandatory field. \n";

	if(document.Form1.attachment != null)
	{
		if(document.Form1.attachment.value != "")
		{
			 if(!IsCorrectUploadFile("pdf,doc,docx,xls,xlsx,ppt,pptx", document.Form1.attachment))
				strError += "-  Invalid Attachment File format.\n";
		}
		else
		{
			strError += "-  Attachment is a mandatory field.\n";
		}
	}
	
	if(strError != "")
	{
		alert(strError);
		return false;
	}
	
	return true;
}

//--------------------------------- ADDITIONAL FORM VALIDATION -------------------------------//

function CheckEmail(email) 
{
	var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (!filter.test(email))
		return false;
		
	return true;
}

function trim(str) 
{
	if(str.replace(/^\s+|\s+$/g,"") == "")
		return true;
		
	return false
}

function ToTrim(str) {
	return str.replace(/^\s+|\s+$/g,"");
}

function GetFileExtension(Filename)
{
  var I = Filename.lastIndexOf(".");
  return (I > -1) ? Filename.substring(I + 1, Filename.length).toLowerCase() : "";
}

function IsCorrectUploadFile(Extensions, FormObj)
{
	var UploadFile = FormObj.value;
	var Extensions = Extensions.split(",");
	var Ext = "";
	var CompareTo = "";
	var By = "";

	if (UploadFile != "")
	{
		Ext = GetFileExtension(UploadFile);
		for(var i = 0; i < Extensions.length; i++)
		{
			CompareTo = ToTrim(Ext.toUpperCase());
			By = ToTrim(Extensions[i].toUpperCase());
			if(CompareTo == By)
				return true; 
		}
		return false;
	}
}