var MM_HasFlashVersion = true;
function MM_CheckFlashVersion(reqVerStr,msg){
  with(navigator){
    var isIE  = (appVersion.indexOf("MSIE") != -1 && userAgent.indexOf("Opera") == -1);
    var isWin = (appVersion.toLowerCase().indexOf("win") != -1);
    if (!isIE || !isWin){  
      var flashVer = -1;
      if (plugins && plugins.length > 0){
        var desc = plugins["Shockwave Flash"] ? plugins["Shockwave Flash"].description : "";
        desc = plugins["Shockwave Flash 2.0"] ? plugins["Shockwave Flash 2.0"].description : desc;
        if (desc == "") flashVer = -1;
        else{
          var descArr = desc.split(" ");
          var tempArrMajor = descArr[2].split(".");
          var verMajor = tempArrMajor[0];
          var tempArrMinor = (descArr[3] != "") ? descArr[3].split("r") : descArr[4].split("r");
          var verMinor = (tempArrMinor[1] > 0) ? tempArrMinor[1] : 0;
          flashVer =  parseFloat(verMajor + "." + verMinor);
        }
      }
      // WebTV has Flash Player 4 or lower -- too low for video
      else if (userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 4.0;
 
      var verArr = reqVerStr.split(",");
      var reqVer = parseFloat(verArr[0] + "." + verArr[2]);
  
      if (flashVer < reqVer){
		MM_HasFlashVersion = false;
        if (confirm(msg))
          window.location = "http://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash";
      }
    }
  } 
}

/* utility functions */
var pm_Initialized = false;
var pm_InitCB = null;

function pm_onload() {
	if (!pm_Initialized) {
		MM_CheckFlashVersion('8,0,0,0','Content on this page requires a newer version of Adobe Flash Player. Do you want to download it now?')
		pm_Initialized = true;
		if (pm_InitCB)
			pm_InitCB();
	}
}

function pm_getOffsetTop(ofsobj, ofs) {
	var ofsTop = ofs;
	
	while (ofsobj.offsetParent != null) {
		ofsTop += ofsobj.offsetTop;
		ofsobj = ofsobj.offsetParent;
	}
	return ofsTop;
}

function pm_getOffsetLeft(ofsobj, ofs) {
	var ofsLeft = ofs;
	
	while (ofsobj.offsetParent != null) {
		ofsLeft += ofsobj.offsetLeft;
		ofsobj = ofsobj.offsetParent;
	}
	return ofsLeft;
}

function pm_showHideDropDowns(elm, visible) {
	var elm = elm || document;
	var elements;
	var i;
	elements = elm.getElementsByTagName("select");
	for (i=0; i<elements.length; i++)
		elements[i].style.visibility = (visible ? "visible" : "hidden");
}

function pm_showProgress(id, visible) {
	var obj = document.getElementById(id);
	var objT = document.getElementById(id + "-text");

	if (obj) {
		if (visible && (obj.className == "noprogress")) {
			// hide dropdowns for IE 5/6
			if (tt_ie56)
				pm_showHideDropDowns(obj.parentNode, false);
				
			// grab parent's dimension
			obj.style.top = "0px";
			obj.style.left = "0px";
			obj.style.width = (obj.parentNode.offsetWidth) + "px";						
			obj.style.height = (obj.parentNode.offsetHeight) + "px";
			obj.className = "withprogress";
			
			if (objT) {
				objT.style.top = (((obj.parentNode.offsetHeight - 16) / 2) + 20) + "px";
			}
		} else if (!visible && (obj.className == "withprogress")) {
			// hide dropdowns for IE 5/6
			if (tt_ie56)
				pm_showHideDropDowns(obj.parentNode, true);
			obj.style.cursor = "default";
			obj.className = "noprogress";
		}
	}
}

function pm_showProgressWithOffset(id, visible, widthoffset, heightoffset) {
	var obj = document.getElementById(id);
	var objT = document.getElementById(id + "-text");

	if (obj) {
		if (visible && (obj.className == "noprogress")) {
			// hide dropdowns for IE 5/6
			if (tt_ie56)
				pm_showHideDropDowns(obj.parentNode, false);
				
			// grab parent's dimension
			obj.style.top = "0px";
			obj.style.left = "0px";
			obj.style.width = (obj.parentNode.offsetWidth) + widthoffset + "px";						
			obj.style.height = (obj.parentNode.offsetHeight) + heightoffset + "px";
			obj.className = "withprogress";
			
			if (objT) {
				objT.style.top = (((obj.parentNode.offsetHeight - 16) / 2) + 20) + "px";
			}
		} else if (!visible && (obj.className == "withprogress")) {
			// hide dropdowns for IE 5/6
			if (tt_ie56)
				pm_showHideDropDowns(obj.parentNode, true);
			obj.style.cursor = "default";
			obj.className = "noprogress";
		}
	}
}

function pm_showHideDisplay(id, showHide, display) {
	var obj = document.getElementById(id);
	if (obj)
		obj.style.display = (showHide ? display : "none");
}

function pm_showHide(id, showHide) {
	pm_showHideDisplay(id, showHide, "block");
}

function pm_enable(id, enabled) {
	var obj = document.getElementById(id);
	if (obj)
		obj.disabled = !enabled;
}

function pm_tk(tk) {
	pm_pageAsync("/include/trackpage.asp?p=" + escape(document.location.pathname) + "&e=" + escape(tk) + "&qd=" + (new Date()).getTime(), true, null);
}

function pm_tip(tip, id) {
	if (typeof(id) != "undefined")
		pm_tk("TIPID=" + id);
	Tip("<span style=\"line-height:1.75;\">" + tip + "</span>", SHADOW, true, BALLOON, true, ABOVE, true, PADDING, 12, FADEIN, 400, FADEOUT, 400, CLICKCLOSE, true);
}

function pm_tipCallout(tip, id, posX, posY) {
	if (typeof(posX) == "undefined")
		posX = -340;
	if (typeof(posY) == "undefined")
		posY = 60;
	Tip("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"340\"><tr><td><img src=\"images/spacer.gif\" width=\"12\" height=\"1\"></td><td><img src=\"images/spacer.gif\" width=\"258\" height=\"1\"></td><td><img src=\"images/spacer.gif\" width=\"15\" height=\"1\"></td><td><img src=\"images/spacer.gif\" width=\"19\" height=\"1\"></td><td><img src=\"images/spacer.gif\" width=\"36\" height=\"1\"></td><td><img src=\"images/spacer.gif\" width=\"1\" height=\"1\"></td></tr><tr><td><img src=\"images/callout_r1_c1.gif\" width=\"12\" height=\"19\"></td><td><img src=\"images/callout_r1_c2.gif\" width=\"258\" height=\"19\"></td><td><img src=\"images/callout_r1_c3.gif\" width=\"15\" height=\"19\"></td><td><img src=\"images/callout_r1_c4.gif\" width=\"19\" height=\"19\"></td><td rowspan=\"2\"><img src=\"images/callout_r1_c5.gif\" width=\"36\" height=\"156\"></td><td><img src=\"images/spacer.gif\" width=\"1\" height=\"19\"></td></tr><tr><td rowspan=\"2\"><img src=\"images/callout_r2_c1.gif\" width=\"12\" height=\"210\"></td><td rowspan=\"2\" colspan=\"2\" valign=\"top\" bgcolor=\"#EFEFEF\"><div class=\"callout-box\"><h4>Explanation</h4><p>" + tip + "</p></div></td><td><img src=\"images/callout_r2_c4.gif\" width=\"19\" height=\"159\"></td><td><img src=\"images/spacer.gif\" width=\"1\" height=\"137\"></td></tr><tr><td colspan=\"2\"><img src=\"images/callout_r3_c4.gif\" width=\"55\" height=\"51\"></td><td><img src=\"images/spacer.gif\" width=\"1\" height=\"51\"></td></tr><tr><td><img src=\"images/callout_r4_c1.gif\" width=\"12\" height=\"18\"></td><td colspan=\"2\"><img src=\"images/callout_r4_c2.gif\" width=\"273\" height=\"18\"></td><td colspan=\"2\"><img src=\"images/callout_r4_c4.gif\" width=\"55\" height=\"18\"></td><td><img src=\"images/spacer.gif\" width=\"1\" height=\"18\"></td></tr></table>", STICKY, true, FADEIN, 400, FADEOUT, 400, CLICKCLOSE, true, FIX, [id, posX, posY], ABOVE, true, BGCOLOR, "", BORDERWIDTH, 0, PADDING, 0);
}

function pm_tipSampleImage(imgPath, width, height) {
	pm_tk("IMG=" + imgPath);	
	Tip("<img src=\"" + imgPath + "\" width=\"" + width + "\" height=\"" + height + "\" />", BORDERCOLOR, "#76AAD1", CLOSEBTNCOLORS, ["#76AAD1","#FFF","#76AAD1","#FFF"], CLOSEBTNTEXT, "<a href=\"#\" onclick=\"return false;\" style=\"color:#FFF;font-size:13px;font-weight:bold;\">Close</a>&nbsp;<a href=\"#\" onclick=\"return false;\" style=\"font-size:16px;color:#FFF;background-color:#568AC2;text-decoration:none;\">&nbsp;X&nbsp;</a>", TITLEPADDING, 4, SHADOW, true, STICKY, true, CENTERWINDOW, true, CENTERALWAYS, true, FADEIN, 400, FADEOUT, 400, CLOSEBTN, true, CLICKCLOSE, true);
}

function pm_tipTag(id) {
	TagToTip(id, BORDERCOLOR, "#76AAD1", CLOSEBTNCOLORS, ["#76AAD1","#FFF","#76AAD1","#FFF"], CLOSEBTNTEXT, "<a href=\"#\" onclick=\"return false;\" style=\"color:#FFF;font-size:13px;font-weight:bold;\">Close</a>&nbsp;<a href=\"#\" onclick=\"return false;\" style=\"font-size:16px;color:#FFF;background-color:#568AC2;text-decoration:none;\">&nbsp;X&nbsp;</a>", TITLEPADDING, 4, SHADOW, true, STICKY, true, CENTERWINDOW, true, CENTERALWAYS, true, FADEIN, 400, FADEOUT, 400, CLOSEBTN, true, CLICKCLOSE, false);
}

function pm_unTip() {
	// BUGFIX - SZ (errors raised by some browsers, function undefined) 
	// UnTip();
}

var pm_fadeEnabled = false;
var pm_fadeT = new Number(0);
function pm_startFade(id, a, now, z, n, fn) {
	if (pm_fadeEnabled) {
		if (now == a)
			pm_fadeT.EndTimer();
		if(n)
		{
			now += Math.round((z - now) / n);
			if((z > a) ? (now >= z) : (now <= z))
				now = z;
			else
				pm_fadeT.Timer(
					"pm_startFade(\"" + id + "\","
					+ a + "," + now + "," + z + "," + (n - 1)
					+ ",\"" + fn + "\")",
					30,
					true
				);
		}
		tt_SetOpa(document.getElementById(id), now);
		if ((fn != "") && (now == z))
			eval(fn);
	} else if (fn != "") {
		eval(fn);
	}
}

function pm_setValue(id, value) {
	var obj = document.getElementById(id);
	if (obj)
		obj.value = value;
}

function pm_setInnerHTML(id, html) {
	var obj = document.getElementById(id);
	if (obj)
		obj.innerHTML = html;
}

function pm_setClassName(id, className) {
	var obj = document.getElementById(id);
	if (obj)
		obj.className = className;
}

function pm_focus(id) {
	var obj = document.getElementById(id);
	if (obj)
		obj.focus();
}

function pm_showTabDisplay(name, tabid, display) {
	var obj = document.getElementById(tabid);
	if ((name != "") && obj) {
		var attrTab = "pm::tab" + name;
		var curtabid = obj.parentNode.getAttribute(attrTab);
		if (curtabid != tabid) {
			obj.parentNode.setAttribute(attrTab, tabid);
			pm_showHideDisplay(curtabid, false, display);
			pm_showHideDisplay(tabid, true, display);
			pm_tk("TAB=" + name + ";CURRENT=" + tabid);
		}
	}
}

function pm_showTab(name, tabid) {
	pm_showTabDisplay(name, tabid, "block");
}

function pm_isNumKey(obj, evt) {
	var charCode = (evt.which) ? evt.which : event.keyCode;
	var maxlen = obj.getAttribute("pmq::maxlen");
	return (!((charCode > 31) && (charCode < 48 || charCode > 57)) && (!maxlen || (obj.value.length < parseInt(maxlen))));
}

function pm_autoTab(obj, maxlen, idtotab) {
	if (obj.value.length >= maxlen)
		pm_focus(idtotab);
}

function pm_setMaxLen(id, maxlen) {
	var obj = document.getElementById(id);
	if (obj) {
		obj.setAttribute("pmq::maxlen", maxlen + "");
		if (obj.value.length > maxlen)
			obj.value = obj.value.substr(0, maxlen);
	}
}
		
function pm_showSeeMore(id, name) {
	pm_showHideDisplay("seemore_" + id, true, "inline");
	pm_showHideDisplay("seemore_" + id + "_label", false, "inline");
	pm_pageAsync("/include/trackpage.asp?p=" + escape(document.location.pathname) + "&e=" + escape(id + "=" + name) + "&qd=" + (new Date()).getTime(), true, null);
}

function pm_page(url) {
	return pm_pageAsync(url, false, null);
}

function pm_pageAsync(url, async, callbackFunction) {
	var theResponse;
	var isMac;
	var xmlhttp;
	
	theResponse = "";
	isMac = (navigator.platform == "MacPPC");
	if (!isMac) {
		var ra = url.split("?");
		var data = "";

		url = (ra.length > 0) ? ra[0] : url;
		data = (ra.length > 1) ? ra[1] : "";
		if (document.all && window.ActiveXObject) {	// IE browsers
			try {
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
		}
		else if (window.XMLHttpRequest) {	// non-IE (Firefox, Chrome)
			xmlhttp = new XMLHttpRequest();
		}
		if (xmlhttp) {
			if (async && callbackFunction) {
				xmlhttp.onreadystatechange = function() {
					var done = 4, ok = 200;
					if (xmlhttp.readyState == done) {
						callbackFunction((xmlhttp.status == ok), xmlhttp.responseText);
					}
				};
			}
			xmlhttp.open("POST", url, async);			
			xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			xmlhttp.setRequestHeader("Content-length", data.length);
			xmlhttp.setRequestHeader("Connection", "close");
			xmlhttp.send(data);
			if (!async)
				theResponse = xmlhttp.responseText;
		}
	}
	return theResponse;
}

function pm_getFormValue(formData, name) {
	var raData = formData.split(";");
	for (var i = 0; i < raData.length; i++) {
		var raNameValue = raData[i].split("=");
		if ((raNameValue.length == 2) && (raNameValue[0] == name))
			return raNameValue[1];
	}
	return "";
}
