 /* CHECK FOR DEMO REGISTRATION*/

function trim(argvalue)
{
    //alert('Entering into a trim function');
	var tmpstr = ltrim(argvalue);
	return rtrim(tmpstr);
}

function ltrim(argvalue)
{
	while (1)
	{
		if (argvalue.substring(0, 1) != " ")
			break;
		argvalue = argvalue.substring(1, argvalue.length);
	}
	return argvalue;
}

function rtrim(argvalue)
{
	while (1)
	{
		if (argvalue.substring(argvalue.length - 1, argvalue.length) != " ")
			break;
		argvalue = argvalue.substring(0, argvalue.length - 1);
	}
	return argvalue;
}

    function checkForm() {
    
    //alert('Entering in to the Function');
    
        if (trim(document.submitForm.firstname.value) == "") {
            alert('Please enter the first name');
            document.getElementById("firstname").focus();
            return false;
        }
        document.submitForm.firstname.value = trim(document.submitForm.firstname.value);
        
        /*if (trim(document.submitForm.lastname.value) == "") {
            alert('Please enter the last name');
            document.getElementById("lastname").focus();
            return false;
        }
        document.submitForm.lastname.value = trim(document.submitForm.lastname.value);
        */
        if (trim(document.submitForm.company.value) == "") {
            alert('Please enter the company');
            document.getElementById("company").focus()
            return false;
        }
        document.submitForm.company.value = trim(document.submitForm.company.value);
        
        /*if (trim(document.submitForm.address.value) == "") {
            alert('Please enter the address');
            document.getElementById("address").focus()
            return false;
        }
        document.submitForm.address.value = trim(document.submitForm.address.value);
        
        if (trim(document.submitForm.add1.value) == "") {
            alert('Please enter the city');
            document.getElementById("add1").focus()
            return false;
        }
        document.submitForm.add1.value = trim(document.submitForm.add1.value);
        
        if (trim(document.submitForm.state.value) == "XX") {
            alert('Please enter the state');
            document.getElementById("state").focus()
            return false;
        }
        document.submitForm.state.value = trim(document.submitForm.state.value);
        
        if (trim(document.submitForm.zip.value) == "") {
            alert('Please enter the zip code');
            document.getElementById("zip").focus()
            return false;
        }else if(isInteger(document.submitForm.zip.value)==false){
            alert('Please enter the valid zip code');
            document.getElementById("zip").focus()
            return false;
        }
        document.submitForm.zip.value = trim(document.submitForm.zip.value);
        
        if (trim(document.submitForm.country.value) == "") {
            alert('Please enter the country');
            document.getElementById("country").focus()
            return false;
        }
        document.submitForm.country.value = trim(document.submitForm.country.value);
        */
        
        if (trim(document.submitForm.phone.value) == "") {
            alert('Please enter the phone number');
            document.getElementById("phone").focus()
            return false;
        }else if (checkInternationalPhone(document.submitForm.phone.value)==false){
            alert("Please Enter the Valid Phone Number")
            document.getElementById("phone").focus()
            return false;
        }
        document.submitForm.phone.value = trim(document.submitForm.phone.value);
        
        if (trim(document.submitForm.email.value) ==""){
            alert('Please enter the E_mail');
            document.getElementById("email").focus()
            return false;
        }else if(validateEmail(document.submitForm.email.value)==false){
            alert('Please enter the Valid  E_mail');
            document.getElementById("email").focus()
            return false;
        }
        document.submitForm.email.value = trim(document.submitForm.email.value);
        
        return true;
    }
    
