var pcname='hpgcrprint=';

function findPrintCookie() {
	var allcookies = document.cookie.split(';');
	var printcookie;
  // return blank if nothing in cookies
  if (allcookies == 'hpgcrprint') { return '';}
	for (var i=0; i < allcookies.length; i++) {
		var c = allcookies[i];
		while (c.charAt(0)==' ')
			c = c.substring(1, c.length);
		if (c.indexOf(pcname) == 0) 
			printcookie = c.substring(pcname.length, c.length);
	}
	return printcookie;
}

function detectPrintCookie(pageid) {
	try {
		var printspan = document.getElementById("printlink");
		if (pageid == 'id') {
			printspan.innerHTML = "";
		} else {
			var printcookie = findPrintCookie();
			// see if this page has already been added to the report
			if (printcookie && printcookie.length != 0 && printcookie != "undefined") {
				var pages = printcookie.split('&');
				var page;
				for (var i = 0; i < pages.length; i++) {
					page = pages[i];
					if (page == pageid) {
						printspan.innerHTML = "In my report";
					}
				}
			}
		}
	} catch(e) {
		alert(e);
	}
}

//-------------------------------------------------------------------------------------
//!sg - mods to allow two printlinkIDs
//-------------------------------------------------------------------------------------

function detectPrintCookieA(pageid) {
	try {
		var printspan = document.getElementById("printlinkA");
		if (pageid == 'id') {
			printspan.innerHTML = "";
		} else {
			var printcookie = findPrintCookie();
			// see if this page has already been added to the report
			if (printcookie && printcookie.length != 0 && printcookie != "undefined") {
				var pages = printcookie.split('&');
				var page;
				for (var i = 0; i < pages.length; i++) {
					page = pages[i];
					if (page == pageid) {
						printspan.innerHTML = "<img height=\"16\" alt=\"\" class=\"social_img\" width=\"16\" border=\"0\" src=\"/hpinfo/globalcitizenship/gcreport/images/hpweb_1-2_prnt_icn.gif\"/><a href=\"javascript://\" onclick=\"popupPrintMini(this);\" class=\"udrlinebold\"><strong>View my report</strong><SPAN class=screenReading> - opens popup layer </SPAN></a><img src=\"http://welcome.hp-ww.com/img/s.gif\" width=\"10\" height=\"10\" alt=\"\">";
					}
				}
			}
		}
	} catch(e) {
		alert(e);
	}
}
 
function detectPrintCookieB(pageid) {
	try {
		var printspan = document.getElementById("printlinkB");
		if (pageid == 'id') {
			printspan.innerHTML = "";
		} else {
			var printcookie = findPrintCookie();
			// see if this page has already been added to the report
			if (printcookie && printcookie.length != 0 && printcookie != "undefined") {
				var pages = printcookie.split('&');
				var page;
				for (var i = 0; i < pages.length; i++) {
					page = pages[i];
					if (page == pageid) {
						printspan.innerHTML = "<img height=\"16\" alt=\"\" class=\"social_img\" width=\"16\" border=\"0\" src=\"/hpinfo/globalcitizenship/gcreport/images/hpweb_1-2_prnt_icn.gif\"/><a href=\"javascript://\" onclick=\"popupPrintMini(this);\" class=\"udrlinebold\"><strong>View my report</strong><SPAN class=screenReading> - opens popup layer </SPAN></a><img src=\"http://welcome.hp-ww.com/img/s.gif\" width=\"10\" height=\"10\" alt=\"\">";
					}
				}
			}
		}
	} catch(e) {
		alert(e);
	}
}

// Function: write pcname cookie into document cookie (overwriting any existing content)
function writePcCookie(cookieValue) {
  document.cookie = pcname+cookieValue+"; path=/";
  return true;
}

// Function: read pcname cookie out of document cookie 
//           this function is just a stub - for symmetry with writePcCookie
function readPcCookie() {
  return findPrintCookie();
}


function getPcCookieAsArray() {
  var retval = new Array();
  var printcookie = readPcCookie();
  if (printcookie && printcookie.length != 0 && printcookie != "undefined") {
    var pages = printcookie.split('&');
    for (var i = 0; i < pages.length; i++) {
      if (pages[i] != "") {
        retval.push(pages[i]);
      }
    }
  }
//  retval.sort(cmpPc);
  // Ids were pseudo-randomly assigned and no longer sort properly by id order.
  // So we're going to use a custom sort array to sort the Pc items by hand.
  // This means that we don't have to fix the ids throughout the site, but we do have to maintain this array in addition to the ids.
  retval.sort(customCmpPc);
  return retval;  
}

