var stateList = new Array("Australian Capital Territory","New South Wales","Northern Territory","Queensland","South Australia","Tasmania","Victoria","Western Australia","Acre","Alagoas","Amapa","Amazonas","Bahia","Ceara","Distrito Federal","Espirito Santo","Goias","Maranhao","Mato Grosso","Mato Grosso do Sul","Minas Gerais","Para","Paraiba","Parana","Pernambuco","Piaui","Rio de Janeiro","Rio Grande do Norte","Rio Grande do Sul","Rondonia","Roraima","Santa Catarina","Sao Paulo","Sergipe","Tocantins","Alberta","British Columbia","Manitoba","New Brunswick","Newfoundland/Labrador","Northwest Territories","Nova Scotia","Nunavut","Ontario","Prince Edward Island","Quebec","Saskatchewan","Yukon","Aichi","Akita","Aomori","Chiba","Ehime","Fukui","Fukuoka","Fukushima","Gifu","Gumma","Hiroshima","Hokkaido","Hyogo","Ibaraki","Ishikawa","Iwate","Kagawa","Kagoshima","Kanagawa","Kouchi","Kumamoto","Kyoto","Mie","Miyagi","Miyazaki","Nagano","Nagasaki","Nara","Niigata","Oita","Okayama","Okinawa","Osaka","Saga","Saitama","Shiga","Shimane","Shizuoka","Tochigi","Tokushima","Tokyo","Tottori","Toyama","Wakayama","Yamagata","Yamaguchi","Yamanashi","Aguascalientes","Baja California","Baja California Sur","Campeche","Chiapas","Chihuahua","Coahuila","Colima","Distrito Federal","Durango","Guanajuato","Guerrero","Hidalgo","Jalisco","Mexico","Michoacan","Morelos","Nayarit","Nuevo Leon","Oaxaca","Puebla","Queretaro","Quintana Roo","San Luis Potosi","Sinaloa","Sonora","Tabasco","Tamaulipas","Tlaxcala","Veracruz","Yucatan","Zacatecas","Alabama","Alaska","Arizona","Arkansas","California","Colorado","Connecticut","Delaware","District of Columbia","Florida","Georgia","Hawaii","Idaho","Illinois","Indiana","Iowa","Kansas","Kentucky","Louisiana","Maine","Maryland","Massachusetts","Michigan","Minnesota","Mississippi","Missouri","Montana","Nebraska","Nevada","New Hampshire","New Jersey","New Mexico","New York","North Carolina","North Dakota","Ohio","Oklahoma","Oregon","Pennsylvania","Rhode Island","South Carolina","South Dakota","Tennessee","Texas","Virgin Islands","Utah","Vermont","Virginia","Washington","West Virginia","Wisconsin","Wyoming");
var stateCountryIdList = new Array("15","15","15","15","15","15","15","15","30","30","30","30","30","30","30","30","30","30","30","30","30","30","30","30","30","30","30","30","30","30","30","30","30","30","30","37","37","37","37","37","37","37","37","37","37","37","37","37","111","111","111","111","111","111","111","111","111","111","111","111","111","111","111","111","111","111","111","111","111","111","111","111","111","111","111","111","111","111","111","111","111","111","111","111","111","111","111","111","111","111","111","111","111","111","111","152","152","152","152","152","152","152","152","152","152","152","152","152","152","152","152","152","152","152","152","152","152","152","152","152","152","152","152","152","152","152","152","226","226","226","226","226","226","226","226","226","226","226","226","226","226","226","226","226","226","226","226","226","226","226","226","226","226","226","226","226","226","226","226","226","226","226","226","226","226","226","226","226","226","226","226","226","226","226","226","226","226","226","226");
var countryList = new Array("Afghanistan","Albania","Algeria","American Samoa","Andorra","Angola","Anguilla","Antarctica","Antigua and Barbuda","Argentina","Armenia","Aruba","Australia","Austria","Azerbaijan","Bahamas","Bahrain","Bangladesh","Barbados","Belarus","Belgium","Belize","Benin","Bermuda","Bhutan","Bolivia","Bosnia and Herzegovina","Botswana","Bouvet Island","Brazil","British Indian Ocean Territory","Brunei Darussalam","Bulgaria","Burkina Faso","Burundi","Cambodia","Cameroon","Canada","Cape Verde Islands","Cayman Islands","Central African Republic","Chad","Chile","China","Christmas Island","Cocos (Keeling) Islands","Colombia","Comoros","Congo, Democratic Republic of","Congo, Republic of","Cook Islands","Costa Rica","Cote d'Ivoire","Croatia/Hrvatska","Cuba","Cyprus","Czech Republic","Denmark","Djibouti","Dominica","Dominican Republic","East Timor","Ecuador","Egypt","El Salvador","Equatorial Guinea","Eritrea","Estonia","Ethiopia","Falkland Islands","Faroe Islands","Fiji","Finland","France","French Guiana","French Polynesia","French Southern Territories","Gabon","Gambia","Georgia","Germany","Ghana","Gibraltar","Greece","Greenland","Grenada","Guadeloupe","Guam","Guatemala","Guinea","Guinea-Bissau","Guyana","Haiti","Heard and McDonald Islands","Honduras","Hong Kong","Hungary","Iceland","India","Indonesia","Iran (Islamic Republic of)","Iraq","Ireland","Israel","Italy","Jamaica","Japan","Jordan","Kazakhstan","Kenya","Kiribati","Korea, Democratic People's Republic of","Korea, Republic of","Kuwait","Kyrgyzstan","Lao, People's Democratic Republic","Latvia","Lebanon","Lesotho","Liberia","Libyan Arab Jamahiriya","Liechtenstein","Lithuania","Luxembourg","Macau","Macedonia, Former Yugoslav Republic","Madagascar","Malawi","Malaysia","Maldives","Mali","Malta","Marshall Islands","Martinique","Mauritania","Mauritius","Mayotte Island","Mexico","Micronesia","Moldova, Republic of","Monaco","Mongolia","Montserrat","Morocco","Mozambique","Myanmar","Namibia","Nauru","Nepal","Netherlands","Netherlands Antilles","New Caledonia","New Zealand","Nicaragua","Niger","Nigeria","Niue","Norfolk Island","Northern Mariana Islands","Norway","Oman","Pakistan","Palau","Palestinian Territories","Panama","Papua New Guinea","Paraguay","Peru","Philippines","Pitcairn Island","Poland","Portugal","Puerto Rico","Qatar","Reunion Island","Romania","Russian Federation","Rwanda","Saint Helena","Saint Kitts and Nevis","Saint Lucia","Saint Pierre and Miquelon","Saint Vincent and the Grenadines","Samoa","San Marino","Sao Tome and Principe","Saudi Arabia","Senegal","Seychelles","Sierra Leone","Singapore","Slovak Republic","Slovenia","Solomon Islands","Somalia","South Africa","South Georgia and South Sandwich Islands","Spain","Sri Lanka","Sudan","Suriname","Svalbard and Jan Mayen Islands","Swaziland","Sweden","Switzerland","Syrian Arab Republic","Taiwan, Province of China","Tajikistan","Tanzania, United Republic of","Thailand","Togo","Tokelau","Tonga Islands","Trinidad and Tobago","Tunisia","Turkey","Turkmenistan","Turks and Caicos Islands","Tuvalu","Uganda","Ukraine","United Arab Emirates","United Kingdom","United States","Uruguay","US Minor Outlying Islands","Uzbekistan","Vanuatu","Vatican City","Venezuela","Viet Nam","Virgin Islands (British)","Virgin Islands (USA)","Wallis and Futuna Islands","Western Sahara","Yemen, Republic of","Yugoslavia","Zambia","Zimbabwe");
var countryIdList = new Array("4","7","60","13","2","10","6","11","5","12","8","16","15","14","17","31","24","20","19","35","21","36","26","27","32","29","18","34","33","30","103","28","23","22","25","114","46","37","51","121","40","207","45","47","52","38","48","116","39","41","44","49","43","95","248","53","54","57","56","58","59","216","61","63","203","85","65","62","67","70","72","69","68","73","77","170","208","74","82","76","55","79","80","86","81","75","84","89","88","83","90","91","96","93","94","92","97","106","102","98","243","249","99","100","107","109","111","110","122","112","115","250","119","120","113","123","132","124","129","128","246","126","130","131","143","139","137","151","153","150","140","148","138","145","146","149","239","152","71","136","135","142","147","134","154","141","155","164","163","161","9","156","166","160","157","159","165","158","144","162","167","173","180","178","168","171","181","169","172","176","174","179","177","182","183","184","185","186","193","117","125","175","230","237","198","202","187","199","189","197","192","196","194","188","200","241","87","66","127","251","201","195","205","191","42","244","220","211","221","210","209","212","215","218","214","217","213","206","219","223","222","3","224","226","227","225","228","235","229","231","234","232","233","236","64","238","240","242","245");

