// JavaScript Document

function validateForm(contact)
{
			
			if(""==document.forms.frmseminar.First_Name.value)
			{
			alert("Please enter your Name.");
			return false;
			}
			
			if(""==document.forms.frmseminar.address.value)
			{
			alert("Please enter your address.");
			//document.forms.form1.phone.focus();
			return false;
			}
			
			if(""==document.forms.frmseminar.city.value)
			{
			alert("Please enter the city.");
			return false;
			}
			
			if(""==document.forms.frmseminar.state.value)
			{
			alert("Please select the state.");
			return false;
			}
			
			if(""==document.forms.frmseminar.zip.value)
			{
			alert("Please enter zip code.");
			return false;
			}
			
			if(""==document.forms.frmseminar.phone.value)
			{
			alert("Please enter phone number.");
			return false;
			}
			
			if(""==document.forms.frmseminar.email.value)
			{
			alert("Please enter your email id.");
			return false;
			}

}


function Printname()
{
		alert(document.forms.form1.req_selectcriteria.value);
}


function TValidateRequiredField(arrFieldIDs)
{
    if(arrFieldIDs.length > 0)
	{
		for(var i=0;i<arrFieldIDs.length;i++)
		{

			if(trim(document.getElementById(arrFieldIDs[i]).value) == "" || document.getElementById(arrFieldIDs[i]).value == "-1"
			     || document.getElementById(arrFieldIDs[i]).value == "Select Status"  || document.getElementById(arrFieldIDs[i]).value =="Select Location" )
			{
			    
				alert('Fields marked as * are required');
				return false;
			}

		}
		return true;		
	}
}

function CheckEmailID(paraEmail)
{
			   
					var sEmail = document.getElementById(paraEmail).value;
			     
					var atsym = sEmail.indexOf("@");
					var period = sEmail.lastIndexOf('.');
					var space = sEmail.indexOf(' ');
					var length = sEmail.length - 1;
					
					if ((atsym < 1) || (period <= atsym+1) || (period == length ) || (space != -1)) 
					{ 
							alert('Please enter a valid email address !');
						    document.getElementById(paraEmail).focus();
							return false;
					}
					return true;
}

function trim(inputString) 
{
	if (typeof inputString != "string") { return inputString; }
	var retValue = inputString;
	var ch = retValue.substring(0, 1);
	while (ch == " ") 
	{ // Check for spaces at the beginning of the string
		retValue = retValue.substring(1, retValue.length);
		ch = retValue.substring(0, 1);
	}
	ch = retValue.substring(retValue.length-1, retValue.length);
	while (ch == " ") 
	{ // Check for spaces at the end of the string
		retValue = retValue.substring(0, retValue.length-1);
		ch = retValue.substring(retValue.length-1, retValue.length);
	}
	while (retValue.indexOf("  ") != -1)
	{ // Note that there are two spaces in the string - look for multiple spaces within the string
		retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
	}
	return retValue; // Return the trimmed string back to the user
} 

function CheckSpecialChar(vObject,vType)
{
	var iChars;
	var AlertMsg;

	if(vType == "String")
	{

		iChars = "`!@#$%^&*()+=-[]\\\;,./{}|\":<>?1234567890";
		AlertMsg ="Special characters are not allowed!"; 
	}
	else if (vType == "Numeric")
	{
		iChars = "`!@#$%^&*()+=-[]\\\;,./{}|\:<>? ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'''";
		AlertMsg ="Invalid value";

	}
	else if (vType == "AlphaNumeric")
	{
		iChars = "`!@#$%^&*()+=[]\\\';,./{}|\":<>?";
		AlertMsg ="Special characters are not allowed!"; 
	}
	else if(vType == "SingleQuote")
	{
		iChars = "'";
		AlertMsg ="Single quote is not allowed!"; 
	}
	for (var i = 0; i < document.getElementById(vObject).value.length; i++) 
	{
		if (iChars.indexOf(document.getElementById(vObject).value.charAt(i)) != -1) 
		{

			alert(AlertMsg);
			document.getElementById(vObject).focus();
			return false;
		}
	}
	return true;	
}