var pcOrder = {
	'a1'  : { index: 1,  id: 'a1',  report: 'Introduction | Letter from Mark Hurd' },
	'a2'  : { index: 2,  id: 'a2',  report: 'Introduction | HP profile' },
	'a4'  : { index: 3,  id: 'a4',  report: 'Introduction | Economic impacts' },
	'b1'  : { index: 4,  id: 'b1',  report: 'Global citizenship at HP | Global citizenship at HP' },
	'b2'  : { index: 5,  id: 'b2',  report: 'Global citizenship at HP | Our approach' },
	'b4'  : { index: 6,  id: 'b4',  report: 'Global citizenship at HP | Stakeholder engagement' },
	'b5'  : { index: 7,  id: 'b5',  report: 'Global citizenship at HP | Responding to perspectives' },
	'b6'  : { index: 8,  id: 'b6',  report: 'Global citizenship at HP | Stakeholder Advisory Council' },
	'b9'  : { index: 9,  id: 'b9',  report: 'Global citizenship at HP | Customers and GC' },
	'b8'  : { index: 10, id: 'b8',  report: 'Global citizenship at HP | Investors and GC' },
	'b10' : { index: 11, id: 'b10', report: 'Global citizenship at HP | Public policy' },
	'c1'  : { index: 12, id: 'c1',  report: 'Ethics and compliance | Ethics and compliance' },
	'c2'  : { index: 13, id: 'c2',  report: 'Ethics and compliance | Approach' },
	'c3'  : { index: 14, id: 'c3',  report: 'Ethics and compliance | Seeking guidance' },
	'm1'  : { index: 15, id: 'm1', 	report: 'Human rights & labor practices | Human rights & labor practices' },
	'm2'  : { index: 16, id: 'm2', 	report: 'Human rights & labor practices | Human rights' },
	'd1'  : { index: 17, id: 'd1', 	report: 'Human rights & labor practices | Supply chain responsibility' },
	'd6'  : { index: 18, id: 'd6', 	report: 'Human rights & labor practices | Strategy' },
	'd20' : { index: 19, id: 'd20', report: 'Human rights & labor practices | Proactive engagement' },
	'd22' : { index: 20, id: 'd22', report: 'Human rights & labor practices | Suppliers' },
	'd21' : { index: 21, id: 'd21', report: 'Human rights & labor practices | Industry and NGOs' },
	'd23' : { index: 22, id: 'd23', report: 'Human rights & labor practices | Transparency' },
	'd24' : { index: 23, id: 'd24', report: 'Human rights & labor practices | External validation' },
	'd25' : { index: 24, id: 'd25', report: 'Human rights & labor practices | Supplier list' },
	'd2'  : { index: 25, id: 'd2', 	report: 'Human rights & labor practices | Results' },
	'd26' : { index: 26, id: 'd26', report: 'Human rights & labor practices | Audit findings' },
	'd17' : { index: 27, id: 'd17', report: 'Human rights & labor practices | Perspective' },
	'd18' : { index: 28, id: 'd18', report: 'Human rights & labor practices | Supplier diversity' },
	'j1'  : { index: 29, id: 'j1', 	report: 'Human rights & labor practices | HP employees' },
	'j2'  : { index: 30, id: 'j2', 	report: 'Human rights & labor practices | Diversity' },
	'j4'  : { index: 31, id: 'j4', 	report: 'Human rights & labor practices | Compensation and benefits' },
	'j5'  : { index: 32, id: 'j5', 	report: 'Human rights & labor practices | Communications' },
	'j6'  : { index: 33, id: 'j6', 	report: 'Human rights & labor practices | Learning and development' },
	'j8'  : { index: 34, id: 'j8', 	report: 'Human rights & labor practices | Work-life programs' },
	'j9'  : { index: 35, id: 'j9', 	report: 'Human rights & labor practices | Health, safety and wellness' },
	'j11' : { index: 36, id: 'j11', report: 'Human rights & labor practices | Employee giving and volunteerism' },
	'n1'  : { index: 37, id: 'n1',  report: 'Environmental sustainability | Environmental sustainability' },
	'e1'  : { index: 38, id: 'e1',  report: 'Environmental sustainability | Climate and energy' },
	'e2'  : { index: 39, id: 'e2',  report: 'Environmental sustainability | Operations' },
	'e3'  : { index: 40, id: 'e3',  report: 'Environmental sustainability | Energy use' },
	'e4'  : { index: 41, id: 'e4',  report: 'Environmental sustainability | Greenhouse gas emissions' },
	'e5'  : { index: 42, id: 'e5',  report: 'Environmental sustainability | Reporting and verification' },
	'e6'  : { index: 43, id: 'e6',  report: 'Environmental sustainability | Travel' },
	'e16' : { index: 44, id: 'e16', report: 'Environmental sustainability | Products / Product manufacturing' },
	'e10' : { index: 45, id: 'e10', report: 'Environmental sustainability | Product transport' },
	'e7'  : { index: 46, id: 'e7',  report: 'Environmental sustainability | Product use' },
	'e11' : { index: 47, id: 'e11', report: 'Environmental sustainability | Enabling a low-carbon economy' },
	'e12' : { index: 48, id: 'e12', report: 'Environmental sustainability | Collaboration' },
	'g1'  : { index: 49, id: 'g1',  report: 'Environmental sustainability | Sustainable design' },
	'g2'  : { index: 50, id: 'g2',  report: 'Environmental sustainability | Research and development' },
	'g10' : { index: 51, id: 'g10', report: 'Environmental sustainability | Life cycle assessment' },
	'g4'  : { index: 52, id: 'g4',  report: 'Environmental sustainability | Materials' },
	'g5'  : { index: 53, id: 'g5',  report: 'Environmental sustainability | Packaging' },
	'g11' : { index: 54, id: 'g11', report: 'Environmental sustainability | Paper' },
	'g8'  : { index: 55, id: 'g8',  report: 'Environmental sustainability | Accessibility' },
	'h1'  : { index: 56, id: 'h1',  report: 'Environmental sustainability | HP operations' },
	'h2'  : { index: 57, id: 'h2',  report: 'Environmental sustainability | Management system' },
	'h3'  : { index: 58, id: 'h3',  report: 'Environmental sustainability | Sustainable building design' },
	'h4'  : { index: 59, id: 'h4',  report: 'Environmental sustainability | Waste and recycling' },
	'h5'  : { index: 60, id: 'h5',  report: 'Environmental sustainability | Ozone' },
	'h6'  : { index: 61, id: 'h6',  report: 'Environmental sustainability | Water' },
	'h7'  : { index: 62, id: 'h7',  report: 'Environmental sustainability | Emissions to air' },
	'h8'  : { index: 63, id: 'h8',  report: 'Environmental sustainability | Compliance' },
	'h9'  : { index: 64, id: 'h9',  report: 'Environmental sustainability | Remediation' },
	'f1'  : { index: 65, id: 'f1',  report: 'Environmental sustainability | Product reuse and recycling' },
	'f2'  : { index: 66, id: 'f2',  report: 'Environmental sustainability | Approach' },
	'f3'  : { index: 67, id: 'f3',  report: 'Environmental sustainability | Programs' },
	'f9'  : { index: 68, id: 'f9',  report: 'Environmental sustainability | Vendor audits' },
	'f4'  : { index: 69, id: 'f4',  report: 'Environmental sustainability | Performance' },
	'f10' : { index: 70, id: 'f10', report: 'Environmental sustainability | External verification' },
	'n2'  : { index: 71, id: 'n2',  report: 'Environmental sustainability | Product gallery' },
	'n3'  : { index: 72, id: 'n3',  report: 'Environmental sustainability | Perspective' },
	'i1'  : { index: 73, id: 'i1',  report: 'Privacy | Privacy' },
	'i2'  : { index: 74, id: 'i2',  report: 'Privacy | Approach' },
	'i4'  : { index: 75, id: 'i4',  report: 'Privacy | Perspective' },
	'k1'  : { index: 76, id: 'k1',  report: 'Social investment | Social investment' },
	'k2'  : { index: 77, id: 'k2',  report: 'Social investment | Innovations in education' },
	'k3'  : { index: 78, id: 'k3',  report: 'Social investment | Entrepreneurship education' },
	'k8'  : { index: 79, id: 'k8',  report: 'Social investment | HP in the community' },
	'k5'  : { index: 80, id: 'k5',  report: 'Social investment | Performance' },
	'k10' : { index: 81, id: 'k10', report: 'Social investment | Measuring impact' },
	'k9'  : { index: 82, id: 'k9',  report: 'Social investment | Perspective' },
	'o2'  : { index: 83, id: 'o2',  report: 'Data & goals | Data & goals' },
	'l1'  : { index: 84, id: 'l1',  report: 'About this report | About this report' },
	'l7'  : { index: 85, id: 'l7',  report: 'About this report | UN Global Compact' },
	'l3'  : { index: 86, id: 'l3',  report: 'About this report | Assurance' },
	'l5'  : { index: 87, id: 'l5',  report: 'About this report | GRI index' },
	'l6'  : { index: 88, id: 'l6',  report: 'About this report | Site map' },
	'o3'  : { index: 89, id: 'o3',  report: 'At a glance | Perspectives' }
};