var baseUrl = "";

var xmlhttp = false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch(e1) {
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch(e2) {
			xmlhttp = false;
		}
	
	}
@end @*/
if(!xmlhttp && typeof XMLHttpRequest != 'undefined') {
	xmlhttp = new XMLHttpRequest();
}

function init_baseUrl(url) {
	baseUrl = url;
}

function init_featuredt() {
	if(xmlhttp && document.getElementById("featuredt_container") != null) {
		load_featuredt();			
	}
}

function load_featuredt() {
	var topElement = document.getElementById("featuredt_top");
	var bottomElement = document.getElementById("featuredt_bottom");
		
	xmlhttp.open("GET", baseUrl + "featuredt.php");
	xmlhttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
	xmlhttp.onreadystatechange = function() {
		if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			topElement.innerHTML = xmlhttp.responseText;			
			self.setTimeout("rotate_featuredt(-140)", 100);			
		}
	}
	xmlhttp.send(null);
}

function rotate_featuredt(top_position) {
	var topElement = document.getElementById("featuredt_top");
	var bottomElement = document.getElementById("featuredt_bottom");
	var topHeight;
	var bottomHeight;	

	top_position += 5;
	if(top_position < 0) {			
		topHeight = String(top_position) + "px";							
		topElement.style.marginTop = topHeight;			
		self.setTimeout("rotate_featuredt(" + top_position + ")", 100);		
	} else {
		bottomElement.innerHTML = topElement.innerHTML;	
		topElement.style.marginTop = "-140px";
		self.setTimeout("load_featuredt()", 5000);		
	}
}

