function toggleLayer( layerVar ) {  
	var elem, vis;  
	if( document.getElementById ) // this is the way the standards work  
		elem = document.getElementById( layerVar );  
	else if( document.all )     
		elem = document.all[layerVar];  
	else if( document.layers )   
		elem = document.layers[layerVar];  
	vis = elem.style;
	if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)    
		vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';  
	vis.display = (vis.display==''||vis.display=='block')?'none':'block';
};

/* jquery on ready event */
/* SEE MORE EXPANDING DIV */
/* replaces the plus graphic with a minus */


// jQuery Ready Event
// ------------------
$j(document).ready(function(){
$j("div.expanding a.see_more").click(function(event) {
		event.preventDefault();		
		if ($j(this).parents("div.expanding").children("div.more").css("display") == 'none') {
			$j(this).removeClass('see_more').addClass('see_less').parents("div.expanding").children("div.more").show("fast");		
		} else {
			$j(this).removeClass('see_less').addClass('see_more').parents("div.expanding").children("div.more").hide("fast");			
		}		
	});

 });


function mailpage() {
	mail_str = "mailto:?subject=Check out " + document.title;
	mail_str += "&body=I thought you might be interested in the " + document.title;
	mail_str += ". You can view it at, " + window.location.href; 
	window.location.href = mail_str;
}

function XHR() {
 var xhr;
 try {
  xhr = new XMLHttpRequest();
 } catch (e) {
  try {
   xhr = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (e) {
   try {
    xhr = new ActiveXObject("Microsoft.XMLHTTP");
   } catch (e) {
    return false;
   }
  }
 }
 return xhr;
};
 
function launchJumpFacebox(e) {
 if (e.preventDefault) {
  e.preventDefault();
  } 
  else {
   e.returnValue = false;
}
   var targ;
   if (!e) var e = window.event;
   if (e.target) targ = e.target;
   else if (e.srcElement) targ = e.srcElement;
   if (targ.nodeType == 3) // defeat Safari bug
   targ = targ.parentNode;
 var xhr = new XHR();
 //you probably want to populate the option value with the entire url, if not we can reconstruct
var select = document.getElementById(targ.id);
var url = select.options[select.selectedIndex].value;
 xhr.open("GET", url, true);
 xhr.onreadystatechange = function()
 {
  if (xhr.readyState == 4)
  {
   jQuery.facebox(xhr.responseText);
  }
 }
 xhr.send(null);
}
//	What's This? Tooltips
//	---------------------
	// Hide tooltips by default.
	$j("div.whats_this_tooltip").hide();
	// What's This? Click Handler
	$j("a.whats_this").click(function(){
		if ($j(this).hasClass("keep_whats_this")) {
			var whats_this_tooltip = $j(this).parents("div.line").next("div.whats_this_tooltip.keep_whats_this");
			// Hide any other tooltips first.
			$j("div.whats_this_tooltip").hide();
			whats_this_tooltip.show();
			// Calculate where to position the tooltip.
			var offset = $j(this).offset();
			var height = whats_this_tooltip.height();
			var positionTop = offset.top - height;
			var width = $j(this).width();
			var positionLeft = offset.left - 140 + Math.round(width/2);
			whats_this_tooltip.css("top",positionTop+"px");
			whats_this_tooltip.css("left",positionLeft+"px");
			// Clicking on the body closes the tooltip.
			$j("body").click(function(){
				$j("div.tab_close_order").hide();
				whats_this_tooltip.hide();
				$j(this).unbind("click");
			});
		} else if($j(this).next().hasClass("whats_this_tooltip")){

			var whats_this_tooltip = $j(this).next();

			// Hide any other tooltips first.
			$j("div.whats_this_tooltip").hide();
			$j(this).next().show();
			// Calculate where to position the tooltip.
			var offset = $j(this).offset();
			var height = $j(this).next().height();
			var positionTop = offset.top - height;
			var width = $j(this).width();
			var positionLeft = offset.left - 140 + Math.round(width/2);
			// Set the x,y position of the tooltip.
			$j(this).next().css("top",positionTop+"px");
			$j(this).next().css("left",positionLeft+"px");
			// Clicking on the body closes the tooltip.
			$j("body").click(function(){
				$j("div.whats_this_tooltip").hide();
				$j(this).unbind("click");
			});
		}

		// Added by HUGE on 03/27/2009 to recalculate positioning for the
		// new "your_coupon" tooltip.
		if (whats_this_tooltip.hasClass("your_coupon")) {
			positionLeft = 90 - (whats_this_tooltip.width() / 2);
			positionTop = 27 - height;
		}

		whats_this_tooltip.css("top",positionTop+"px");
		whats_this_tooltip.css("left",positionLeft+"px");
		whats_this_tooltip.show();

		return false;
	});
	// Tooltip "close" button.
	$j("div.whats_this_tooltip a.close").click(function(){
		$j(this).parents().find("div.whats_this_tooltip").hide();
		return false;
	});