// Custom compare function to sort by index of a custom array.
function customCmpPc(a, b)
{
  a = (pcOrder[a]) ? pcOrder[a].index : 0;
  b = (pcOrder[b]) ? pcOrder[b].index : 0;
  return (a - b);
}

// Comparison function for sorting Pc.
function cmpPc(a, b)
{
  // Separate alphabetic portion from numeric portion.
  var pcRegExp = /^([a-z]*)([0-9]*)$/i,
	aMatch = pcRegExp.exec(a),
	bMatch = pcRegExp.exec(b);
  return strcmp(aMatch[1], bMatch[1]) || (parseInt(aMatch[2]) - parseInt(bMatch[2]));
}

// Compares two strings case insensitive.
function strcmp(a, b)
{
  a = a.toLowerCase();
  b = b.toLowerCase();
  return (a == b) ? 0 : ((a < b) ? -1 : 1);
}

// Function: adds a pageId to PcCookie, unless it alread exists
function addToPcCookie(pageId) {
  // don't add any pc cookies unless they are in a valid format
  if (!isValidPcCookie(pageId)) { return false; }
  var pages = getPcCookieAsArray();
  var foundcookie = false;
  // find this pageId
  for (var i = 0; i < pages.length; i++) {
    // notice if we find the pageId, so we can skip adding it
    if (pages[i] == pageId) {
      foundcookie = true;
    }
  }
  if (!foundcookie) {
    pages.push(pageId);
    pages.sort();
    var cookiestr = pages.join('&')+'&';
    writePcCookie(cookiestr);
  }
}


