// JavaScript Document
//<!--
// Check Text or Not
function isText(str)
{
	var i=0;
	if(str.charAt(0)==' ')i++;
	while(i<str.length)
	{
		if (str.charAt(i)>='0' && str.charAt(i)<= '9' || str.charAt(i)=='+' || str.charAt(i)=='-' || str.charAt(i)=='*' || str.charAt(i)=='/' || str.charAt(i)=='\\' || str.charAt(i)=='\'' || str.charAt(i)=='@' || str.charAt(i)=='!' || str.charAt(i)=='~' || str.charAt(i)=='`' || str.charAt(i)=='#' || str.charAt(i)=='$' || str.charAt(i)=='%' || str.charAt(i)=='^' || str.charAt(i)=='&' || str.charAt(i)=='(' || str.charAt(i)==')' || str.charAt(i)=='_' || str.charAt(i)=='=' || str.charAt(i)=='?' || str.charAt(i)=='.' || str.charAt(i)==',' || str.charAt(i)==';' || str.charAt(i)==':' || str.charAt(i)=='"' || str.charAt(i)=='{' || str.charAt(i)=='}' || str.charAt(i)=='[' || str.charAt(i)==']' || str.charAt(i)=='<' || str.charAt(i)=='>' || str.charAt(i)=='|')
		return false;
		i++;
	}
	return true;
}

//Check city or not
function isCity(str)
{
	var i=0;
	while(i<str.length)
	{
		if (str.charAt(i)=='+' || str.charAt(i)=='-' || str.charAt(i)=='*' || str.charAt(i)=='/' || str.charAt(i)=='\\' || str.charAt(i)=='\'' || str.charAt(i)=='@' || str.charAt(i)=='!' || str.charAt(i)=='~' || str.charAt(i)=='`' || str.charAt(i)=='#' || str.charAt(i)=='$' || str.charAt(i)=='%' || str.charAt(i)=='^' || str.charAt(i)=='&' || str.charAt(i)=='(' || str.charAt(i)==')' || str.charAt(i)=='_' || str.charAt(i)=='=' || str.charAt(i)=='?' || str.charAt(i)=='.' || str.charAt(i)==',' || str.charAt(i)==';' || str.charAt(i)==':' || str.charAt(i)=='"' || str.charAt(i)=='{' || str.charAt(i)=='}' || str.charAt(i)=='[' || str.charAt(i)==']' || str.charAt(i)=='<' || str.charAt(i)=='>' || str.charAt(i)=='|')
		{
				return false;
		}
		i++;
	}
	return true;
}

// Check Phone Number or not
function isTelephoneNumber(str)
{
	var i=0;
	if(str.charAt(0)=='+')i++;
	while(i<str.length)
	{
		if (!(str.charAt(i)>='0' && str.charAt(i)<= '9' || str.charAt(i)==' ' || str.charAt(i)=='-' || str.charAt(i)=='(' || str.charAt(i)==')') )
			return false;
		i++;
	}
	return true;
}
// Check Phone Number length
function isLength(str)
{
	var len=str.length;
		if(len<10)
		{
			return false;
		}
		return true;
}
// Check Number or Not
function isNumeric(str)
{
	var i=0;
	while(i<str.length)
	{
		if (!(str.charAt(i)>='0' && str.charAt(i)<= '9' || str.charAt(i)==' '))
		return false;
		i++;
	}
	return true;
}

// Remove the empty space
function trim(String)
{
   if (String == null)
   {   
   	return ("");
   }
   return String.replace(/(^\s+)|(\s+$)/g,"");
}

