var PATH_TO_DIY_NAV_SWF = "/asa/wce/SWF/curl_163x280.swf";
// PATH_TO_DIY_NAV_SWF = "/MasterCard/DIY/swf/curl_163x280.swf";

	function getCurrentProject() {
		retVal = GetCookie( "currentProject" );
		retVal = ( retVal ) ? retVal : 0;
		return retVal;
	}
	
	function getCurrentTab() {
		retVal = GetCookie( "currentTab" );
		retVal = ( retVal ) ? retVal : 0;
		return retVal;
	}
	
	function initDIYNav() {
		var theTop = "107";
		currentTab = 0;
		currentProject = 0; 

		if( document.all ) {
			theTop = "105";
		}

		include_css( "div#DIYNavContainer { position: absolute; right: 0; top: " + theTop + "px; }" );
		var MyObjRewrite = new ObjectRewrite( PATH_TO_DIY_NAV_SWF + '?currentTab=' + getCurrentTab() + '&currentProject=' + getCurrentProject(), 163, 280, 7 );
      	MyObjRewrite.prepForFlash();
		var flashCode = MyObjRewrite.getHTML();
		document.write( "<div id='DIYNavContainer'>" +  flashCode  + "</div>" );
	}

//--------------------------------------------------------------------------------------------------------------	
// Utils.js, ActiveXFix.js and Cookies.js
//--------------------------------------------------------------------------------------------------------------	

// Utils.js
function include_css( styles ) {
	var styleTag = document.createElement("style");
	styleTag.setAttribute( "type", "text/css" );
	if( styleTag.styleSheet ) { // IE only
		styleTag.styleSheet.cssText = styles;
	} else { // w3c standard
		var stylesNode = document.createTextNode( styles );
		styleTag.appendChild( stylesNode );
	}
	document.getElementsByTagName("head")[0].appendChild( styleTag );
}

// Cookies.js

var today = new Date();
//expires in a year....
var expiry = new Date(today.getTime() + 365 * 24 * 60 * 60 * 1000);

function getCookieVal (offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1) { endstr = document.cookie.length; }
	return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name) {
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen) {
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg) {
			return getCookieVal (j);
			}
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break; 
		}
	return null;
}

function DeleteCookie (name,path,domain) {
	if (GetCookie(name)) {
		document.cookie = name + "=" +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		"; expires=Thu, 01-Jan-70 00:00:01 GMT";
		}
}

function SetCookie (name,value,expires,path,domain,secure) {
	// alert("SetCookie('" + name + "', '" + value + "');");
  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "; expires=" + expiry.toGMTString()) +
    ((path) ? "; path=" + path : "; path=/") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
}

// ActiveXFix.js

function ObjectRewrite(URL, width, height, version, bgcolor, wmode, id) {
	this.URL = URL;
	this.height = height;
	this.width = width;
	this.version = 7;
	this.objectHTML = "";
	if(version) {
		this.version = version;
	}
	this.bgcolor = "ffffff";
	if(bgcolor) {
		this.bgcolor = bgcolor;
	}
	this.wmode = "transparent";
	if(wmode) {
		this.wmode = wmode;
	}
	this.id = "__newObject__";
	if(id) {
		this.id = id;
	}
}

ObjectRewrite.prototype = {
	"prepForFlash": function() {
		this.objectHTML = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + this.version + ',0,0,0" width="' + this.width + '" height="' + this.height + '" id="' + this.id + '">';
		this.objectHTML += '<param name="allowScriptAccess" value="sameDomain" />';
		this.objectHTML += '<param name="movie" value="' + this.URL + '" />';
		this.objectHTML += '<param name="menu" value="false" />';
		this.objectHTML += '<param name="quality" value="best" />';
		this.objectHTML += '<param name="wmode" value="' + this.wmode + '" />';
		this.objectHTML += '<param name="bgcolor" value="' + this.bgcolor + '" />';
		this.objectHTML += '<embed src="' + this.URL + '" quality="high" bgcolor="' + this.bgcolor + '" width="' + this.width + '" height="' + this.height + '" name="' + this.id + '" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" wmode="' + this.wmode + '" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
		this.objectHTML += '</object>';
	},
	"getHTML": function() {
		return this.objectHTML;
	},
	"default_Image": function(img, alt) {
		this.testForPlugin = true;
		this.defaultImage = img;
		this.defaultImageAltText = alt;
	},
	"write": function() {
		document.open();
		document.write(this.objectHTML);
		document.close();
	}
}

var showNav = GetCookie("showDIYNav");
if( showNav == "true" ) {
	initDIYNav();
}