var validPcLetters = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'];
var validPcNumbers = [1,2,3,4,5,6,7,8,9,0];

// Function: returns true if pageId is in regex form "[a-z][0-9][0-9]" - with the second [0-9] being optional
function isValidPcCookie(pageId) {
  var retval = false;
  // it must be 2-3 chars long
  if (pageId.length <= 3 && pageId.length >= 2) {
    var letter = pageId.charAt(0);
    var num1 = pageId.charAt(1);
    var num2 = pageId.charAt(2);
    var lettervalid = false;
    var num1valid = false;
    var num2valid = false;
    // letter must be a letter
    jQuery.map(validPcLetters, function(n,i) {if (letter == n) {lettervalid=true;}});
    // num1 must be a number
    jQuery.map(validPcNumbers, function(n,i) {if (num1 == n) {num1valid=true;}});
    // num2 can be blank or it must be a number
    if (num2.length == 0) {
      num2valid = true;
    } else {
      jQuery.map(validPcNumbers, function(n,i) {if (num2 == n) {num2valid=true;}});
    }
    retval = lettervalid && num1valid && num2valid;
  }
  
  return retval;
}

// Function: removes an item from PcCookie if found
function removeFromPcCookie(pageId) {
  var pages = getPcCookieAsArray();
  // find this pageId
  var newcookie = new Array();
  for (var i = 0; i < pages.length; i++) {
    // add all pageId's except the one specified to new cookie
    if (pages[i] != pageId) {
      newcookie.push(pages[i]);
    }
  }
  if (newcookie.length > 0) {
    var cookiestr = newcookie.join('&')+'&';
    writePcCookie(cookiestr);
  } else {
    writePcCookie('');
  }
}

// Function: returns true if there are no elements in PcCookie
function pcCookieEmpty() {
  if (getPcCookieAsArray().length > 0) {
    return false;
  } else {
    return true;
  }
}

function hasInPcCookie(pageId) {
  var pages = getPcCookieAsArray();
  for (var i = 0; i < pages.length; i++) {
    // return true if/when we find pageId
    if (pages[i] == pageId) {
      return true;
    }
  }
  return false;
}