// Check the E-Mail Id
function isMailid(str) 
{
	var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
	if(document.form.email.value.match(emailExp))
	{
		var string1=document.form.email.value;
		var atPosition = string1.indexOf("@");
		var dotPosition = string1.lastIndexOf(".");
		var EmailAddress = string1.substring(atPosition+1,dotPosition);
		if ( (EmailAddress.toLowerCase() == "gmail") || (EmailAddress.toLowerCase() == "yahoo") ||  (EmailAddress.toLowerCase() == "hotmail") || (EmailAddress.toLowerCase() == "aol") || (EmailAddress.toLowerCase() == "rediffmail") || (EmailAddress.toLowerCase() == "indiatimes") || (EmailAddress.toLowerCase() == "msn") || (EmailAddress.toLowerCase() == "inbox") || (EmailAddress.toLowerCase() == "about") || (EmailAddress.toLowerCase() == "about") || (EmailAddress.toLowerCase() == "facebook") || (EmailAddress.toLowerCase() == "myspace") || (EmailAddress.toLowerCase() == "hi5") || (EmailAddress.toLowerCase() == "mac") || (EmailAddress.toLowerCase() == "lycos") || (EmailAddress.toLowerCase() == "fastmail") || (EmailAddress.toLowerCase() == "icqmail") || (EmailAddress.toLowerCase() == "hotmaillive") || (EmailAddress.toLowerCase() == "bigstring") || (EmailAddress.toLowerCase() == "hotpop") || (EmailAddress.toLowerCase() == "zapakmail") || (EmailAddress.toLowerCase() == "mail") || (EmailAddress.toLowerCase() == "latino") || (EmailAddress.toLowerCase() == "joymail") || (EmailAddress.toLowerCase() == "ivillage") || (EmailAddress.toLowerCase() == "orkut") || (EmailAddress.toLowerCase() == "sify") || (EmailAddress.toLowerCase() == "tamilmail"))
		{
			alert("Enter official email address.");
			document.form.email.focus();
			return false;
		}
		else
		{
			return true;
		}
	}
	else
	{
		alert("Invalid email address");
		document.form.email.focus();
		return false;
	}	
}
//======================================
// Form Validation
function formValidation()
{
	//Select Firstname
	document.form.fname.value=trim(document.form.fname.value);
	fname=document.form.fname.value;
	if (document.form.fname.value=="")
	{
		alert("Enter first name");		
		document.form.fname.focus();		
		return false;
	}
	else
		if(!isText(fname))
		{
			alert("This field will not accept numerical values.");
			document.form.fname.focus();
			return false;
		}
//Select lastname
	document.form.lname.value=trim(document.form.lname.value);
	lname=document.form.lname.value;
	if (lname=="")
	{
		alert("Enter last name");
		document.form.lname.focus();		
		return false;
	}
	else
		if(!isText(lname))
		{
			alert("This field will not accept numerical values.");
			document.form.lname.focus();
			return false;
		}
	
	//Select City
	document.form.city.value=trim(document.form.city.value);
	city=document.form.city.value;
	if (city=="")
	{
		alert("Enter city");
		document.form.city.focus();		
		return false;
	}		
	
//Select country
	document.form.country.value=trim(document.form.country.value);
	country=document.form.country.value;
	if (document.form.country.value=="")
	{
		alert("Select country");
		document.form.country.focus();
		return false;
	}
//Enter area code
	document.form.areacode.value=trim(document.form.areacode.value);
	areacode=document.form.areacode.value;
	if (document.form.areacode.value=="")
	{
		alert("Enter area code");		
		document.form.areacode.focus();		
		return false;
	}
	else if(isText(areacode))
	{
		alert("This field will only accept numerical values.");
		document.form.areacode.focus();
		return false;
	}
//Enter phone number
	document.form.phonenum.value=trim(document.form.phonenum.value);
	phonenum=document.form.phonenum.value;
	if (document.form.phonenum.value=="")
	{
		alert("Enter phone number");		
		document.form.phonenum.focus();		
		return false;
	}
	else if(isText(phonenum))
	{
		alert("This field will only accept numerical values.");
		document.form.phonenum.focus();
		return false;
	}	
		//Enter Email
 document.form.email.value=trim(document.form.email.value);
	email=trim(document.form.email.value);
	if ((email==null)||(email==""))
	{
		alert("Enter email address")
		document.form.email.focus()
		return false
	}
	if (isMailid(email)==false)
	{
		document.form.email.focus()
		return false
	}

//Select Type of whatledyou 
	document.form.whatledyou.value=trim(document.form.whatledyou.value);
	whatledyou=document.form.whatledyou.value;
	if (document.form.whatledyou.value=="")
	{
		alert("Select any one type of whatledyou");
		document.form.whatledyou.focus();
		return false;
	}

//Enter Message
	message=trim(document.form.message.value);
	if (message=="")
	{
		alert("Enter message");
		document.form.message.focus ();
		return false;
	}
	
		document.form.submit();
	return true;
}
//======================================
// Schedule a meeting Validation
function meetingValidation()
{
	//Select Type of enquiry 
	document.form.enquiry.value=trim(document.form.enquiry.value);
	enquiry=document.form.enquiry.value;
	if (document.form.enquiry.value=="")
	{
		alert("Select any one type of enquiry");
		document.form.enquiry.focus();
		return false;
	}
	//Select Firstname
	document.form.firstName.value=trim(document.form.firstName.value);
	firstName=document.form.firstName.value;
	if (document.form.firstName.value=="")
	{
		alert("Enter first name");		
		document.form.firstName.focus();		
		return false;
	}
	else
		if(!isText(firstName))
		{
			alert("This field will not accept numerical values.");
			document.form.firstName.focus();
			return false;
		}
//Select lastname
	document.form.lastName.value=trim(document.form.lastName.value);
	lastName=document.form.lastName.value;
	if (lastName=="")
	{
		alert("Enter last name");
		document.form.lastName.focus();		
		return false;
	}
	else
		if(!isText(lastName))
		{
			alert("This field will not accept numerical values.");
			document.form.lastName.focus();
			return false;
		}
	//Select Designation
	document.form.designation.value=trim(document.form.designation.value);
	designation=document.form.designation.value;
	if (designation=="")
	{
		alert("Enter designation");
		document.form.designation.focus();		
		return false;
	}
	else
		if(!isText(designation))
		{
			alert("This field will not accept numerical values.");
			document.form.designation.focus();
			return false;
		}
	//Select Organization
	document.form.organization.value=trim(document.form.organization.value);
	organization=document.form.organization.value;
	if (organization=="")
	{
		alert("Enter organization");
		document.form.organization.focus();		
		return false;
	}		
	
//Select country
	document.form.country.value=trim(document.form.country.value);
	country=document.form.country.value;
	if (document.form.country.value=="")
	{
		alert("Select country");
		document.form.country.focus();
		return false;
	}
//Enter area code
	document.form.areacode.value=trim(document.form.areacode.value);
	areacode=document.form.areacode.value;
	if (document.form.areacode.value=="")
	{
		alert("Enter area code");		
		document.form.areacode.focus();		
		return false;
	}
	else if(isText(areacode))
	{
		alert("This field will only accept numerical values.");
		document.form.areacode.focus();
		return false;
	}
//Enter phone number
	document.form.phonenum.value=trim(document.form.phonenum.value);
	phonenum=document.form.phonenum.value;
	if (document.form.phonenum.value=="")
	{
		alert("Enter phone number");		
		document.form.phonenum.focus();		
		return false;
	}
	else if(isText(phonenum))
	{
		alert("This field will only accept numerical values.");
		document.form.phonenum.focus();
		return false;
	}	

//Enter Email
 document.form.email.value=trim(document.form.email.value);
	email=trim(document.form.email.value);
	if ((email==null)||(email==""))
	{
		alert("Enter e-mail")
		document.form.email.focus()
		return false
	}
	if (isMailid(email)==false)
	{
		document.form.email.focus()
		return false
	}
//Select Date
	document.form.dateandmonth.value=trim(document.form.dateandmonth.value);
	dateandmonth=document.form.dateandmonth.value;
	if (document.form.dateandmonth.value=="")
	{
		alert("Select date");
		document.form.dateandmonth.focus();
		return false;
	}
/*//Select Preferred date 
	document.form.date.value=trim(document.form.date.value);
	date=document.form.date.value;
	if (document.form.date.value=="")
	{
		alert("Select date");
		document.form.date.focus();
		return false;
	}
//Select Preferred date 
	document.form.date.value=trim(document.form.date.value);
	date=document.form.date.value;
	if (document.form.date.value=="")
	{
		alert("Select date");
		document.form.date.focus();
		return false;
	}
//Select Preferred month 
	document.form.month.value=trim(document.form.month.value);
	month=document.form.month.value;
	if (document.form.month.value=="")
	{
		alert("Select month");
		document.form.month.focus();
		return false;
	}
//Select Preferred year
	document.form.year.value=trim(document.form.year.value);
	year=document.form.year.value;
	if (document.form.year.value=="")
	{
		alert("Select year");
		document.form.year.focus();
		return false;
	}*/
//Select Preferred time
	document.form.time.value=trim(document.form.time.value);
	time=document.form.time.value;
	if (document.form.time.value=="")
	{
		alert("Select time");
		document.form.time.focus();
		return false;
	}
 //Select Preferred mins
	document.form.mins.value=trim(document.form.mins.value);
	mins=document.form.mins.value;
	if (document.form.mins.value=="")
	{
		alert("Select mins");
		document.form.mins.focus();
		return false;
	}
	document.form.submit();
	return true;
}
//======================================
// Brochures Validation
function broValidation()
{

	//Select Firstname
	document.form.firstname.value=trim(document.form.firstname.value);
	firstname=document.form.firstname.value;
	if (document.form.firstname.value=="")
	{
		alert("Enter first name");		
		document.form.firstname.focus();		
		return false;
	}
	else
		if(!isText(firstname))
		{
			alert("This field will not accept numerical values.");
			document.form.firstname.focus();
			return false;
		}
//Select lastname
	document.form.lastname.value=trim(document.form.lastname.value);
	lastname=document.form.lastname.value;
	if (lastname=="")
	{
		alert("Enter last name");
		document.form.lastname.focus();		
		return false;
	}
	else
		if(!isText(lastname))
		{
			alert("This field will not accept numerical values.");
			document.form.lastname.focus();
			return false;
		}
	//Select Designation
	document.form.designation.value=trim(document.form.designation.value);
	designation=document.form.designation.value;
	if (designation=="")
	{
		alert("Enter designation");
		document.form.designation.focus();		
		return false;
	}
	else
		if(!isText(designation))
		{
			alert("This field will not accept numerical values.");
			document.form.designation.focus();
			return false;
		}
	//Select Organization
	document.form.organization.value=trim(document.form.organization.value);
	organization=document.form.organization.value;
	if (organization=="")
	{
		alert("Enter organization");
		document.form.organization.focus();		
		return false;
	}		
	
//Select country
	document.form.country.value=trim(document.form.country.value);
	country=document.form.country.value;
	if (document.form.country.value=="")
	{
		alert("Select country");
		document.form.country.focus();
		return false;
	}
//Enter area code
	document.form.areacode.value=trim(document.form.areacode.value);
	areacode=document.form.areacode.value;
	if (document.form.areacode.value=="")
	{
		alert("Enter area code");		
		document.form.areacode.focus();		
		return false;
	}
	else if(isText(areacode))
	{
		alert("This field will only accept numerical values.");
		document.form.areacode.focus();
		return false;
	}
//Enter phone number
	document.form.phonenum.value=trim(document.form.phonenum.value);
	phonenum=document.form.phonenum.value;
	if (document.form.phonenum.value=="")
	{
		alert("Enter phone number");		
		document.form.phonenum.focus();		
		return false;
	}
	else if(isText(phonenum))
	{
		alert("This field will only accept numerical values.");
		document.form.phonenum.focus();
		return false;
	}	

//Enter Email
 document.form.email.value=trim(document.form.email.value);
	email=trim(document.form.email.value);
	if ((email==null)||(email==""))
	{
		alert("Enter e-mail")
		document.form.email.focus()
		return false
	}
	if (isMailid(email)==false)
	{
		document.form.email.focus()
		return false
	}
	
	

	
//Select Preferred mode of contact 
	document.form.perferredmode.value=trim(document.form.perferredmode.value);
	perferredmode=document.form.perferredmode.value;
	if (document.form.perferredmode.value=="")
	{
		alert("Select preferred mode of contact.");
		document.form.perferredmode.focus();
		return false;
	}
	//Select brochure
	 var b1 = document.getElementById('a');
	 var b2 = document.getElementById('b');
	 var b3 = document.getElementById("c");
	 var b4 = document.getElementById('d');
	 var b5 = document.getElementById('e');
	 var b6 = document.getElementById('f');
	 var b7 = document.getElementById('g');
	 		 
	if (b1.checked ||  b2.checked || b3.checked || b4.checked || b5.checked || b6.checked || b7.checked )
	{
	  return true;
	}
	else
	{
		alert("Please select at least one brochure");
		return false;
	}
	document.form.submit();
	return true;
}