function process_email_course() {
  var email = document.getElementById("email_course").value;
  if(email == "" || !email.match(/^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/)) {
    document.getElementById("email_course").style.background = "#FFC0C0";
    return false;
  }
  document.getElementById("header_email_course_signup").style.display = "none";  
  document.getElementById("header_email_course_complete").style.display = "inline";
   
  data = "email=" + escape(email);
  xmlhttp.open("POST", baseUrl + "submit_email_course.php", true);  
  xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  xmlhttp.setRequestHeader("Content-length", data.length);  
  xmlhttp.setRequestHeader("Connection", "close");
  xmlhttp.send(data);
  
  return false;
}

function getCountryIdByCountry(countryName) {
	var i;
	var countryId;
	for(i = 0; i < countryList.length; i++) {
		if(countryList[i] == countryName) {
			countryId = countryIdList[i];
			break;
		}
	}
	return countryId;
}

function updateStatesList(formName) {
	var countryId;
	var i;
	var stateCount = 0;
	var selectedStateIndex = 0;
	var selectBox = document.forms[formName]['state'];
	var countryName = document.forms[formName]['country'].value;
	var otherstate_input = document.forms[formName]['otherstate'];
	var otherstate_box = 'otherstate_option';
	var stateselect_box = 'stateselect_option';
	var selectedStateValue = otherstate_input.value;				
		
	if (countryName == 'United States' || countryName == 'Australia' || countryName == 'Brazil' || countryName == 'Canada' || countryName == 'Mexico' || countryName == 'Japan') {		
		otherstate_input.value = '';
		document.getElementById(stateselect_box).style.display = "";
		document.getElementById(otherstate_box).style.display = "none";
	} else {		
		document.getElementById(stateselect_box).style.display = "none";
		document.getElementById(otherstate_box).style.display = "";
	}
	
	countryId = getCountryIdByCountry(countryName);	
	selectBox.options.length = 0;
	for(i = 0; i < stateList.length; i++) {
		if(stateCountryIdList[i] == countryId) {
			stateCount++;
			selectBox.options.length = (stateCount);
			selectBox.options[stateCount] = new Option(stateList[i], stateList[i]);
			if(stateList[i].toLowerCase() == selectedStateValue.toLowerCase()) {
				selectedStateIndex = stateCount;
			}
		}
	}
	if(countryName == 'Australia' || countryName == 'Canada') {
		selectBox.options[0] = new Option('Select Province', 'Select Province');
	} else {
		selectBox.options[0] = new Option('Select State', 'Select State');
	}
	selectBox.selectedIndex = 0;
	if(selectedStateIndex > 0) {
		selectBox.selectedIndex = selectedStateIndex;
		otherstate_input.value = '';
	}
}
		
