// JavaScript Document

// <script>

// ********************
// Copyright (c) 2007 Reaction Design. All rights reserved.
//
// $Workfile: footer.js $  $Revision: 9 $
// $Modtime: 11/04/10 6:38p $
//
// $NoKeywords: $
//*************************

// Standard footer to supply copyright, privacy, trademark, and mailto links and
// provide location for easy to maintain content at bottom of pages.

function footer_build()
{
  var user = setUserLevel();

  document.write('<td height="100" colspan="3">');
  document.write('<div id="footer_bar2"></div>');
  document.write('<div id="footer_text2">');
  document.write('<a class="footerlink" href="/support/open/terms_n_conditions.html">Privacy Policy</a> | ');
  document.write('<a class="footerlink" href="/company/open/trademarks.html">Trademarks</a> | ');
  document.write('Send any comments to <a class="footerlink" href="mailto:webmaster@ReactionDesign.Com">webmaster@ReactionDesign.Com</a><br />');
  document.write('Copyright&copy; 2011 Reaction Design. All Rights Reserved.');
//  document.write('<br />Highest web access level this session: ' + user + '<br />');
  document.write('<br /><br />');
  document.write('<p>&nbsp;</p>');
  document.write('<center>');
  document.write('<a class="footerlink" href="http://www.reactiondesign.com/products/open/chemkin-pro.html">Combustion Reactions</a> | ');
  document.write('<a class="footerlink" href="http://www.reactiondesign.com/products/open/multi-zone.html">Combustion Chemistry Emissions</a> | ');
  document.write('<a class="footerlink" href="http://www.reactiondesign.com/products/open/kinetics_module.html">Computational Fluid Dynamics Modeling</a> | ');
  document.write('<a class="footerlink" href="http://www.reactiondesign.com/support/open/mfc.html">Byproducts of Combustion</a><br />');
  document.write('<a class="footerlink" href="http://www.reactiondesign.com/products/open/products.html">Chemistry Simulation Software</a> | ');
  document.write('<a class="footerlink" href="http://www.reactiondesign.com/support/open/citations.html">Chemical Kinetics and Rates of Reaction</a>');
  document.write('</center>');
  document.write('</div>');
  document.write('</td>');

}
// =========================================================================
// Examines the document URL to decide if the page being accessed is in
// visitor, guest (registered user), or customer access area.
// This function is only as accurate as the search paths that it knows about.
// =========================================================================
function getPageAccessLevel() {

    var accessLevel = "0"; //visitor, not password required
    if (document.URL) {
       // guest level access areas
       var patternG1 = /(\/support\/guest)/;
       var patternG2 = /(\/discus)/;
       if (patternG1.test(document.URL)) {
        accessLevel = "1";
       }
       if (patternG2.test(document.URL)) {
          accessLevel = "1";
       }
       // customer level access areas
       var patternC1 = /(\/support\/m)/;
       var patternC2 = /(\/discus\/messages\/76)/;
       var patternC3 = /(\/industries\/mfc_private)/;
       if (patternC1.test(document.URL)) {
        accessLevel = "2";
       }
       if (patternC2.test(document.URL)) {
          accessLevel = "2";
       }
       if (patternC3.test(document.URL)) {
          accessLevel = "2";
       }
    }
    //alert(document.URL + "    access level=" + accessLevel);
    return accessLevel;
}

// =========================================================================
// loads an Object (passed in) with name-value pairs of all cookies
// this function also exists in cookie_utils.js
// =========================================================================
function extractCookies(cookies) {
   var name, value;
   var beginning, middle, end;
   for (name in cookies) {
      //cookies = new Object();
      break;
   }
   beginning = 0;
   while (beginning < document.cookie.length) {
      middle = document.cookie.indexOf('=', beginning);
      end = document.cookie.indexOf(';', beginning);
      if (end == -1) {
         end = document.cookie.length;
      }
      if (middle > end || (middle == -1)) {
         name = document.cookie.substring(beginning, end);
         value = "";
      } else {
         name = document.cookie.substring(beginning, middle);
         value = document.cookie.substring(middle+1, end);
      }
      cookies[name] = unescape(value);
      beginning = end + 2;
   }
}

// =========================================================================
// returns a text string with the highest access level
// that the user has obtained during this web session
// by using a session Cookie named "webAccess" to track
// that access based on the location of the URL loaded
// =========================================================================
function setUserLevel() {
    var cookieName = "webAccess";
    var level = getPageAccessLevel();
    var user = "Visitor";
    if (level == "2") {
        user = "Customer";
    } else if (level == "1") {
        user = "Registered Guest";
    }
    var cookies = new Object();
    extractCookies(cookies);
    if (cookies[cookieName]) {
        // cookie is only set for level 1 or 2 access
        // retain highest level already granted
        var myCookie = cookies[cookieName];
        if (myCookie == "2") {
            user = "Customer";
        } else if (myCookie == "1") {
            if (level == "2") {
                setCookie(cookieName,"2","www.reactiondesign.com","/")
                user = "Customer";
            } else {
                user = "Registered Guest";
            }
        }
    } else if (level != "0") {
        setCookie(cookieName,level,"www.reactiondesign.com","/")
    }
    return user;
}


// </script>
//Google Analytics tracking code for every page: ga.js version (not urchin.js, which is "old-style")

// <script type="text/javascript">

var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");

document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));

// </script>

// <script type="text/javascript">

try {

var pageTracker = _gat._getTracker("UA-6900890-1");

pageTracker._trackPageview();

} catch(err) {}
// </script>


// =========================================================================
// sets a Cookie with option parameters provided
// this function also exists in cookie_utils.js
// =========================================================================
function setCookie( name, value, expires, path, domain, secure )
{
	// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );

	/*
	if the expires variable is set, make the correct
	expires time, the current script below will set
	it for x number of days, to make it for hours,
	delete * 24, for minutes, delete * 60 * 24
	*/
	if ( expires )
	{
		expires = expires * 1000 * 60 * 60 * 24 * 365;
	}
	var expires_date = new Date( today.getTime() + (expires) );

	document.cookie = name + "=" +escape( value ) +
	( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
	( ( path ) ? ";path=" + path : "" ) +
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );
}




