function Trimtext()
{
	
	txt1 = document.frm.comments;
	if(txt1.value.length > 250) {
		//txt1.value="";
		alert("Please enter message maximum 250 characters");
		txt1.value = txt1.value.substr(0,250);
		txt1.focus();
		return false;
	}	
}
function trim(str)
{
    return str.replace(/^\s+|\s+$/g,'');
}
function validate_frm()
{

var name=document.frm.name;
var country=document.frm.country;
var contact=document.frm.contact;
var email=document.frm.email;
var comments=document.frm.comments;
if(name.value=="")
{
alert("Please enter your name");
document.frm.name.focus();
document.frm.name.value='';
return false;
}
if(trim(document.frm.name.value).length < 3)
{
        alert('Please enter name - minimum 3 characters');
        document.frm.name.focus();
        return false;
}
var myRegExp = new RegExp("[^a-zA-Z. ]");
var val=document.frm.name.value;
var result=val.match(myRegExp);
if (result)
{
	alert('Please enter your name correctly');
	document.frm.name.focus();
	return false;
}

///////////////////////////email validation end/////////////////////////////////////
if(trim(document.frm.country.value)=="")
{
	alert("Please enter your country");
	document.frm.country.focus();
	document.frm.country.value = '';
	return false;

}
if(trim(document.frm.country.value).length < 3)
{
        alert('Please enter  country name minimum 3 characters');
        document.frm.country.focus();
        return false;
}
var myRegExp_country = new RegExp("[^a-zA-Z ]");
var val_country=document.frm.country.value;
var result_country=val_country.match(myRegExp_country);
if (result_country)
{
	alert('Please enter your country name correctly');
	document.frm.country.focus();
	return false;
}




////////////////////////phone//////////////////////////
var phoneNumberDelimiters = "()- ";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 6;

function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function checkInternationalPhone(strPhone){
s=stripCharsInBag(strPhone,validWorldPhoneChars);
return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}

	/*if(document.frm.email.value!="")
	{
	var mail=document.frm.email;
	if (echeck(mail.value)==false){
		alert("Please enter a valid email");
		document.frm.email.value="";
		document.frm.email.focus();
		return false;
	}
	}
*/
	if(trim(document.frm.contact.value)=="")
	{
		alert("Please enter your phone/mobile number");
		document.frm.contact.focus();
		document.frm.contact.value='';
		return false;
	}
	
	if(document.frm.contact.value!="")
	{
	var Phone=document.frm.contact;
	if (checkInternationalPhone(Phone.value)==false){
		alert("Please enter a valid phone/mobile number");
		document.frm.contact.value="";
		document.frm.contact.focus();
		return false;
	}
	}

///////////////////////////phone end/////////////////////////////
if(trim(document.frm.email.value)=="")
{
alert("Please enter your email ID");
document.frm.email.focus();
document.frm.email.value='';
return false;
}


if(document.frm.email.value.length > 0){ 
if(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.frm.email.value))
{
 
 }
 else
 {
 alert("Invalid E-mail Address! Please re-enter."); 
 document.frm.email.select(); 
 return false;
 }
 }
if(trim(document.frm.comments.value)=="")
{
	alert("Please enter your message");
	document.frm.comments.focus();
	document.frm.comments.value = '';
	return false;

}
if(trim(document.frm.comments.value).length < 10)
{
        alert('Please enter message - minimum 10 characters');
        document.frm.comments.focus();
        return false;
}
if(trim(document.frm.comments.value).length >250)
{
        alert('Please enter message maximum 250 characters!');
        document.frm.comments.focus();
        return false;
}
var myRegExp_comments = new RegExp("[^-(),/&_ 0-9a-zA-Z.\n\t\f\r]");
var val_comments=document.frm.comments.value;
var result_comments=val_comments.match(myRegExp_comments);
if (result_comments)
{
	alert('Please enter message correctly');
	document.frm.comments.focus();
	return false;
}

return true;
//document.frm.submit();
//document.frm.action="redirect_doshi_nakshatra.php";




}

