﻿// make "safe-ish" email links...
function MPHideEAddr(part1, part2) {
	var atSign = '&#64;';
	var results = '<a href="mai';
	results += 'lto:'+part1+atSign+part2+'">email</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 popoup 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;
	}

// function to append size to product name in PayPal form...
function MPUpdateProd(thisForm) {
	with (thisForm) {
		var thisAmount = amount.options[amount.selectedIndex].value;
		var thisSize = (thisAmount == '3.00') ? ' (small)' : ' (large)';
		item_name.value = item_name.value + thisSize;
		}
	return true;
	}