//Function: toggles cookie for pageId - if it exists, it is removed. If it doesn't exist it is added
function togglePageId(pageId) {
  if (hasInPcCookie(pageId)) {
    removeFromPcCookie(pageId);
  } else {
    addToPcCookie(pageId);
  }
}

// Function: adds to report if truefalse is true, removes from report if false
function changePageId(pageId, truefalse) {
  if (truefalse) {
    addToPcCookie(pageId)
  } else {
    removeFromPcCookie(pageId)  
  }
}

function addToReport(pageid) {
	try {		
		var printcookie = findPrintCookie();
		if (!printcookie || printcookie.length == 0 || printcookie == "undefined") {	
			printcookie = pageid + "&";
		} else {
			printcookie = printcookie + pageid + "&";
		}			
		document.cookie = pcname + printcookie + "; path=/";
		//detectPrintCookie(pageid); !sg
		detectPrintCookieA(pageid);
		detectPrintCookieB(pageid);
	} catch(e) {
		alert(e);
	}
}

function removeFromReport(pageid) {
	try {		
		var printcookie = findPrintCookie();
		if (printcookie && printcookie.length != 0 && printcookie != "undefined") {	
			var start = printcookie.indexOf(pageid);
			var newcookie = printcookie.substring(0, start) + printcookie.substring(start+pageid.length+1, printcookie.length);
			printcookie = printcookie + pageid + "&";
			document.cookie = pcname + printcookie;
		}
		//detectPrintCookie(pageid); !sg
		detectPrintCookieA(pageid);
		detectPrintCookieB(pageid);
	} catch(e) {
		alert(e);
	}
}

//-------------------------------------------------------------------------------------
//!sg - end mods 
//-------------------------------------------------------------------------------------
 
function clearCookie() {
	try {
		document.cookie = pcname + "; path=/";		
	} catch(e) {
		alert(e);
	}
}

function prefillBoxes() {

	var printcookie = findPrintCookie();
	if (printcookie && printcookie.length != 0 && printcookie != "undefined") {
		var pages = printcookie.split('&');
		var page;
		var checkbox;
		var tr;
		for (var i = 0; i < pages.length; i++) {
			page = pages[i];
			if (page) {
				checkbox = document.getElementById(page);
				checkbox.checked = true;
				tr = document.getElementById("row" + page);
				tr.style.display = '';
					
					//to open all TR's if any TR is checked, set to true
					openTRs = false;
					if (openTRs) {
						//alert(tr.parentNode.parentNode.getElementsByTagName('tr')[i+1].id);
						parentEl = tr.parentNode.parentNode
						var numTR = parentEl.getElementsByTagName('tr');
						//alert(parentEl.id)
						for (var j=1; j<numTR.length; j++) {
							numTR[j].style.display = '';
							//var td = document.getElementById('expandimg' + numTR.id);
							//td.innerHTML = '&nbsp;&#45;&nbsp;';
						}
					}
					
			}
		}
	}
	for (var i=1; i<15; i++) {
		if (i != 2 && i != 7 && i != 8 && i != 9 && i != 11) {
			var table = document.getElementById('table' + i);
			var checkboxes = table.getElementsByTagName('input');
			var allchecked = true;
			for (var j=0; j<checkboxes.length && allchecked; j++) {
				if (checkboxes[j].id.indexOf("box") == -1 && !checkboxes[j].checked) {
					allchecked = false;
				}
			}
			if (allchecked) {
				var td = document.getElementById('expandimg' + i);
				td.innerHTML = '&nbsp;&#45;&nbsp;';
				document.getElementById('box' + i).checked = true;
			} else {
				document.getElementById('box' + i).checked = false;
			}
		}
	}
  setPageCounts();
}

function resetCookie() {
	var printcookie = "";
	// loop through checkboxes and set cookie
	var checkboxes = document.getElementsByTagName('input');
	for (var i=0; i<checkboxes.length; i++) {
		if (checkboxes[i].type=="checkbox" && checkboxes[i].id.indexOf("box") == -1 && checkboxes[i].checked) {
			printcookie += checkboxes[i].id + "&";
		}
	}
	document.cookie = pcname + printcookie + "; path=/";
}

function addContent(url, divid) {
	if (!ValidateInput(url)) {
		return false;
	}

	var objHttpRequest = GetXmlHttpObject();
	if (objHttpRequest) {
		objHttpRequest.onreadystatechange = function() { processResponse(objHttpRequest, divid) };
		objHttpRequest.open("GET", url);
		objHttpRequest.send(null);
	} else {
		return false;
	}
	return true;
}

