/**
 * Helper object to parse the query string variables from 
 * <script> element's src attribute.
 * 
 * For example, in test.html:
 *
 *   <script src="test.js?name=value"></script>
 *
 * and in test.js, you can get query as name/value pairs:
 * 
 *   var queries = new ScriptQuery('test.js').parse();
 *   for (var name in queries) {
 *     var values = queries[name]; // property is Array instance.
 *     ...
 *   }
 * 
 * If you would like to avoid array manipulation.
 * ScriptQuery also provides flatten method, which returns 
 * only first value for each properties.
 * 
 *   var queries = new ScriptQuery('test.js').flatten();
 *   for (var name in queries) {
 *     alert(queries[name]); // property is simply string
 *   }
 */
var ScriptQuery = function(scriptPath) {
  this.scriptPath = scriptPath;
}
ScriptQuery.prototype = {
  get: function() {
    var srcRegex = new RegExp(this.scriptPath.replace('.', '\\.') + '(\\?.*)?$');
    var scripts = document.getElementsByTagName("script");
    for (var i = 0; i < scripts.length; i++) {
      var script = scripts[i];
      if (script.src && script.src.match(srcRegex)) {
        var query = script.src.match(/\?([^#]*)(#.*)?/);
        return !query ? '' : query[1];
      }
    }
    return '';
  },
  parse: function() {
    var result = {};
    var query = this.get();
    var components = query.split('&');
 
    for (var i = 0; i < components.length; i++) {
      var pair = components[i].split('=');
      var name = pair[0], value = pair[1];
 
      if (!result[name]) result[name] = [];
      // decode
      if (!value) {
        // value = 'true';
        value = '';        
      } else {
        try {
          value = decodeURIComponent(value);
        } catch (e) {
          value = unescape(value);
        }
      }
 
      // MacIE way
      var values = result[name];
      values[values.length] = value;
    }
    return result;
  },
  flatten: function() {
    var queries = this.parse();
    for (var name in queries) {
      queries[name] = queries[name][0];
    }
    return queries;
  },
  toString: function() {
    return 'ScriptQuery [path=' + this.scriptPath + ']';
  }
}


var queries = new ScriptQuery('menustructure.js').flatten();
for (var name in queries) {
  // alert(queries[name]); // property is simply string
  var sRoot = queries[name];
}



document.write('\
\
<div id="qm0" class="qmmc">\
\
\
<a href="'+sRoot+'index.html">Home<\/a>\
\
<a href="'+sRoot+'AboutUs.html">About Us<\/a>\
<div>\
	<a href="'+sRoot+'OurPeople.html">The Purtzki Team<\/a>\
	<a href="'+sRoot+'OurPurposeAndValues.html">Our Purpose And Values<\/a>\
	<a href="'+sRoot+'WhatsNew.html">What&rsquo;s New<\/a>\
<\/div>\
\
\
\
<a href="'+sRoot+'UnparalleledServiceAndValue.html">Services &amp; Solutions<\/a>\
<div>\
	<a href="'+sRoot+'Accounting.html">Accounting<\/a>\
	<a href="'+sRoot+'BusinessAdvisory.html">Business Advisory Services<\/a>\
	<a href="'+sRoot+'TaxPlanning.html">Tax Planning<\/a>\
	<a href="'+sRoot+'FinancialPlanningAndManagement.html">Financial Planning and Management<\/a>\
<\/div>\
\
\
\
<a href="'+sRoot+'TailoredSolutions.html">Specialties<\/a>\
<div>\
	<a href="'+sRoot+'Dentists.html">Dentists<\/a>\
	<a href="'+sRoot+'Physicians.html">Physicians<\/a>\
	<a href="'+sRoot+'FamilyBusiness.html">Entrepreneurs and Family Businesses<\/a>\
	<a href="'+sRoot+'HighNetWorthIndividuals.html">High net-worth Individuals<\/a>\
	<a href="'+sRoot+'RealEstateAndConstruction.html">Real Estate and Construction<\/a> \
<\/div>\
\
\
\
<a href="'+sRoot+'Resources.html">Resources<\/a>\
\
\
\
<a href="'+sRoot+'FinancialTools.html">Tools<\/a>\
\
\
\
<a href="'+sRoot+'Careers.html">Careers<\/a>\
<div>\
	<a href="'+sRoot+'CareerOpportunities.html">Careers at Purtzki &amp; Associates<\/a>\
	<a href="'+sRoot+'HowToApply.html">How to Apply?<\/a>\
	<a href="'+sRoot+'apply-online.html">Apply Online<\/a>\
<\/div>\
\
\
\
<a style="border-right:1px solid #ccc;" href="'+sRoot+'ContactUs.html">Contact Us<\/a>\
\
<a class="mmain" style="border-right:1px solid #ccc;" href="#">Strategic Alliances<\/a>\
<div>\
  <a href="http:\/\/www.purtzkidental.com\/">Purtzki Dental Recruitment Inc.<\/a>\
  <a href="http:\/\/www.purtzkistaley.com\/">Purtzki Staley &amp; Associates Inc.<\/a>\
  <a href="http:\/\/www.justfordentists.com\/">Just For Dentists<\/a>\
  <a href="http:\/\/www.justfordoctors.ca\/">Just For Doctors<\/a>\
<\/div>\
\
<span class="qmclear">&nbsp;<\/span><\/div>\
');