
// function to hide email addresses from spambots...
function MPHideEAddr(part1, part2) {
	var atSign = '&#64;';
	var results = '<a href="mai';
	results += 'lto:'+part1+atSign+part2+'">Email Us</a>';
	return results;
	}

// encode text string...
function MPEncodeText(thisString) {
	var results = '';
	for (var i=0; i<thisString.length; i++) {
		results += "&#"+thisString.charCodeAt(i)+";";
		}
	return results;
	}

// function for launching centered popup window...
var thisPopup = "";
function MPShowPopup(url, width, height) {
	var xpos = (Math.round(screen.availWidth/2)-(width/2));
	var ypos = (Math.round(screen.availHeight/2)-(height/2));
	if (xpos > screen.availWidth) xpos = screen.availWidth;
	if (ypos > screen.availHeight) ypos = screen.availHeight;
	var windowOptions = "";
	windowOptions += "width="+width;
	windowOptions += ",height="+height;
	windowOptions += ",resizable=yes";
	windowOptions += ",scrollbars=yes";
	windowOptions += ",menubar=no";
	windowOptions += ",toolbar=no";
	windowOptions += ",directories=no";
	windowOptions += ",location=no";
	windowOptions += ",status=no";
	windowOptions += ",left="+xpos;
	windowOptions += ",top="+ypos;
	thisPopup = window.open(url, "popUpWin1", windowOptions);
	if (thisPopup && typeof thisPopup == "object") if (!thisPopup.closed) thisPopup.focus();
	return false;
	}

// function to make string safe for URL query string...
function MPUrlEncode(thisString) {
	var regexp1 = /\//g
	var regexp2 = /\./g
	var replace1 = "[slash]";
	var replace2 = "[dot]";
	var thisString = thisString.replace(regexp1, replace1);
	var thisString = thisString.replace(regexp2, replace2);
	return escape(thisString);
	}

// function to decode MPUrlEncode...	
function MPUrlDecode(thisString) {
	thisString = unescape(thisString);
	var regexp1 = /\[slash\]/g
	var regexp2 = /\[dot\]/g
	var replace1 = "/";
	var replace2 = ".";
	var thisString = thisString.replace(regexp1, replace1);
	var thisString = thisString.replace(regexp2, replace2);
	return thisString;
	}

// function to delete record...
function MPConfirmDelete(recordType) {
	var msg = "Are you sure you want to permanently delete this "+recordType+"?";
	if (confirm(msg)) return true;
		else return false;
	}
	
// form validation
function FormValidator() {
	with (document.formRetail) {
		if (itemPrice.value == "") {
			alert("You must enter a valid price.");
			return false;
			} else return true;
		}
	}

// build navigation links from list and selected
function MPBuildNav(selected) {
	var html = MPGetNavHTML(selected);
	MPWriteDivContent(navDiv, html);
	}

// build HTML code for navigation
function MPGetNavHTML(selected) {
	if (selected == selectedLink) selectedLink = '';
		else if (selected != '' && selected != 'default') selectedLink = selected;
	var html = '';
	for (var n=0; n<linkVault.length; n++) {
		var thisKey = linkVault[n]['key'];
		var thisText = linkVault[n]['text'];
		var thisURL = linkVault[n]['url'];
		var thisSub = linkVault[n]['sub'];
		var rCode = (thisURL == '#') ? ' onclick="MPBuildNav(\''+thisKey+'\');return false;"' : '';
		var thisClass = (selectedLink == thisKey) ? mainClass2 : mainClass1;
		html += '<div class="'+thisClass+'"><a href="'+thisURL+'"'+rCode+'><span class="'+navSpan+'">'+thisText+'<\/span><\/a><\/div>'+"\n";
		if (selectedLink == thisKey && thisSub.length > 0) {
			html += '<div class="'+subDiv+'">'+"\n";
			for (var i=0; i<thisSub.length; i++) {
				var subKey = thisSub[i]['key'];
				var subText = thisSub[i]['text'];
				var subURL = thisSub[i]['url'];
				var subClass = (selectedSubLink == subKey && onLoadLink == selectedLink) ? subClass2 : subClass1;
				html += '<div class="'+subClass+'"><a href="'+subURL+'"><span class="'+subSpan+'">'+subText+'<\/span><\/a><\/div>'+"\n";
				}
			html += "<\/div>\n"
			}
		}
	return html;
	}

// write new content into div tag
function MPWriteDivContent(div, text) {
	if (document.layers) {
		if (typeof eval("document."+div+".document") != "undefined") {
			with (eval("document."+div+".document")) {
				open();
				write("<"+"HTML"+"><"+"HEAD"+"><"+"/HEAD"+"><"+"BODY"+">"+text+"<"+"/BODY"+"><"+"/HTML"+">");
				close();
				}
			}
		} else if (document.all && typeof document.all[div] != "undefined") {
		document.all[div].innerHTML = text;
		} else if (document.getElementById && !document.all && typeof document.getElementById(div) != "undefined") {
		document.getElementById(div).innerHTML = text;
		}
	}
