function resizeWindow() {
	if ($("#container_7").width() > 1750){
	body_height = $("#container_7").height();
	$("#orange_left").css({height:body_height});
	}
}	 

function resizeWindow2() {
	if ($("#container_7").width() > 1750){
	body_height = $("#container_7").height();
	$("#orange_left").css({height:body_height});
	}
}
// CALL RESIZE WINDOW FUNCTION ON WINDOW RESIZE

$(window).bind("resize", resizeWindow);

// PAGE LOAD RULES

$(document).ready(function() {
	
	
	// AJAX BODY PREPEND FOR GREY EXTENTION
	
	$("body").prepend('<div id="orange_left">&nbsp;</div>');

	
	// INITIAL CALL TO  RESIZE WINDOW FUNCTION 
	
	resizeWindow();						   
	
	// DROPDOWNS
	
	$('#navigation li a').hover(
	function() {
		$('#navigation li a').css({backgroundPosition: '0px 0px'});
		$(this).css({backgroundPosition: '0px -74px'});	
		$('.drop_down').stop(true, true).slideUp(200);
		dd_name = $(this).attr("id");
		dd_name = dd_name.replace("_link","_dd");
		dd_selector = "div#"+dd_name;
		$(dd_selector).stop().slideDown(400);
	}, function() {});	
	
	$("#navigation_container").hover(
		function (){},
		function (){
			$('.drop_down').stop(true, true).slideUp(200);
			$('#navigation li a').css({backgroundPosition: '0px 0px'});			
		}
	);
	
	$('.drop_down ul li').hover(
		function(){
			$(this).find(".sub_dd").show();
			$(this).find("a, a span").not(".sub_dd li a").not(".sub_dd li a span").css({
				'background-position': '-231px bottom'
			 });
		},
		function(){
			$(this).find(".sub_dd").hide();
			$(this).find("a, a span").not(".sub_dd li a").not(".sub_dd li a span").css({
				'background-position': '0px bottom'
			 });
		}
	);
		
	if($("body").hasClass("home")){

		// SLIDER
	
		// USER DEFINED VARIABLES 
		
		slide_height = -148;
		slides_shown = 2;
		slide_selector = '.home_text_point';
		slide_selector_container = '#body_text';
		
		// BROWSER DEFINED VARIABLES
		
		slide_current = 1;
			
		pos_slide_height = slide_height * -1;
		
		slide_amount =  $(slide_selector).length;
		
		$(slide_selector).addClass("jq_slides");
		slide_container_height = slide_height * slide_amount;
		new_slide_container_height = slide_height * -1 * slide_amount;
		single_group_length = slide_height * -1 * slides_shown;
		new_slide_container_height = new_slide_container_height + single_group_length;
		$(slide_selector_container).css({'height':new_slide_container_height});
	
		slide_duplicate_selector = slide_selector+':lt('+slides_shown+')'
		
		$(slide_duplicate_selector).clone().appendTo($(slide_selector_container));
	
	
		// SLIDER FUNCTIONS
		
		function home_slider(slide_current_overide) {
	
			if(slide_current_overide != "test"){
				if (slide_current_overide == "next") {
					slide_current = slide_current + 1;
				}
				else if (slide_current_overide == "prev") {
					slide_current = slide_current - 1;
				}
				else{
					slide_current = slide_current_overide;
				}
		
				if(slide_current == 0){
					$(slide_selector_container).animate({"top" : slide_container_height}, 0);
					slide_current = slide_amount;
				}
		
				slide_current_multiplier = slide_current - 1;		
				top_slide_value = slide_current_multiplier * slide_height;
			
				if (slide_current_overide == "next") {
					top_slide_value = '-='+pos_slide_height;
				}
				if (slide_current_overide == "prev") {
					top_slide_value = '+='+pos_slide_height;
				}
				
				if(!$(default_container).hasClass('popup')){
					$(slide_selector_container).animate({top : top_slide_value},{duration:900 });
				}
				else {
					if ($(default_container).hasClass('init_click')) {
						//$(slide_selector_container).css({top : top_slide_value});
					}
					else {
						//console.log("popup manual");							
						$(slide_selector_container).animate({top : top_slide_value},{duration:0 });
					}
				}
				if (slide_current == slide_amount+1) {
					$(slide_selector_container).animate({"top" : "0"},0);
					slide_current = 1;
				}
			}
			else{
				if(slide_current == slide_amount+1){slide_current = 1};
				
		
				slide_current = slide_current + 1;
				
				slide_current_multiplier = slide_current - 1;
		
				top_slide_value = slide_current_multiplier * slide_height;
		
		
				$(slide_selector_container).animate({top : top_slide_value},{duration:900 });
	
				if (slide_current == slide_amount+1) {
					$(slide_selector_container).animate({"top" : "0"},0);
					slide_current = 1;
				}
			}
		}
	
	
		// SLIDER INTRAVAL 
		
		rotating = setInterval(function() {
			home_slider("test");
		},8000)
	
		// HOVER PAUSE 
		
		$("#slides li div").hover(
			function (){			
				clearInterval(rotating);
			}, 
			function(){
				rotating = setInterval(function() {
				home_slider("test");
				},8000)			
			}
		);

	}
	
	if($("body").hasClass("staff_profile")){

		// SLIDER
	
		// USER DEFINED VARIABLES 
		
		slide_width = 600;
		slide_width = slide_width *-1;
		slides_shown = 1;
		slide_selector = '#staff_profile_testimonial_list li';
		slide_selector_container = '#staff_profile_testimonial_list';
		
		
		// BROWSER DEFINED VARIABLES
		
		slide_current = 1;
			
		pos_slide_width = slide_width * -1;
		
		slide_amount =  $(slide_selector).length;
		
		$(slide_selector).addClass("jq_slides");
		slide_container_width = slide_width * slide_amount;
		new_slide_container_width = slide_width * -1 * slide_amount;
		single_group_length = slide_width * -1 * slides_shown;
		new_slide_container_width = new_slide_container_width + single_group_length;
		$(slide_selector_container).css({'width':new_slide_container_width});
	
		slide_duplicate_selector = slide_selector+':lt('+slides_shown+')'
		
		$(slide_duplicate_selector).clone().appendTo($(slide_selector_container));
		
		staff_profile_testimonials_height = $("#staff_profile_testimonial_list>:nth-child(1)").height();
		$("#staff_profile_testimonials").height(staff_profile_testimonials_height);
		
		// SLIDER FUNCTIONS
		
		function slider(slide_current_overide) {
	
			if(slide_current_overide != "run"){
				if (slide_current_overide == "next") {
					slide_current = slide_current + 1;
				}
				else if (slide_current_overide == "prev") {
					slide_current = slide_current - 1;
				}
				else{
					slide_current = slide_current_overide;
				}
		
				if(slide_current == 0){
					$(slide_selector_container).animate({"left" : slide_container_width}, 0);
					slide_current = slide_amount;
				}
		
				slide_current_multiplier = slide_current - 1;		
				left_slide_value = slide_current_multiplier * -600;
			
				if (slide_current_overide == "next") {
					left_slide_value = '-='+pos_slide_width;
				}
				if (slide_current_overide == "prev") {
					left_slide_value = '+='+pos_slide_width;
				}	
				$(slide_selector_container).animate({left : left_slide_value},{duration:300 });
				if (slide_current == slide_amount+1) {
					$(slide_selector_container).animate({"left" : "0"},0);
					slide_current = 1;
				}
				staff_profile_testimonials_height_selector = "#staff_profile_testimonial_list>:nth-child("+slide_current+")";
				staff_profile_testimonials_height = $(staff_profile_testimonials_height_selector).height();
				$("#staff_profile_testimonials").animate({"height":staff_profile_testimonials_height},300, function(){
					resizeWindow();
				});
			}
			else{
				if(slide_current == slide_amount+1){slide_current = 1};
	
				slide_current = slide_current + 1;
				
				slide_current_multiplier = slide_current - 1;
		
				left_slide_value = slide_current_multiplier * slide_width;
		
		
				$(slide_selector_container).animate({left : left_slide_value},{duration:900 });
	
				if (slide_current == slide_amount+1) {
					$(slide_selector_container).animate({"left" : "0"},0);
					slide_current = 1;
				}
				staff_profile_testimonials_height_selector = "#staff_profile_testimonial_list>:nth-child("+slide_current+")";
				staff_profile_testimonials_height = $(staff_profile_testimonials_height_selector).height();
				$("#staff_profile_testimonials").animate({"height":staff_profile_testimonials_height},300, function(){
					resizeWindow();
				});
			}
		}
	
	
		// SLIDER INTRAVAL 
	
		$("#staff_profile_testimonial_back").click(function(){
			clearInterval(rotating);
			slider("prev");
			return false;
		});
	
		$("#staff_profile_testimonial_forward").click(function(){
			clearInterval(rotating);
			slider("next");
			return false;
		});
	
		rotating = setInterval(function() {
			slider("run");
		},8000)
	
		// HOVER PAUSE 
	}
		
		
	// DIV SHOW/HIDE TOGGLE
		
	$(".trigger_content").hide(0, function(){
		resizeWindow();						   
	});
	$("h3.trigger_heading").click(function(){
		$(this).toggleClass("active").next().slideToggle("slow", function(){
			resizeWindow();						   
		});
		return false;
	});
	$(".trigger_content1").hide(0, function(){
		resizeWindow();						   
	});
	$("h3.trigger_heading1").click(function(){
		$(this).toggleClass("active").next().slideToggle("slow", function(){
			resizeWindow();						   
		});
		return true;
	});
	$(".trigger_content2").hide(0, function(){
		resizeWindow();						   
	});
	$("h4.trigger_heading2").click(function(){
		$(this).toggleClass("active").next().slideToggle("slow", function(){
			resizeWindow();						   
		});
		return false;
	});


		// GENERAL FORM RULES							 	
	
		if ($("form").hasClass("body_form")){	
		$.getScript('/scripts/validate_rules.js');
		$(".body_form p").not(".body_form p.checkbox_container").not(".body_form p.select_container").hover(function(){
				$(this).find("em").hide();										 
				$(this).find("label").not(".radio_label").show(200, function(){
				});
				$(this).addClass("active");
			}, function(){
				$(this).find("label").not(".radio_label").hide(200, function(){
				});
				$(this).removeClass("active");
		});
		
		$(".body_form p input").not(".body_form p.checkcbox_container input").not(".body_form p.select_container input").focus(function(){
				if(!$(this).parent().hasClass("active")){
					$(".body_form p label, .body_form p em").hide();
					$(".body_form p").removeClass("active");					
					$(this).parent().find("em").hide();										 
					$(this).parent().find("label").show(200);
					$(this).parent().addClass("active");
				}											   
		 });
		
		// DETECT AND FIX PLACEHOLDER SUPPORT 
		
		if (Modernizr.input.placeholder) {
		  // your placeholder text should already be visible!
		}
		else {
		  // no placeholder support :(
		  $("input[placeholder]").each(function(){
			if($(this).val()==""){
			  $(this).addClass('hasplaceholder');
			  $(this).val($(this).attr("placeholder"));
			  $(this).focus(function(){
				if($(this).val()==$(this).attr("placeholder")) $(this).val("");
				$(this).removeClass('hasplaceholder');
			  });
			  $(this).blur(function(){
				if($(this).val()==""){
				 $(this).addClass('hasplaceholder');
				 $(this).val($(this).attr("placeholder"));
				}
			   });
			}
		  });
		}
		
		$('form').submit(function(evt){
			$('input[placeholder]').each(function(){
				if($(this).attr("placeholder") == $(this).val()) {$(this).val('');}
			});
		});
					
		
		var count = 10;
		countdown = setInterval(function(){
		$("#timer").html("Please wait " + count + " seconds before you submit!");
		if (count == 0) {
			$('#timer').remove();
			$("#submit_container").html('<a href="#" class="submit_button "><span>Submit</span></a>');
			$(".submit_button").fadeIn('slow');
		}
		count--;
		}, 1000);
		$("a.submit_button").live('click', function() {
			$(this).parents("form").submit();
			return false;
		});
		
		
		// STAR SELECT 
		
		
		$(".select_star").hover(
			function(){
				$(this).addClass("select_star_hover");
				$(this).prevUntil("p").addClass("select_star_hover");
			},
			function(){
				$(this).siblings().removeClass("select_star_hover");
				$(this).removeClass("select_star_hover");
			}
		);
		
		$(".select_star").click(function(){
			$(this).removeClass("select_star_hover selected_select_star");									 
			$(this).siblings().removeClass("select_star_hover selected_select_star");									 
			$(this).addClass("selected_select_star");
			$(this).prevUntil("p").addClass("selected_select_star");
			select_star_val = $(this).text();
			//console.log(select_star_val);
			$(this).parent("p").find("select").val(select_star_val);
		});
		

		
// PCR STAR RATING 
		
	
		

	}
});
