function fixpng(){
	var arVersion = navigator.appVersion.split("MSIE");
	var version = parseFloat(arVersion[1]);
	if ((version >= 5.5) && (document.body.filters) && (version < 7)){
		var png_images = $$('.pngfix');	
		png_images.each(function(element) {
			if(!$(element).hasClass('pngfixed')){
				$(element).addClass('pngfixed');
				var img = $(element);
				var imgID = (img.id) ? "id='" + img.id + "' " : ""
				var imgClass = (img.className) ? "class='" + img.className + "' " : ""
				var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
				var imgStyle = "display:inline-block;" + img.style.cssText 
				if (img.align == "left") imgStyle = "float:left;" + imgStyle
				if (img.align == "right") imgStyle = "float:right;" + imgStyle
				if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
				var strNewHTML = "<span " + imgID + imgClass + imgTitle + " style=\"" + "width:" + img.getProperty('width') + "px; height:" + img.getProperty('height') + "px;" + imgStyle + ";"
				+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
				img.outerHTML = strNewHTML					
			}
		});
	} else {
		$$('.pngfix').addClass('pngfixed');
	}
}

function init(){
	fix();
	fixpng();
}

function show_category(id, button){
	$$('.spotlight_items').each(function(item){
		item.setStyle('display', 'none');
	});
	$(id).setStyle('display', 'block');
	
	$$('.spotlight_selector .categories .category').each(function(item){
		item.removeClass('active');
	});
	$(button).addClass('active');
}

function fix(){
	// fix content height
	var max_height = $('content').getSize().y;
	var correction = 30;
	var found = false;
	$$('.fixheight').each(function(item){
		found = true;
		var height = item.getSize().y;
		if(height > max_height) max_height = height;
	});
	if(found) $('content').setStyle('height', max_height + correction + 'px');
	
	// fix portfolio divider height
	if($('portfolio_divider') != null){
		$('portfolio_divider').setStyle('height', max_height + 0 + 'px');
	}
	
	// fix spotlight height
	max_height = $('content').getSize().y;
	correction = 300;
	found = false;
	$$('.fixheight_spotlight').each(function(item){
		found = true;
		var height = item.getSize().y;
		if(height > max_height) max_height = height;
	});
	if(found) $('content').setStyle('height', max_height + correction + 'px');
	
	// fix footer height
	$('footer').setStyle('display', 'block');
	correction = 40;
	max_height = $('footer_lists').getSize().y - correction;
	found = false;
	$$('.lists ul').each(function(item){
		found = true;
		var height = item.getSize().y;
		if(height > max_height) max_height = height;
	});
	if(found) $('footer_lists').setStyle('height', max_height + correction + 'px');
	
	// portfolio_mouseover
	$$('.portfolio_mouseover').each(function(el){
		el.addEvent('mouseover', function(){
			var title = el.getParent().getParent().getFirst('.title');
			if(title != null) title.addClass('over');
		});
		el.addEvent('mouseleave', function(){
			var title = el.getParent().getParent().getFirst('.title');
			if(title != null) title.removeClass('over');
		});
	});
}

window.addEvent('load', init);

Shadowbox.init();
