jQuery(document).ready(function(){	
								
								
								
								
	   //staff layout
	jQuery("#Mappy").children().each(function() {
		var _thisMap = jQuery(this);
		var _id = _thisMap.attr('id');
		//alert(_id);
		_thisMap.click(function() {
			//alert(_id || 'nothing');
			checkStaff(_id);
		});
	});
	
	jQuery("#Mappy").click(function() {
		var _h = jQuery("#left").height();
		
		if (_h < 800) {
			jQuery("#left").animate({height: 950}, 700, "easeOutExpo");
		/*if(jQuery("#staffMembers").find('.currentStaff')) {
			jQuery('#left').height();
			th = jQuery('.currentSlide').height();*/
		} else {
			return null;
		}
	});
	
	function checkStaff(id){
		var _div = jQuery("#staffMembers").find('.'+id);
		jQuery("#staffMembers").find('.currentStaff').fadeOut(450, "easeOutExpo").removeClass('currentStaff');
		_div.fadeIn(650, "easeOutExpo").addClass('currentStaff');
		
		//rewrote the function slightly to not be as bulky. left it commented out below this comment for you to use if you'd like. lots of quick clicks (or just using a slower computer) causes the current script to get really trippy and laggy because each time you click it's looking through every single div and computing the IF statement. you're a bad dude, good work!
		/*jQuery("#staffMembers div").each(function() {
				var _thisDiv = jQuery(this);
				var _class = _thisDiv.attr("class");
				//alert(_class || 'nothing');
				//alert(id);
				if(id === _class) {
					//alert(id + "===" + _class);
					_thisDiv.fadeIn('slow');
				} else {
					_thisDiv.fadeOut('slow');
				}
				
			});*/
	}					
								
								
								
								
								
								
								
	//hide menu on load
	jQuery("div.sub").hide();
	
	//add class 'last' to last topper element
	jQuery("#innermenu > .abscontainer").last().addClass('last');
	
	jQuery("a.active").mouseover(function(){
		jQuery('.hover').removeClass('hover');
		jQuery(this).addClass('hover');
		menuShow(this); 
		return(false);
	});
	
	jQuery("a.empty").mouseover(function() {
		jQuery('.hover').removeClass('hover');
	});
													
	jQuery(".content, .contINT, a.empty").mouseover(function(){
		jQuery(".topsub > div.sub").stop().slideUp(300).removeClass("topsub");
		jQuery('.hover').removeClass('hover');
 	});
	
	jQuery('.topper.active').click(function() {
		return false;
	});
	
	//no boxy outline on clicks
	jQuery("a").focus(function() {
		jQuery(this).blur();
	});
		
	//remove border on blank images
	if(jQuery(".sidepic > img").width() == 1) {
		jQuery(".sidepic > img").css({'border-color': "#377DBB"});
	}
	
	 if (jQuery("#flash-video").length) { // if div exists...
   flowplayer("flash-video", "/Portals/0/invisalign/flash/flowplayer-3.1.5.swf", {
		plugins: { controls: { url: 'flowplayer.controls-tube-3.1.5.swf' } },
		clip: { autoPlay: false, autoBuffering: true }
	});
   
   
}
 
 if (jQuery("#faq").length) { // if div exists...
   var sshow = new SWFObject("/Portals/0/faq/faq.swf", "faq", "500", "260", "6", "#ffffff"); 
   sshow.addParam("quality", "high"); 
   /*sshow.addParam("wmode", "transparent"); */
   sshow.addVariable("faq", "/Portals/0/faq/faq.xml"); sshow.write("faq");
 }
		
	jQuery("#header .call-1").click(function() {
		window.location='/PatientInfo/Request1stAppointment.aspx';
	});
	
	jQuery("#header .call-2").click(function() {
		window.location='/PatientInfo/FAQ.aspx';
	});
	
	jQuery("#header .call-3").click(function() {
		window.location='/AsSeenonTV.aspx';
	});
	
	jQuery("#right .c1").click(function() {
		window.open('http://www.getnside.com/cc/magazine/medical/102009/profiles/1489-Dr_Richard_Ingraham/', '_blank');
	});
	
	jQuery("#right .c2").click(function() {
		window.location='/FunZone/IncredibleKidsClub.aspx';
	});
	
	jQuery("#right .c3").click(function() {
		window.location='/PracticeInfo/PracticeNews.aspx';
	});
	
	
	 //open external links in new window
/*jQuery("a[href^='http']")
.not("a[href*='" + window.location.host + "'])")
.each(function() {
jQuery(this).attr("target", "_blank");
}); */

	
	jQuery('#header .callouts div').hover(
		function() {
			jQuery(this).children('.more').show();
		},
		function() {
			jQuery(this).children('.more').hide();
		}
	);
	
	jQuery('#right .callouts div').each(function() {
		jQuery(this).children('.arrow').hide();
		jQuery(this).hover(
			function() {
				jQuery(this).children('.arrow').show();
			},
			function() {
				jQuery(this).children('.arrow').hide();
			}
		);
	});
	
	footNumberHovers('.adrs1','.num1', '.adrs2', '.num2', '.adrs3','.num3');
	
});

