	//alert('nilesh'); 

  //remove leading whitespaces

  function LTrim( value ) {



	 var re = /\s*((\S+\s*)*)/;

	 return value.replace(re, "$1");



   }

  // Removes ending whitespaces

  function RTrim( value ) {

	

   var re = /((\s*\S+)*)\s*/;

   return value.replace(re, "$1");

	

  }

  // Removes leading and ending whitespaces

  function trim(value) {



   return LTrim(RTrim(value));

 }



 //check the paramter is int ot not

  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;

  }



  // email format validation

    function xcheckEmail(email) {

       	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email)){

   		    return true;

        }

	 //  alert("Please enter valid email id.");

	  // return false;

    }

 

function validate(){

	var firstName = document.getElementById("FirstName");

	var lastName = document.getElementById("LastName");

	var companyName = document.getElementById("CompanyName");

	var address = document.getElementById("Address");

	var cityName = document.getElementById("City");

	var zipCode = document.getElementById("Zip");

	var state = document.getElementById("State");

	var emailId = document.getElementById("EmailId");

	var telephone = document.getElementById("Telephone");

	

	//check null value

	if(firstName.value == ""){

		alert("Please enter Full Name");

		firstName.focus();

		return false;

	}



	//check is there any no. in name field

	if(isInteger(firstName.value)){

		alert("Please enter only character value in first name field.");

		firstName.focus();

		return false;

	}



	//check null value

	if(lastName.value == ""){

		alert("Please enter your last name");

		lastName.focus();

		return false;

	}



	//check is there any no. in name field

	if(isInteger(lastName.value)){

		alert("Please enter only character value in last name field.");

		lastName.focus();

		return false;

	}



	//check null value

	if(companyName.value == ""){

		alert("Please enter your company name");

		companyName.focus();

		return false;

	}



	//check is there any no. in name field

/*	if(isInteger(lastName.value)){

		alert("Please enter only character value in company field.");

		companyName.focus();

		return false;

	}

*/



	//check null value

	if(address.value == ""){

		alert("Please enter your Address");

		address.focus();

		return false;

	}



	//check null value

	if(cityName.value == ""){

		alert("Please enter your city");

		cityName.focus();

		return false;

	}



	//check null value

	if(zipCode.value == ""){

		alert("Please enter your zip code");

		zipCode.focus();

		return false;

	}



	//check is there any no. in name field

	if(!isInteger(zipCode.value)){

		alert("Please enter proper zip code.");

		zipCode.focus();

		return false;

	}



	//check null value

	if(state.value == ""){

		alert("Please enter your state");

		state.focus();

		return false;

	}



	//check is there any no. in name field

	if(isInteger(state.value)){

		alert("Please enter proper state name.");

		state.focus();

		return false;

	}



	//check null value

	if(emailId.value == ""){

		alert("Please enter your email id");

		emailId.focus();

		return false;

	}



	if(!checkEmail(emailId.value)){

		alert("Please enter valid email id");

		emailId.focus();

		return false;

	}



	//check null value

	if(telephone.value == ""){

		alert("Please enter your telephone no");

		telephone.focus();

		return false;

	}

	

	//check is there any no. in name field

	if(!isInteger(telephone.value)){

		alert("Please enter valid telephone no.");

		telephone.focus();

		return false;

	}

}





//************************************* Komal's code **************************************



//this function use to trim the spaces in text field

function trimspace(str){		

	var len = str.length;



	if (len != 0){

		for (var i=0;i<len;i++){	

			if(str.indexOf(" ")==0)

				str=str.substring(1,len);

		}

		var strtrim = str;

		return strtrim;

	}

	else {

		return str;

	}

}



// email format validation

function checkEmail(email) {

	if(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(email)){

		return true;

	}

	alert("Please Enter valid E-mail Id");

	return false;

}





// Validate US as well as india ZIP code.

