
// this should be set to the full path of some transparent GIF 
var TRANSPARENT_IMG_PATH = "/images/layout/transparent.gif";

// fix PNG <img> elements
window.addEvent('domready', function()
{
	var ie6 = (typeof document.addEventListener != 'function');	
	$$("img").each(function(image)
	{
		if(ie6 && image.src.match(/\.png$/i))
		{
			var loadImage = new Image();			
			var src = image.src;
			loadImage.onload = function()
			{
				image.setStyles(
				{
					'filter': 'progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=\'true\', src=\'' + 
						src + '\', sizingMethod=\'scale\')',
					'width': loadImage.width,
					'height': loadImage.height
				});
			};
			loadImage.src = src;
			image.src = TRANSPARENT_IMG_PATH;
		}			
	});
});
		
// Promo column taller than content fix
window.addEvent('domready', function() {
	
	if (!$('flash_content')) {
		
		if ($('community_module') && $('content') && $('promos')) {
			contentHeight = $('content').clientHeight;
			promoHeight = $('promos').clientHeight;
			leftHeight = $('left_column').clientHeight;
			rightHeight = $('right_column').clientHeight;
			moduleHeight = $('community_module').clientHeight;
			
			if (promoHeight > contentHeight && leftHeight < rightHeight) {
				promoHeight -= 36;
				$('content').setStyle('height', promoHeight + 'px');
			}
			else if (leftHeight > rightHeight) {
				adjustedHeight = (leftHeight - moduleHeight) - 30;
				$('content').setStyle('height', adjustedHeight + 'px');
			}
		}
	}
});

// Make all black overlay bars on images transparent
window.addEvent('domready', function() {
	if ($('black_bar')) {
		$$("#black_bar .backdrop")[0].setStyle("opacity", 0.5);
	};
});

// add rollover states for buttons / images
window.addEvent('domready', function() 
{
	$$(".rollover").each(function(element)
	{
		if(!element.src) { return; }
		var originalURL = element.src;
		var hoverURL = originalURL;
		hoverURL = hoverURL.replace(".gif", "_hover.gif");
		hoverURL = hoverURL.replace(".jpg", "_hover.jpg");
		var loader = new Image();
		loader.src = hoverURL;
		element.onmouseover = function() { element.src = hoverURL; };
		element.onmouseout = function() { element.src = originalURL; };
	});
});

// toggles the display of the "gallery groups" in the "Explore" page.
function ToggleGalleryGroup(e) {
    var li = $(e).getParent(); // the li element clicked
    $$('li.group').each(
                function(x) {
                    if (x == li && !x.hasClass('show')) {
                        x.addClass('show');
                    }
                    else {
                        if (!x.hasClass('current')) {
                            x.removeClass('show');
                        }
                    }
                }
            )
    /*if (!li.hasClass('show'))
    li.addClass('show');
    else
    li.removeClass('show');*/
}