//======================================
// Demo Validation
function demoValidation()
{
	
	//Select Firstname
	document.form.firstName.value=trim(document.form.firstName.value);
	firstName=document.form.firstName.value;
	if (document.form.firstName.value=="")
	{
		alert("Enter first name");		
		document.form.firstName.focus();		
		return false;
	}
	else
		if(!isText(firstName))
		{
			alert("This field will not accept numerical values.");
			document.form.firstName.focus();
			return false;
		}
//Select lastname
	document.form.lastName.value=trim(document.form.lastName.value);
	lastName=document.form.lastName.value;
	if (lastName=="")
	{
		alert("Enter last name");
		document.form.lastName.focus();		
		return false;
	}
	else
		if(!isText(lastName))
		{
			alert("This field will not accept numerical values.");
			document.form.lastName.focus();
			return false;
		}
	//Select Designation
	document.form.designation.value=trim(document.form.designation.value);
	designation=document.form.designation.value;
	if (designation=="")
	{
		alert("Enter designation");
		document.form.designation.focus();		
		return false;
	}
	else
		if(!isText(designation))
		{
			alert("This field will not accept numerical values.");
			document.form.designation.focus();
			return false;
		}
	//Select Organization
	document.form.organization.value=trim(document.form.organization.value);
	organization=document.form.organization.value;
	if (organization=="")
	{
		alert("Enter organization");
		document.form.organization.focus();		
		return false;
	}		
	
//Select country
	document.form.country.value=trim(document.form.country.value);
	country=document.form.country.value;
	if (document.form.country.value=="")
	{
		alert("Select country");
		document.form.country.focus();
		return false;
	}
//Enter area code
	document.form.areacode.value=trim(document.form.areacode.value);
	areacode=document.form.areacode.value;
	if (document.form.areacode.value=="")
	{
		alert("Enter area code");		
		document.form.areacode.focus();		
		return false;
	}
	else if(isText(areacode))
	{
		alert("This field will only accept numerical values.");
		document.form.areacode.focus();
		return false;
	}
//Enter phone number
	document.form.phonenum.value=trim(document.form.phonenum.value);
	phonenum=document.form.phonenum.value;
	if (document.form.phonenum.value=="")
	{
		alert("Enter phone number");		
		document.form.phonenum.focus();		
		return false;
	}
	else if(isText(phonenum))
	{
		alert("This field will only accept numerical values.");
		document.form.phonenum.focus();
		return false;
	}	

//Enter Email
 document.form.email.value=trim(document.form.email.value);
	email=trim(document.form.email.value);
	if ((email==null)||(email==""))
	{
		alert("Enter e-mail")
		document.form.email.focus()
		return false
	}
	if (isMailid(email)==false)
	{
		document.form.email.focus()
		return false
	}
//Select Preferred mode of contact 
	document.form.perferredmode.value=trim(document.form.perferredmode.value);
	perferredmode=document.form.perferredmode.value;
	if (document.form.perferredmode.value=="")
	{
		alert("Select preferred mode of contact.");
		document.form.perferredmode.focus();
		return false;
	}
	document.form.submit();
	return true;
}
//======================================

