        $(document).ready(function(){            
            
            /// check if required fields contain string
            $('#txtname').blur(checkNameOnBlur);
            $('#txtEmailAddress').blur(checkEmailOnBlur);            
            
            $('#txtname').focus(function() {
                $('#nameRequired').hide("slow"); 
            });
            $('#txtEmailAddress').focus(function(){
                $('#emailRequired').hide("slow");
            });
            
            $('#btnSubmit').click(function() {
                checkNameOnBlur();
                checkEmailOnBlur();
                
                if ($('#nameRequired').is(':visible'))
                {
                    return false;
                }
                else if ($('#emailRequired').is(':visible'))
                {
                    return false;
                }
                else
                {
                    submitDetails();
                    return true;                
                }
            });
        });
        
        function checkNameOnBlur()
        {
            var _name = $('#txtname').val();
            if (_name.length == 0)
            {
                $('#nameRequired').show("slow");
            }
            else
            {
                $.post("demoaccount_downloadform.php", {
                    action: 'checkName', 
                    txtname: $('#txtname').val()                        
                    }, function (response) {
                        if (response != "valid")
                        {
                            $('#nameRequired').show("slow");
                        }                           
                });
            }
        }
        
        function checkEmailOnBlur()
        {
             var _email = $('#txtEmailAddress').val();
			//Added by Jonathan Decorion 09/14/2009 4:02 pm
			var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
			//end
            if (_email.length == 0)
            {
                $('#emailRequired').show("slow");
				  return false;
            }
			//Added by Jonathan Decorion 09/14/2009 4:02 pm
			else if(reg.test(_email) == false) 
			{	
				$('#emailRequired').show("slow");
				  return false;
			}
			//end
            else
            {
                $.post("SaveToOptionTable.php", {
                    action: 'checkEmail', 
                    email: $('#txtEmailAddress').val()                        
                    }, function (response) {
                        if (response != "valid")
                        {
                            $('#emailRequired').show("slow");
                        }                           
                });
				  return true;
            }
        }
        
        function submitDetails()
        {
            var _name = $('#txtname').val();
            var _country = $('#txtCountry').val();
            var _state = $('#txtState').val();
            var _city = $('#txtCity').val();
            var _zipcode = $('#txtZipCode').val();
            var _address = $('#txtAddress').val();
            var _phone = $('#txtPhone').val();
            var _email = $('#txtEmailAddress').val();
            
            $.post("demoaccount_downloadform.php", {
                action: 'submitDetails',
                name: _name,
                country: _country,
                state: _state,
                city: _city,
                zipcode: _zipcode,
                address: _address,
                phone: _phone,
                email: _email
                }, function (response) {
                    $('#tblForm').hide("slow");
                    $('#btnSubmit').hide("slow");
                     $('#JonathanGwapo').hide("slow");
					/*
                    window.open("http://www.wsd-fx.com/software/wsd4setup.exe");
                    document.getElementById('downloadId').style.display == 'block';
					document.getElementById('downloadId').style = "display = block";
					*/
					
                    $('#lblDownloadLink').show("slow");       
					//added by Jonathan Decorion 08/17/2009 3:30 pm
					$('#downloadId2').show("slow");
					//End
                }
            );
        }
				