/*
	cosmetic & plastic surgeons - healthpartners 2011
	global js
*/

$(document).ready(function() {

 	// ie9 browser issue - Detect if there is a broken DivX plugin
	// Giving the DivX extension time to set up
	setTimeout(function() {

		try {
			$("body").append("<div></div>");
		} catch (e) {
			if (!(window.location.href.split('/')[4]) || (window.location.href.split('/')[3] == "index.html")) {
				$("#home-body").append("There is a problem with your DivX Web Player Add-on for Internet Explorer 9. Please install the latest version available at the following url:\n\nhttp://www.divx.com");
			}
		}
	}, 2000);

	function animation() {
		photo();
		window.setTimeout(function() {
			copy(true);
		}, 500);
		
		window.setTimeout(function() {
    		promos(true);
		}, 1500);
	}

	function photo() {	
		$("#home-body #photo-container").animate({opacity:"1.0"}, 2000).animate({right:'1px'},{queue:false, duration:1000, easing:'easeOutQuint'});
	}
		
	function copy() {	
		$("#home-body #landing-banner-copy h2, #home-body #landing-banner-copy p").animate({opacity:"1.0"}, 2000).animate({left:'20px'},{queue:false, duration:1000, easing:'easeOutQuint'});
	}
		
	function promos() {	
		$("#home-body #promos").fadeIn("slow");
	}	
	
	$(window).bind("load", function() {
		$("#landing-banner").fadeIn("slow");
		if ( !($.browser.msie && $.browser.version <= 6 ) ) {
			window.setTimeout(function() {
	    		animation(true);
			}, 500);
		}				
	});
  	
		// ie roundies - top left - top right - bottom right - bottom left
	if ($.browser.msie && $.browser.version <= 8 ) {
		DD_roundies.addRule('ul#navigation', '0 0 8px 8px');
		DD_roundies.addRule('#navigation a#home', '0 0 0 8px');
		DD_roundies.addRule('#navigation a#contact', '0 0 8px 0');
		DD_roundies.addRule('.bordered', '8px');
		DD_roundies.addRule('.container-header', '8px 8px 0 0');
		DD_roundies.addRule('.container-body', '0 0 8px 8px');
		DD_roundies.addRule('#promos', '8px');
	}	
	
	if ($("#home-body").length > 0) {
		$("#home-body #photo-container, #home-body #landing-banner-copy h2, #home-body #landing-banner-copy p").css({'opacity':'0.0'});
		$("#home-body #promos").hide();
		$("#home-body #coda-slider-1").codaSlider({
			firstPanelToLoad: 1,
			autoSlide: true,
			autoSlideInterval: 8000,
			slideEaseDuration: 2000,
			autoSlideStopWhenClicked: false,
			dynamicArrows: true,
			dynamicArrowLeftText: "&#171;",
			dynamicArrowRightText: "&#187;"
		});
	}


		// active navagation
	//$('ul#navigation li a[href^=/'+window.location.href.split('/')[3]+"/"+']').addClass('active');

 	
		// Phone Number
	if (location.hash == "#phone-number") {
			$.fn.colorbox({open:true, inline:true, scrolling:false, href:"#main-phone-number"});
	}
	
	if ($.client.os != "iPad" && $.client.os != "iPhone") {
		$("a[rel*=phone-number]").click(function() {
			$.fn.colorbox({open:true, inline:true, scrolling:false, href:"#main-phone-number"});	
			return false;
		});
	}
	
		// Button Color Hover
	$(".button").hover(function() {
    	$(this).stop().animate({textShadow: "#26a69e"}, 200);
	}, function() {
		$(this).stop().animate({textShadow: "#42c5bd"}, 200);
	});
	
	// Navigation Button Color Hover
	$("ul#navigation a").hover(function() {
    	$(this).stop().animate({backgroundColor: "#bcbcbc"}, 100);
	}, function() {
		$(this).stop().animate({backgroundColor: "#dbdcdd"}, 100);
	});
	
	$("ul#navigation a.active").hover(function() {
    	$(this).stop().animate({backgroundColor: "#bcbcbc"});
	});
	 
		// Gecko 1.9.0 or less font-face override
	$.each($.browser, function(i, val) {
   		if(i=="mozilla" && $.browser.version.substr(0,5)<="1.9.0") {
	  		$(".container-header h1").css({'font-size' : '23px', 'margin-top' : '8px'});
	  		$("a.schedule").css({'font-size' : '17px', 'padding-left' : '24px'});
	  	}
 	});

		
});