function scrubRelLinks(myHTML)
{

	// find all ../
	regExString  = /\.\.\//g;
	myregexp = new RegExp(regExString);
	
	// replace with empty string
	return myHTML.replace(myregexp,"");

}

function processResponse(objHttpRequest, divid) {

	var responseText = "";
	var titleBlock = "";
	var	contentBlock = "";

	if ((objHttpRequest.readyState == 4) || (objHttpRequest.readyState == "complete")) {
		if (objHttpRequest.status == 200) {
			responseText = objHttpRequest.responseText;
			titleBlock = getTextBetween(responseText, "<h1><span dir=\"ltr\"><!-- InstanceBeginEditable name=\"pageTitle\" -->", "<!-- InstanceEndEditable --><\/span><\/h1>");
			contentBlock = getTextBetween(responseText, "<!-- Start Content Area.  To increase width of content area, modify width of table cell below. -->", "<!-- End Content Area -->");
			var div = document.getElementById(divid);
			
			//quickfix to image URLs
			contentBlock = scrubRelLinks(contentBlock);
			
			div.innerHTML += "<table width='560' border='0' cellspacing='0' cellpadding='0'><tr><td><h1>" + titleBlock + "<\/h1><\/td><\/tr>" + contentBlock + "<\/tr><tr><td><hr/><\/td><\/tr><\/table>";
		}	
	}
}

function getTextBetween(strResponse, strPrefix, strSuffix) {
	var indexPrefix = strResponse.indexOf(strPrefix);
	indexPrefix = (indexPrefix == -1) ? 0 : indexPrefix;

	var indexSuffix = strResponse.indexOf(strSuffix);
	indexSuffix = ( (indexSuffix == -1) || (indexSuffix == 0) ) ? strResponse.length : indexSuffix + strSuffix.length;

	var strDisplay = strResponse.substring(indexPrefix, indexSuffix );
	return strDisplay;
}

function process() {
	/**
	try {
    	netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
    } catch (e) {
    	alert("Permission UniversalBrowserRead denied.");
    }
    **/
	try {		
		var printcookie = findPrintCookie();
		if (!printcookie || printcookie.length == 0 || printcookie == "undefined") {
			document.getElementById("goback").innerHTML = 'Oops! You did not select any pages. Please go back to the <a href="print.html">Build and print custom report page<\/a> and make your selections.';
		} else {
			var pages = printcookie.split('&');
			var page;
			var div;
			for (var i = 0; i < pages.length; i++) {
				page = pages[i];
				if (page) {
					var newdiv = document.createElement("div");
					newdiv.id = "subsection_" + page;
					var printdiv = document.getElementById('print');
					printdiv.appendChild(newdiv);
					addContent(resolvePageId(page) + ".html", newdiv.id);
				}	
			}
		}
	} catch(e) {
		alert(e);
	}
	//setTimeout("hidePleaseWaitMessage()", 3000);
	//setTimeout("Tabblo.embedded.printabulous()", 4000);
}

function hidePleaseWaitMessage() {
	div = document.getElementById('pleasewait');
	div.style.display = "none";
}

function processResults() {
	try {		
	
		var printcookie = findPrintCookie();
		if (!printcookie || printcookie.length == 0 || printcookie == "undefined") {
			document.getElementById("goback").innerHTML = 'Oops! You did not select any pages. Please go back to the <a href="print.html">Build and print custom report page<\/a> and make your selections.';
		} else {
			var pages = printcookie.split('&');
			var page;
			var div;
			for (var i = 0; i < pages.length; i++) {
				page = pages[i];
				if (page) {
					// get the subsection div and unhide it
					div = document.getElementById('page_' + page);
					div.style.display = "block";
					//alert(div + ": " + div.style.display);
				}	
			}
		}
	} catch(e) {
		alert(e);
	}
}