//make menu work
function menuShow(menuitem){
	jQuery(".topsub>div.sub").stop().slideUp(350).parent().removeClass("topsub");
	jQuery(menuitem).next().css("height", "auto").stop().slideDown(500).parent().addClass("topsub");
}

//sifr script
function pageScripts(){
var trebuchet = {  src: DNN_skinPath + 'trebuchet.swf' };
sIFR.activate(trebuchet);
	sIFR.replace(trebuchet, {
	  selector: 'h1, h2, div.title', 
	  wmode: 'transparent', 
	  src:  DNN_skinPath +  'trebuchet.swf', 
	  css: [ '.sIFR-root {color:#ffffff; font-style:italic;}']
	});
}


function doTour() {
	//get first and last labeled w/ class; use later to remove appropriate arrow
	jQuery('.slides').children(":first").addClass('first');
	jQuery('.slides').children(":last").addClass('last');
	
	//fade the first image in
	jQuery('.slides .first').fadeIn(450, 'easeOutExpo').addClass('currentSlide');
	
	checkArrows();
	
	
	//get forward motion functional
	jQuery('.arrows .next').bind('click', function() {
		jQuery('.currentSlide').stop().fadeOut(400, 'easeOutExpo').removeClass('currentSlide').next().stop().fadeIn(500, 'easeOutExpo').addClass('currentSlide');
		checkArrows();
	});
	
	//get backward motion functional
	jQuery('.arrows .prev').bind('click', function() {
		jQuery('.currentSlide').stop().fadeOut(400, 'easeOutExpo').removeClass('currentSlide').prev().stop().fadeIn(500, 'easeOutExpo').addClass('currentSlide');
		checkArrows();
	});
}

function checkArrows() {
	//remove arrows as needed
	if(jQuery('.currentSlide').hasClass('first')) {
		jQuery('.arrows .prev').hide();
	} else {
		jQuery('.arrows .prev').show();
	}
	
	if(jQuery('.currentSlide').hasClass('last')) {
		jQuery('.arrows .next').hide();
	} else {
		jQuery('.arrows .next').show();
	}	
}

function footNumberHovers(a,aa, b,bb, c,cc) {
	jQuery(a).hover(
					
		function() {
			jQuery(aa).stop().show();
		},
		function() {
			jQuery(aa).stop().hide();
		}
	);
	jQuery(b).hover(
		function() {
			jQuery(bb).stop().show();
		},
		function() {
			jQuery(bb).stop().hide();
		}
	);
	jQuery(c).hover(
		function() {
			jQuery(cc).stop().show();
		},
		function() {
			jQuery(cc).stop().hide();
		}
	);
}



