function checkForm(evnt) {
    if (typeof(required) != "undefined") {
	var me = (evnt.srcElement) ? evnt.srcElement : this;
	var stop = false;

	for (a = 0; a < required.length; a++) {
		var reqd = required[a].split(":");
		if (me.elements[reqd[0]]) {
			var val = me.elements[reqd[0]];
			if (reqd[1] == "date") {
				var pattern = /^\d\d[\-\/]\d\d[\-\/]\d\d\d\d$/;
				if (val.value && !val.value.match(pattern)) stop = val;
			} else if (reqd[1] == "email") {
				var pattern = /^[\w\d]+[\w\d\.\-_]*\@[\w\d]+[\w\d\.\-_]*\.\w+$/;
				if (!val.value.match(pattern)) stop = val;
			} else if (reqd[1] == "number") {
				val.value = val.value.replace(/[^\d\.]/g, "");
				if (!val.value) stop = val;
			} else if (reqd[1] == "phone") {
				stop = checkPhone(val)
			} else {
				stop = checkBlank(val);
			}
			if (stop) break;
		}
	}

	if (stop) {
		alert(reqd[2]);
		stop.focus();
		if (evnt.preventDefault != undefined) evnt.preventDefault();
		return false;
	}
    }
    return true;
}

function checkBlank(field) {
	// Text Field Validation
	if (field.type == "text" || field.type == "textarea" || field.type == "password" || field.type == "hidden") {
		if (field.value == "") return field;

	// File Uploads
	} else if (field.type == "file") {
		if (!field.value) return field;

	// Single Checkboxes
	} else if (field.checked != undefined) {
		if (!field.checked) return field;

	// Select Boxes
	} else if (field.selectedIndex != undefined) {
		if (field.selectedIndex == -1 || field[field.selectedIndex].value == "") return field;

	// Radio Buttons and Multiple Checkboxes
	} else if (field.length) {
		var checked = false;
		for (var i=0; i < field.length; i++) {
			if (field[i].checked) checked = true;
		}
		if (!checked) return field[0];
	}
	return false;
}

