function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


// JavaScript Document
function MM_showHideLayers() { //v9.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
  with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'block':(v=='hide')?'none':v; }
    obj.display=v; }
}

// Image Rollovers  
function initRollovers() {
    if (!document.getElementById) return
      
    var aPreLoad = new Array();
    var sTempSrc;
    var aImages = document.getElementsByTagName('img');
    for (var i = 0; i < aImages.length; i++) {
                if (aImages[i].className == 'roll') {
                    var src = aImages[i].getAttribute('src');
                    var ftype = src.substring(src.lastIndexOf('.'), src.length);
                    var hsrc = src.replace(ftype, '_r'+ftype);

                    aImages[i].setAttribute('hsrc', hsrc);
                    
                    aPreLoad[i] = new Image();
                    aPreLoad[i].src = hsrc;
                    
                    aImages[i].onmouseover = function() {
                                sTempSrc = this.getAttribute('src');
                                this.setAttribute('src', this.getAttribute('hsrc'));
                    }
                    aImages[i].onmouseout = function() {
                                if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_r'+ftype, ftype);
                                this.setAttribute('src', sTempSrc);
                    }
                }
    }
}
jQuery(document).ready(function($){ initRollovers();});


if(window.jQuery) {	// Check for jQuery only, so no errors show up on non-jQueried pages.
jQuery(function() {
	
/* --------------------------------------------------
/ Default DNN Modules
-------------------------------------------------- */

	// Check for module selector
	if(jQuery("table.ControlPanel").length>0) {
		// make the new module the default
		jQuery("table.ControlPanel option[value=78]").attr("selected", "selected");
	}
	

/* --------------------------------------------------
/ Extras Tabs	
-------------------------------------------------- */
	
	if(jQuery("#tabH1").length>0) {
	
	// No Conflicts, bro. Peace.
	jQuery.noConflict();

	// Just some functions and variables
	var GoldPage = jQuery("#dnn_goldContent");
	var SilverPage = jQuery("#dnn_silverContent");
	var BronzePage = jQuery("#dnn_bronzeContent");
	
	var GoldTab = jQuery("#goldTab");
	var SilverTab = jQuery("#silverTab");
	var BronzeTab = jQuery("#bronzeTab");
	
	var TabHeader = jQuery("#tabH1");
	
	function ClearActive() {
		jQuery("#tabContainer a").removeClass("active");	
	}
	
	function HideTabs() {
		GoldPage.hide();
		SilverPage.hide();
		BronzePage.hide();
		ClearActive();
	}
	
	// Check if we're in Hospitals or Extras section and chuck the difference in to a variable
	if(TabHeader.text() == "Gold Extras") {
		var TabHeaderEnd = " Extras";
	} else if (TabHeader.text() == "Gold Hospital") {
		var TabHeaderEnd = " Hospital";
	}

	// Hide EVERYTHING!
	HideTabs();

	// Check for hashtag
	function tabHashCheck(hash) {
		
		// If no hash value is passed to this function, grab it from the URL
		if(hash == null) {
			var hash = window.location.href.slice(window.location.href.indexOf('#') + 1);
		}
		
		// Compare hash to values and do the appropriate dance
		if (hash == "gold") {
			HideTabs();
			GoldPage.show();
			GoldTab.addClass("active");
			TabHeader.text("Gold"+TabHeaderEnd);			
		} else if (hash == "silver") {
			HideTabs();
			SilverPage.show();
			SilverTab.addClass("active");
			TabHeader.text("Silver"+TabHeaderEnd);			
		} else if (hash == "bronze") {
			HideTabs();
			BronzePage.show();
			BronzeTab.addClass("active");
			TabHeader.text("Bronze"+TabHeaderEnd);
		}
	}
	
	// If no hashtag is available, just show first tab, yo.
	GoldPage.show();
	GoldTab.addClass("active");
	
	// Show tab if hashtag is available
	tabHashCheck();
	
	// Clicky Buttons
	jQuery("#tabContainer a").click(function(e) {
		
		// Stopping it from doing what it does
		e.preventDefault;
		
		// Sending the HREF value to the function, minus the #
		var hash = jQuery(this).attr("href");
		hash = hash.substring(1, hash.length);
		tabHashCheck(hash);
	});
	
	// Adding Clear Elements
	GoldPage.append("<div class='clear'></div>");
	SilverPage.append("<div class='clear'></div>");
	BronzePage.append("<div class='clear'></div>");
	
	// Bonuse Round!
	jQuery(".itsGold").click(function(e) {
		e.preventDefault();
		HideTabs();
		GoldPage.show();
		GoldTab.addClass("active");
		TabHeader.text("Gold"+TabHeaderEnd);
		return false;
	});
	jQuery(".itsSilver").click(function(e) {
		e.preventDefault();
		HideTabs();
		SilverPage.show();
		SilverTab.addClass("active");
		TabHeader.text("Silver"+TabHeaderEnd);
		return false;
	});
	jQuery(".itsBronze").click(function(e) {
		e.preventDefault();
		HideTabs();
		BronzePage.show();
		BronzeTab.addClass("active");
		TabHeader.text("Bronze"+TabHeaderEnd);
		return false;
	});
	
	
	// Natural Plus Show/Hide
	jQuery(".naturalPlusContent").show();
	jQuery(".naturalPlusTab").click(function(e) {
		e.preventDefault;
		jQuery(".naturalPlusContent").toggle();
	});
	
	//Click on menu items for iPhone drop down menu to show
	jQuery("#nav li a.ArrowPointer").click(function(){
		jQuery(this).parent('li').children('ul').css({'left': 'auto', 'z-index': '99999'});
		jQuery(this).parent('li').siblings('li').children('ul').css({'left': '-9999px', 'z-index': '11112'});
	});
	
	// Search blur/focus
	jQuery("#search input[type=text]").val("Search").focus(function() {
		if(this.value=='Search'){this.value='';}
	});
	jQuery("#search input[type=text]").blur(function() {
		if(this.value==''){this.value='Search';}
	});
	
	}

});
}

