
var runform = function() {
                $("div.email-form input").not('.read-only').focus(function() {
                   var check = $(this).not(".cleared").size();
                   if(check) {
                     $(this).addClass("cleared");
                     $(this).removeClass("unfilled");
                     $(this).val("");
                     //$(this).css({fontWeight: 'bold', border: 'solid 1px white', width: '12px'});
                     //$(this).autoGrowInput({ comfortZone: 12, minWidth: 30, maxWidth: 300 });
                   }
                 });
                $(".ajax-fc-container").captcha({formId: "new-enquiry-form",captchaDir: "/userimgs/js/fancy-captcha/captcha",url: "/userimgs/js/fancy-captcha/captcha/captcha.php",borderColor: "#F6F4ED"});
/*
*/
                $("div.email-form a.add-email").click(function() {
                   $('span.hideable').eq(0).show().removeClass('hideable');
                   return false;
                 });
                $("input#first_name").bind("keyup keydown blur update",function() {
                   $('span#sender-name').html($(this).val());
                 });
                $("input#first_name_1").bind("keyup keydown blur update",function() {
                   $('span#recipient-name').html($(this).val());
                 });
                var spam_checked = false;
                $("#enter-contest-form").hide();
                var formoptions = {
/*
                    rules: {
                      realname: {
                        required: true,
                        depends: function(element) { return !($(element).val().match(/^Friend's Name/)); } 
                      }
                    },
*/
                    // form plugin settings
                    //target:     "#form_div_wrapper",
                    beforeSerialize:    function() {
                      $("div.email-form input.unfilled").val('');
                      $("div.email-form input.unfilled").removeClass('required');
                      $("div.email-form input.unfilled").removeClass('email');
                      var captcha_val = $("input#captcha").val();
                      if(!spam_checked) {
                        var friend_blank = $("div.email-form input#first_name_1").val().match(/^Friend/);
                        if(friend_blank) {
                          $("div.email-form input#first_name_1").val('');
                          alert("Please enter your friend's name");
                          return false;
                        }
                        var check_captcha = $.ajax({ 
                            type: 'POST', 
                            data: {captcha: captcha_val}, 
                            url: 'userimgs/js/fancy-captcha/captcha/captcha.php',
                            async: false 
                          }).responseText;
                        if(check_captcha.match(/^Passed!/)) {
                          spam_checked = true;
                          return true;
                        } else {
                          //alert('Please follow the instructions in the anti-spam box! "' + check_captcha + '"');
                          alert('Please follow the instructions in the anti-spam box!');
                          return false;
                        }
                      }
                    },
                    success:    function(resultText, statusText) {
                      $(".email-only").html("");
                      $("#share-video-form").hide();
                      if(resultText && resultText == 'contest') {
                        $("#enter-contest-form").show();
                        $("input#share-action").val("enter-contest");
                        $("#absolute-holder h3.title-bar").html('Thanks! Answer these questions for a chance to win &euro;300!');
                      } else if(resultText && resultText == 'entered') {
                        $("#enter-contest-form").hide();
                        $("#form-holder").hide();
                        $("#response").html('<div style="font-size: 14px; height: 380px; padding: 12px;">Thanks very much for sharing the video with your friend, and good luck in the competition!  Please enjoy the rest of your visit to the site.</div>');
                        $("#absolute-holder h3.title-bar").html('Thanks and Good Luck!');
                        $("#overlay2").css({height: '480px'});
                      } else {
                        $("#form-holder").hide();
                        $("#response").html('<div style="font-size: 14px; height: 380px; padding: 12px;">Thanks very much for sharing the video with your friend.  Please enjoy the rest of your visit to the site.</div>');
                        $("#absolute-holder h3.title-bar").html('Thanks for Sharing!');
                        $("#overlay2").css({height: '480px'});
                      }
                    },
                    //target:     "#form-result",
                    url:        "vimeo.php"
                  };
                $("form.new-enquiry-form").validate({
                  submitHandler: function(form) {
                      jQuery(form).ajaxSubmit(formoptions);
                    }
                });
                //$("form.new-enquiry-form").ajaxForm(formoptions);
};

