<!--
var maMaxV = [2, 2, 1, 2, 1, 2, 2, 2, 1, 2, 2, 2, 4, 3, 2, 2, 2, 2, 2, 2, 2, 2, 3, 2, 2, 1];
var maMinV = [2, 2, 1, 2, 1, 1, 2, 2, 1, 1, 2, 1, 2, 2, 2, 1, 2, 1, 1, 1, 2, 2, 3, 2, 1, 1];

function verifyWithAlert() {
  var w1 = document.getElementById('option1forward').value;
  var w2 = document.getElementById('option2upsidedown').value;
  //alert w1;
  alert(ambigramCheck(w1,w2));
}

function minVC(ch) {
	return maMinV[ch.toLowerCase().charCodeAt(0) - 97];
}

function maxVC(ch) {
	return maMaxV[ch.toLowerCase().charCodeAt(0) - 97];
}

function maxVS(st) {
        var i = 0;
        var v = 0;
        var l = st.length;

		for (i=0; i<l; i++) {
			v = v + maxVC(st.charAt(i));
		}
	return v;
}

function minVS(st) {
        var i = 0;
        var v = 0;
        var l = st.length;

		for (i=0; i<l; i++) {
			v = v + minVC(st.charAt(i));
		}
	return v;
}

function ambigramCheck(w1, w2) {
	//(c) 2008 Mark Hunter, WowTattoos.  It is illegal to use this algorithm without prior permission from Mark Hunter or WowTattoos.

    if (w1 == "") {
    	return "You must specify both words before performing a compatibility check";
    }

    if (w2 == "") {
    	return "You must specify both words before performing a compatibility check";
    }

	if (minVS(w1) > maxVS(w2)) {
		return "Sorry, but Mark will probably not be able to make these words into an Ambigram.  Although the two words don't necessarily need to be the same length, they do need to be compatible.\n\nThe problem with this combination is that the number and type of letters in '" + w1 + "' is too long compared to the number and type of letters in '" + w2 + "'.\n\nIf you're trying to match two names, don't forget to try nicknames, middle names, full names, and last names.";
	} else {
		if (maxVS(w1) < minVS(w2)) {
			return "Sorry, but Mark will probably not be able to make these words into an Ambigram.  Although the two words don't necessarily need to be the same length, they do need to be compatible.\n\nThe problem with this combination is that the number and type of letters in '" + w1 + "' is too short compared to the number and type of letters in '" + w2 + "'.\n\nIf you're trying to match two names, don't forget to try nicknames, middle names, full names, and last names.";
		} else {
			return "'" + w1 + "' and '" + w2 + "' appear to be Ambigram compatible!\n\nAlthough only our world-class Ambigram artist Mark Palmer will be able to make the final determination, as of right now things look good! Please place an order through our website using the boxes below so that Mark can get started on your design!";
		}
	}
}
//-->
