function findObj(n, d) {
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function showHideLayers() {
  var i,p,v,obj,args=showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'':(v=='hide')?'none':v; }
    if(v=="none") {
      showContent();  
    }
  }
}
function showContent() {
	if(!$.boat.functions.isIE6()) {
    $("#logo").fadeIn("slow", function() {});
	}
}

(function($) {
  var $boat;
  $.boat = {
		constants: {
			blankImage: "gui/img/blank.gif"
		},
		functions: {
      isIE6: function() {
        return ($.browser.msie && $.browser.version == "6.0") ? true : false;
      },
			pngFix: function(callback) {
			  var elements = new Array();
			  $(".alpha").each(function() {
			    elements.push(this);
			  });
			  var pattern = /\.png/i;
			  var i = elements.length;
			  while(i-- > 0) {
			   var element = elements[i];
			   var elementStyle = element.style;
			   if(element.src && element.src.match(pattern) && !elementStyle.filter) {
			      elementStyle.height = element.height;
			      elementStyle.width = element.width;
			      elementStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + element.src + "', sizingMethod='crop')";
			      element.src = $.boat.constants.blankImage;
			    } else {
			      var elementBackground = element.currentStyle.backgroundImage;
			      if(elementBackground.match(pattern)) {
			        var imagePath = elementBackground.split('"');
			        var backgroundRepeat = (element.currentStyle.backgroundRepeat == "no-repeat") ? "crop" : "scale";
			        elementStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + imagePath[1] + "', sizingMethod='" + backgroundRepeat + "')";
			        elementStyle.backgroundImage = "none";
			        var elementChildren = element.getElementsByTagName("*");
			        if(elementChildren) {
			          var iC = elementChildren.length;
			          if(element.currentStyle.position != "absolute") {
			            elementStyle.position = "static";
			          }
			          while(iC-- > 0) {
			            if(!elementChildren[iC].style.position) {
			              elementChildren[iC].style.position = "relative";
			            }
			          }
			        }
			      }
			    }
			  }
				callback();
			}
		}
	};
  $(function() {
		showHideLayers("document","","hide");
		if($.boat.functions.isIE6()) {
	    try {
	      document.execCommand('BackgroundImageCache', false, true);
	    } catch(e) {}
	    $.boat.functions.pngFix(function() {
				$(".alpha").css("visibility","visible");
			});
		}
  });
})(jQuery);