//======================================
// Success Stories Validation
function successValidation()
{
	
	//Select Firstname
	document.form.firstName.value=trim(document.form.firstName.value);
	firstName=document.form.firstName.value;
	if (document.form.firstName.value=="")
	{
		alert("Enter first name");		
		document.form.firstName.focus();		
		return false;
	}
	else
		if(!isText(firstName))
		{
			alert("This field will not accept numerical values.");
			document.form.firstName.focus();
			return false;
		}
//Select lastname
	document.form.lastName.value=trim(document.form.lastName.value);
	lastName=document.form.lastName.value;
	if (lastName=="")
	{
		alert("Enter last name");
		document.form.lastName.focus();		
		return false;
	}
	else
		if(!isText(lastName))
		{
			alert("This field will not accept numerical values.");
			document.form.lastName.focus();
			return false;
		}
	//Select Designation
	document.form.designation.value=trim(document.form.designation.value);
	designation=document.form.designation.value;
	if (designation=="")
	{
		alert("Enter designation");
		document.form.designation.focus();		
		return false;
	}
	else
		if(!isText(designation))
		{
			alert("This field will not accept numerical values.");
			document.form.designation.focus();
			return false;
		}
	//Select Organization
	document.form.organization.value=trim(document.form.organization.value);
	organization=document.form.organization.value;
	if (organization=="")
	{
		alert("Enter organization");
		document.form.organization.focus();		
		return false;
	}		
	
//Select country
	document.form.country.value=trim(document.form.country.value);
	country=document.form.country.value;
	if (document.form.country.value=="")
	{
		alert("Select country");
		document.form.country.focus();
		return false;
	}
//Enter area code
	document.form.areacode.value=trim(document.form.areacode.value);
	areacode=document.form.areacode.value;
	if (document.form.areacode.value=="")
	{
		alert("Enter area code");		
		document.form.areacode.focus();		
		return false;
	}
	else if(isText(areacode))
	{
		alert("This field will only accept numerical values.");
		document.form.areacode.focus();
		return false;
	}
//Enter phone number
	document.form.phonenum.value=trim(document.form.phonenum.value);
	phonenum=document.form.phonenum.value;
	if (document.form.phonenum.value=="")
	{
		alert("Enter phone number");		
		document.form.phonenum.focus();		
		return false;
	}
	else if(isText(phonenum))
	{
		alert("This field will only accept numerical values.");
		document.form.phonenum.focus();
		return false;
	}	

//Enter Email
 document.form.email.value=trim(document.form.email.value);
	email=trim(document.form.email.value);
	if ((email==null)||(email==""))
	{
		alert("Enter e-mail")
		document.form.email.focus()
		return false
	}
	if (isMailid(email)==false)
	{
		document.form.email.focus()
		return false
	}
//Select Preferred mode of contact 
	document.form.perferredmode.value=trim(document.form.perferredmode.value);
	perferredmode=document.form.perferredmode.value;
	if (document.form.perferredmode.value=="")
	{
		alert("Select preferred mode of contact.");
		document.form.perferredmode.focus();
		return false;
	}
	document.form.submit();
	return true;
}
//======================================
//Country code
/*function dispCode()
{
//alert("hi code");
document.form.countrycode.value = document.form.country.value;
}*/
function dispCode()
{
//alert("hi code");
var countrycode1=document.form.country.value;
var hyp=countrycode1.indexOf('-');
document.form.countrycode.value = countrycode1.substring(0,hyp);
document.form.countryname.value = countrycode1.substring(5,50);
//document.form.country.value = countrycode1.substring(hyp,0);
}
/*function dispCode1()
{
//alert("hi code");
var countrycode2=document.form.country.value;
//var hyp=countrycode2.indexOf('-');
document.form.countryname.value = countrycode2.substring(4,50);
//document.form.country.value = countrycode1.substring(hyp,0);
}*/
//--->

//str1.substring(4,50)