function validateZipCode(string){

	var validZipCode = true;

	for (var n = 0; n < string.length; n++) {



		var c = string.charCodeAt(n);

		if(!(((c >= 48) && (c <= 57)) || ((c >= 65) && (c <= 90)) || ((c >= 97) && (c <= 122)) || (c == 45) || (c == 43) || (c == 32))){

			validZipCode = false;

		}

	}

	return validZipCode;

}

// Validate US as well as india phone no.

function validatePhoneNumber(string){

	var validPhoneNo = true;

	for (var n = 0; n < string.length; n++) {



		var c = string.charCodeAt(n);

		if(!(((c >= 48) && (c <= 57)) || (c == 46) || (c == 45) || (c == 43) || (c == 40) || (c == 41) || (c == 32))){

			validPhoneNo = false;

		}

	}

	return validPhoneNo;

}



//alert('nilesh11');

function career_validation() {
//alert('nilesh1');


	var fullName = document.getElementById('txtfname').value;

	var dobDay = document.getElementById('dobDay').value;

	var dobMonth = document.getElementById('dobMonth').value;

	var dobYear = document.getElementById('dobYear').value;

	var email = document.getElementById('txtemail').value;

	var address = document.getElementById('txthomeaddress').value;

	

	

	// Validate full name

	fullName = trimspace(fullName);

	if(fullName == '') {

		alert("Please enter your name");

		document.getElementById('txtfname').focus();

		return false;

	}

	// Validate dob Day

	if(dobDay == '') {

		alert("Please select your date of birth day");

		document.getElementById('dobDay').focus();

		return false;

	}

	// Validate dob Month

	if(dobMonth == '') {

		alert("Please select your date of birth month");

		document.getElementById('dobMonth').focus();

		return false;

	}

	// Validate dob Year

	if(dobYear == '') {

		alert("Please select your date of birth year");

		document.getElementById('dobMonth').focus();

		return false;

	}

	

	// Validate email

	email = trimspace(email);

	if(email == '') {

		alert("Please enter a valid email address");

		document.getElementById('txtemail').focus();

		return false;

	}

	if(!checkEmail(email)) {

		alert("Please enter a valid email address");

		document.getElementById('txtemail').focus();

		return false;

	}

	

	// Validate address

	address = trimspace(address);

	if(address == '') {

		alert("Please enter address");

		document.getElementById('txthomeaddress').focus();

		return false;

	}

	return true;

}



// Function for validate registration

