/* contact form */
$(document).ready(function(){
    $('.error').hide();
    $(".button").click(function(){
     // validate form here
        
        $('.error').hide();
        var first=$("input#first").val();
        if(first==="") {
          $("label#first_error").show();
          $("input#first").focus();
            return false;
        }
        var last=$("input#last").val();
        if(last==="") {
            $("label#last_error").show();
            $("input#last").focus();
              return false;
        }
        
        var email=$("input#email").val();
        if(email==="") {
         $("label#email_error").show();
         $("input#email").focus();
         return false;   
        }
        
        // two fields not required definition
        var message=$("textarea#message").val();
        
        var subscribe=$("input#subscribe").val();
        
        var dataString = 'first=' + first + '&last=' + last + '&email=' + email + '&message=' + message;
        // for testing - turn off when working right
        // alert (dataString);return false;
        $.ajax({
            type:  "POST",
            url: "processcontactform.php",
            data:  dataString,
            success:  function() {
             $('#innercontent_contact').html("<img src='images/check.png' align='left' /><h2>Contact Form Submitted!</h2>")         
             .hide()
             .fadeIn(1500, function() {
                $('#innercontent_contact').html("<h3>Thanks for your Interest</h3><div class='closebtn'><a href=javascript:void(0); onclick=lightboxHide('contactform');><img src='images/closebtn.png' border='0' /></a></div>")
                .append("<p><center><img src='images/logo-200.png' /></p><p>I want to thank you for your interest in Oakland H.O.G.</p> <p>Someone will respond to you shortly.</p>")   
                .append((""))    
					
              });
			  
              //$('#contact_form').html
            }
        });
      return false;
	  
	   
  });  

});
   


   			function SmallWindow1(wintype) {

   			SmallWin=window.open(wintype,"SmallWin","toolbar=no,directories=no,status=no,scrollbars=yes,menubar=no,width=350,height=500"); SmallWin.window.focus() }


$(document).ready(function(){
    $("#button").click(function(){
       var pw1= $("input#pw1").val();
       var pw2=$("input#pw2").val();  
        
        if(pw1!=pw2) {
         
            alert("Your passwords didn't match");   
        }
    });
});


$(document).ready(function() {
    function validatePasswordsMatch() {
        var $pwd = $("#password");
        var $confirm = $("#confirmPassword");
        if ($pwd.val().length > 0 && $confirm.val().length > 0 && $pwd.val() != $confirm.val()) {
            $("#match").text("Passwords do not match.");
            $confirm.keyup(validatePasswordsMatch);
            $pwd.keyup(validatePasswordsMatch);
            console.log('alert bad');
        } else {
            $("#match").text("");
            console.log('alert');
            $confirm.unbind('keyup', validatePasswordsMatch);
            $pwd.unbind('keyup', validatePasswordsMatch);
        }
    }

    function validatePasswordLength() {
        var $pwd = $("#password");
        if ($pwd.val().length < 5) {
            $("#lengthMsg").text("Password does not meet length requirement.");
            // Bind to keypress so the validator re-validates as the user types when the text box gains focus.
            $pwd.keypress(validatePasswordLength);
        } else {
            $("#lengthMsg").text("");
            $pwd.unbind('keypress', validatePasswordLength);
        }
    }

    $("#password").blur(validatePasswordLength).blur(validatePasswordsMatch);
    $("#confirmPassword").blur(validatePasswordsMatch);

});

$(document).ready(function(){
    $('.clickme').click(function(){
        $("#showlist").toggle(400);
        
    });
});

function CheckDeleteRC(redirect_url)
                    {
                        if (confirm("You are about to permanently delete a Road Captain from the database which has site-wide effects. Do you want to proceed?"))
                        {
                          location.replace(redirect_url);
                        }
                        else
                        {
                          alert("Deletion cancelled.");
                        }
                    }
					
/* password login check */

$(document).ready(function(){

//$('form').submit(function() {
$('#loginform').submit(function() {
  var passwordli=$('#loginpassword').val();
  var userlogin=$('#loginuser').val();
  if(userlogin==='lets') 
  {
     if(passwordli==='ride')
     {
        return true;
     }
     else
     {
      
        $('#result').html('<p "style=color:red;">Incorrect password</p>');
		return false;
     }
     
  }
  else
  {
   
    $('#result').html('<p "style=color:red;">Incorrect Username</p>' + userlogin);
    return false;
  }
  
});
});

/* newsletter year archive show n hide */
$(document).ready(function() {
	$('.nlarchive').click(function() {
	  $(this).next().toggle();
      $(this).next().next().toggle();  
	});
});