function flagField(form, field) {
	document.forms[form][field].style.backgroundColor = "red";
	document.forms[form][field].style.color = "black";
}		

function unflagField(form, field) {
	document.forms[form][field].style.backgroundColor = "";
	document.forms[form][field].style.color = "";
}

function validateEMail(email) {
	return email.match(/^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/);
}

function validatePhone(phone) {	
	//return phone.match(/^[0-9]*[\-\s]?((\([0-9]{3}\))|([0-9]{3}))[\-\s]?[0-9]{3}[\-]?[0-9]{4}(\s?([Xx]|([Ee][Xx][Tt]\.?))\s?[0-9]+)?$/);
	return true;
}

function validateState(formName) {
	var result = true;

	if(document.getElementById("stateselect_option").style.display == "none") {	
		if(document.forms[formName]["otherstate"].value == "") {
			flagField(formName, "otherstate");
			result = false;
		} else {
			unflagField(formName, "otherstate");
		}
		unflagField(formName, "state");		
	} else {		
		if(document.forms[formName]["state"].value == "Select State" || document.forms[formName]["state"].value == "Select Province") {
			flagField(formName, "state");
			result = false;
		} else {
			unflagField(formName, "state");
		}		
	}		
	
	return result;
}

function validateZip(zip) {
	//return zip.match(/^(([a-zA-Z][0-9][a-zA-Z]\s?[0-9][a-zA-Z][0-9])|([0-9]{5})(\-?[0-9]{4})?)$/);
	return true;
}

function validateUrl(url) {
	return url.match(/^[a-zA-Z0-9.][-a-zA-Z0-9.]*\.[a-zA-Z]{2,3}\.?$/);
}
		
function validateWSignup() {
	var result = true;
	var text_fields = new Array("fn","ln","email","address1","city","zip","phone","password","confirm_password","url","title","description");	
			
	for(i = 0; i < text_fields.length; i++) {			
		if(document.forms["signup"][text_fields[i]].value == "") {
			flagField("signup", text_fields[i]);
			result = false;		
		} else {
			unflagField("signup", text_fields[i]);
		}
	}
	
	if(document.forms["signup"]["password"].value != document.forms["signup"]["confirm_password"].value) {
		flagField("signup", "password");
		flagField("signup", "confirm_password");
		result = false;
	} else if(document.forms["signup"]["password"].value != "") {
		unflagField("signup", "password");
		unflagField("signup", "confirm_password");
	}	
	
	
	if(validateState("signup") == false) {
		result = false;
	}	
	
	if(!validateEMail(document.forms["signup"]["email"].value)) {	
		flagField("signup", "email");
		result = false;
	}	
	if(document.forms["signup"]["altemail"].value != "" && !validateEMail(document.forms["signup"]["altemail"].value)) {
		flagField("signup", "altemail");
		result = false;
	}				
	
	if(!validatePhone(document.forms["signup"]["phone"].value)) {
		flagField("signup", "phone");
		result = false;
	}
	
	if(!validateZip(document.forms["signup"]["zip"].value)) {
		flagField("signup", "zip");
		result = false;
	}
	
	if(!validateUrl(document.forms["signup"]["url"].value)) {
		flagField("signup", "url");
		result = false;
	}
	
	return result;
}

