	function checkname(win, validateName) {
	    // cache the 'this' instance as we need access to it within a setTimeout, where 'this' is set to 'window'
            var t = win; 
            
            // only run the check if the username has actually changed - also means we skip meta keys
            if (win.value != win.lastValue) {
                
                // the timeout logic means the ajax doesn't fire with *every* key press, i.e. if the user holds down
                // a particular key, it will only fire when the release the key.
                                
                if (win.timer) clearTimeout(win.timer);
                
                // show our holding text in the validation message space
		validateName.removeClass('error').html('<img src=\"images/ajax_loader.gif\" height=\"16\" width=\"16\" />');

                // fire an ajax request in 1/5 of a second
                win.timer = setTimeout(function () {
			$.ajax({
                        url: 'registration.php',
                        data: 'action=check_name&name=' + t.value,
                        dataType: 'json',
                        type: 'post',
                        success: function (j) {
                            // put the 'msg' field from the $resp array from check_username (php code) in to the validation message
                            validateName.html(j.msg);
                        }
                    });
                }, 500);
                
                // copy the latest value to avoid sending requests when we don't need to
                win.lastValue = win.value;
            }
	}

	function checksecurity(win, validate) {
            var t = win; 
            if (win.value != win.lastValue) {
                if (win.timer) clearTimeout(win.timer);
                validate.removeClass('error').html('<img src=\"images/ajax_loader.gif\" height=\"16\" width=\"16\" />');
                win.timer = setTimeout(function () {
                    $.ajax({
                        url: 'registration.php',
                        data: 'action=check_captcha&captcha=' + t.value,
                        dataType: 'json',
                        type: 'post',
                        success: function (j) {
                            // put the 'msg' field from the $resp array from check_username (php code) in to the validation message
                            validate.html(j.msg);
                        }
                    });
                }, 500);
                
                // copy the latest value to avoid sending requests when we don't need to
                win.lastValue = win.value;
	    }
	}
	
	function checkemail(win, validate) {
            var t = win; 
            if (win.value != win.lastValue) {
                if (win.timer) clearTimeout(win.timer);
                 validate.removeClass('error').html('<img src=\"images/ajax_loader.gif\" height=\"16\" width=\"16\" /> validating...');
                win.timer = setTimeout(function () {
                    $.ajax({
                        url: 'registration.php',
                        data: 'action=check_email&email=' + t.value,
                        dataType: 'json',
                        type: 'post',
                        success: function (j) {
                            // put the 'msg' field from the $resp array from check_username (php code) in to the validation message
                            validate.html(j.msg);
                        }
                    });
                }, 1500);
                
                // copy the latest value to avoid sending requests when we don't need to
                win.lastValue = win.value;
	    }
	}

    function openHelp(help) {
	    var helpWindow = window.open("", "help", "height=200, width=250,toolbar=no,scrollbars=yes,menubar=no,resizable=yes");
	    helpWindow.document.write("<title>Help Window</title>");
	    helpWindow.document.write("<body>");

	    if (help == "fname" || help == "lname" || help == "org") {
		    helpWindow.document.write("The name can only contain alphanumeric letters, dashes (-), commas (,), periods (.), apostrophes ('), and spaces ( ). For example - John Smith, 4EX Corporation.");
	    }
	    else if (help == "email") {
		    helpWindow.document.write("The email address must be in the form - john.smith@company.com. In addition, email addresses from free public email services are not permitted (Yahoo, Gmail, etc). If you believe this is in error, please call support at (646) 442-2828 or email <a href='mailto:support@codestreet.com'>support@codestreet.com</a>.");
	    }
	    else if (help == "security") {
		    helpWindow.document.write("This security code is implemented in order to prevent spam. Please type the letter sequence into the text box in order to request a download. A check mark will appear if the sequence was entered correctly.");
	    }
	    helpWindow.document.write("</body>");
	    helpWindow.document.write("</html>");

	    helpWindow.document.close();
	    self.name="main";
	    return true;
    }

