// JavaScript Document
$( function( $ ){
	
	var current = 0;
	
	$( 'div.page-right ul li:first' ).css( 'display' , 'none' );
	
	$( 'div#navigation ul li:last' ).css({ 'float':'right', 'padding-top': '40px'});
	
	$( 'div.page-right ul li' ).each( function( index ){
								 
		$( this ).find( 'input:first' ).css( 'margin-left','0px' );
		
								 
	});
	$( 'div.page-right ul li' ).eq( 3 ).find( 'label' ).addClass( 'align' );
	$( 'div.page-right ul li' ).eq( 3 ).find( 'label:first' ).css( 'width', '135px' );
	$( 'div.page-right ul li:last input, div.page-right ul li img' ).css({ 'float':'right', 'clear':'both', 'cursor':'pointer' });
	
	$( 'div.page-right ul:last' ).addClass( 'hide' );
	
	
	
	var v = $( 'form#validate' ).validate({
						
		rules:{
			
			essay: {
				
				accept: 'doc|pdf|docx|dot|dotx|docm|dotm'	
				
			},firstname:{
				
				filled: true
			},lastname:{
				
				filled:true	
			}
			
			
		}
	});


	$(".next").click(function() {
		
		var arr = [];
		
		v.form();
		
		$( 'input,select' ).each( function( index ){
			
			if( $( this ).hasClass( 'error' ) ){
				
				arr.push( $( this ).attr( 'name' ) );
				
			}					     
			
		
		});
		
		if( arr.length == 0 ){
				
						
			var $firstList 	= $( 'div.page-right ul:first' );
			var $lastList	= $( 'div.page-right ul:last' ); 
			
			$firstList
				.slideUp( 800 , function( objEvent ){
					$( 'html, body' ).animate( { scrollTop: 200 } , 'fast' );
								     
					$lastList
						.slideDown( 500 , function( objEvent ){
							
							$( 'input[ name="terms" ],textarea' ).addClass( 'required' );
				   
						});
				
				});
		
		
	
		}
			
	


		
	});


	$.validator.addMethod("filled", function(value, element) { 
  
  		if( value == 'First' || value == 'Last' ){
			
			return false;	

		}else{
			
			return true;
		}
	

	}, "");

	

	$(".mask_phone").mask("(999) 999-9999");
	$(".mask_zip").mask("99999");



	$('.dob' ).datepicker({
			changeMonth: true,
			changeYear: true,
			yearRange: '1970:2010'
	});




});
