//start jQuery functions
jQuery(document).ready(function($){
	
	$("#nav ul")
	.superfish({
		hoverClass	: "sfHover",
		pathClass	: "overideThisToUse",
		delay		: 2000,
		animation	: {opacity:"show",height:"show"},
		speed		: "normal",
		oldJquery	: false, // set to true if using jQuery version below 1.2
		disableHI	: false, // set to true to disable hoverIntent detection
		onInit		: function(){},
		onBeforeShow	: function(){},
		onShow		: function(){},
		onHide		: function(){}
	});
	
	// cycle the homepage images
	$('#homePics').load(skinpath+'slideshow.asp', function() {
		$('.slideshow').cycle({ speed: 2000, timeout: 7000 });
	});
	
	// this prevents the page from jumping when main level nav items with submenus are clicked		
	$('#nav a[href="#"]').click(function() { return false	});
	
	// remove box from links
	$("a").focus(function(){ this.blur(); });
	
	// pads the top of the h3's after the first h3
	$('h3').not(':first').css('padding-top','22px');	
	
	// randomize page photos - copy the link below to content to add one
	// <img id="pagePhoto" src="" alt="" class="random"/>
	$('.random').attr('src',"/Portals/0/pagePhotos/" + Math.floor(Math.random() * 18 + 1) + ".jpg");
	
	// controls the accordion of the FAQ
	// .length is used to check that the element exists on the page. this prevents script errors from some browsers
	if ($('#faq').length) {
		$('.faqAnswer').hide();
   	$('.question a').click(function() {
     		$(this).toggleClass('active').next('.faqAnswer').slideToggle('fast')
				.siblings('.faqAnswer:visible').slideUp('fast');
   	});
	}
	
	// jaw surgery flash feature
	// uses the Flashembed script from jQuery Tools.  So much nicer than swfobject
	$('.tmjFF').flashembed('http://tools.televoxsites.com/features/orthognathic.swf');
	
	// load the feedback form
	// did it this way because with DNN you can't have <form> tags in the content pane 
	$('#feedback-form').load(skinpath+'feedbackform.asp');
	
	// animated tagline
	$('.tagline').flashembed({ src: skinpath+'flash/tagline.swf', wmode: 'transparent' });
	
	// invisalign video
	$('#flash-video').flashembed({
				src: "/Portals/0/vendor/flash/flowplayer-3.2.6.swf",
				wmode: "transparent"
			},
			{
			config: {
				plugins: {
					controls: {
						url: '/Portals/0/vendor/flash/flowplayer.controls-tube-3.2.4.swf'
					}
				},
				clip: {
					url: '/Portals/0/vendor/flash/invisalign.flv',
					autoPlay: false,
					autoBuffering: true
				}
			}
	});
	
	// uncomment the next line to enable the popup window
	//$('.popup-window').show('slow');
	
	$('.popup-window').click(function() {
		$(this).hide();
	});
	
});

//activates the sIFR
//code for the h1 tags
var pageTitle = {  src: skinpath+'flash/Trajan.swf' };
sIFR.activate(pageTitle);
sIFR.replace(pageTitle, {
	selector: 'h1', 
	wmode: 'transparent', 
	src: skinpath+'flash/Trajan.swf', 
	css: [ '.sIFR-root {color:#183861; }'  ]
});
