function createRequestObject() {
  
  var request = new Object();
  var nameVal = "";
  var inString = location.search;
  var separator = ",";
  
  if(inString.charAt(0) == "?")
  {
	inString = inString.substring(1, inString.length);
	keypairs = inString.split("&");
	
	for(var i=0; i<keypairs.length; i++)
	{
		nameVal = keypairs[i].split("=");
		for (a in nameVal)
		{	
			nameVal[a] = nameVal[a].replace("+", " ");
			 nameVal[a] = unescape(nameVal[a]);
		}
			
			if(request[nameVal[0]])
			{
				request[nameVal[0]] += separator + nameVal[1];
			}
			else
			{
				request[nameVal[0]] = nameVal[1];
			}
	}
  }
  return request;
}

request = createRequestObject();
var locale = request.locale;
if (locale==null)
	locale="US";
var language = request.language;
if (language==null) 
	language="ENG";
var homepg = request.homepg;
if (homepg==null)
  homepg="index.htm";
  
var which_td_align;
var globalImagePath = "/images/global_nav/" + language + "/";
var imagePath = "/images/" + language + "/";


function openNewWindow(fileName){
   var Window = window.open(fileName,"newWindow", "height=500,width=695,menubar=yes,resizable=yes,toolbar=yes,status=yes,scrollbars=yes,dependent=yes");
   Window.focus();
}     

function openNewWindowSmall(fileName){
   var Window = window.open(fileName,"newWindow", "height=300,width=400,menubar=no,resizable=no,toolbar=no,status=yes,scrollbars=yes,dependent=yes");
   Window.focus();
}   

function movepic(img_name,img_src) {
this.document[img_name].src=img_src;
}

//for extranet nav
function AutoLink()
{
var number = document.dropdown.quickNav.selectedIndex;
top.location.href = document.dropdown.quickNav.options[number].value;
}

function preLoadImages(){
image1 = new Image();
image1.src = "/images/global_nav/ENG/search_off.gif";

image2 = new Image();
image2.src = "/images/global_nav/ENG/search_on.gif";

image3 = new Image();
image3.src = "/images/global_nav/ENG/pbi_off.gif";

image4 = new Image();
image4.src = "/images/global_nav/ENG/pbi_on.gif";
	
}

/* A method of the menuObj that renders the menu as a simple table */
function draw_text_menu_children_sub() {
which_td_align = 'right'; 
	if(current_text_menu_item != 'undefined') {
		current_text_menu_item.is_current = true;
	}
	
	//document.write("<td align="center"><a href="<%=editorialURL%>" class="globalNav" onFocus="if(this.blur)this.blur()"><%=editorialManager.thisEditorial.title%></a></td>;
	
	for(i=0;i<this.array_of_menu_items.length;i++) {
		// spacer_element is the visual divider between menu items,
		// typically, its a green pipe, but in special cases we'll 
		// change it, see lines 40-41 for special case:
		var spacer_element = "<td bgcolor='#33CC33' width='1'><img src='" + imagePath + "spacer.gif' width='1' height='1'></td>\n";
		if(this.array_of_menu_items[i].is_current == true) {
			// We don't want to draw the home link on the home page:
			if (this.array_of_menu_items[i].name != 'home') {
					this.array_of_menu_items[i].draw_current_text_item_sub(); 
			} else {
				 	// Also, if there's no home link (we're on the homepage), 
					// we don't want a green divider pipe:
					spacer_element = "";	
					}
		} else {
				this.array_of_menu_items[i].draw_non_current_text_item_sub();
				}
			// On the homepage, the layout is different, we 
			// account for that here:
			if (i == 5 && current_text_menu_item == home) {
				spacer_element = "<td><img src= '/images/global_nav/spacer.gif' width='16' height='27' border='0'></td>\n";
			} 
			// We don't add a spacer element after the last menu item:												
			if (i != (this.array_of_menu_items.length - 1)) {
					document.write(spacer_element);
			}
		}


}
	
/* method for adding children to a menu object */
function addTextItem_sub(new_item) {
	this.array_of_menu_items.length ++;
	var this_items_index = this.array_of_menu_items.length - 1;
	this.array_of_menu_items[this_items_index] = new_item;
}

/* The constructor function for entire menus */
function textMenuObjSub(name) {
	this.array_of_menu_items = new Array();
	this.name = name;
	this.addTextItemSub = addTextItem_sub;
	this.draw_text = draw_text_menu_children_sub;
	this.drawTopSubSite = drawTopSubSiteImage;
}

/* A method of the menuItem object */
function draw_non_current_text_item_sub() {
	document.write("<td align='center'><a href='" + this.href + "' class='globalNav' onFocus='if(this.blur)this.blur()'>&nbsp;&nbsp;" + this.name + "&nbsp;&nbsp;</a></td>");
}

/* A second method of the menuItem object */
function draw_current_text_item_sub() {
	document.write("<td align='center'><a href='" + this.href + "' class='greenLink' onFocus='if(this.blur)this.blur()'>&nbsp;&nbsp;" + this.name + "&nbsp;&nbsp;</a></td>");
}

function roll_on_sub() {
        this.state='on';
        this.update();
}

function roll_off_sub() {
        this.state='off';
		this.update();
}

/* Constructor function for menu items */
function textMenuItemSub(name,is_current,href,alt) {
	this.name = name;
	this.is_current = is_current;
	this.href = href;
	this.alt = alt;
	this.state = 'off';
	this.draw_non_current_text_item_sub = draw_non_current_text_item_sub;
	this.draw_current_text_item_sub = draw_current_text_item_sub;
}