function valid_registration(){

	var txtFname = document.getElementById("txtFname").value;

	var txtEmail = document.getElementById("txtEmail").value;

	var txtCompanyName = document.getElementById("txtCompanyName").value;

	var drpIndustry = document.getElementById("drpIndustry").value;
	
	var txtother = document.getElementById("txtother").value;

	var txtDesignation = document.getElementById("txtDesignation").value;

	var txtAddress = document.getElementById("txtAddress").value;

	var txtCity = document.getElementById("txtCity").value;

	var txtZip = document.getElementById("txtZip").value;

	var txtState = document.getElementById("txtState").value;

	var txtCountry = document.getElementById("txtCountry").value;	

	var txtPhoneCC = document.getElementById("txtPhoneCC").value;

	var txtPhoneAreaCode = document.getElementById("txtPhoneAreaCode").value;

	var txtPhone = document.getElementById("txtPhone").value;

	var txtPassword = document.getElementById("txtPassword").value;

	var txtCnfPassword = document.getElementById("txtCnfPassword").value;

	

	

	// Validate first name

	txtFname = trimspace(txtFname);

	if(txtFname == '') {

		alert("Please enter Full Name");

		document.getElementById('txtFname').focus();

		return false;

	}

	

	// Validate email

	txtEmail = trimspace(txtEmail);

	

	if(!checkEmail(txtEmail)) {

		//alert("Please enter a valid email address");

		document.getElementById('txtEmail').focus();

		return false;

	}

	

	

	// Validate company name

	txtCompanyName = trimspace(txtCompanyName);

	if(txtCompanyName == '') {

		alert("Please enter your company name");

		document.getElementById('txtCompanyName').focus();

		return false;

	}



	// Validate industry name

	drpIndustry = trimspace(drpIndustry);

	if(drpIndustry == '') {

		alert("Please select your industry name");

		document.getElementById('drpIndustry').focus();

		return false;

	}



	// Validate industry name

	if(drpIndustry == 'Other')
	{
		txtother = trimspace(txtother);

		if(txtother == '') {

			alert("Please select your industry name");

			document.getElementById('txtother').focus();

			return false;

		}
	}
	// Validate designation name

	txtDesignation = trimspace(txtDesignation);

	if(txtDesignation == '') {

		alert("Please enter your designation");

		document.getElementById('txtDesignation').focus();

		return false;

	}



	// Validate address

	txtAddress = trimspace(txtAddress);

	if(txtAddress == '') {

		alert("Please enter your address");

		document.getElementById('txtAddress').focus();

		return false;

	}



	// Validate city

	txtCity = trimspace(txtCity);

	if(txtCity == '') {

		alert("Please enter your city");

		document.getElementById('txtCity').focus();

		return false;

	}



	// Validate zip

	txtZip = trimspace(txtZip);

	if(txtZip == '') {

		alert("Please enter your zip code");

		document.getElementById('txtZip').focus();

		return false;

	}



	// Validate zip

	if(!validateZipCode(txtZip)){

		alert('Enter valid zip code');

		document.getElementById('txtZip').focus();

		return false;

	}



	// Validate state

	txtState = trimspace(txtState);

	if(txtState == '') {

		alert("Please enter your state");

		document.getElementById('txtState').focus();

		return false;

	}



	

	// Validate country

	txtCountry = trimspace(txtCountry);

	if(txtCountry == '') {

		alert('Enter your country name');

		document.getElementById('txtCountry').focus();

		return false;

	}

	

	

	// Validate resi phone country code.

	txtPhoneCC = trimspace(txtPhoneCC);

	if(txtPhoneCC == '') {

		alert('Please enter a valid country code');

		document.getElementById('txtPhoneCC').focus();

		return false;

	}

	// Validate resi phone country code.

	if(!validatePhoneNumber(txtPhoneCC)){

		alert('Please enter a valid country code');

		document.getElementById('txtPhoneCC').focus();

		return false;

	}



	// Validate resi phone area code.

	txtPhoneAreaCode = trimspace(txtPhoneAreaCode);

	if(txtPhoneAreaCode == '') {

		alert('Please enter a valid residence number area code');

		document.getElementById('txtPhoneAreaCode').focus();

		return false;

	}

	// Validate resi phone area code.

	if(!validatePhoneNumber(txtPhoneAreaCode)){

		alert('Please enter a valid residence number area code');

		document.getElementById('txtPhoneAreaCode').focus();

		return false;

	}



	// Validate resi phone country code.

	txtPhone = trimspace(txtPhone);

	if(txtPhone == '') {

		alert('Please enter a valid residence number');

		document.getElementById('txtPhone').focus();

		return false;

	}

	

	// Validate resi phone country code.

	if(!validatePhoneNumber(txtPhone)){

		alert('Please enter a valid residence number');

		document.getElementById('txtPhone').focus();

		return false;

	}



	// Validate password

	txtPassword = trimspace(txtPassword);

	if(txtPassword == '') {

		alert("Please enter your password");

		document.getElementById('txtPassword').focus();

		return false;

	}



	// Validate confirm password

	txtCnfPassword = trimspace(txtCnfPassword);

	if(txtCnfPassword == '') {

		alert("Please re-enter your password");

		document.getElementById('txtCnfPassword').focus();

		return false;

	}

}





// Function for validet forgot password.

function valid_forgotpassword(){

	var email = trimspace(document.getElementById("forgotpassemail").value);
//alert(email);
	// Check email Id
	if(!checkEmail(email)) {
		document.getElementById('forgotpassemail').focus();
		return false;
	}
}


// Function for validet forgot password.

