// JavaScript Document
jQuery(document).ready(function($) {
	
	$('#menu').accordion({
		active: false,
		header: '.head',
		navigation: true,
		fillSpace: false,
		animated: 'easeslide'
	});
	
	$('#menu > ul').addClass('clearfix');
	
	$('ul.Level0 > li > a').each(function() {
		if ($(this).next('ul.Level1').length)
			$(this).addClass('head');
	});

	$('a').focus(function() { this.blur(); });
	
	$('li:first', 'ul.Level1').addClass('first');
	
	//home flash
	$('#flash-home').flashembed({ src:skinpath+'flash/homepage.swf', wmode:'transparent'});
	// retainer FF
	$('#retainerFF').flashembed({ src:'http://tools.televoxsites.com/features/retainer.swf', wmode:'transparent'});
	// surgery
	$('#jawFF').flashembed({ src:'http://tools.televoxsites.com/features/orthognathic.swf', wmode:'transparent'});
	
	//invisalign video
	if ($('#invisalign-video').length) {
		flowplayer("invisalign-video", {
				src: "http://tools.televoxsites.com/vendor/flash/flowplayer-3.2.6.swf",
				wmode: "transparent"
			}, {
			plugins: { controls: { url: 'flowplayer.controls-tube-3.2.4.swf' } },
			clip: { autoPlay: false, autoBuffering: true, url: 'http://tools.televoxsites.com/vendor/flash/invisalign.flv' }
		});
	}
	
	// open off-site links in new window
	$("a[href^='http']:not([href*='lovellorthodontics.com'])").each(function() {
		$(this).attr("target", "_blank");
	});
	// for pdfs
	$("a[href$='.pdf']").attr("target","_blank");
	
	//office news video
	$('#video-office-news').flash(
		{ 
			src: skinpath+'video/flvPlayer.swf',
			width: 350,
			height: 290,
			wmode: 'transparent',
			allowFullScreen: true,
			smoothVideo: true,
			flashvars:	{
		  		flvToPlay: "office-news.flv",
		  		scaleMode: "full",
      		hiddenGui: false,
      		showScaleModes: false,
      		autoStart: false,
      		startImage: skinpath+"video/office-news.jpg"
			}
		},
		{ version: 9 }
	);
	
	// FAQ
	$('.accordion-faq h2').click(function() {
		var $this = $(this), $submenu = $(this).next();
		
		if ($this.hasClass('active')) {
			$this.removeClass('active');
			$submenu.slideUp('normal');
		}
		else {
			$('.accordion-faq h2.active').removeClass('active').next().toggle("normal");
			$this.addClass('active');
			$submenu.toggle("normal");	
		}
		return false;	
	});
	
});
