
(function($) {
	$.fn.tables = function(options) {
		return this.each(function() {
			$this = $(this);
			$("th:last", $this).addClass("last");
			$("th:first", $this).addClass("first");
			if ($("th", $this).length == 1) {
				var th = $("th", $this);
				th.html("<div>" +  th.html() + "</div>");
				th.css("padding",0);
				$("div", th).eq(0).css("padding","10px 14px 14px").css("border-right","1px solid white")
			}
			$("th", $this).eq(0).parent().next().addClass("first");
			$("tr:even", $this).addClass("alt");
			$("th br", $this).parent().addClass("twolines");
			
			
		});
	};
	
	$.fn.imageDescriptions = function(options) {
		return this.each(function() {
			$this = $(this);
			if ($this.attr("alt") == '') return;
			var imgwidth = $this.width();
			if (imgwidth == 0) {
				 imgwidth = $this.attr("width");
			}
			var tabletowrap = $('<table class="wrapimg"><tr><td class="wrapimgsub"></td></tr><tr><td class="wraptxtsub"></td></tr></table>');
			tabletowrap.insertBefore($this);
			tabletowrap.find('td.wrapimgsub').append($this);
			tabletowrap.eq(0).css("width", imgwidth + "px");

			var s = $this.attr("alt");
			s = s.replace(/\{link to=([^\}]+)\}([^\{]+)\{\/link\}/g, '<a target="_blank" href="$1">$2</a>');
			//$this.after("<p>" + s + "</p>");
			tabletowrap.find('td.wraptxtsub').append(s);
			if($this.css("float") != "none") {
				tabletowrap.css("float", $this.css("float"));
				$this.css("float","none");	
			}
			try {
				if ($this.css("margin") != ''){
					tabletowrap.css("margin", $this.css("margin"));
					$this.css("margin","0");	
				}
			} catch(e){}
			if ($this.hasClass("imagehasfooterright")){
				tabletowrap.addClass("imagehasfooterright");
				$this.removeClass("imagehasfooterright");
			}
			if ($this.hasClass("imagehasfooterleft")){
				tabletowrap.addClass("imagehasfooterleft");
				$this.removeClass("imagehasfooterleft");
			}
		});
	};	
})(jQuery);


var blank = new Image();
blank.src = '/ui/images/blank.gif';

$(document).ready(function() {
   var ie6Browser = (/MSIE ((5\.5)|6)/.test(navigator.userAgent) && navigator.platform == "Win32");
   if (ie6Browser) {
	 // get all pngs on page
	 $('img[src$=.png]').each(function() {
	   if (!this.complete) {
		 this.onload = function() { fixPng(this) };
	   } else {
		 fixPng(this);
	   }
	 });
   }
 });
 
 function fixPng(png) {
   // get src
   var src = png.src;
   // set width and height
   if (!png.style.width) { png.style.width = $(png).width(); }
   if (!png.style.height) { png.style.height = $(png).height(); }
   // replace by blank image
   png.onload = function() { };
   png.src = blank.src;
   // set filter (display original image)
   png.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
 }