function validateBilling() {
	var result = true;
	var text_fields = new Array("fn","ln","address1","city","zip","phone","email");	

	for(i = 0; i < text_fields.length; i++) {			
		if(document.forms["purchase_billing"][text_fields[i]].value == "") {
			flagField("purchase_billing", text_fields[i]);
			result = false;		
		} else {
			unflagField("purchase_billing", text_fields[i]);
		}
	}	

	if(!validateEMail(document.forms["purchase_billing"]["email"].value)) {	
		flagField("purchase_billing", "email");
		result = false;
	}	
	
	if(!validatePhone(document.forms["purchase_billing"]["phone"].value)) {
		flagField("purchase_billing", "phone");
		result = false;
	}

	if(validateState("purchase_billing") == false) {
		result = false;
	}		
	
	if(document.forms["purchase_billing"]["terms_agree"].checked == false) {
		document.getElementById("agree_block").style.display = "";
		result = false;
	} else {
		document.getElementById("agree_block").style.display = "none";
	}

	return result;
}

function validateAddTestimonial() {
	var result = true;
	var text_fields = new Array("fn", "ln", "email", "city");
	
	for(i = 0; i < text_fields.length; i++) {			
		if(document.forms["addt"][text_fields[i]].value == "") {
			flagField("addt", text_fields[i]);
			result = false;		
		} else {
			unflagField("addt", text_fields[i]);
		}
	}
	
	if(!validateEMail(document.forms["addt"]["email"].value)) {
		flagField("addt", "email");
		result = false;
	}
	
	if(document.forms["addt"]["phone"].value == "" || validatePhone(document.forms["addt"]["phone"].value)) {
		unflagField("addt", "phone");
	} else {
		result = false;
		flagField("addt", "phone");
	}
	
	if(validateState("addt") == false) {
		result = false;
	}
	
	return result;
}

function validatePVerify() {
	var result = true;
	var text_fields = new Array("fn", "ln", "phone", "city");
	
	for(i = 0; i < text_fields.length; i++) {			
		if(document.forms["pverify"][text_fields[i]].value == "") {
			flagField("pverify", text_fields[i]);
			result = false;		
		} else {
			unflagField("pverify", text_fields[i]);
		}
	}
	
	if(document.forms["pverify"]["ttext"] != null) {
		if(document.forms["pverify"]["ttext"].value == "") {
			flagField("pverify", "ttext");
			result = false;
		} else {
			unflagField("pverify", "ttext");
		}
	}
	
	if(!validatePhone(document.forms["pverify"]["phone"].value)) {
		flagField("pverify", "phone");
		result = false;
	}

	if(validateState("pverify") == false) {
		result = false;
	}	
	
	return result;
}

function validateAddDomain() {
	var result = true;
	var text_fields = new Array("url", "title", "description");
	
	for(i = 0; i < text_fields.length; i++) {			
		if(document.forms["add_domain"][text_fields[i]].value == "") {
			flagField("add_domain", text_fields[i]);
			result = false;		
		} else {
			unflagField("add_domain", text_fields[i]);
		}
	}
	
	if(document.forms["add_domain"]["usecurrentcontact"].checked == false) {
		if(document.forms["add_domain"]["email"].value == "") {
			flagField("add_domain", "email");
			result = false;
		} else {
			unflagField("add_domain", "email");
		}
	} else {
		unflagField("add_domain", "email");
	}
	
	if(document.forms["add_domain"]["usecurrentcontact"].checked || document.forms["add_domain"]["phone"].value == "" || validatePhone(document.forms["add_domain"]["phone"].value)) {
		unflagField("add_domain", "phone");
	} else {
		result = false;
		flagField("add_domain", "phone");
	}
	
	if(!validateUrl(document.forms["add_domain"]["url"].value)) {
		flagField("add_domain", "url");
		result = false;
	}
	
	return result;
}

