﻿function showhide(layer_ref, link_ref, link_text) {
	var visibleState;
	var flashVisibileState;
	var linkText;
	var layerReference = $get(layer_ref);
	var flashLayerReference = $get('flashWrapper');
	
	if (layerReference.currentStyle) { 
		visibleState = layerReference.currentStyle.display;
		if(flashLayerReference)
		{
			flashVisibileState = flashLayerReference.currentStyle.display;
		}
	} else if (window.getComputedStyle) {
		var currentComputedStyle = window.getComputedStyle(layerReference, "");
		visibleState = currentComputedStyle != null ? currentComputedStyle.display : 'none';
		if(flashLayerReference)
		{
			var flashCurrentComputedStyle = window.getComputedStyle(flashLayerReference, "");
			flashVisibileState = flashCurrentComputedStyle != null ? flashCurrentComputedStyle.display : 'none';
		}
	}

	if (visibleState == 'block' || visibleState == '') {
		visibleState = 'none';
		if(flashLayerReference)
		{
			flashVisibileState = 'block';
		}
		if (link_text == '') {
			linkText = 'Show Details';
		} else {
			linkText = 'Show ' + link_text;
		}
	} else {
		visibleState = 'block';
		if(flashLayerReference)
		{
			flashVisibileState = 'none';
		}
		if (link_text == '') {
			linkText = 'Hide Details';
		} else {
			linkText = 'Hide ' + link_text;
		}
	}

	layerReference.style.display = visibleState;
	if(flashLayerReference)
	{
		flashLayerReference.style.display = flashVisibileState;
	}
	if (link_ref && link_ref != '') {
		$get(link_ref).innerHTML = linkText;
	}
}
