var IE4 = (document.all && !document.getElementById) ? true : false;
var NS4 = (document.layers) ? true : false;
var IE5 = (document.all && document.getElementById) ? true : false;
var N6 = (document.getElementById && !document.all) ? true : false;
var currentPageLink;

  function RemoveBad(newStr) {
    var index = 0;
    var strLength = 0;
    var left = "";
    var right = "";
    var badChars;
    var InStr;
  
    badChars = new Array(7);
    badChars[0] = "<";
    badChars[1] = ">";
    badChars[2] = "'";
    badChars[3] = "%";
    badChars[4] = ";";
    badChars[5] = "&";
    badChars[6] = "+";
  
    InStr = newStr;
  
    strLength = InStr.length;
  
    for (var i=0; i<=6; i++) {
  	  index = 0;
  	  while (index != -1) {
    		index = InStr.indexOf(badChars[i]);
    		if (index != -1) {
    			if (index != 0) {
    				left = InStr.substring(0,index);
    			}
    			else {
    				left = "";
    			}
    			if (index != strLength - 1) {
    				right = InStr.substring(index + 1, strLength);
    			}
    			else {
    				right = "";
    			}
    			InStr = left + right;
    		}
    	}
    }	 
    return InStr;
  }

function jumpto(sel){
  var i;
  i = sel.selectedIndex;

    if (sel.options[i].value != "") {
     window.location = sel.options[i].value;
    }

}

function which_Browser()
    {var a,b;
    a  = navigator.appVersion;
    b = a.charAt(0);
    if (b > 2)
    	{nav_refresh();
    	}
	}

function nav_refresh() {
	document.navform.reset();
}

var browserOK = false;
              var pics;
              var NameString;
              var objCount = 0;
              NameString = navigator.appname + navigator.appCodeName + navigator.appVersion;
              if (NameString.indexOf("Explorer") == -1)
                {if (NameString.indexOf("2.0") == -1)
                  {browserOK = true;
                          pics = new Array();
                  }
                }

              function preload(name, first, second) {
                        if (browserOK) {
                          var args = (arguments.length);
                          pics[objCount] = new Array(args);
                          pics[objCount][0] = name;
                          for(var i=1; i < args; i++) {
                                  pics[objCount][i] = new Image();
                                  pics[objCount][i].src = arguments[i];
                          }
                  objCount++;
                  }
              }

              function on(name) {
                var imgIndex = 2;
                if (browserOK) {
                  if (arguments.length > 1) {
                    imgIndex = parseInt(arguments[1]);
                  }
                  for (i = 0; i < objCount; i++) {
                    if (document.images[pics[i][0]] != null) {
                      if (name != pics[i][0])
                        { document.images[pics[i][0]].src = pics[i][1].src; }
                      else {
                        if (imgIndex < pics[i].length) { document.images[pics[i][0]].src =
			pics[i][imgIndex].src;
                        } else { document.images[pics[i][0]].src = pics[i][1].src; }
                      }
                    }
                  }
                }
              }

              function extra(name) {
                var i=0;
                var imgIndex = 2;
                if (browserOK) {
                  if (document.images[name] == null) { return 0; }
                  if (arguments.length > 1) {
                    imgIndex = parseInt(arguments[1]);
                  }
                  for(i=0;i<objCount;i++) {
                    if (pics[i][0] == name) { break; }
                  }
                  if (pics[i][0] != null && imgIndex < pics[i].length)
                  { document.images[name].src = pics[i][imgIndex].src; }
                  else { document.images[name].src = pics[i][1].src; }
                  return 1;
                }
                return 0;
              }

              function off() {
                if (browserOK) {
                  for (i = 0; i < objCount; i++) {
                    if (document.images[pics[i][0]] != null) {
                    document.images[pics[i][0]].src = pics[i][1].src;
                    }
                  }
                }
	      }
			
function goToMailForm (formURL, recipient)
{
	document.mailRecipientForm.recipient.value = recipient;
	document.mailRecipientForm.action = formURL;
	document.mailRecipientForm.submit ();
}

function writeMailRecipientBlock ()
{
	document.write ("<form name='mailRecipientForm' action='http://www.dow.com/' method='POST'>");
	document.write ("<input name='recipient' type='hidden' value='' />");
	document.write ("</form>");
}

function litOrder(title, formnum, business)
 {
    changecookie("doctitle", title);
    changecookie("formnum", formnum);
    var oldvar = "http://www.dow.com/webapps/lit/litorder.asp?OPTION="+formnum+"&Business="+business+"&DocTitle="+title;
    var newvar = oldvar;
    while(oldvar.indexOf(" ") != -1)
     {
        newvar = oldvar.substring(0,oldvar.indexOf(" "))+"%20"+oldvar.substring(oldvar.indexOf(" ")+1,oldvar.length);
        oldvar = newvar;
     }
    window.location = oldvar;
  }