function validateChangePassword() {
	var result = true;	
	
	if(document.forms["change_password"]["password"].value == "") {
		result = false;
	}
	
	if(document.forms["change_password"]["password"].value != document.forms["change_password"]["confirm"].value) {
		result = false;
	}
	
	if(result == false) {
		flagField("change_password", "password");
		flagField("change_password", "confirm");
	} else {
		unflagField("change_password", "password");
		unflagField("change_password", "confirm");
	}
	
	return result;
}

function validateBestTimeToCall(formName) {		
	var checked = false;
	for(i = 0; i < 5; i++) {
		if(document.forms[formName]["bestday1"][i].checked) {
			checked = true;
			break;
		}
	}
	if(checked == false) {
		return false;
	}

	if(document.forms[formName]["besttime1_morning"].checked == false && document.forms[formName]["besttime1_afternoon"].checked == false) {
		return false;
	}
}

function validateAffiliateApply() {
	var result = true;
	var text_fields = new Array("partners_fn", "partners_ln", "partners_email", "partners_phone", "partners_url", "partners_shortdesc", "partners_uniquedailyvisitors");
	
	for(i = 0; i < text_fields.length; i++) {			
		if(document.forms["partners_applynow"][text_fields[i]].value == "") {
			flagField("partners_applynow", text_fields[i]);
			result = false;		
		} else {
			unflagField("partners_applynow", text_fields[i]);
		}
	}
	
	if(!validatePhone(document.forms["partners_applynow"]["partners_phone"].value)) {
		flagField("partners_applynow", "partners_phone");
		result = false;
	}
	
	if(!validateEMail(document.forms["partners_applynow"]["partners_email"].value)) {
		flagField("partners_applynow", "partners_email");
		result = false;
	}
	
	return result;
}

function calculateROI(affiliateAmount, newSignupAmount) {
	var result = true;
	var text_fields = new Array("numOfVisitorsPerDay", "avgProfitMarginPerOrder", "percentMoreVisitors", "percentMoreSignUps");
	var visitsPerDay;
	var percentMoreVisitors;
	var profitMarginPerOrder;
	var percentMoreSignups;
	var enhancedConversion;
	var enhancedReferals;
	var enhancedTotal;
	var calculatedROI;
	var payoffMonths;
	var payoffDays;
	var t;
	
	for(i = 0; i < text_fields.length; i++) {			
		if(document.forms["merchants_roi"][text_fields[i]].value == "") {
			flagField("merchants_roi", text_fields[i]);
			result = false;		
		} else {
			unflagField("merchants_roi", text_fields[i]);
		}
	}	
	
	visitsPerDay = document.forms["merchants_roi"]["numOfVisitorsPerDay"].value;
	percentMoreVisitors = document.forms["merchants_roi"]["percentMoreVisitors"].options[document.forms["merchants_roi"]["percentMoreVisitors"].selectedIndex].value;
	profitMarginPerOrder = document.forms["merchants_roi"]["avgProfitMarginPerOrder"].value;
	percentMoreSignups = document.forms["merchants_roi"]["percentMoreSignUps"].options[document.forms["merchants_roi"]["percentMoreSignUps"].selectedIndex].value;
	
	enhancedConversion = Math.round(visitsPerDay * percentMoreVisitors * profitMarginPerOrder * 365/100);
	enhancedReferals = Math.round(visitsPerDay * percentMoreSignups * affiliateAmount * 365/100);
	enhancedTotal = parseFloat(enhancedConversion) + parseFloat(enhancedReferals);
	calculatedROI = ((parseInt(enhancedTotal)*100) / newSignupAmount) + 0.5;
		
	payoffDays = parseInt(parseFloat(newSignupAmount) / (parseFloat(enhancedTotal) / 365.0));		
	payoffMonths = parseInt(payoffDays / 30);
	payoffDays -= payoffMonths * 30;
	
	if(result) {
		document.getElementById("enhancedConversionText").style.color = "#009900";
		document.getElementById("enhancedReferralsText").style.color = "#009900";
		document.getElementById("calculatedROIText").style.color = "#000099";
		document.getElementById("enhancedConversion").style.color = "#009900";
		document.getElementById("enhancedReferrals").style.color = "#009900";
		document.getElementById("calculatedROI").style.color = "#000099";
		document.getElementById("enhancedConversion").innerHTML = "$" + enhancedConversion;
		document.getElementById("enhancedReferrals").innerHTML = "$" + enhancedReferals;
		document.getElementById("calculatedROI").innerHTML = calculatedROI + "%";
		if(payoffMonths > 0) {
			if(payoffMonths > 1) {
				document.getElementById("calculatedROIPayoffMonths").innerHTML = payoffMonths + " Months";
			} else {
				document.getElementById("calculatedROIPayoffMonths").innerHTML = payoffMonths + " Month";
			}
		} else {
			document.getElementById("calculatedROIPayoffMonths").innerHTML = "";
		}
		if(payoffDays > 1) {
			document.getElementById("calculatedROIPayoffDays").innerHTML = payoffDays + " Days";
		} else {
			document.getElementById("calculatedROIPayoffDays").innerHTML = "1 Day";
		}
		document.getElementById("ROITimeResultLine").style.visibility = "visible";
	}
	
	return false;
}

