jQuery(document).ready(function(){
	/* remove box from links */
	jQuery("a").focus(function(){
		this.blur();
	});
	//get search bar pretty
	setupSearch();
	//append some divs for spacing purposes in nav
	padIt();
	//parent nav elements go to url of first child
	//getChildUrl();
	
	currentPage();
	
	//jQuery("#subnav a").after("<span>&#160;|&#160;</span>");
	
	if(jQuery("#subnav").children().size() > 0) {
		jQuery('.subnav').show();
		jQuery(".content").css("padding-top", "380px");
	}else{
		jQuery('.subnav').hide();
	}
	
	jQuery("#tab174").siblings(".divider").css({"top":"-28px"});
	
	/*jQuery("a.active").mouseover(function(){menuShow(this); return(false);});*/
	
	/*jQuery('#content').mouseover(function(){
		jQuery(".topsub > p.active").stop().hide().removeClass("topsub");
	});*/
	
	jQuery('.empty').mouseover(function() {
		jQuery(".topsub > p.active").stop().hide().removeClass("topsub");
	});
	
	jQuery('.abscontainer').hover(
		function() {
			jQuery('a.active', this).next().show();
		},
		function() {
			jQuery('a.active', this).next().hide();
		}
	);
	
	//underline current main menu item
	//jQuery(".sfbreadcrumb > a").append("<div class='liner'></div>");
	//var wid = jQuery('.SelectedTab').parent().parent().find("a img").width();
	//jQuery(".liner").css({'width':wid});
	
	jQuery('.subnav2 a').click(function() {
		var _link = jQuery(this).attr("href");
		var _container = "#" + jQuery(this).attr("rel");
		var _url = _link + " " + _container;
		ajaxLoad(_url);
		return false;
	});
	
	//jQuery('a.active').click(function() { return false });
	
});

function ajaxLoad(u) {
	jQuery("#ajax-page").load(u);	
}

//make menu work
/*function menuShow(menuitem){
	jQuery(".topsub > p.active").stop().hide().removeClass("topsub");
	jQuery(menuitem).next().css("height", "auto").stop().show().parent().addClass("topsub");
}*/

function pageScripts(){
var P22Corinthia = {  src: DNN_skinPath + 'P22Corinthia.swf'};
sIFR.activate(P22Corinthia);
sIFR.replace(P22Corinthia, {
  selector: 'h1', 
  wmode: 'transparent', 
  src:  DNN_skinPath +  'P22Corinthia.swf', 
  css: [ '.sIFR-root {color:#003e7e;font-size:48px;text-indent:5px;}']
});
}

function currentPage() {
	jQuery(".currentpage").css({"text-decoration": "underline", "font-weight":"bold"});
	jQuery("p.active:has(a.currentpage)").parent().append("<div class='divider'></div>");
	jQuery(".currentpage + .empty").parent().append("<div class='divider'></div>");
}


function setupSearch() {
	jQuery("#dnn_dnnSEARCH_txtSearch").val("Search text here...").focus( function() {
		jQuery(this).val(""); 
	}).blur( function() {
		if(jQuery(this).val()==""){
			jQuery(this).val("Search text here...");
		}
	});	
}


function padIt() {
	jQuery("#tab174").parent().append("<div class='buff'></div>");
	jQuery("#tab166").parent().append("<div class='buff2'></div>");
}


/*function getChildUrl() {
	jQuery("a.active").each(function() {
		var url;
		url = jQuery(this).next().children(":first-child").attr("href");
		jQuery(this).attr("href", url);
	});
	
	jQuery("a.active").onload(function() {
		var url;
		url = jQuery(this).next().children(":first-child").attr("href");
		jQuery(this).attr("href", url);
	});
	
	//removed this line from snapsis menu.template.txt to resolve issue w/o jquery
	IIF({Page.HasChildren}=true,href="")
}*/

/*function showSubnav() {
	//figure out what page we're on
	var curr = window.location.href;
	jQuery("p.active a").attr("href", curr).addClass('curr');
	//jQuery("p.active(:has(a).attr('href',"+curr+"))").parent().hide();//.addClass('curr');
	var subnav;
	subnav = jQuery(".curr").html();
	jQuery(".subnav").html(subnav);
}*/


//old jQuery code for old Nav system

/*jQuery("#Navigation > ul").superfish({
		hoverClass:"hover",
		pathClass:"SelectedTab",
		pathLevels: 2,
		delay:1000,
		animation:{height:"show"},
		speed:"normal",
		oldJquery:false,
		disableHI:false,
		onInit:function () {},
		onBeforeShow:function () {},
		onShow:function () {jQuery(this).addClass('opened');},
		onHide:function () {jQuery(this).removeClass('opened');}
	/*}).find(">li:has(ul)").mouseover(function () {
		jQuery("ul", this).bgIframe({opacity:true});
	}).find("a").focus(function () {
		jQuery("ul", jQuery("#Navigation > ul >li:has(ul)")).bgIframe({opacity:true});
	});*/
	/*Preload the menu backgrounds
	menuImage = new Image(); 
	menuImage.src = DNN_skinPath + "images/about_hover.jpg";
	menuImage1 = new Image(); 
	menuImage1.src = DNN_skinPath + "images/contact_hover.jpg";
	menuImage2 = new Image(); 
	menuImage2.src = DNN_skinPath + "images/cosmdent_hover.jpg";
	menuImage3 = new Image(); 
	menuImage3.src = DNN_skinPath + "images/financial_hover.jpg";
	menuImage4 = new Image(); 
	menuImage4.src = DNN_skinPath + "images/general_hover.jpg";
	menuImage5 = new Image(); 
	menuImage5.src = DNN_skinPath + "images/home_hover.jpg";
	menuImage6 = new Image(); 
	menuImage6.src = DNN_skinPath + "images/login_hover.jpg";
	menuImage7 = new Image(); 
	menuImage7.src = DNN_skinPath + "images/newpatient_hover.jpg";
	menuImage8 = new Image(); 
	menuImage8.src = DNN_skinPath + "images/ortho_hover.jpg";
	menuImage9 = new Image(); 
	menuImage9.src = DNN_skinPath + "images/ourdoc_hover.jpg";
	menuImage10 = new Image(); 
	menuImage10.src = DNN_skinPath + "images/pedia_hover.jpg";	
	menuImage11 = new Image(); 
	menuImage11.src = DNN_skinPath + "images/request_hover.jpg";	
	menuImage12 = new Image(); 
	menuImage12.src = DNN_skinPath + "images/submenubg.jpg";
	menuImage12 = new Image(); 
	menuImage12.src = DNN_skinPath + "images/community_hover.jpg";*/
	
	/*jQuery("#Navigation > .superfish > li > a").hover(function(){
		jQuery('.sfbreadcrumb').removeClass('sfbreadcrumb');
		jQuery(this).addClass('sfbreadcrumb');
	});
	
	
	jQuery("#Navigation .Level0 > li:last").addClass("last");
	jQuery("#Navigation .Level1").find("li:last").addClass("last");*/
	
	
		/*jQuery(".Level0 a img").rollover("_hover");
	//jQuery('.SelectedTab').parent().parent().find("a").append("<div class='liner'></div>");
	jQuery(".sfbreadcrumb > a").append("<div class='liner'></div>");
	var wid = jQuery('.SelectedTab').parent().parent().find("a img").width();
	jQuery(".liner").css({'width':wid});
	*/
