﻿
	function CheckMailAddressOK(emailControl) {
		if (emailControl.value == '') {
			alert('An email is required');
			return false;
		} else if (mailFormatOK(emailControl.value)) {
			alert('The email address does not seem to be valid');
			return false;
		}

		return true;
	}

	function validatePageMethod() {
		if (PageMethods.get_path().startsWith('/'))
			PageMethods.set_path(PageMethods.get_path().substring(1));
	}

	function SendCheetahStep2() {
		var emailTextBox = $get("TextBoxEmail2");
		if (CheckMailAddressOK(emailTextBox)) {


			validatePageMethod();
			PageMethods.SendCheetah(emailTextBox.value, OnCheetahSuccess, OnFailed);

			//clear email field
			emailTextBox.value = '';
		}
	}


	function SendCheetahStep3() {
		var emailTextBox = $get("TextBoxEmail2");

		if (CheckMailAddressOK(emailTextBox)) {
			validatePageMethod();
			PageMethods.SendCheetah(emailTextBox.value, OnCheetahSuccessStep3, OnFailed);

			//clear email field
			emailTextBox.value = '';
		}
	}


	function SendCheetahStep3nomail() {
		var emailTextBox = $get("TextBoxEmail2");
		if (CheckMailAddressOK(emailTextBox)) {

			validatePageMethod();
			PageMethods.SendCheetah(emailTextBox.value, OnCheetahSuccessStep3nomail, OnFailed);

			//clear email field
			emailTextBox.value = '';
		}
	}


	function OnCheetahSuccess() {
		document.getElementById('cheetahConfirmstep2').style.visibility = 'visible';
		document.bgColor = '#DCDCDC';
		SendOnCheetahSuccessOmniture();
	}

	function OnCheetahSuccessStep3() {
		document.getElementById('cheetahConfirmstep3').style.visibility = 'visible';
		document.bgColor = '#E3E3E3';
		SendOnCheetahSuccessOmniture();
	}
	function OnCheetahSuccessStep3nomail() {
		document.getElementById('cheetahConfirmstep3').style.visibility = 'visible';
		document.bgColor = '#E3E3E3';
		SendOnCheetahSuccessOmniture();
	}

	function SendOnCheetahSuccessOmniture() {

		var s = s_gi('carnivalprod');
		s.linkTrackVars = 'prop20,prop21,prop50,events';
		s.linkTrackEvents = 'event15,event20';
		s.prop20 = 'eBrochure';
		s.prop21 = 'eBrochure';
		s.prop50 = document.location.href;
		s.events = 'event15,event20';
		s.tl(this, 'o', 'eBrochure_EmailConfirm');
	}

	function OnFailed() {
		window.alert("Thank you!");
	}
