$(document).ready(function(){	
	jQuery.validator.addMethod("alphanumeric", function(value, element) {
		return this.optional(element) || /^[a-zA-z0-9-]+$/i.test(value);
	}, "Letters, numbers, spaces or underscores only please");  
	
	$("#slider2").easySlider({
		nextId:"button1",
		prevId:"button2",
		prevText:'<img src="images/btn_prev.gif" border="0" />',
		nextText:'<img src="images/btn_next.gif" border="0" />',
		controlsBefore:	'<p id="controls">',
		controlsAfter:	'</p>',
		speed:1000
		
		
	});
	$("#slider").easySlider({
		nextId:"button3",
		prevId:"button4",
		prevText:'<img src="images/arrow_up.jpg" border="0" />',
		nextText:'<img src="images/arrow_down.jpg" border="0" />',
		vertical: true
	});

	
	$("#register_form").validate({
		rules: {
			account_number: {
				required: true,
				minlength: 3,
				maxlength:10,
				remote: "validations.php?act=accountNumber",
				numeric:true
			},
			password: {
				required: true,
				minlength: 3
			},
			password2: {
				required: true,
				minlength: 3,
				equalTo: "#password"
			},

			zipCode: {
				required: "#havezip:unchecked",
				minlength: 2,
				alphanumeric:true
				
			},
			
			city: {
				required: "#havezip:checked"
			}
		},
		messages: {
			
			account_number: {
				required: "Please enter your Account Number ",
				minlength: "Invalid Account Number, should be 3 digits or more in length.If you do not know your Account Number, please contact Customer Service for more information",
				remote: "The Account Number does not match our records. Please try again or contact Customer Service for further assistance",
				numeric:"Account Number must be Numeric. Please enter a valid Account Number. If you do not know your Account Number please contact Customer Service for more information."
			},
			zipCode: {
				required: "Please enter your Zip Code",
				minlength: jQuery.format("Enter at least {0} characters"),
				alphanumeric:"Please enter a valid zip code without any special characters"
			
			},
			password: {
				required: "Please enter your new Private Label Password",
				minlength: "Password must be of at least 5 characters and consist of both alpha and numeric characters"
			},
			password2: {
				required: "Retype your password in the 'Confirm Password' text box",
				minlength: "Password must be of at least 5 characters and consist of both alpha and numeric characters",
				equalTo: "Please enter the same password as above"
			}

		}
							   
							   
	}); //validate
	
	  $(".simple_text").editable("?act=partialsave" , { 
        indicator 	: "<img src='images/indicator.gif'>",
        submit    	: 'OK',
        tooltip   	: "Click to edit...",
		cssclass  	:'inplace_input',
		name	  	: 'common_input',
		width		:"100%",
		type		: "text",
		submitdata 	: function() {
           return {fieldName: $(this).attr("fieldName"),fieldId: $(this).attr("fieldId")}
       } 
    });
	  
	  $(".row_text").editable("?act=partialsave" , { 
        indicator 	: "<img src='images/indicator.gif'>",
        submit    	: 'OK',
        tooltip   	: "Click to edit...",
		cssclass  	:'inplace_input',
		name	  	: 'common_input',
		width		:"100%",
		type		: "text",
		submitdata 	: function() {
           return {fieldName: $(this).attr("fieldName"),recordId: $(this).parents('tr').attr("recordId")}
       } 
    });  
	  
	
});


function clearThis(obj){
	if ( (obj.value == "State Account #") || (obj.value == "Password") ){
			obj.value ="";
		} 
	}
	
function cambiarRegShow(obj){
		if ( $("#havezip").attr('checked') == true ){
			$("#cityd").show();
			}else{
				$("#city").val("");
				$("#cityd").hide();
				}
	}	