function drawTopSubSiteImage(fileName, tagLine, background, alt) {
	document.open();
	
	//document.write("<table border=0 cellpadding=0 cellspacing=0><tr><td height=5><img src= '/images/global_nav/spacer.gif' width='14' height='1' border='0'></td></tr></table>\n");
	document.write('<table width="760" cellpadding="0" cellspacing="0" border="0" bgcolor="#003366">\n');
	document.write('<tr>\n');
	document.write('<td height="4" colspan="10"><img src="/extranet/global/images/spacer.gif" width="1" height="1" border="0"></td>\n');
	document.write('</tr>\n');
	document.write('<tr>\n');	
	document.write('<td width="9" nowrap><img src="/extranet/global/images/spacer.gif" width="1" height="1" border="0"></td>\n');
	document.write('<td width="410" nowrap><a onFocus="if(this.blur)this.blur()" href="http://www.pb.com"><img src="/bv70/images/pbLogoDark.gif" width="320" height="27" border="0" alt="Pitney Bowes"></a></td>\n');	
	document.write('<td align="right" nowrap><a onFocus="if(this.blur)this.blur()" href="../jsp/MyAccount.do" class="white" target="_top">My Account Home</a></td>\n');
	document.write('<td width="6" nowrap><img src="/extranet/global/images/spacer.gif" width="1" height="1" border="0"></td>\n');
	document.write('<td align="right" nowrap><a onFocus="if(this.blur)this.blur()" href="../jsp/Login.do?store_id=myaccount" class="white" target="_top">Log In</a></td>\n');
	document.write('<td width="6" nowrap><img src="/extranet/global/images/spacer.gif" width="1" height="1" border="0"></td>\n');
	document.write('<form name="dropdown" target="_top"><td align="right"><select name="quickNav" class="footer" onChange="javascript:AutoLink(this.form)">\n');
	document.write('<option selected value="#">Visit a PB Site</option>\n');
	document.write('<option value="http://www.pb.com">PB.com</option>\n');
	document.write('<option value="http://www.pb.com/supplies">Supplies Online</option>\n');
	document.write('<option value="http://www.pitneyworks.com">Pitney Works</option>\n');
	document.write('<option value="http://www.postagebyphone.com">Postage by Phone</option>\n');
	document.write('<option value="../jsp/PlaceCall.do?OnSiteTraining=false">Request Service</option>\n');
	document.write('<option value="http://www.pb.com/ratechange">Rate Change</option>\n');
	document.write('</select></td></form>\n');
	document.write('<td width="6"><img src="/extranet/global/images/spacer.gif" width="1" height="1" border="0"></td>\n');
	document.write('<td>&nbsp;</td>\n');
	document.write('<td>&nbsp;</td>\n');	
	document.write('</tr>\n');
	document.write('<tr>\n');	
	document.write('<td height="5" colspan="10"><img src="/extranet/global/images/spacer.gif" width="1" height="1" border="0"></td>\n');
	document.write('</tr>\n');	
	document.write('</table>\n');	
	document.write("<TABLE width='760' border='0' cellpadding='0' cellspacing='0'><TR><TD><TABLE width='760' border='0' cellpadding='0' cellspacing='0'>\n");
	document.write("<TR>");	
	document.write("<TD width='386' height='65' rowspan='2' valign='top' align='left' nowrap><IMG src='" + imagePath + fileName + "' alt='" + alt + "' border='0'></TD>");
	document.write("<TD width='374' height='28' valign='bottom' nowrap colspan='2'><IMG src='" + imagePath + tagLine + "' alt='" + alt + "'></TD>");
	document.write("</TR>");	
	document.write("<TR>");		
	document.write("<TD width='187' height='21' valign='top' nowrap>&nbsp;</TD>");
	document.write("<TD align='right' width='187' height='21' valign='bottom' nowrap><table border='0' cellspacing='0' cellpadding='0'>");
	document.write("<TR>");	
which_td_align = 'right'; 
	if(current_text_menu_item != 'undefined') {
		current_text_menu_item.is_current = true;
	}
	
	for(i=0;i<this.array_of_menu_items.length;i++) {
		// spacer_element is the visual divider between menu items,
		// typically, its a green pipe, but in special cases we'll 
		// change it, see lines 40-41 for special case:
		var spacer_element = "<td bgcolor='#000066' width='1'><img src='" + imagePath + "spacer.gif' width='1' height='1'></td>\n";
		if(this.array_of_menu_items[i].is_current == true) {
			// We don't want to draw the home link on the home page:
			if (this.array_of_menu_items[i].name != 'home') {
					this.array_of_menu_items[i].draw_current_text_item_sub(); 
			} else {
				 	// Also, if there's no home link (we're on the homepage), 
					// we don't want a green divider pipe:
					spacer_element = "";	
					}
		} else {
				this.array_of_menu_items[i].draw_non_current_text_item_sub();
				}
			// We don't add a spacer element after the last menu item:												
			if (i != (this.array_of_menu_items.length - 1)) {
					document.write(spacer_element);
			}
		}
	document.write("</tr></table>\n");
	document.write("</td>\n");
	document.write("</tr>\n");
	document.write("<TR>\n");
	document.write("<TD colspan='3' nowrap bgcolor='#000066' height='1'><IMG src='" + imagePath + "spacer.gif' width='1' height='1'></TD>\n");
	document.write("</TR>\n");
	document.write("</TABLE>\n");
	document.write("</TD>\n");
	document.write("</TR>\n");
	document.write("</TABLE>\n");	
	document.close();
}
/* 	Global Navigation Text Menu for Sub- Sites - END  */