function clearROI() {
	document.getElementById("enhancedConversionText").style.color = "#000000";
	document.getElementById("enhancedReferralsText").style.color = "#000000";
	document.getElementById("calculatedROIText").style.color = "#000000";
	document.getElementById("enhancedConversion").style.color = "#000000";
	document.getElementById("enhancedReferrals").style.color = "#000000";
	document.getElementById("calculatedROI").style.color = "#000000";

	document.getElementById("enhancedConversion").innerHTML = "$";
	document.getElementById("enhancedReferrals").innerHTML = "$";
	document.getElementById("calculatedROI").innerHTML = "%";
	
	document.getElementById("ROITimeResultLine").style.visibility = "hidden";
	
	return true;
}

function updateDomainSubCatList(formName) {			
	var subCatSelect = document.forms[formName]["subcat"];		
	var selectedValue = document.forms[formName]["cat"].value;		
	var valueCount = 0;	
		
	subCatSelect.options.length = 0;		
	for(i = 0; i < domainSubCatNames.length; i++) {		
		if(domainSubCatRefIDs[i] == selectedValue) {
			valueCount++;
			subCatSelect.options.length = valueCount;
			subCatSelect.options[valueCount - 1] = new Option(domainSubCatNames[i], domainSubCatIDs[i]);
		}
	}		
}

function submitForm(formName) {
	document.forms[formName].submit();
}

function updatePaymentForm() {
	if(document.forms["payment_select"]["method"][0].checked || document.forms["payment_select"]["method"][1].checked) {
		document.getElementById("credit_card_payment").style.display = "";
		document.getElementById("paypal_payment").style.display = "none";
		if(document.forms["payment_select"]["method"][0].checked) {
			document.forms["card_payment"]["method"].value = "visa";
		} else {
			document.forms["card_payment"]["method"].value = "mastercard";
		}
	} else {
		document.getElementById("paypal_payment").style.display = "";
		document.getElementById("credit_card_payment").style.display = "none";
	}
}

function placeCallCountryChange() {
	document.forms["pcall"]["intl_phone1"].value = document.forms["pcall"]["countryList"].options[document.forms["pcall"]["countryList"].selectedIndex].value;
}

