// JavaScript Document
jQuery(function($) {
	/*$("#state").niceSelect({
		virtualSelectClass:"sortbyDown",
		virtualInputClass: "sortbyDownInput"
	});*/

	$("#state").flexselect();
	$("input#state_flexselect").val("");

	$("#register").bind("click", function(){
		window.scrollTo(0, 0);
	});
	$('input:radio').checkbox();
	var container = $("#error");
	$('#reg_form').validate({
            errorClass:'red',	
			errorContainer: container,
			errorLabelContainer: $("ul",container),
			wrapper: "li",
			highlight:function(element, errorClass) {
				$("#reg_form").find("label[for="+element.name+"]").addClass(errorClass);
				$("#error").addClass("showerror");
			},
			unhighlight:function(element, errorClass) {
				$("#reg_form").find("label[for="+element.name+"]").removeClass(errorClass);
			},
             rules:{
                 
				 email:{required:true,
				 		email:true,
				 		maxlength: 200},
				 confirmemail:{required:true,
				 				email:true,
								equalTo: "#email",
								maxlength: 200},	
				hiemailstate:{required:true},							
				password:{required:true,
								rangelength: [6,12],
								maxlength: 50},
				confirmpassword:{required:true,
								equalTo: "#password",
								maxlength: 50},
				firstname:{required:true,
				maxlength: 50,
				englishName: true	 
				},
                lastname:{required:true,
                maxlength: 50,
				englishName: true 
				},
				//gender:{required:true},
				txeventidchk:{required:true},
				zip:{required:true,
					 digits:true,
				 		rangelength: [5,5]},
				 address1:{maxlength: 200},	
				 address2:{maxlength: 200},			
				 city:{maxlength: 200}														
             },
			 messages:{
				 
				 email:{required:'Your e-mail is required.',
				 		email:'Please provide a valid e-mail address (e.g., name@provider.com).'},
				 confirmemail:{required:'Your confirm e-mail is required.',
				 				email:'Please provide a valid confirm e-mail address (e.g., name@provider.com).',
								equalTo: 'Your confirm e-mail must match with your e-mail.'},		
				hiemailstate:{required: 'You have registered with this email before.'},						
				password:{required:'Your password is required.',
								rangelength: 'Your password must be between 6 and 12 characters in length.'},
				confirmpassword:{required:'Your confirm password is required.',
								equalTo: 'Your confirm password must match with your password.'},
				firstname:{required:'Your first name is required.',
				englishName: 'You first name contains invalid characters.'	 
				},
                lastname:{required:'Your last name is required.',
				englishName: 'You last name contains invalid characters.'	 
				},
				//gender:{required:'Your gender is required.'},
				txeventidchk:{required:'workshop is required.'},
				zip:{
					 required:'Your zip is required.',
					 digits: 'Please enter a valid zip.',
				 	 rangelength:'Please enter a valid zip.'
				}				
			}, 
			    

             submitHandler: function(form) {
             	
jQuery(form).ajaxSubmit({
			});
		}
	});
	var hidepart = $("tbody[class='selreg']")[0];
	
	if($('#password').parent().parent().parent().css("display")=='none'){
		$('#password').attr("value","111111");
		$('#confirmpassword').attr("value","111111");
		$('#selreg').attr("checked",false);
	}
	$('#selreg').bind("click", function(){
		if($(this).attr("checked")==true){
			$(hidepart).css("display","block");
			if($('#password').attr("value")=="111111"){
				$('#password').attr("value","");
				$('#confirmpassword').attr("value","");
			}
		}else{
			$(hidepart).css("display","none");
			$('#password').attr("value","111111");
			$('#confirmpassword').attr("value","111111");
		}
		
	});
	
});
var hidestep2 = function(){
	
	$('#step2').css("display","none");
	$('#password').attr("value","111111");
	$('#confirmpassword').attr("value","111111");
}
var showstep2 = function(){
	
	$('#step2').css("display","block");
	$('#password').attr("value","");
	$('#confirmpassword').attr("value","");
}
var hidecheckmail = function(){
	$('#checkmail').removeClass("red");
}
var showcheckmail = function(){
	$('#checkmail').addClass("red");
}