// JavaScript Document
function checkTypes(id){
	$(".typesofbraces div").each(function() {
		var _types = $(this);
		var _class = $(this).attr("class");
		$(_types).hide();
		if(id === _class) {
			_types.fadeIn('slow');
		} else {
			_types.fadeOut('slow');
		}			
	});	
}
	
function types(){
	$(".links a").each(function() {
		var _link = jQuery(this);
		var _id = _link.attr('id');
		_link.click(function() {			
			checkTypes(_id);
		});
	});
}

function preload(arrayOfImages) {
    $(arrayOfImages).each(function(){
        $('<img/>')[0].src = this;        
    });
}

$(document).ready(function(){
				
	//preloading header photos	
	preload([
		'/Portals/_default/Skins/siteSkin/images/pages/Meet Dr. D.png',
		'/Portals/_default/Skins/peakfamilydental/images/banner/Our Team.png'		
	]);
	
	//audio files	
	$("#music").jmp3({
		backcolor: "CC2211",
		forecolor: "ffffff",
		width: 25,
		showdownload: "false",
		showfilename: "false",
		autoplay: "true"
	});
	
	$("#voice").jmp3({
		backcolor: "CC2211",
		forecolor: "ffffff",
		width: 25,
		showdownload: "false",
		showfilename: "false",
		autoplay: "true"
	});
	
	//hiding elements
	$('.sub').hide();
			
	//remove focus box
	if(document.getElementsByTagName) {
		var a = document.getElementsByTagName("a");
		for(var i = 0; i < a.length; i++){
		a[i].onfocus = function(){this.blur();};
		}
	}
			
	//menu
	function mouseOver(elem) {
		$('.sub', this).slideDown().parent().addClass('current');		
	}
	function mouseOut(elem) {
		$('.sub', this).slideUp().parent().removeClass('current');	
	}
	
	$('#innermenu > .abscontainer').hoverIntent(mouseOver, mouseOut);
					
	//types of braces
	checkTypes();
	types();
			
	//logo rotation
	$('#logos').fadeIn(1100);
    $('#logos').cycle({
		fx: 'fade',
		speed: 1200,
		timeout: 5000	
	});	
	
	//iphone icons
	$(".icons img").hover(
    	function(){$(this).animate({width: 50, height:50}, 200);},        
    	function(){$(this).animate({width: 55, height:55}, 200);}
	);
			
	if ($("#slides").length) { // if div exists...
   		//embed be an orthodontist feature
		flashembed("slides",{src:"/Portals/_default/Skins/siteSkin/flash/Flash_Photos_2.swf", wmode:"transparent"});
 	}	
	
	if ($("#shuttle").length) { // if div exists...
   		//embed be an orthodontist feature
		flashembed("shuttle",{src:"/Portals/_default/Skins/siteSkin/flash/Flash_Shuttle_3.swf", wmode:"transparent"});
 	}	

				
	//img opacity
	/*$('.footer img').css({'opacity' : '0.8' })
	$('.footer img').each(function() {
	$(this).hover(function() {
		$(this).stop().animate({ opacity: 1.0 }, 200);
	},
	    function() {
		   $(this).stop().animate({ opacity: 0.8 }, 200);
	    });
	});	*/
					
});//end document ready