function validatePlaceCall() {
	var result = true;
	var text_fields;
	var text_fields_unflag;
	if(document.forms["pcall"]["phoneChoice"][0].checked) {
		text_fields = new Array("uscan_phone1", "uscan_phone2", "uscan_phone3");
		text_fields_unflag = new Array("intl_phone1", "intl_phone2");
	} else {
		text_fields = new Array("intl_phone1", "intl_phone2");
		text_fields_unflag = new Array("uscan_phone1", "uscan_phone2", "uscan_phone3");
	}
	
	for(i = 0; i < text_fields.length; i++) {			
		if(document.forms["pcall"][text_fields[i]].value == "") {
			flagField("pcall", text_fields[i]);
			result = false;		
		} else {
			unflagField("pcall", text_fields[i]);
		}
	}
	
	for(i = 0; i < text_fields_unflag.length; i++) {			
		unflagField("pcall", text_fields_unflag[i]);
	}
	
	return result;
}

function validatePlaceCall() {
	var result = true;
	var text_fields;
	var text_fields_unflag;
	if(document.forms["wactivate"]["phoneChoice"][0].checked) {
		text_fields = new Array("uscan_phone1", "uscan_phone2", "uscan_phone3");
		text_fields_unflag = new Array("intl_phone1", "intl_phone2");
	} else {
		text_fields = new Array("intl_phone1", "intl_phone2");
		text_fields_unflag = new Array("uscan_phone1", "uscan_phone2", "uscan_phone3");
	}
	
	for(i = 0; i < text_fields.length; i++) {			
		if(document.forms["wactivate"][text_fields[i]].value == "") {
			flagField("wactivate", text_fields[i]);
			result = false;		
		} else {
			unflagField("wactivate", text_fields[i]);
		}
	}
	
	for(i = 0; i < text_fields_unflag.length; i++) {			
		unflagField("wactivate", text_fields_unflag[i]);
	}
	
	return result;
}

function validateOptIn() {
	var result = true;
	var text_fields = new Array("fn", "ln", "email", "confirm_email");
	
	for(i = 0; i < text_fields.length; i++) {			
		if(document.forms["optin"][text_fields[i]].value == "") {
			flagField("optin", text_fields[i]);
			result = false;		
		} else {
			unflagField("optin", text_fields[i]);
		}
	}

	if(document.forms["optin"]["email"].value != document.forms["optin"]["confirm_email"].value) {
		flagField("optin", "email");
		flagField("optin", "confirm_email");
		result = false;
	}
	
	if(!validateEMail(document.forms["optin"]["email"].value)) {
		flagField("optin", "email");
		result = false;
	}
	
	return result;
}

function emphasize_testimonial_text(textarea_name) {
	var textarea = document.getElementById(textarea_name);
	if(!textarea.setSelectionRange) {
		var selected = document.selection.createRange().text;
		if(selected.length > 0) {
			document.selection.createRange().text = "[em]" + selected + "[/em]";			
		}
	} else {
		var pretext = textarea.value.substring(0, textarea.selectionStart);
		var modified = "[em]" + textarea.value.substring(textarea.selectionStart, textarea.selectionEnd) + "[/em]";
		var posttext = textarea.value.substring(textarea.selectionEnd, textarea.value.length);
		textarea.value = pretext + modified + posttext;
	}
	
	textarea.focus();
	return false;
}

var offer_seconds_remaining = 0;

function start_time_offer(remaining) {
  offer_seconds_remaining = remaining;
  update_time_offer();  
}

function update_time_offer() {
  var minutes_entry = document.getElementById("limited_time_offer_minutes");
  var seconds_entry = document.getElementById("limited_time_offer_seconds");
  var seconds = offer_seconds_remaining % 60;
  minutes_entry.innerHTML = Math.ceil((offer_seconds_remaining - seconds) / 60).toFixed(0);
  seconds_entry.innerHTML = seconds.toFixed(0);
  offer_seconds_remaining -= 1;
  if(offer_seconds_remaining < 0) {
    offer_seconds_remaining = 0;
  }
  setTimeout('update_time_offer();', 1000); 
}