
			jQuery(document).ready(function() {

		$('.popup_close').click(function() {
		$('#backgroundPopup').hide();
		$('.vedio_popup').hide();		
	});
	

// black screen dynamic height on window resize
	$(window).resize(function(){
	   var body_win_height = parseInt(document.body.clientHeight) ;
	   var win_height = parseInt(document.documentElement.clientHeight) ;

	   if( body_win_height > win_height) {
		$('#backgroundPopup').height(body_win_height);
	   } else {
		$('#backgroundPopup').height(win_height);
	   }
	});
	
   var body_win_height = parseInt(document.body.clientHeight) ;
   var win_height = parseInt(document.documentElement.clientHeight) ;
   

	   if( body_win_height > win_height) {
		$('#backgroundPopup').height(body_win_height);
	   } else {
		$('#backgroundPopup').height(win_height);
	   }

	function position_popup () {
		var pop_pos = $(window).scrollTop() +150;
		$('.popup_pos').css('top', pop_pos);
	}





	
	// Place ID's of all required fields here.
	required = ["first_name", "last_name", "phone"];
	// If using an ID other than #email or #error then replace it here
	first_name = jQuery("#first_name");
	last_name = jQuery("#last_name");
	phone = jQuery("#phone");
	
	//date = jQuery("#date");	
	errornotice = jQuery("#error");
	// The text to show up within a field when it is incorrect
	emptyerror = "Please fill out this field.";
	emailerror = "Invalid Email";
	phoneerror = "Phone"
	
	jQuery("#consult_form").submit(function(){ 
		$('.custom_dropdown').find('ul').hide();
		//Validate required fields
	//	alert('test');
		for (i=0;i<required.length;i++) {
			var input = jQuery('#'+required[i]);
			if ((input.val() == "First Name") || (input.val() == "Last Name") || (input.val() == "Phone")) 
			
			{
				input.addClass("error_input_field");
				$('#compensation_h3').addClass('error_h');
	
				
				
			} else {
				input.removeClass("error_input_field");
				$('#compensation_h3').removeClass('error_h');
	
				
			}
		}

	var value = $('#phone').val().replace(/^\s\s*/, '').replace(/\s\s*$\./, '');
    var intRegex = /^[0-9\-\+\.]+$/;
    if(!intRegex.test(value)) {
			phone.addClass("error_input_field");
			phone.val(phoneerror);
    }
	


/*		if ($('#message').val() == "Message") {
			$('#message').addClass("error_input_field");		
		} else {
			$('#message').removeClass("error_input_field");
		} */

 


		
		//if any inputs on the page have the class 'error_input_field' the form will not submit
		if (jQuery(":input").hasClass("error_input_field") || jQuery("span").hasClass("error_label") || jQuery("p").hasClass("error_label") || jQuery("textarea").hasClass("error_input_field") || jQuery("select").hasClass("select_error") || jQuery('#00NU0000001FWAv, #00NU0000001FWjc, #00NU0000001FXD4, #00NU0000001FXD9').hasClass("error_border")) {
			
				$('.form_head').addClass('error_form_header');
				$('.form_submit').addClass('form_error_submit');
			
			return false;
		} else {
						$('.form_head').removeClass('error_form_header');
				$('.form_submit').removeClass('form_error_submit');
			errornotice.hide();
			return true;
		}
	});
	
	
	
	
	jQuery.fn.clearOnFocus = function(){
    return this.focus(function(){
        var v = jQuery(this).val();
		var p = jQuery(this).val('Phone');
        jQuery(this).val(v === this.defaultValue ? '' : v );
		;
    }).blur(function(){
        var v = jQuery(this).val();
        jQuery(this).val( v.match(/^\s+$|^$/) ? this.defaultValue : v );
    });
 
	};

	jQuery('input.input_field').clearOnFocus();
	jQuery('textarea.form_text_area').clearOnFocus();
	jQuery('input.length').clearOnFocus();

/*	 
	$("#00NU0000001FWAv").click(function(){										
	$("#00NU0000001FWAv ul").show();
	$("#00NU0000001FWAv").addClass("hide_dropdown");
    });


$(".hide_dropdown").click(function(){										
	$("#00NU0000001FWAv ul").hide();
	$("#00NU0000001FWAv").removeClass("hide_dropdown");
});

 $("#00NU0000001FWjc").click(function(){										
	$("#00NU0000001FWjc ul").show();
	$("#00NU0000001FWjc").addClass("hide_dropdown");
	
    });

$(".hide_dropdown").click(function(){											
	$("#00NU0000001FWjc ul").hide();
	$("#00NU0000001FWjc").removeClass("hide_dropdown");
	
});
$("#state").click(function(){										
	$("#state ul").show();
	$("#state").addClass("hide_dropdown");
	
    });

$(".hide_dropdown").click(function(){											
	$("#state ul").hide();
	$("#state").removeClass("hide_dropdown");
	
});*/
	
	/*$("#00NU0000001FWjc").click(function() {
		$(this).children('ul').show();
	});
	$("#00NU0000001FWjc").find('li').click(function() {
		$(this).parent('ul').hide();
	});*/

	$('.custom_dropdown').find('li').click(function() {
		$(this).parent().parent().children('label').html($(this).html());
		$(this).parent().parent().children('input').val($(this).html());
		$(this).parent().hide();
		
	}); 
	
	$('.custom_dropdown').find('label, code').click(function() {
		$('.custom_dropdown').find('ul').hide();
		$(this).parent().children('ul').show();
			
	});
	
	//Show the paging and activate its first link

$(".image_reel li:first").addClass("active");

//Get size of the image, how many images there are, then determin the size of the image reel.
var imageWidth = $(".window").width();
var imageSum = $(".image_reel li").size();
var imageReelWidth = imageWidth * imageSum;

//Adjust the image reel to its new size
$(".image_reel").css({'width' : imageReelWidth});

//Paging  and Slider Function
rotate = function(){
    var triggerID = $active.attr("rel") - 1; //Get number of times to slide
    var image_reelPosition = triggerID * imageWidth; //Determines the distance the image reel needs to slide

    $(".image_reel li").removeClass('active'); //Remove all active class
    $active.addClass('active'); //Add active class (the $active is declared in the rotateSwitch function)

    //Slider Animation
    $(".image_reel").animate({
        left: -image_reelPosition
    }, 500 );

}; 

//Rotation  and Timing Event
rotateSwitch = function(){
    play = setInterval(function(){ //Set timer - this will repeat itself every 7 seconds
        $active = $('.image_reel li.active').next(); //Move to the next paging
        if ( $active.length === 0) { //If paging reaches the end...
            $active = $('.image_reel li:first'); //go back to first
        }
        rotate(); //Trigger the paging and slider function
    }, 8000); //Timer speed in milliseconds (7 seconds)
};

rotateSwitch(); //Run function on launch

//On Hover
$(".image_reel li").hover(function() {
    clearInterval(play); //Stop the rotation
}, function() {
    rotateSwitch(); //Resume rotation timer
});	

//On Click

$('.video').click(function() {
		$('#backgroundPopup').show();
		$('.vedio_popup').fadeIn();		
   		position_popup ();
	 });

	 
});


