$(document).ready(function($){	
								
	//hide menu on load
	$(".nav-wrap").hide();
	
	//add class 'last' to last topper element
	$("#innermenu > .abscontainer").last().addClass('last');
	
	
	$('p.sub').each(function() 
	{
		$(this).children("a").first().addClass('first');
		$(this).children("a").last().addClass("last");
	});
		
	//no boxy outline on clicks
	$("a").focus(function() {
		$(this).blur();
	});
	
	$("a.topper").mouseover(function()
	{
		menuShow(this); 
		return(false);
	});
	
	$('#content, #header').mouseover(function()
	{
		$('.hover').removeClass('hover');
    	$(".topsub > div.nav-wrap").stop().hide();	
	});
	
	//remove border on blank images
	if($(".pagephoto").width() <= 30) {
		$(".pagephoto").remove();
	}
	
	if($("#guestbook").length) {
		$("#guestbook").load("/portals/0/gb/guestbook.asp");	
	}
	
	
	//add flash junk
		var so = new SWFObject("/portals/_default/skins/siteskin/flash/flash.swf", "flash1", "980", "377", "8", "#CCCCCC");
		so.addParam("quality", "high");
		so.addParam("wmode", "transparent");
		so.write("flasher");
	
	if($("#ptcare").length) {
		var so = new SWFObject("/portals/0/PtCare128k.swf", "features", "430", "308", "9", "#FF6600"); 
		so.addParam("wmode", "transparent"); 
		so.addParam("quality", "high");
		so.write("ptcare");
	}
	
	if($(".befores").length) {
		var so = new SWFObject("/features/loader.swf", "features", "500", "315", "9", "#FF6600"); so.addVariable("config", "/features/config.xml"); so.addVariable("feature", "beforeafter"); so.addParam("wmode", "transparent"); so.addParam("quality", "high"); so.write("feature"); 
	}
	
	
	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' }
		});
	}
	
	// this part goes in site.js inside the DOCUMENT READY - DO NOT PUT IT IN TWICE
	$('.accordion-faq h3').click(function() {
		$(this).toggleClass('active').next().toggle('normal');
		return false;
	});
	
	
	$('.exam-hover, .login-hover').parent().hover(function() {
		$(this).children(0).css("display", "block").fadeIn(350, "easeOutExpo");
	}, function() {
		$(this).children(0).fadeOut(250);
	});
	
	
	//remove side picture if editing
	if($('.RadEditor').length) {
		$('.sidepic').remove();
	}
	
	if($("#loader").length) {
		var so = new SWFObject("/portals/0/video/FlashMediaPlayer2.swf", "sotester", "504", "464", "9");
		so.addParam("allowFullScreen", "true");
		so.addParam("flashvars", "&xmlLocation=/portals/0/video/data.xml");
		so.write("loader");
	}
	
	if($("#tests").length) {
		var so = new SWFObject("/portals/0/video/FlashMediaPlayer2.swf", "sotester", "504", "464", "9");
		so.addParam("allowFullScreen", "true");
		so.addParam("flashvars", "&xmlLocation=/portals/0/video/data2.xml");
		so.write("tests");
	}
	
});

//sifr script
function pageScripts(){
var Castellar = {  src: DNN_skinPath + '/flash/Castellar.swf' };
sIFR.activate(Castellar);
	sIFR.replace(Castellar, {
	  selector: 'h1', 
	  wmode: 'transparent', 
	  src:  DNN_skinPath +  '/flash/Castellar.swf', 
	  css: [ '.sIFR-root {color:#004785; font-weight:bold;}']
	});
	
}

//make menu work
function menuShow(menuitem){
    $('.hover').removeClass('hover');
    $(menuitem).addClass('hover');
    $(".topsub > div.nav-wrap").stop().hide();
    $('.topsub').removeClass('topsub');
    $(menuitem).next().css("height", "auto").stop().slideDown(500).parent().addClass("topsub");
}

function OpenChildWin(nurl,nname, nwidth,nheight) {
	popupWin = window.open(nurl, nname, 'scrollbars=1,width=' + nwidth +',height=' + nheight)
}