var rootPath = '/hpinfo/globalcitizenship/gcreport/'
function resolvePageId(id) {
	var page;
	var sectionId = id.charAt(0);
	var pageId = id.substring(1, id.length);
	
	if (sectionId == 'a') {
		page = "intro";
		if (pageId == '1') {
			page += "/ceoletter";
		} else if (pageId == '2') {
			page += "/hpprofile";
		/*} else if (pageId == '3') { unused
			page += "/priorities";*/
		} else if (pageId == '4') {
			page += "/economicimpacts";
		/*} else if (pageId == '5') { unused
			page += "/economicimpacts/performance";*/
		}
	} else if (sectionId == 'b') {
		page = "globalcitizen";
		if (pageId == '2') {
			page += "/managinggc";
		/*} else if (pageId == '3') { unused
			page += "/timeline";*/
		} else if (pageId == '4') {
			page += "/stakeholder";
		} else if (pageId == '5') {
			page += "/stakeholder/responding";
		} else if (pageId == '6') {
			page += "/stakeholder/advisory";
		/*} else if (pageId == '7') { unused
			page += "/business";*/
		} else if (pageId == '8') {
			page += "/business/investorsgc";
		} else if (pageId == '9') {
			page += "/business/customersgc";
		} else if (pageId == '10') {
			page += "/publicpolicy";
		}
	} else if (sectionId == 'c') {
		page = "ethics";
		if (pageId == '2') {
			page += "/approach";
		} else if (pageId == '3') {
			page += "/seekingguidance";
		} else if (pageId == '4') {
			page += "/perspective";
		}
	} else if (sectionId == 'd') {
		page = "supplychain";
		if (pageId == '2') {
			page += "/supplyperformance";
		/* } else if (pageId == '3') { unused
			page += "/auditresultsExpanded";
		} else if (pageId == '4') { unused
			page += "/casestudies";
		} else if (pageId == '5') { unused
			page += "/hpsupply"; */
		} else if (pageId == '6') {
			page += "/hpapproach";
		/* } else if (pageId == '7') {  unused 
			page += "/hpapproach/governance";
		} else if (pageId == '8') { unused
			page += "/hpapproach/sourcing";
		} else if (pageId == '9') { unused
			page += "/standards";
		} else if (pageId == '10') { unused
			page += "/standards/humanrights";
		} else if (pageId == '11') { unused
			page += "/conformity";
		} else if (pageId == '12') { unused
			page += "/collaboration";
		} else if (pageId == '13') { unused
			page += "/collaboration/eicc";
		} else if (pageId == '14') { unused
			page += "/collaboration/thirdpartystandards";
		} else if (pageId == '15') { unused
			page += "/thirdparty";
		} else if (pageId == '16') { unused
			page += "/goals"; */
		} else if (pageId == '17') {
			page += "/perspectives";
		} else if (pageId == '18') {
			page += "/supplier";
		/* } else if (pageId == '19') { unused
			page += "/supplier/performance"; */
		} else if (pageId == '20') {
			page += "/proactive";
		} else if (pageId == '21') {
			page += "/proactive/industry";
		} else if (pageId == '22') {
			page += "/proactive/suppliers";
		} else if (pageId == '23') {
			page += "/transparency";
		} else if (pageId == '24') {
			page += "/transparency/externalvalidation";
		} else if (pageId == '25') {
			page += "/transparency/supplierlist";
		} else if (pageId == '26') {
			page += "/auditresults";
		}
	} else if (sectionId == 'e') {
		page = "energy";
		if (pageId == '2') {
			page += "/operations";
		} else if (pageId == '3') {
			page += "/operations/energyuse";
		} else if (pageId == '4') {
			page += "/operations/greenhouse";
		} else if (pageId == '5') {
			page += "/operations/reporting";
		} else if (pageId == '6') {
			page += "/operations/travel";
		} else if (pageId == '7') {
			page += "/products";
		/*} else if (pageId == '8') { unused
			page += "/products/examples";
		} else if (pageId == '9') { unused
			page += "/products/performance";*/
		} else if (pageId == '10') {
			page += "/logistics";
		} else if (pageId == '11') {
			page += "/busopportunities";
		} else if (pageId == '12') {
			page += "/collaboration";
		/*} else if (pageId == '13') { unused
			page += "/casestudies";
		} else if (pageId == '14') { unused
			page += "/goals";
		} else if (pageId == '15') { unused
			page += "/perspectives";*/
		} else if (pageId == '16') {
			page += "/products/manufacturing";
		}
	} else if (sectionId == 'f') {
		page = "productreuse";
		if (pageId == '2') {
			page += "/recyclingapproach";
		} else if (pageId == '3') {
			page += "/programs";
		} else if (pageId == '4') {
			page += "/performance";
		/*} else if (pageId == '5') { unused
			page += "/casestudy";
		} else if (pageId == '6') { unused
			page += "/goals";
		} else if (pageId == '7') { unused
			page += "/perspectives";
		} else if (pageId == '8') { unused
			page += "/extverification";*/
		} else if (pageId == '9') {
			page += "/vendoraudits";
		} else if (pageId == '10') {
			page += "/extverification";
		}
	} else if (sectionId == 'g') {
		page = "productdesign";
		if (pageId == '2') {
			page += "/innovation";
		/*} else if (pageId == '3') { unused
			page += "/standards";*/
		} else if (pageId == '4') {
			page += "/materials";
		} else if (pageId == '5') {
			page += "/packaging";
		/*} else if (pageId == '6') { unused
			page += "/packaging/performance";
		} else if (pageId == '7') {
			page += "/packaging/casestudies";*/
		} else if (pageId == '8') {
			page += "/accessibility";
		/*} else if (pageId == '9') {
			page += "/productgoals";*/
		} else if (pageId == '10') {
			page += "/lifecycle";
		} else if (pageId == '11') {
			page += "/paper";
		}
	} else if (sectionId == 'h') {
		page = "operations";
		if (pageId == '2') {
			page += "/management";
		} else if (pageId == '3') {
			page += "/sustainable";
		} else if (pageId == '4') {
			page += "/waste";
		} else if (pageId == '5') {
			page += "/ozone";
		} else if (pageId == '6') {
			page += "/water";
		} else if (pageId == '7') {
			page += "/emissions";
		} else if (pageId == '8') {
			page += "/compliance";
		} else if (pageId == '9') {
			page += "/remediation";
		/*} else if (pageId == '10') { unused
			page += "/goals";*/
		}
	} else if (sectionId == 'i') {
		page = "privacy";
		if (pageId == '2') {
			page += "/hpapproach";
		/*} else if (pageId == '3') { unused
			page += "/goals";*/
		} else if (pageId == '4') {
			page += "/perspective";
		}
	} else if (sectionId == 'j') {
		page = "employees";
		if (pageId == '2') {
			page += "/diversity";
		/*} else if (pageId == '3') { unused
			page += "/diversity/performance";*/
		} else if (pageId == '4') {
			page += "/compensation";
		} else if (pageId == '5') {
			page += "/communications";
		} else if (pageId == '6') {
			page += "/learning";
		/*} else if (pageId == '7') {unused
			page += "/learning/performance";*/
		} else if (pageId == '8') {
			page += "/worklife";
		} else if (pageId == '9') {
			page += "/health";
		/*} else if (pageId == '10') {unused
			page += "/health/performance";*/
		} else if (pageId == '11') {
			page += "/volunteerism";
		/*} else if (pageId == '12') {unused
			page += "/volunteerism/performance";
		} else if (pageId == '13') {unused
			page += "/volunteerism/examples";
		} else if (pageId == '14') {unused
			page += "/casestudy";
		} else if (pageId == '15') {unused
			page += "/goals";*/
		}
	} else if (sectionId == 'k') {
		page = "socialinvestment";
		if (pageId == '2') {
			page = "socialinvest/education";
		} else if (pageId == '3') {
			page = "socialinvest/economicdevelopment";
		/*} else if (pageId == '4') {
			page = "socialinvest/environmentalsustainability";*/
		} else if (pageId == '5') {
			page = "socialinvest/performance";
		/*} else if (pageId == '6') {
			page = "socialinvest/measuring";
		} else if (pageId == '7') {
			page = "socialinvest/goals";*/
		} else if (pageId == '8') {
			page = "socialinvest/hpcommunity";
		} else if (pageId == '9') {
			page = "socialinvest/perspective";
		} else if (pageId == '10') {
			page = "socialinvest/measuring";
		}
	} else if (sectionId == 'l') {
		page = "about";
		if (pageId == '3') {
			page += "/assurance";
		} else if (pageId == '4') {
			page += "/glossary";
		} else if (pageId == '5') {
			page += "/griindex";
		} else if (pageId == '6') {
			page += "/sitemap";
		} else if (pageId == '7') {
			page += "/unglobalcompact";
		}
	} else if (sectionId == 'm') {
		page = "humanrights";
		if (pageId == '2') {
			page += "/humanrights";
		}
	} else if (sectionId == 'n') {
		page = "envsustainability";
		if (pageId == '2') {
			page += "/casestudies";
		} else if (pageId == '3') {
			page += "/perspective";
		}
	} else if (sectionId == 'o') {
		page = "ataglance";
		if (pageId == '2') {
			page += "/data";
		} else if (pageId == '3') {
			page += "/perspectives";
		} else if (pageId == '4') {
			page += "/policies";
		}
	}
  return rootPath+page;
}	