function checkPhone (you) {
	var cc = {

/****
TEMP Options -- Pending update to WMA within Clickability to support rendering option values. Indexed variations supplied below.
****/
		"1": 93, "3": 355, "4": 213, "5": 1, "6": 376, "7": 244, "8": 1, "10": 1, "11": 54, "12": 374, "13": 297, "2": 247, "14": 61, "15": 43, "16": 994,
		"17": 1, "18": 973, "19": 880, "20": 1, "21": 375, "22": 32, "23": 501, "24": 229, "25": 1, "26": 975, "27": 591, "28": 387, "29": 267, "30": 0, "31": 55, "32": 0, "33": 673, "34": 359, "35": 226, "36": 257,
		"37": 855, "38": 237, "39": 1, "40": 238, "41": 1, "42": 236, "43": 235, "54": 0, "44": 56, "45": 86, "46": 61, "47": 61, "48": 57, "49": 269, "50": 242, "52": 682, "53": 506, "55": 385, "56": 53, "247": 599, "57": 357, "58": 420,
		"59": 45, "60": 253, "61": 1, "62": 1,
		"219": 0, "63": 593, "64": 20, "65": 503, "66": 240, "67": 291, "68": 372, "69": 251,
		"70": 500, "71": 298, "72": 679, "73": 358, "74": 33, "75": 594, "76": 689, "77": 0,
		"78": 241, "79": 220, "80": 995, "81": 49, "82": 233, "83": 350, "84": 30, "85": 299, "86": 1, "87": 590, "88": 1, "89": 502, "91": 224, "92": 245, "93": 592,
		"94": 509, "95": 0, "96": 39, "97": 504, "98": 852, "99": 36,
		"100": 354, "101": 91, "102": 62, "103": 98, "104": 964, "105": 353, "107": 972, "108": 39, "106": 225,
		"109": 1, "110": 81, "112": 962,
		"113": 7, "114": 254, "115": 686, "117": 850, "116": 82, "118": 965, "119": 996,
		"120": 856, "121": 371, "122": 961, "123": 266, "124": 231, "125": 218, "126": 423, "127": 370, "128": 352,
		"129": 853, "130": 389, "131": 261, "132": 265, "133": 60, "134": 960, "135": 223, "136": 356, "137": 692, "138": 596, "139": 222, "140": 230, "141": 269, "142": 52, "143": 691, "144": 373, "145": 377, "146": 976, "148": 1, "149": 212, "150": 258, "151": 95,
		"152": 264, "153": 674, "154": 977, "155": 31, "156": 599, "157": 687, "158": 64, "159": 505, "160": 227, "161": 234, "162": 683, "163": 672, "164": 1, "165": 47,
		"166": 968,
		"167": 92, "168": 680, "169": 970, "170": 507, "171": 675, "172": 595, "173": 51, "174": 63, "175": 0, "176": 48, "177": 351, "178": 1,
		"179": 974,
		"180": 262, "181": 40, "182": 7, "183": 250,
		"191": 0, "192": 378, "193": 239, "194": 966, "195": 221, "196": 381, "197": 248, "198": 232, "199": 65, "200": 421, "201": 386, "202": 677, "203": 252, "204": 27, "205": 0, "206": 34, "207": 94, "185": 290, "186": 1, "187": 1, "189": 508, "190": 1, "208": 249, "209": 597, "210": 0, "211": 268, "212": 46, "213": 41, "214": 963,
		"215": 886, "216": 992, "217": 255, "218": 66, "220": 228, "221": 960, "222": 676, "223": 1, "224": 216, "225": 90, "226": 993, "227": 1, "228": 688,
		"234": 1, "233": 1, "229": 256, "230": 380, "231": 971, "232": 44, "234": 598, "236": 998,
		"237": 678, "238": 58, "239": 84, "240": 1, "241": 1,
		"242": 681, "243": 0,
		"244": 967,
		"245": 260, "246":263,
/****
End Temp Options
****/

		"Afghanistan": 93, "Albania": 355, "Algeria": 213, "American Samoa": 1, "Andorra": 376, "Angola": 244, "Anguilla": 1, "Antigua and Barbuda": 1, "Argentina": 54, "Armenia": 374, "Aruba": 297, "Ascension Island": 247, "Australia": 61, "Austria": 43, "Azerbaijan": 994,
		"Bahamas": 1, "Bahrain": 973, "Bangladesh": 880, "Barbados": 1, "Belarus": 375, "Belgium": 32, "Belize": 501, "Benin": 229, "Bermuda": 1, "Bhutan": 975, "Bolivia": 591, "Bosnia and Herzegovina": 387, "Botswana": 267, "Bouvet Island": 0, "Brazil": 55, "British Indian Ocean Territory": 0, "Brunei Darussalam": 673, "Bulgaria": 359, "Burkina Faso": 226, "Burundi": 257,
		"Cambodia": 855, "Cameroon": 237, "Canada": 1, "Cape Verde": 238, "Cayman Islands": 1, "Central African Republic": 236, "Chad": 235, "Channel Islands": 0, "Chile": 56, "China": 86, "Christmas Island": 61, "Cocos (Keeling) Islands": 61, "Colombia": 57, "Comoros": 269, "Congo": 242, "Cook Islands": 682, "Costa Rica": 506, "Croatia": 385, "Cuba": 53, "Curacao": 599, "Cyprus": 357, "Czech Republic": 420,
		"Denmark": 45, "Djibouti": 253, "Dominica": 1, "Dominican Republic": 1,
		"East Timor": 0, "Ecuador": 593, "Egypt": 20, "El Salvador": 503, "Equatorial Guinea": 240, "Eritrea": 291, "Estonia": 372, "Ethiopia": 251,
		"Falkland Islands (Malvinas)": 500, "Faroe Islands": 298, "Fiji": 679, "Finland": 358, "France": 33, "French Guiana": 594, "French Polynesia": 689, "French Southern Territories": 0,
		"Gabon": 241, "Gambia": 220, "Georgia": 995, "Germany": 49, "Ghana": 233, "Gibraltar": 350, "Greece": 30, "Greenland": 299, "Grenada": 1, "Guadeloupe": 590, "Guam": 1, "Guatemala": 502, "Guinea": 224, "Guinea-Bissau": 245, "Guyana": 592,
		"Haiti": 509, "Heard and McDonald Islands": 0, "Holy See / Vatican City": 39, "Honduras": 504, "Hong Kong": 852, "Hungary": 36,
		"Iceland": 354, "India": 91, "Indonesia": 62, "Iran": 98, "Iraq": 964, "Ireland": 353, "Israel": 972, "Italy": 39, "Ivory Coast": 225,
		"Jamaica": 1, "Japan": 81, "Jordan": 962,
		"Kazakhstan": 7, "Kenya": 254, "Kiribati": 686, "Korea": 850, "Korea, Democratic People's Rep": 82, "Kuwait": 965, "Kyrgyzstan": 996,
		"Laos": 856, "Latvia": 371, "Lebanon": 961, "Lesotho": 266, "Liberia": 231, "Libyan Arab Jamahiriya": 218, "Liechtenstein": 423, "Lithuania": 370, "Luxembourg": 352,
		"Macau": 853, "Macedonia": 389, "Madagascar": 261, "Malawi": 265, "Malaysia": 60, "Maldives": 960, "Mali": 223, "Malta": 356, "Marshall Islands": 692, "Martinique": 596, "Mauritania": 222, "Mauritius": 230, "Mayotte": 269, "Mexico": 52, "Micronesia": 691, "Moldova, Republic of": 373, "Monaco": 377, "Mongolia": 976, "Montserrat": 1, "Morocco": 212, "Mozambique": 258, "Myanmar": 95,
		"Namibia": 264, "Nauru": 674, "Nepal": 977, "Netherlands": 31, "Netherlands Antilles": 599, "New Caledonia": 687, "New Zealand": 64, "Nicaragua": 505, "Niger": 227, "Nigeria": 234, "Niue": 683, "Norfolk Island": 672, "Northern Mariana Islands": 1, "Norway": 47,
		"Oman": 968,
		"Pakistan": 92, "Palau": 680, "Palestinian Authority": 970, "Panama": 507, "Papua New Guinea": 675, "Paraguay": 595, "Peru": 51, "Philippines": 63, "Pitcairn Islands": 0, "Poland": 48, "Portugal": 351, "Puerto Rico": 1,
		"Qatar": 974,
		"Reunion": 262, "Romania": 40, "Russian Federation": 7, "Rwanda": 250,
		"Samoa": 0, "San Marino": 378, "Sao Tome and Principe": 239, "Saudi Arabia": 966, "Senegal": 221, "Serbia and Montenegro": 381, "Seychelles": 248, "Sierra Leone": 232, "Singapore": 65, "Slovakia": 421, "Slovenia": 386, "Solomon Islands": 677, "Somalia": 252, "South Africa": 27, "South Georgia/South Sandwich": 0, "Spain": 34, "Sri Lanka": 94, "St. Helena": 290, "St. Kitts and Nevis": 1, "St. Lucia": 1, "St. Pierre and Miquelon": 508, "St. Vincent and Grenadines": 1, "Sudan": 249, "Suriname": 597, "Svalbard and Jan Mayen Islands": 0, "Swaziland": 268, "Sweden": 46, "Switzerland": 41, "Syrian Arab Republic": 963,
		"Taiwan": 886, "Tajikistan": 992, "Tanzania, United Republic of": 255, "Thailand": 66, "Togo": 228, "Tokelau": 960, "Tonga": 676, "Trinidad and Tobago": 1, "Tunisia": 216, "Turkey": 90, "Turkmenistan": 993, "Turks and Caicos Islands": 1, "Tuvalu": 688,
		"US Minor Outlying Islands": 1, "USA": 1, "Uganda": 256, "Ukraine": 380, "United Arab Emirates": 971, "United Kingdom": 44, "Uruguay": 598, "Uzbekistan": 998,
		"Vanuatu": 678, "Venezuela": 58, "Vietnam": 84, "Virgin Islands (British)": 1, "Virgin Islands (U.S.)": 1,
		"Wallis and Futuna Islands": 681, "Western Sahara": 0,
		"Yemen": 967,
		"Zambia": 260, "Zimbabwe":263
	};



	you.value = you.value.replace(/\D/g, "");
	you.value = you.value.replace(/^00+/, "");
	var bob = you.value;
	country = (typeof(you.form.elements["country"]) != "undefined") ? you.form.elements["country"].value : false;
	if (cc[country]) {
		var where = bob.indexOf(cc[country]);
		you.value = "+" + ((you.value.indexOf(cc[country]) == 0) ? you.value : cc[country] + you.value);
		var marg = you.value;
		if (cc[country] == 1) {
			if (you.value.length > 12) you.value = you.value.substring(0,12) + " x" + you.value.substring(12);
			if (!you.value.match(/^\+1[2-9]\d{2}[2-9]\d{6}/)) return you;
		} else {
			if (!you.value.match(/^\+\d{3,}/)) return you;
		}
	} else {
		return checkBlank(you);
	}
}

