document.write('<table width="700" cellspacing="0" cellpadding="0" border="0"><tr valign="middle"><td bgcolor="#006cb0"><form action="http://ns.networktechinc.com/cgi-bin/htsearch" method="get" class="mt0">&nbsp;&nbsp;<input type="hidden" name="restrict" value="vpi.us"><input name="words" type="text" class="red" onFocus="if( this.value==this.defaultValue ) this.value=\'\'\;" value="Search" size="20">&nbsp;&nbsp;<input name="submit" type="image" src="http://www.vpi.us/images/re-go.gif" alt="search" align="top" width="22" height="18" border="0"> <input type="hidden" name="search_results_wrapper" value="/usr/local/share/htdig/wrapper-vpi.html"><input type="hidden" name="nothing_found_file" value="/usr/local/share/htdig/nomatch-vpi.html"></form></td><td align="center" valign="middle" bgcolor="#006cb0" class="nav2">800-626-7801</td><td align="right" valign="middle" bgcolor="#006cb0" class="navtop"><a href="http://www.vpi.us/customer-support.html">Customer Support</a>&nbsp;&nbsp;</td><script type="text/javascript">DisplayItems();</script></tr></table><script type="text/javascript">eraseCartItemsTemp();</script>');
function extLink(name) { 
	// Get Cart Info to Display on Exit
	// Intialize Variables
	var bitems = 0;
	var bsubtotal = 0;
	var subtotal = 0;
	var noitems = 0;
	// WebShop Number of Items and Subtotal
  	var y = readCookieWebShop('bitems');
  	if (y) {
		// WebShop Number of Items
		var bitems = readCookieWebShop('bitems');
  		if (bitems) {
			bitems = bitems.replace(/^\s+|\s+$/g, '') ;
		}
		// WebShop SubTotal
	  	var bsubtotal = readCookieWebShop('bsubtotal');
	  	if (bsubtotal) {
			bsubtotal = bsubtotal.replace("%24","");
			bsubtotal = bsubtotal.replace("%2e",".");	
			bsubtotal = bsubtotal.replace("%2c",",");			
			bsubtotal = bsubtotal.replace(/^\s+|\s+$/g, '') ;
		}
	}
	// Non-WebShop Cart Items
	var z = readCookiePage('cartitemstotal');
	if (z) { 
		z = z.replace(/^\s+|\s+$/g, '') ;	
		// Split on | to get individual values into an array
		var items = z.split('|');	
		// Get number of items and subtotal and build cartform contents
		var i=1;
		while (i < items.length) {
			var subtotal = parseFloat(subtotal) + (parseFloat(items[i])*parseInt(items[i+1]));
			var subtotal = subtotal.toFixed(2);	
			var noitems = parseInt(noitems) + parseInt(items[i+1]);	
		    i = i + 3;
		}
	}
	// Get Variables
		var itemsDisplay = parseInt(noitems) + parseInt(bitems);
		var subTotalDisplay = parseFloat(subtotal) + parseFloat(bsubtotal);
		var subTotalDisplay = subTotalDisplay.toFixed(2);
	// Display as MouseOut when leaving page
		if (itemsDisplay == '0'){
		msgstring="<table border=\"0\" valign=\"middle\"><tr onClick=\"extLink('cart', '" + itemsDisplay + "', '" + subTotalDisplay + "')\" onMouseOver=\"DisplayItemsMouseOver('" + itemsDisplay + "', '" + subTotalDisplay + "'); this.style.cursor='pointer'\"><td class=\"cart\"><img src=\"images/icon-cart-empty.gif\" alt=\"Cart icon\" width=\"21\" height=\"17\" border=\"0\" align=\"absmiddle\">Your Cart&nbsp;&nbsp;</td><td class=\"cartsub\">Items in Cart: ";
		}
		else {
				msgstring="<table border=\"0\" valign=\"middle\"><tr onClick=\"extLink('cart', '" + itemsDisplay + "', '" + subTotalDisplay + "')\" onMouseOver=\"DisplayItemsMouseOver('" + itemsDisplay + "', '" + subTotalDisplay + "'); this.style.cursor='pointer'\"><td class=\"cart\"><img src=\"images/icon-cart-full.gif\" alt=\"Cart icon\" width=\"21\" height=\"17\" border=\"0\" align=\"absmiddle\">Your Cart&nbsp;&nbsp;</td><td class=\"cartsub\">Items in Cart: ";
		}
		msgstring= msgstring + itemsDisplay;
		msgstring= msgstring + "<br>Sub-Total: ";
		msgstring= msgstring + subTotalDisplay;
		msgstring= msgstring + "</td></tr></table>";
  	if(document.layers){
	   	//Browser="NN4";
	  	textlayer = document.layers['cart'];
	  	textlayer.document.open();
	  	textlayer.document.write(msgstring);
	  	textlayer.document.close();  
	  	}
	if(document.all){
	  	//Browser="IE"
	  	textlayer = document.all['cart'];
	  	textlayer.innerHTML=msgstring;  
	}
	if(document.getElementById){
	  	//Browser="NN6+";
	  	textlayer = document.getElementById('cart');
	  	textlayer.innerHTML =msgstring;
	} 
	if (name == "cart"){
		var z = readCookiePage('cartitemstotal');
		// Submit Cart items from cartitemstotal cookie if it exists, otherwise go directly to shopping cart
		if (z) {
			eraseCartItemsTotal();
			document.cartform.submit();
			}
		else {
			window.location = 'http://www.vpi.us/cgi-bin/vpi/ord/basket.html';
		}
	}
	if (name == "shop"){
		var z = readCookiePage('cartitemstotal');
		// Submit Cart items from cartitemstotal cookie if it exists, otherwise go directly to WehShop home page
		if (z) {
			eraseCartItemsTotal();
			document.cartform.submit();
			}
		else {
			window.location = 'http://www.vpi.us/cgi-bin/vpi';
		}
	}
}
function eraseCartItemsTemp() {
	createCookiePage('cartitems',"",-1);
}
function eraseCartItemsTotal() {
	createCookiePage('cartitemstotal',"",-1);
}
function createCookiePage(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}
function readCookiePage(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
function addCartItems(sku, price, qty){
	strCookie = sku + "|" + price + "|" + qty;
	// Check if numeric value has been entered for qty
	var addItems = 0; 
	var NumericExpression = /^[0-9]+$/; 
	if(qty.match(NumericExpression)){ 
		addItems = 1; // Proceed with adding items 		
  	}
  	else // Non-numeric values have been entered
  	{ 
  		alert('Only Numeric Values may be entered for this field.');
  	}	
	if (addItems == 1){
	  	var y = readCookiePage('cartitems');
		skuMatch = 0;
		if (y) { 
			y = y.replace(/^\s+|\s+$/g, '') ;	
			// Split on | to get individual values into an array
			var items = y.split('|');	
			// See if the sku already exists
			var i=0;
			while (i < items.length) {
				// If sku matches, update quantity 
				if (sku == items[i]){
					items[i+2]=qty;
					skuMatch = 1;
				}		
				i = i + 3;
			}		
			// Rewrite Cookie
			if (skuMatch == 1){
				var i=1;
				strCookie = items[0];
				while (i < items.length) {
				  strCookie = strCookie + "|" + items[i];
				  i = i + 1; 
				}
			}
			// Append Existing Cookie
			else {
				strCookie = y + "|" + strCookie;	
			}
			createCookiePage('cartitems',strCookie,0);
		} 
		else { 
			// Create New Cookie
			createCookiePage('cartitems',strCookie,0);
		}	
	}	
}
function addToCart(){
  	var y = readCookiePage('cartitems');
	var z = readCookiePage('cartitemstotal');
	skuMatch = 0;
	// Both a Temp and Totals cookie exists
	if (z && y) { 
		y = y.replace(/^\s+|\s+$/g, '') ;	
		z = z.replace(/^\s+|\s+$/g, '') ;	
		// Split on | to get individual values into an array for each cookie	
		var yitems = y.split('|');	
		var zitems = z.split('|');			
		// Compare items in Temp cookie against those in the Totals cookie
		var i=0;		
		var strAppend="";
		while (i < yitems.length) {
			var k=0;
			skuMatch = 0;
			while (k < zitems.length) {
				// If sku matches, update quantity 
				if (zitems[k] == yitems[i]){
					zitems[k+2]= parseInt(yitems[i+2])+ parseInt(zitems[k+2]);
					skuMatch = 1;
				}		
				k = k + 3;
			}	
			if (skuMatch != 1){
			strAppend = strAppend + "|" + yitems[i] + "|" + yitems[i+1] + "|" + yitems[i+2];
			}
			i = i + 3;
		}			
		// Append Existing Cookie
		var j=1;
		strCookie = zitems[0];
		while (j < zitems.length) {
			strCookie = strCookie + "|" + zitems[j];
			j = j + 1; 
		}	
		strCookie = strCookie + strAppend;
		createCookiePage('cartitemstotal',strCookie,0);
		// Refresh Page
		setTimeout("location.reload(true);",0);
	} 
	// Only a Temp cookie exists
	else if (y) { 
		// Create New Cookie
		strCookie = y;
		createCookiePage('cartitemstotal',strCookie,0);
		// Refresh Page
		setTimeout("location.reload(true);",0);
	}		
}
function readCookieWebShop(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
function DisplayItems() {  
	// Open cartform Form
	document.write('<form action="http://www.vpi.us/cgi-bin/vpi/process.html?" method="post" class="mtb" name="cartform"><input type="hidden" name="mv_doit" value="refresh">');
	// Intialize Variables
	var bitems = 0;
	var bsubtotal = 0;
	var subtotal = 0;
	var noitems = 0;
	// WebShop Number of Items and Subtotal
  	var y = readCookieWebShop('bitems');
  	if (y) {
		//document.write("<b>Items in Cart</b>: ");
		// WebShop Number of Items
		var bitems = readCookieWebShop('bitems');
  		if (bitems) {
			bitems = bitems.replace(/^\s+|\s+$/g, '') ;
			//document.write(bitems);
		}
		//document.write("&nbsp;&nbsp;&nbsp;<b>Sub-Total</b>: ");
		// WebShop SubTotal
	  	var bsubtotal = readCookieWebShop('bsubtotal');
	  	if (bsubtotal) {
			bsubtotal = bsubtotal.replace("%24","");
			bsubtotal = bsubtotal.replace("%2e",".");	
			bsubtotal = bsubtotal.replace("%2c",",");			
			bsubtotal = bsubtotal.replace(/^\s+|\s+$/g, '') ;
			//document.write(bsubtotal);
		}
		// Recent Orders
		//document.write("&nbsp;&nbsp;&nbsp;<b><a href=\"http://www.vpi.us/cgi-bin/vpi/query/check_orders.html\"><b>Previous Orders</b></a><br>");
	}
	// Non-WebShop Cart Items
	var z = readCookiePage('cartitemstotal');
	//if (z) {
		//document.write("<br>");
		//document.write(z);
		//document.write("<br>");
	//}
	if (z) { 
		z = z.replace(/^\s+|\s+$/g, '') ;	
		// Split on | to get individual values into an array
		var items = z.split('|');	
		// Get number of items and subtotal and build cartform contents
		var i=1;
		while (i < items.length) {
			var subtotal = parseFloat(subtotal) + (parseFloat(items[i])*parseInt(items[i+1]));
			var subtotal = subtotal.toFixed(2);	
			var noitems = parseInt(noitems) + parseInt(items[i+1]);	
			// Create cartform contents
			document.write('<input type="hidden" name="mv_order_item" value="' + items[i-1] + '"><input type="hidden" name="mv_order_quantity" value="'+ items[i+1] +'">');	
			i = i + 3;
		}			
		//document.write("<b>Items in Cart</b>: ");
		//document.write(noitems);
		//document.write("&nbsp;&nbsp;&nbsp;<b>Sub-Total</b>: ");
		//document.write(subtotal);
		//document.write("<br>");
			
	}
	// Display Number of Items in Cart and Subtotal	if Webshop and/or Non-Webshop cookie exists
		var itemsDisplay = parseInt(noitems) + parseInt(bitems);
		var subTotalDisplay = parseFloat(subtotal) + parseFloat(bsubtotal);
		var subTotalDisplay = subTotalDisplay.toFixed(2);
		
		if (itemsDisplay == '0'){
		document.write("<td bgcolor=\"#3399cc\"><div id=\"cart\"><table border=\"0\" valign=\"middle\"><tr onClick=\"extLink('cart')\" onMouseOver=\"DisplayItemsMouseOver('" + itemsDisplay + "', '" + subTotalDisplay + "'); this.style.cursor='pointer'\"><td class=\"cart\"><img src=\"images/icon-cart-empty.gif\" alt=\"Cart icon\" width=\"21\" height=\"17\" border=\"0\" align=\"absmiddle\">Your Cart&nbsp;&nbsp;</td>");
		} 
		else {
		document.write("<td bgcolor=\"#3399cc\"><div id=\"cart\"><table border=\"0\" valign=\"middle\"><tr onClick=\"extLink('cart')\" onMouseOver=\"DisplayItemsMouseOver('" + itemsDisplay + "', '" + subTotalDisplay + "'); this.style.cursor='pointer'\"><td class=\"cart\"><img src=\"images/icon-cart-full.gif\" alt=\"Cart icon\" width=\"21\" height=\"17\" border=\"0\" align=\"absmiddle\">Your Cart&nbsp;&nbsp;</td>");
		}
		document.write("<td class=\"cartsub\">Items in Cart: ");
		document.write(itemsDisplay);
		document.write("<br>Sub-Total: ");
		document.write(subTotalDisplay);
		document.write("</td></tr></table></div></td>");
	// Close cartform Form
	document.write('</form>');
}
function DisplayItemsMouseOver(itemsDisplay, subTotalDisplay) {
	if (itemsDisplay == '0'){
		msgstring="<table border=\"0\" valign=\"middle\" bgcolor=\"#ff0000\"><tr onClick=\"extLink('cart')\" onMouseOut=\"DisplayItemsMouseOut('" + itemsDisplay + "', '" + subTotalDisplay + "');\" onMouseOver=\"this.style.cursor='pointer';\"><td class=\"cart-over\"><img src=\"images/icon-cart-empty-o.gif\" alt=\"Cart icon\" width=\"21\" height=\"17\" border=\"0\" align=\"absmiddle\">Your Cart&nbsp;&nbsp;</td><td class=\"cartsub-over\">Items in Cart: ";
		}
	else{
		msgstring="<table border=\"0\" valign=\"middle\" bgcolor=\"#ff0000\"><tr onClick=\"extLink('cart')\" onMouseOut=\"DisplayItemsMouseOut('" + itemsDisplay + "', '" + subTotalDisplay + "');\" onMouseOver=\"this.style.cursor='pointer';\"><td class=\"cart-over\"><img src=\"images/icon-cart-full-o.gif\" alt=\"Cart icon\" width=\"21\" height=\"17\" border=\"0\" align=\"absmiddle\">Your Cart&nbsp;&nbsp;</td><td class=\"cartsub-over\">Items in Cart: ";
		}
		msgstring= msgstring + itemsDisplay;
		msgstring= msgstring + "<br>Sub-Total: ";
		msgstring= msgstring + subTotalDisplay;
		msgstring= msgstring + "</td></tr></table>";
  	if(document.layers){
	   	//Browser="NN4";
	  	textlayer = document.layers['cart'];
	  	textlayer.document.open();
	  	textlayer.document.write(msgstring);
	  	textlayer.document.close();  
	  	}
	if(document.all){
	  	//Browser="IE"
	  	textlayer = document.all['cart'];
	  	textlayer.innerHTML=msgstring;  
	}
	if(document.getElementById){
	  	//Browser="NN6+";
	  	textlayer = document.getElementById('cart');
	  	textlayer.innerHTML =msgstring;
	}  
} 
function DisplayItemsMouseOut(itemsDisplay, subTotalDisplay) {
	if (itemsDisplay == '0'){
		msgstring="<table border=\"0\" valign=\"middle\"><tr onClick=\"extLink('cart')\" onMouseOver=\"DisplayItemsMouseOver('" + itemsDisplay + "', '" + subTotalDisplay + "'); this.style.cursor='pointer'\"><td class=\"cart\"><img src=\"images/icon-cart-empty.gif\" alt=\"Cart icon\" width=\"21\" height=\"17\" border=\"0\" align=\"absmiddle\">Your Cart&nbsp;&nbsp;</td><td class=\"cartsub\">Items in Cart: ";
		}
	else{
		msgstring="<table border=\"0\" valign=\"middle\"><tr onClick=\"extLink('cart')\" onMouseOver=\"DisplayItemsMouseOver('" + itemsDisplay + "', '" + subTotalDisplay + "'); this.style.cursor='pointer'\"><td class=\"cart\"><img src=\"images/icon-cart-full.gif\" alt=\"Cart icon\" width=\"21\" height=\"17\" border=\"0\" align=\"absmiddle\">Your Cart&nbsp;&nbsp;</td><td class=\"cartsub\">Items in Cart: ";
		}
		msgstring= msgstring + itemsDisplay;
		msgstring= msgstring + "<br>Sub-Total: ";
		msgstring= msgstring + subTotalDisplay;
		msgstring= msgstring + "</td></tr></table>";
  	if(document.layers){
	   	//Browser="NN4";
	  	textlayer = document.layers['cart'];
	  	textlayer.document.open();
	  	textlayer.document.write(msgstring);
	  	textlayer.document.close();  
	  	}
	if(document.all){
	  	//Browser="IE"
	  	textlayer = document.all['cart'];
	  	textlayer.innerHTML=msgstring;  
	}
	if(document.getElementById){
	  	//Browser="NN6+";
	  	textlayer = document.getElementById('cart');
	  	textlayer.innerHTML =msgstring;
	}  
} 