function valid_newsletter(){

	var email = trimspace(document.getElementById("email").value);
//alert(email);
	// Check email Id
	if(!checkEmail(email)) {
		document.getElementById('email').focus();
		return false;
	}
}


// Function for downloading alert

function download_alert(){

	alert('For downloading file, you have to log in first');

	window.location = "http://www.mosil.in/login/index.php";

	return false;

}



function valid_other()

{

	var industry = document.getElementById("drpIndustry").value;



	if(industry == 'Other')

	{

		//alert(document.getElementById('txtother').value);

		document.getElementById('txtother').style.display = '';

		document.getElementById('txtother').focus();

		//return false;

	}

}



function feedback_validation(){

	var fullName = document.getElementById("txtFname").value;

	var email = document.getElementById("txtEmail").value;

	var companyName = document.getElementById("txtCompanyName").value;

	var industry = document.getElementById("drpIndustry").value;
	var txtother = document.getElementById("txtother").value;
	var designation = document.getElementById("txtDesignation").value;

	var address = document.getElementById("txtAddress").value;

	var city = document.getElementById("txtCity").value;

	var pincode = document.getElementById("txtZip").value;

	var state = document.getElementById("txtState").value;

	var country = document.getElementById("txtCountry").value;

	var phone = document.getElementById("txtPhone").value;



	//alert('nilesh');

	// Validate full name

	fullName = trimspace(fullName);

	if(fullName == '') {

		alert("Please enter your name");

		document.getElementById('txtFname').focus();

		return false;

	}

	

	// Validate email

	email = trimspace(email);

	if(email == '') {

		alert("Please enter a valid email address");

		document.getElementById('txtEmail').focus();

		return false;

	}

	if(!checkEmail(email)) {

		alert("Please enter a valid email address");

		document.getElementById('txtEmail').focus();

		return false;

	}



	// Validate company name

	companyName = trimspace(companyName);

	if(companyName == '') {

		alert("Please enter company name");

		document.getElementById('txtCompanyName').focus();

		return false;

	}



	// Validate industry name

	industry = trimspace(industry);

	if(industry == '') {

		alert("Please enter industry type");

		document.getElementById('drpIndustry').focus();

		return false;

	}

	
	if(industry == 'Other')
	{
		txtother = trimspace(txtother);

		if(txtother == '') {

			alert("Please enter industry type");

			document.getElementById('txtother').focus();

			return false;

		}
	}

	// Validate industry name

	designation = trimspace(designation);

	if(designation == '') {

		alert("Please enter designation");

		document.getElementById('txtDesignation').focus();

		return false;

	}



	// Validate address

	address = trimspace(address);

	if(address == '') {

		alert("Please enter address");

		document.getElementById('txtAddress').focus();

		return false;

	}



	// Validate city

	city = trimspace(city);

	if(city == '') {

		alert("Please enter your city");

		document.getElementById('txtCity').focus();

		return false;

	}



	// Validate zip

	pincode = trimspace(pincode);

	if(pincode == '') {

		alert('Enter valid zip code');

		document.getElementById('txtZip').focus();

		return false;

	}



	// Validate state

	state = trimspace(state);

	if(state == '') {

		alert("Please enter your state");

		document.getElementById('txtState').focus();

		return false;

	}

	// Validate country

	country = trimspace(country);

	if(country == '') {

		alert("Please select your country");

		document.getElementById('txtCountry').focus();

		return false;

	}



	// Validate resi phone no.

	phone = trimspace(phone);

	if(phone == '') {

		alert('Please enter a valid residence number');

		document.getElementById('txtPhone').focus();

		return false;

	}

	

	// Validate resi phone no.

	if(!validatePhoneNumber(phone)){

		alert('Please enter a valid residence number');

		document.getElementById('txtPhone').focus();

		return false;

	}

}



// Function for set email id as user id

function setUserId()

{

	var emailValue = document.getElementById('txtEmail').value;

	

	document.getElementById('txtUsername').value = emailValue;

}



function redirect_value(value)

{

	if(value != '')

	{

		window.location = 'products/index.php?value='+value;

	}

}


