  $(document).ready(function(){

$(".teh tr").mouseover(function() {$(this).addClass("over");}).mouseout(function() {$(this).removeClass("over");});
$(".teh tr:even").addClass("zebra");

$("tr > td:first-child").width(1).css("text-align", "left" );



	$("#refreshimg").click(function(){
	$.post('js/captcha/newsession.php');
		$("#captchaimage").load('js/captcha/image_req.php');
		return false;
	});



	$("#f").validate({
		rules: {
                        firstname: "required",
 			lastname: "required",
	                address: "required",
                        city: "required",
                        state: "required",
                        zipcode: "required",
                        terms: "required",


                        email: {
				required: true,
				email: true,
                         	remote: "tl/emails.php"
			},

                       emails: {
				required: true,
				email: true,
			},


                        password: {
				required: true,
				minlength: 5
			},
			password_confirm: {
				required: true,
				minlength: 5,
				equalTo: "#password"
			},
                        username: {
				required: true,
				minlength: 3,
				remote: "tl/users.php"
			},



			captcha: {
				required: true,
				minlength: 6,
				remote: "js/captcha/process.php"
			}


		},

		messages: {

                        firstname: "Enter your firstname",
			lastname: "Enter your lastname",
			captcha: {remote:"Incorrect captcha"},
                        password: {
				required: "Provide a password",
				rangelength: jQuery.format("Enter at least {0} characters")
			},
			password_confirm: {
				required: "Repeat your password",
				minlength: jQuery.format("Enter at least {0} characters"),
				equalTo: "Enter the same password as above"
			},
                        username: {
				required: "Enter a username",
				minlength: jQuery.format("Enter at least {0} characters"),
				remote: jQuery.format("Username is already in use")
			},

                       email: {
				required: "Enter your email",
                                email:  "Please enter a valid email address.",
				remote: "Email is already in use"
			},

			terms: " "
	
		},

		success: function(label) {
			label.html("&nbsp;").addClass("checked");
                 
		},
		onkeyup: false
	});




			$("select#brandSelect").change(function(){

$.ajaxSetup({ cache: false }); 
$.getJSON("/advt2.php?ajax=true",{brand: $(this).val()}, function(j) {
					var options = '';

						options += '<option value="">Any Model</option>';

					for (var i = 0; i < j.length; i++) {
						options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>';
					}
					$("select#modelSelect").html(options);
					$('select#modelSelect option:first').attr('selected', 'selected');

				})

			});			


			$("select#modelSelect").change(function(){

			        //, $('#brandSelect').val()

$.ajaxSetup({ cache: false }); 
				$.getJSON("/advt2.php?ajax=true",{model: $(this).val()}, function(j) {

					var options = '';

						options += '<option value="">Any Year</option>';

					for (var i = 0; i < j.length; i++) {
						options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>';
					}
					$("select#yearSelect").html(options);
					$('select#yearSelect option:first').attr('selected', 'selected');

				})

			});			





              $.mask.masks = $.extend($.mask.masks,{
                    price:{ mask : '99.999,999,999,999', type : 'reverse', defaultValue: '000' }
                });
                $('input:text').setMask();




	$("#l").validate({
		rules: {

                        password: {required:true,minlength:3},
                        login: {required: true,minlength: 3}
                        },
		messages: {

                        password: {
				required: "Provide a password",
				rangelength: jQuery.format("Enter at least {0} characters")
			},
                        login: {
				required: "Enter a username",
				minlength: jQuery.format("Enter at least {0} characters"),
			}

	
		},

		success: function(label) {
			label.html("&nbsp;").addClass("checked");
                 
		},
		onkeyup: false
	});






  });