/**** Rot13 encoding/decoding ****/
/**** Used to deobfuscate contact form recipients ****/
function JSrot13(text) {
	var rot13text_rotated = ""; /* the function will return this string */;

	for (i = 1 ; i < (text.length + 1); i++) {
		k = text.charCodeAt(i-1);

		if (k >= 97 && k <= 109) {
			k = k + 13;
		} else {
			if (k >= 110 && k <= 122) {
				k = k - 13;
			} else {
				if (k >= 65 && k <= 77) {
					k = k + 13;
				} else {
					if (k >= 78 && k <= 90) {
						k = k - 13;
					}
				}
			}
		}
		rot13text_rotated = rot13text_rotated + String.fromCharCode(k);
	}
	return rot13text_rotated;
}

function iframeFix(CurFrame) 
	{
	if(document.all)
		{
		CurFrame.width='100%';
		CurFrame.height=0;
		CurFrame.height=CurFrame.document.body.scrollHeight;
		NewHeight = CurFrame.height;
		NewHeight = CurFrame.document.body.offsetHeight-CurFrame.height+1*(CurFrame.height);
		CurFrame.height=NewHeight;
		}
	else
		{
		CurFrame.width='100%';
		CurFrame.height=450;
		}
	}

function CreateAnswerCenterLink(Destination)
	{
	document.write('<a href="' + Destination + '"><img onmouseover="this.src=');
	document.write("'/images/icon-ac2-roll.gif'");
	document.write('" onmouseout="this.src=');
	document.write("'/images/icon-ac2.gif'");
	document.write('" height="46" alt="Answer Center" src="/images/icon-ac2.gif" width="224" border="0" name="icon" /></a>');
	}

/**
 * Add a new function to be executed when the page loads.
 */
function addLoadEvent(func) {
  var oldOnload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  }
  else {
    window.onload = function() {
      oldOnload();
      func();
    }
  }
}

/**
 * Add a new class to the given DOM element.
 */
function addClass(element, value) {
  if (!element) {
    return;
  }
  if (!element.className) {
    element.className = value;
  }
  else {
    var oldClassName = element.className;
    element.className = oldClassName + ' ' + value;
  }
}

/**
 * Remove a given class from a DOM element.
 */
function removeClass(element, value) {
  if (!element || !element.className) {
    return;
  }
  else {
    var oldClasses = element.className.split(' ');
    for (var i = 0; i < oldClasses.length; i++) {
      if (oldClasses[i] == value) {
        oldClasses.splice(i, 1);
      }
    }
    element.className = oldClasses.join(' ');
  }
}

function expandIframeDiv(ExpandButtonDiv)
	{
	NewIframeHeight = window.screen.height-325;
	NewIframeWidth = window.screen.width-100;
	CurActiveIframeDiv=ExpandButtonDiv.parentNode;
	cids=CurActiveIframeDiv.style;
	cids.position='absolute';
	cids.top='130px';
	cids.left='50px';
	if (NewIframeWidth >= 750)
		{
		NewIframeWidth = 750;
		}
	cids.height=NewIframeHeight + 'px';
	cids.width=NewIframeWidth + 'px';
	cids.border='black 4px solid';
	ActionButtons = CurActiveIframeDiv.getElementsByTagName('div')
	ActionButtons[0].style.display='';
	ActionButtons[1].style.display='none';
	ActionButtons[2].style.display='';
	}

function collapseIframeDiv(CloseButtonDiv)
	{
	CurActiveIframeDiv=CloseButtonDiv.parentNode;
	cids=CurActiveIframeDiv.style;
	cids.top='0px';
	cids.left='0px';
	cids.width='100%';
	cids.height='25%';
	cids.position='relative';
	cids.border='none';
	ActionButtons = CurActiveIframeDiv.getElementsByTagName('div')
	ActionButtons[0].style.display='none';
	ActionButtons[1].style.display='';
	ActionButtons[2].style.display='none';
	} 

function buildExpandableIframe(expandLabel,iframeSource)
	{
	document.write('<div width="100%">');
	document.write('<div align="right" onclick="collapseIframeDiv(this)" class="iframe_action_button_div" style="display: none;">');
	document.write('<table border=0>');
	document.write('<tr>');
	document.write('<td class="iframe_div_action_button"><a href="#">Close</a></td>');
	document.write('<td class="iframe_div_action_button" style="border: black 1px solid"><a href="#">X</a></td>');
	document.write('</tr>');
	document.write('</table>');
	document.write('</div>');
	document.write('<div align="right" onclick="expandIframeDiv(this)" class="iframe_action_button_div">');
	document.write('<table border=0>');
	document.write('<tr>');
	document.write('<td class="iframe_div_action_button"><a href="#">' + expandLabel + '</a></td>');
	document.write('<td class="iframe_div_action_button" style="border: black 1px solid"><a href="#">+</a></td>');
	document.write('</tr>');
	document.write('</table>');
	document.write('</div>');
	document.write('<div style="display: none">');
	document.write('<iframe width="100%" height="100%" frameborder="0" src="' + iframeSource + '"></iframe>');
	document.write('</div>');
	document.write('</div>');
	}
    
function openNewWindow(url)
	{
	var newwindow;
	newwindow=window.open(url,"mywindow", "location=0,resizable=1,status=1.scrollbars=yes");
	if (window.focus) {newwindow.focus()}
	}    

