function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6.
{
   var arVersion = navigator.appVersion.split("MSIE")
   var version = parseFloat(arVersion[1])
   if ((version >= 5.5) && (document.body.filters)) 
   {
      for(var i=0; i<document.images.length; i++)
      {
         var img = document.images[i]
         var imgName = img.src.toUpperCase()
         if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
         {
            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.width + "px; height:" + img.height + "px;" + imgStyle + ";"
            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
            + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
            img.outerHTML = strNewHTML
            i = i-1
         }
      }
   }    
}

/* FlyFrame */
FlyFrame = function(swf, id, w, h, t, l, ctag) {
	this.attrib = new Array();	
	this.attrib['src'] =  swf;
	this.attrib['width'] = w;
	this.attrib['height'] = h;
	this.attrib['id'] = id;
	this.attrib['top'] = t;
	this.attrib['left'] = l;
	this.params = new Array();
	this.params['wmode'] = 'transparent';
	this.params['swLiveConnect'] = 'true';
	this.params['allowScriptAccess'] = 'transparent';
	this.params['quality'] = 'high';
	this.params['scale'] = (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length)?'noscale':'noscale';
	this.params['loop'] = 'no';
	this.params['menu'] = 'false';
	this.params['salign'] = 'lt';
	this.position = (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length)?'fixed':'absolute';
	this.clicktag = ctag;
}

/* FlyFrame write */
FlyFrame.prototype.ff_write = function() {
    var flashHTML = "<div id=\""+flyframe.attrib['id']+"_div\" style=\"visibility:hidden;position:"+this.position+";top:"+this.attrib['top']+"px;left:"+this.attrib['left']+"px;width:"+this.attrib['width']+";height:"+this.attrib['height']+";z-index:102;\">";
    if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) { 
        flashHTML += '<embed type="application/x-shockwave-flash" src="'+ this.attrib['src'] +'?clickTag='+this.clicktag+'" width="'+ this.attrib['width'] +'" height="'+ this.attrib['height'] +'" id="'+ this.attrib['id'] + '" name="'+ this.attrib['id'] +'"';
        var  param = this.params;
        for(var key in param) { 
        	flashHTML += ' '+ key +'="'+ param[key] +'"'; 
        }
        flashHTML += '></embed>';
    } else { // PC IE
		flashHTML += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+ this.attrib['width'] +'" height="'+ this.attrib['height'] +'" id="'+ this.attrib['id'] +'">';
		flashHTML += '<param name="movie" value="'+ this.attrib['src'] +'?clickTag='+this.clicktag+'" />';
        var  param = this.params;
        for(var key in param) { 
			flashHTML += '<param name="' + key + '" value="' + param[key] + '" />';
		}
		flashHTML += '</object>';
    }
    flashHTML += "</div>";
    return flashHTML;
}

//Olde Fav MacroMedia Functions
function MM_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++)
	  x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) 
	  x=document.getElementById(n); 
  return x;
}

//Olde
function MM_showHideLayers()  {
	var i,p,v,obj,args=MM_showHideLayers.arguments;
	for (i=0; i<(args.length-2); i+=3) {
		if ((obj=MM_findObj(args[i]))!=null)  {
			v=args[i+2];
			if (obj.style) {
				obj=obj.style;
				v=(v=='show')?'visible':(v='hide')?'hidden':v; 
			}
			obj.visibility=v; 
		}
	}
}

function flyframe_init() { 
	flyframe_start();
}

function flyframe_start() {
	MM_showHideLayers(flyframe.attrib['id']+'_div', '', 'show');
}

function flyframe_close() {
	MM_showHideLayers(flyframe.attrib['id']+'_div', '', 'hide');
	MM_showHideLayers('mask', '', 'hide');
}

function flyframe_end() {
	MM_showHideLayers(flyframe.attrib['id']+'_div', '', 'hide');
	MM_showHideLayers('mask', '', 'hide');
}

function flyframe_ready() {
	if (typeof(window[flyframe.attrib['id']]) != "undefined") {
		flyframe_init()
	} else {
		setTimeout('flyframe_ready()', 30);
	}
}

function flyframe_click() {
	return false;
	//window.open(flyframe_link,flyframe_target,flyframe_wndparams);
}

var flyframe = null;

function showOverlay() {
	flyframe = new FlyFrame('/assets/projects/diesel-heaven/feather.swf', 'flyframe', '100%', '100%', 0, 0, 'http://www.diesel.com/');	
	document.write(flyframe.ff_write());
	setTimeout('flyframe_ready()', 30);
}

var cookie_name = "diesel-overlay";
var cookie = readCookie(cookie_name);
if (show_overlay_onload && cookie) {
	console.log("do nothing");
	document.getElementById("mask").style.display = "none";
} else {
	showOverlay();
	console.log("show overlay");
}
createCookie(cookie_name, "true", 999);