$(document).ready(function(){
	
	$("#defenders_tab").click(function () {
		$(this).css("color", "#fff");
		$("#flossing_tab").css("color", "#201D51");
		$("#brushing_tab").css("color", "#201D51");
	});
	
	$("#brushing_tab").click(function () {
		$(this).css("color", "#fff");
		$("#flossing_tab").css("color", "#201D51");
		$("#defenders_tab").css("color", "#201D51");
	});
	
	$("#flossing_tab").click(function () {
		$(this).css("color", "#fff");
		$("#defenders_tab").css("color", "#201D51");
		$("#brushing_tab").css("color", "#201D51");
	});
	
});

function openPreview(id)
{
	grayOut(true);
	$('#preview_'+id).slideDown();
	$('#module1').css({'display' : 'none'});
	$('#module2').css({'display' : 'none'});
	return false;
}

function closePreview(id)
{
	grayOut(false);
	$('#preview_'+id).hide();
	$('#module1').css({'display' : 'inline'});
	$('#module2').css({'display' : 'inline'});
	return false;
}

function swapNoGrey(show_id, hide_id)
{
	$('#preview_'+hide_id).css({'display' : 'none'});
	$('#preview_'+show_id).css({'display' : 'inline'});
	return false;
}

function grayOut(vis, options) {
	
	// Props: http://www.hunlock.com/blogs/Snippets:_Howto_Grey-Out_The_Screen
  	var options = options || {}; 
	  var zindex = options.zindex || 50;
	  var opacity = options.opacity || 40;
	  var opaque = (opacity / 100);
	  var bgcolor = options.bgcolor || '#ffffff';
	  var dark=document.getElementById('darkenScreenObject');
	  if (!dark) {
	    // If you are getting errors in IE see: http://support.microsoft.com/default.aspx/kb/927917
	    var tbody = document.getElementsByTagName("body")[0];
	    var tnode = document.createElement('div');           // Create the layer.
	        tnode.style.position='absolute';                 // Position absolutely
	        tnode.style.top='0px';                           // In the top
	        tnode.style.left='0px';                          // Left corner of the page
	        tnode.style.overflow='hidden';                   // Try to avoid making scroll bars            
	        tnode.style.display='none';                      // Start out Hidden
	        tnode.id='darkenScreenObject';                   // Name it so we can find it later
	    tbody.appendChild(tnode);                            // Add it to the web page
	    dark=document.getElementById('darkenScreenObject');  // Get the object.
	  }
  	if (vis) {
	    /*if( document.body && ( document.body.scrollWidth || document.body.scrollHeight ) ) {
		        var pageWidth = document.body.scrollWidth+'px';
		        var pageHeight = document.body.scrollHeight+'px';
		    } else if( document.body.offsetWidth ) {
		      var pageWidth = document.body.offsetWidth+'px';
		      var pageHeight = document.body.offsetHeight+'px';
		    } else {
		       var pageWidth='100%';
		       var pageHeight='100%';
		}*/
		
		if (window.innerHeight) // Firefox 
		{
			pageWidth = window.innerWidth + window.scrollMaxX + "px";
			pageHeight = window.innerHeight + window.scrollMaxY + "px";
			//alert(window.innerWidth + "\n" + window.innerHeight + "\n" + "if1\n" + window.ScrollMaxX + "\n" + window.ScrollMaxY);
		}
		else if (document.body.scrollHeight > document.body.offsetTop) // all but Explorer Mac
		{
			pageWidth = document.body.scrollWidth + "px";
			pageHeight = document.body.scrollHeight + "px";
			//alert(pageWidth + "\n" + pageHeight + "\nif2\n" + document.body.scrollWidth + "\n" + document.body.scrollHeight);
		} 
		else // works in Explorer 6 Strict, Mozilla (not FF) and Safari
		{
			pageWidth = document.body.offsetWidth + document.body.offsetLeft + "px"; 
			pageHeight = document.body.offsetHeight + document.body.offsetTop + "px"; 
			//alert(pageWidth + "\n" + pageHeight + "\nif3\n" + document.body.offsetWidth + "\n" + document.body.offsetHeight + "\n" + document.body.offsetLeft + "\n" + document.body.offsetTop);
		}
		
	    //set the shader to cover the entire page and make it visible.
	    dark.style.opacity=opaque;                      
	    dark.style.MozOpacity=opaque;                   
	    dark.style.filter='alpha(opacity='+opacity+')'; 
	    dark.style.zIndex=zindex;        
	    dark.style.backgroundColor=bgcolor;  
	    dark.style.width= pageWidth;
	    dark.style.height= pageHeight;
	    dark.style.display='block';                          
	  } else {
	     dark.style.display='none';
	  }
}
