
// method to remove left blank space
function LTrim(str){
	var whitespace = new String("\t\n\r");
	var s = new String(str);
	if (whitespace.indexOf(s.charAt(0)) != -1){
		var j=0, i = s.length;
		while (j < i && whitespace.indexOf(s.charAt(j)) != -1){
    		j=j+1;
		}
    	s = s.substring(j, i);
	}
	return s;
}

// method to remove right blank space
function RTrim(str){
	var whitespace = new String("\t\n\r");
	var s = new String(str);
	if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
		var i = s.length - 1;
		while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1){
      		i=i-1;
		}
		s = s.substring(0, i+1);
	}
	return s;
}

// method to remove left and right blank space
function Trim(str){
  return RTrim(LTrim(str));
}

function checkNumber(strValue, message, fieldName){
	var flag=true;
	var length=strValue.length;
	for (var j = 0; j < length; j=j+1){
		var ch = strValue.substring(j, j + 1);
		if (ch < "0" || "9" < ch){
			if(((ch < "a" || "z" < ch) && (ch < "A" || "Z" < ch)) ||  ch!=" " || ch < "0" || "9" < ch || ch != "_" || ch != "/" || ch != "*" || ch != "+" || ch != "-" || ch != "%" || ch != "^" || ch != "#" || ch != "@" || ch != "!" || ch != "$" || ch != "<" || ch != ">" || ch != ":"){
				alert(" Please use valid Number in ..."+message);
				fieldName.focus();
				flag=false;
				break;
			 }
		}
   	}
	return flag;
}

function echeckMail(str) {
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
	   return false
	}
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   return false
	}
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
	    return false
	}
	if (str.indexOf(at,(lat+1))!=-1){
		return false
	}
	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		return false
	}
	if (str.indexOf(dot,(lat+2))==-1){
		return false
	}
	if (str.indexOf(" ")!=-1){
		return false
	}
	return true;					
}

function preventSpChr(strValue, title, fieldName){
	var iChars = "\"";
	for (var i = 0; i < strValue.length; i++) {
		if (iChars.indexOf(strValue.charAt(i)) != -1){
			alert (title+" contains illegal characters!");
			fieldName.focus(); 
			return false;
		}
	}
	return true;
}

function submitContactUs(){
	if(document.contactUs.sname.value=="" || document.contactUs.sname.length==0){
		alert("Please enter name here");
		document.contactUs.sname.focus();
		return false;
	}
	if(document.contactUs.add1.value=="" || document.contactUs.add1.length==0){
		alert("Please enter address here");
		document.contactUs.add1.focus();
		return false;
	}
	if(document.contactUs.country.value=="" || document.contactUs.country.length==0){
		alert("Please enter country name here");
		document.contactUs.country.focus();
		return false;
	}
	if(document.contactUs.email.value=="" || document.contactUs.email.length==0){
		alert("Please enter email address here");
		document.contactUs.email.focus();
		return false;
	}
	if(!echeckMail(document.contactUs.email.value)){
		alert("Please enter valid email address");
		document.contactUs.email.focus();
		return false;
	}
	if(document.contactUs.conEmail.value=="" || document.contactUs.conEmail.length==0){
		alert("Please enter confirm email here");
		document.contactUs.conEmail.focus();
		return false;
	}
	if(!echeckMail(document.contactUs.conEmail.value)){
		alert("Please enter valid email address for confirm");
		document.contactUs.conEmail.focus();
		return false;
	}
	document.contactUs.submit();
}

function nriMethod(pkgName, pkgType){
        alert(pkgName);
	
}

