/* BEGIN COMMON CODE */

var unityHost = "http://" + window.location.href.match(/:\/\/(.[^/]+)/)[1];
//var unityHost="http://localhost:8089";
function SendRequest(params, callbackFunction) {

	var http = new XMLHttpRequest();

	var url =  unityHost + "/app/globalx/contact.castle";
	http.open("POST", url, true);

	//Send the proper header information along with the request
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http.setRequestHeader("Content-length", params.length);
	http.setRequestHeader("Connection", "close");

	http.onreadystatechange = function() {//Call a function when the state changes.
		if(http.readyState == 4 && http.status == 200) {
			callbackFunction(http.responseText);
		}
	}

	http.send(params);

}

function IsValidEmail(email) {
	var regex = /(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])/

	return email.match(regex);
}

/* BEGIN NEWS ALERT SIGNUP EMAIL */

function SendNewsAlertsEmail() {

	if (ValidateNewsAlertsEmail()) {
		
		$("#newsAlertButton")[0].style.display = "none";
		$("#newsAlertLoading")[0].style.display = "inline-block";
		
		var params =
			"cu.Type=0&" +
			"cu.Email=" + encodeURI($("#newsEmail").attr("value")) + "&" +
			"cu.State=" + encodeURI($("#newsState")[0].value) + "&";
			
		params += ($("#newsWantsLegal").attr("checked") ? "cu.WantsLegalNews=on&" : "");
		params += ($("#newsWantsProperty").attr("checked") ? "cu.WantsPropertyNews=on&" : "");
		params += ($("#newsWantsCommercial").attr("checked") ? "cu.WantsCommercialNews=on&" : "");
		params += ($("#newsWantsIS").attr("checked") ? "cu.WantsInformationServices=on&" : "");
		params += ($("#newsWantsGIS").attr("checked") ? "cu.WantsGlobalXProductsAndServices=on&" : "");
		params += ($("#newsWantsJobs").attr("checked") ? "cu.WantsJobOpportunities=on&" : "");
		
		// if the parameter string ends with an ampersand
		// remove it
		if (params.substr(params.length - 1, 1) == "&") {
			params = params.substr(0, params.length - 1);
		}
		
		SendRequest(params, NewsAlertMailCallback);

	}
}

function ValidateNewsAlertsEmail() {

	var email = $("#newsEmail").attr("value");

	if (email == "") {
		return ShowNewsAlertError();
	} else {
		if (!IsValidEmail(email)) {
			return ShowNewsAlertError();
		}
	}

	$("#newsEmailError")[0].style.visibility = "hidden";
	return true;
}

function ShowNewsAlertError() {
	$("#newsEmailError")[0].style.visibility = "visible";
	return false;
}

function NewsAlertMailCallback(response) {
	$("#newsAlertLoading")[0].style.display = "none";
	$("#signupForm")[0].style.display = "none";

	if (response === "True") {
		$("#newsFormSuccess")[0].style.display = "inline-block";
	} else {
		$("#newsFormFailure")[0].style.display = "inline-block";
	}
}

/* BEGIN ENQUIRY EMAIL - THIS IS THE ONE IN THE NAV BAR */

function SendEnquiryEmail() {

	if (ValidateEnquiryEmail()) {

		$("#enquiryButton")[0].style.display = "none";
		$("#enquiryLoading")[0].style.display = "inline-block";
	
		var params =
			"cu.Name=" 		+ encodeURI($("#emailName")		.attr("value")) 	+ "&" +
			"cu.Email=" 	+ encodeURI($("#emailFrom")		.attr("value")) 	+ "&" +
			"cu.Subject=" 	+ encodeURI($("#emailSubject")	.attr("value")) 	+ "&" +
			"cu.Body=" 		+ encodeURI($("#emailBody")		.attr("value"))     + "&" +
			"cu.Type=1";

		SendRequest(params, EnquiryEmailCallback);

	}
}

function ValidateEnquiryEmail() {

	var email = $("#emailFrom").attr("value");

	if (email == "") {
		return ShowEnquiryError();
	} else {
		if (!IsValidEmail(email)) {
			return ShowEnquiryError();
		}
	}

	$("#emailFromError")[0].style.visibility = "hidden";
	return true;
}

function ShowEnquiryError() {
	$("#emailFromError")[0].style.visibility = "visible";
	return false;
}

function EnquiryEmailCallback(response) {

	$("#enquiryLoading")[0].style.display = "none";
	$("#enquiriesForm")[0].style.display = "none";

	if (response === "True") {
		$("#enquiriesFormSuccess")[0].style.visibility = "visible";
	} else {
		$("#enquiriesFormFailure")[0].style.visibility = "visible";
	}

}

/* BEGIN QUICK ENQUIRY EMAIL - THIS IS THE ONE IN THE SIDE FORM */

function SendQuickEnquiryEmail() {

	if (ValidateSideEnquiryEmail()) {

		$("#quickEnquiryButton")[0].style.display = "none";
		$("#quickEnquiryLoading")[0].style.display = "inline-block";
	
		var params =
			"cu.Name="           + encodeURI($("#sideEmailName")       .attr("value")) + "&" +
			"cu.Email="          + encodeURI($("#sideEmailFrom")       .attr("value")) + "&" +
			"cu.CompanyName="    + encodeURI($("#sideEmailCompanyName").attr("value")) + "&" +
			"cu.PhoneNumber="    + encodeURI($("#sideEmailPhone")      .attr("value")) + "&" +
			"cu.Body="           + encodeURI($("#sideEmailBody")       .attr("value")) + "&" +
			"cu.Type=2";

		SendRequest(params, QuickEnquiryEmailCallback);

	}
}

 function ValidateSideEnquiryEmail() {

	var email = $("#sideEmailFrom").attr("value");

	if (email == "") {
		return ShowSideEnquiryError();
	} else {
		if (!IsValidEmail(email)) {
				return ShowSideEnquiryError();
		}
	}

	$("#sideEmailFromError")[0].style.visibility = "hidden";
	return true;
}

function ShowSideEnquiryError() {
	$("#sideEmailFromError")[0].style.visibility = "visible";
	return false;
}

function QuickEnquiryEmailCallback(response) {

	$("#sideEnquiriesForm")[0].style.display = "none";
	$("#quickEnquiryLoading")[0].style.display = "none";

	if (response === "True") {
			$("#sideEnquiriesFormSuccess")[0].style.visibility = "visible";
	} else {
			$("#sideEnquiriesFormFailure")[0].style.visibility = "visible";
	}

}
		
/* BEGIN STRATA ENQUIRY EMAIL - THIS IS THE ONE FOR THE STRATA LANDING PAGE */
		
function SendStrataEnquiryEmail() {

	if (ValidateStrataEnquiryEmail()) {

		$("#quickStrataEnquiryButton")[0].style.display = "none";
		$("#quickStrataEnquiryLoading")[0].style.display = "inline-block";
	
		var params =
			"cu.Type=3&" +
			"cu.Name=" 			 + encodeURI($("#conferenceEmailName")			.attr("value")) 	+ "&" +
			"cu.Email=" 		 + encodeURI($("#conferenceEmailFrom")			.attr("value")) 	+ "&" +
			"cu.CompanyName="    + encodeURI($("#conferenceEmailCompanyName")   .attr("value"))     + "&" +
			"cu.PhoneNumber="    + encodeURI($("#conferencePhoneNumber")        .attr("value"))     + "&" +
			"cu.KeyContact="   	 + encodeURI($("#conferenceKeyContact")   		.attr("value"))     + "&" +
			"cu.JobFunction="    + encodeURI($("#conferenceJobFunction")        .attr("value"))     + "&" +
			"cu.Body=" 			 + encodeURI($("#conferenceEmailBody")			.attr("value"))     + "&" +
			"cu.State=" + encodeURI($("#newsState")[0].value) + "&";
			
		params += ($("#conferenceBodyCorpStrataReports").attr("checked") ? "cu.WantsBodyCorpStrataReports=on&" : "");
		params += ($("#conferenceSpatialSearching").attr("checked") ? "cu.WantsSpatialSearching=on&" : "");
		params += ($("#conferenceNatTitlesPlansDealingsInstruments").attr("checked") ? "cu.WantsNatTitlesPlansDealingsInstruments=on&" : "");
		params += ($("#conferenceCadastralMapsAerialPhoto").attr("checked") ? "cu.WantsCadastralMapsAerialPhoto=on&" : "");
		params += ($("#conferenceSalesValuationsInfo").attr("checked") ? "cu.WantsSalesValuationsInfo=on&" : "");
		params += ($("#conferencePracticeManagementSolutions").attr("checked") ? "cu.WantsPracticeManagementSolutions=on&" : "");
		params += ($("#conferenceTalkingNewsletter").attr("checked") ? "cu.WantsTalkingNewsletter=on&" : "");
		params += ($("#conferenceSetUp").attr("checked") ? "cu.WantsSetUp=on&" : "");
		params += ($("#conferenceCallDemo").attr("checked") ? "cu.WantsCallDemo=on&" : "");
		
	
		if (params.substr(params.length - 1, 1) == "&") {
			params = params.substr(0, params.length - 1);
		}
		
		SendRequest(params, StrataNewsAlertMailCallback);

	}
}

function ValidateStrataEnquiryEmail() {

	var email = $("#conferenceEmailFrom").attr("value");

	if (email == "") {
		return ShowStrataEnquiryError();
	} else {
		if (!IsValidEmail(email)) {
			return ShowStrataEnquiryError();
		}
	}

	$("#conferenceEmailFromError")[0].style.visibility = "hidden";
	return true;
}	

function ShowStrataEnquiryError() {
	$("#conferenceEmailFromError")[0].style.visibility = "visible";
	return false;
}
	
function StrataNewsAlertMailCallback(response) {
	$("#quickStrataEnquiryLoading")[0].style.display = "none";
	$("#conferenceEnquiriesForm")[0].style.display = "none";

	if (response === "True") {
		$("#conferenceEnquiriesFormSuccess")[0].style.display = "inline-block";
	} else {
		$("#conferenceEnquiriesFormFailure")[0].style.display = "inline-block";
	}
}

/* BEGIN LIV LEGAL SYMPOSIUM EMAIL - THIS IS THE ONE FOR THE LIV LEGAL SYMPOSIUM PAGE */
		
function SendLivLegalEmail() {

	if (ValidateLivLegalEmail()) {

		$("#livLegalButton")[0].style.display = "none";
		$("#livLegalLoading")[0].style.display = "inline-block";
	
		var params =
			"cu.Type=7&" +
			"cu.Name=" 			 + encodeURI($("#conferenceEmailName")			.attr("value")) 	+ "&" +
			"cu.Email=" 		 + encodeURI($("#conferenceEmailFrom")			.attr("value")) 	+ "&" +
			"cu.CompanyName="    + encodeURI($("#conferenceEmailCompanyName")   .attr("value"))     + "&" +
			"cu.PhoneNumber="    + encodeURI($("#conferencePhoneNumber")        .attr("value"))     + "&" +
			"cu.KeyContact="   	 + encodeURI($("#conferenceKeyContact")   		.attr("value"))     + "&" +
			"cu.JobFunction="    + encodeURI($("#conferenceJobFunction")        .attr("value"))     + "&" +
			"cu.Body=" 			 + encodeURI($("#conferenceEmailBody")			.attr("value"))     + "&" +
			"cu.State=" 		 + encodeURI($("#newsState")[0].value) 								+ "&" +
			"cu.Choice="		 + encodeURI($("#officialChoice")[0].value)+ "&";
			
		params += ($("#conferenceBodyCorpStrataReports").attr("checked") ? "cu.WantsBodyCorpStrataReports=on&" : "");
		params += ($("#conferenceSpatialSearching").attr("checked") ? "cu.WantsSpatialSearching=on&" : "");
		params += ($("#conferenceNatTitlesPlansDealingsInstruments").attr("checked") ? "cu.WantsNatTitlesPlansDealingsInstruments=on&" : "");
		params += ($("#conferenceCadastralMapsAerialPhoto").attr("checked") ? "cu.WantsCadastralMapsAerialPhoto=on&" : "");
		params += ($("#conferenceSalesValuationsInfo").attr("checked") ? "cu.WantsSalesValuationsInfo=on&" : "");
		params += ($("#conferencePracticeManagementSolutions").attr("checked") ? "cu.WantsPracticeManagementSolutions=on&" : "");
		params += ($("#conferenceTalkingNewsletter").attr("checked") ? "cu.WantsTalkingNewsletter=on&" : "");
		params += ($("#conferenceLegalNews").attr("checked") ? "cu.WantsLegalNews=on&" : "");
		params += ($("#conferenceUpdates").attr("checked") ? "cu.WantsUpdates=on&" : "");
		params += ($("#conferenceSetUp").attr("checked") ? "cu.WantsSetUp=on&" : "");
		params += ($("#conferenceCallDemo").attr("checked") ? "cu.WantsCallDemo=on&" : "");
		params += ($("#officialExistingCustomersISBU").attr("checked") ? "cu.WantsExistingCustomersISBU=on&" : "");
		params += ($("#officialExistingCustomersSSBU").attr("checked") ? "cu.WantsExistingCustomersSSBU=on&" : "");
		params += ($("#officialExistingCustomersMSBU").attr("checked") ? "cu.WantsExistingCustomersMSBU=on&" : "");
	
		if (params.substr(params.length - 1, 1) == "&") {
			params = params.substr(0, params.length - 1);
		}
		
		SendRequest(params, LivLegalNewsAlertMailCallback);

	}
}

function ValidateLivLegalEmail() {

	var email = $("#conferenceEmailFrom").attr("value");

	if (email == "") {
		return ShowLivLegalError();
	} else {
		if (!IsValidEmail(email)) {
			return ShowLivLegalError();
		}
	}

	$("#conferenceEmailFromError")[0].style.visibility = "hidden";
	return true;
}	

function ShowLivLegalError() {
	$("#conferenceEmailFromError")[0].style.visibility = "visible";
	return false;
}
	
function LivLegalNewsAlertMailCallback(response) {
	$("#livLegalLoading")[0].style.display = "none";
	$("#conferenceEnquiriesForm")[0].style.display = "none";

	if (response === "True") {
		$("#conferenceEnquiriesFormSuccess")[0].style.display = "inline-block";
	} else {
		$("#conferenceEnquiriesFormFailure")[0].style.display = "inline-block";
	}
}

/* BEGIN Managing Partners Forum EMAIL - THIS IS THE ONE FOR THE Managing Partners Forum PAGE */
		
function SendManagingPartnersEmail() {

	if (ValidateManagingPartnersEmail()) {

		$("#managingPartnersButton")[0].style.display = "none";
		$("#managingPartnersLoading")[0].style.display = "inline-block";
	
		var params =
			"cu.Type=8&" +
			"cu.Name=" 			 + encodeURI($("#conferenceEmailName")			.attr("value")) 	+ "&" +
			"cu.Email=" 		 + encodeURI($("#conferenceEmailFrom")			.attr("value")) 	+ "&" +
			"cu.CompanyName="    + encodeURI($("#conferenceEmailCompanyName")   .attr("value"))     + "&" +
			"cu.PhoneNumber="    + encodeURI($("#conferencePhoneNumber")        .attr("value"))     + "&" +
			"cu.KeyContact="   	 + encodeURI($("#conferenceKeyContact")   		.attr("value"))     + "&" +
			"cu.JobFunction="    + encodeURI($("#conferenceJobFunction")        .attr("value"))     + "&" +
			"cu.Body=" 			 + encodeURI($("#conferenceEmailBody")			.attr("value"))     + "&" +
			"cu.State=" 		 + encodeURI($("#newsState")[0].value) 								+ "&" +
			"cu.Choice="	     + encodeURI($("#officialChoice")[0].value)+ "&";
			
		params += ($("#conferenceBodyCorpStrataReports").attr("checked") ? "cu.WantsBodyCorpStrataReports=on&" : "");
		params += ($("#conferenceSpatialSearching").attr("checked") ? "cu.WantsSpatialSearching=on&" : "");
		params += ($("#conferenceNatTitlesPlansDealingsInstruments").attr("checked") ? "cu.WantsNatTitlesPlansDealingsInstruments=on&" : "");
		params += ($("#conferenceCadastralMapsAerialPhoto").attr("checked") ? "cu.WantsCadastralMapsAerialPhoto=on&" : "");
		params += ($("#conferenceSalesValuationsInfo").attr("checked") ? "cu.WantsSalesValuationsInfo=on&" : "");
		params += ($("#conferencePracticeManagementSolutions").attr("checked") ? "cu.WantsPracticeManagementSolutions=on&" : "");
		params += ($("#conferenceTalkingNewsletter").attr("checked") ? "cu.WantsTalkingNewsletter=on&" : "");
		params += ($("#conferenceLegalNews").attr("checked") ? "cu.WantsLegalNews=on&" : "");
		params += ($("#conferenceUpdates").attr("checked") ? "cu.WantsUpdates=on&" : "");
		params += ($("#conferenceSetUp").attr("checked") ? "cu.WantsSetUp=on&" : "");
		params += ($("#conferenceCallDemo").attr("checked") ? "cu.WantsCallDemo=on&" : "");
		params += ($("#officialExistingCustomersISBU").attr("checked") ? "cu.WantsExistingCustomersISBU=on&" : "");
		params += ($("#officialExistingCustomersSSBU").attr("checked") ? "cu.WantsExistingCustomersSSBU=on&" : "");
		params += ($("#officialExistingCustomersMSBU").attr("checked") ? "cu.WantsExistingCustomersMSBU=on&" : "");
	
		if (params.substr(params.length - 1, 1) == "&") {
			params = params.substr(0, params.length - 1);
		}
		
		SendRequest(params, ManagingPartnersNewsAlertMailCallback);

	}
}

function ValidateManagingPartnersEmail() {

	var email = $("#conferenceEmailFrom").attr("value");

	if (email == "") {
		return ShowManagingPartnersError();
	} else {
		if (!IsValidEmail(email)) {
			return ShowManagingPartnersError();
		}
	}

	$("#conferenceEmailFromError")[0].style.visibility = "hidden";
	return true;
}	

function ShowManagingPartnersError() {
	$("#conferenceEmailFromError")[0].style.visibility = "visible";
	return false;
}
	
function ManagingPartnersNewsAlertMailCallback(response) {
	$("#managingPartnersLoading")[0].style.display = "none";
	$("#conferenceEnquiriesForm")[0].style.display = "none";

	if (response === "True") {
		$("#conferenceEnquiriesFormSuccess")[0].style.display = "inline-block";
	} else {
		$("#conferenceEnquiriesFormFailure")[0].style.display = "inline-block";
	}
}


/* BEGIN 50th Anniversary Vincents SYMPOSIUM EMAIL - THIS IS THE ONE FOR THE 50th Anniversary Vincents SYMPOSIUM PAGE */
		
function SendVincentsEmail() {

	if (ValidateVincentsEmail()) {

		$("#VincentsButton")[0].style.display = "none";
		$("#livLegalLoading")[0].style.display = "inline-block";
	
		var params =
			"cu.Type=9&" +
			"cu.Name=" 			 + encodeURI($("#conferenceEmailName")			.attr("value")) 	+ "&" +
			"cu.Email=" 		 + encodeURI($("#conferenceEmailFrom")			.attr("value")) 	+ "&" +
			"cu.CompanyName="    + encodeURI($("#conferenceEmailCompanyName")   .attr("value"))     + "&" +
			"cu.PhoneNumber="    + encodeURI($("#conferencePhoneNumber")        .attr("value"))     + "&" +
			"cu.KeyContact="   	 + encodeURI($("#conferenceKeyContact")   		.attr("value"))     + "&" +
			"cu.JobFunction="    + encodeURI($("#conferenceJobFunction")        .attr("value"))     + "&" +
			"cu.Body=" 			 + encodeURI($("#conferenceEmailBody")			.attr("value"))     + "&" +
			"cu.Choice=" 		 + encodeURI($("#officialChoice")[0].value) 						+ "&" +
			"cu.State="		 	 + encodeURI($("#newsState")[0].value)+ "&";
			
		params += ($("#conferenceBodyCorpStrataReports").attr("checked") ? "cu.WantsBodyCorpStrataReports=on&" : "");
		params += ($("#conferenceSpatialSearching").attr("checked") ? "cu.WantsSpatialSearching=on&" : "");
		params += ($("#conferenceNatTitlesPlansDealingsInstruments").attr("checked") ? "cu.WantsNatTitlesPlansDealingsInstruments=on&" : "");
		params += ($("#conferenceCadastralMapsAerialPhoto").attr("checked") ? "cu.WantsCadastralMapsAerialPhoto=on&" : "");
		params += ($("#conferenceSalesValuationsInfo").attr("checked") ? "cu.WantsSalesValuationsInfo=on&" : "");
		params += ($("#conferencePracticeManagementSolutions").attr("checked") ? "cu.WantsPracticeManagementSolutions=on&" : "");
		params += ($("#conferenceTalkingNewsletter").attr("checked") ? "cu.WantsTalkingNewsletter=on&" : "");
		params += ($("#conferenceLegalNews").attr("checked") ? "cu.WantsLegalNews=on&" : "");
		params += ($("#conferenceUpdates").attr("checked") ? "cu.WantsUpdates=on&" : "");
		params += ($("#conferenceSetUp").attr("checked") ? "cu.WantsSetUp=on&" : "");
		params += ($("#conferenceCallDemo").attr("checked") ? "cu.WantsCallDemo=on&" : "");
		params += ($("#officialExistingCustomersISBU").attr("checked") ? "cu.WantsExistingCustomersISBU=on&" : "");
		params += ($("#officialExistingCustomersSSBU").attr("checked") ? "cu.WantsExistingCustomersSSBU=on&" : "");
		params += ($("#officialExistingCustomersMSBU").attr("checked") ? "cu.WantsExistingCustomersMSBU=on&" : "");
	
		if (params.substr(params.length - 1, 1) == "&") {
			params = params.substr(0, params.length - 1);
		}
		
		SendRequest(params, VincentsNewsAlertMailCallback);

	}
}

function ValidateVincentsEmail() {

	var email = $("#conferenceEmailFrom").attr("value");

	if (email == "") {
		return ShowVincentsError();
	} else {
		if (!IsValidEmail(email)) {
			return ShowVincentsError();
		}
	}

	$("#conferenceEmailFromError")[0].style.visibility = "hidden";
	return true;
}	

function ShowVincentsError() {
	$("#conferenceEmailFromError")[0].style.visibility = "visible";
	return false;
}
	
function VincentsNewsAlertMailCallback(response) {
	$("#livLegalLoading")[0].style.display = "none";
	$("#conferenceEnquiriesForm")[0].style.display = "none";

	if (response === "True") {
		$("#conferenceEnquiriesFormSuccess")[0].style.display = "inline-block";
	} else {
		$("#conferenceEnquiriesFormFailure")[0].style.display = "inline-block";
	}
}

/* BEGIN 7Side Solicitors Group EMAIL - THIS IS THE ONE FOR THE 7Side Solicitors Group Page */
		
function SendSevenSideSolicitorsGroupEmail() {

	if (ValidateSevenSideSolicitorsGroupEmail()) {

		$("#solicitorsGroupButton")[0].style.display = "none";
		$("#solicitorsGroupLoading")[0].style.display = "inline-block";
	
		var params =
			"cu.Type=10&" +
			"cu.Name=" 			 + encodeURI($("#conferenceEmailName")			.attr("value")) 	+ "&" +
			"cu.Email=" 		 + encodeURI($("#conferenceEmailFrom")			.attr("value")) 	+ "&" +
			"cu.CompanyName="    + encodeURI($("#conferenceEmailCompanyName")   .attr("value"))     + "&" +
			"cu.PhoneNumber="    + encodeURI($("#conferencePhoneNumber")        .attr("value"))     + "&" +
			"cu.JobFunction="    + encodeURI($("#conferenceJobFunction")        .attr("value"))     + "&" +
			"cu.Body=" 			 + encodeURI($("#conferenceEmailBody")			.attr("value"))		+ "&";
			
		params += ($("#conferenceBodyCorpStrataReports").attr("checked") ? "cu.WantsBodyCorpStrataReports=on&" : "");
		params += ($("#conferenceSpatialSearching").attr("checked") ? "cu.WantsSpatialSearching=on&" : "");
		params += ($("#conferenceNatTitlesPlansDealingsInstruments").attr("checked") ? "cu.WantsNatTitlesPlansDealingsInstruments=on&" : "");
		params += ($("#conferenceCadastralMapsAerialPhoto").attr("checked") ? "cu.WantsCadastralMapsAerialPhoto=on&" : "");
		params += ($("#conferenceSalesValuationsInfo").attr("checked") ? "cu.WantsSalesValuationsInfo=on&" : "");
		params += ($("#conferencePracticeManagementSolutions").attr("checked") ? "cu.WantsPracticeManagementSolutions=on&" : "");
		params += ($("#conferenceTalkingNewsletter").attr("checked") ? "cu.WantsTalkingNewsletter=on&" : "");
		params += ($("#conferenceLegalNews").attr("checked") ? "cu.WantsLegalNews=on&" : "");
			
		if (params.substr(params.length - 1, 1) == "&") {
			params = params.substr(0, params.length - 1);
		}
		
		SendRequest(params, SideSolicitorsGroupNewsAlertMailCallback);

	}
}

function ValidateSevenSideSolicitorsGroupEmail() {

	var email = $("#conferenceEmailFrom").attr("value");

	if (email == "") {
		return ShowSevenSideSolicitorsGroupError();
	} else {
		if (!IsValidEmail(email)) {
			return ShowSevenSideSolicitorsGroupError();
		}
	}

	$("#conferenceEmailFromError")[0].style.visibility = "hidden";
	return true;
}	

function ShowSevenSideSolicitorsGroupError() {
	$("#conferenceEmailFromError")[0].style.visibility = "visible";
	return false;
}
	
function SideSolicitorsGroupNewsAlertMailCallback(response) {
	$("#solicitorsGroupLoading")[0].style.display = "none";
	$("#conferenceEnquiriesForm")[0].style.display = "none";

	if (response === "True") {
		$("#conferenceEnquiriesFormSuccess")[0].style.display = "inline-block";
	} else {
		$("#conferenceEnquiriesFormFailure")[0].style.display = "inline-block";
	}
}



/* BEGIN LIBTECH ENQUIRY EMAIL - THIS IS THE ONE FOR THE LIBTECH LANDING PAGE */

function SendLibtechEnquiryEmail() {

	if (ValidateLibtechEnquiryEmail()) {

		$("#quickLibtechEnquiryButton")[0].style.display = "none";
		$("#quickLibtechEnquiryLoading")[0].style.display = "inline-block";
	
		var params =
			"cu.Type=4&" +
			"cu.Name=" 			 + encodeURI($("#conferenceEmailName")			.attr("value")) 	+ "&" +
			"cu.Email=" 		 + encodeURI($("#conferenceEmailFrom")			.attr("value")) 	+ "&" +
			"cu.CompanyName="    + encodeURI($("#conferenceEmailCompanyName")   .attr("value"))     + "&" +
			"cu.PhoneNumber="    + encodeURI($("#conferencePhoneNumber")        .attr("value"))     + "&" +
			"cu.KeyContact="   	 + encodeURI($("#conferenceKeyContact")   		.attr("value"))     + "&" +
			"cu.JobFunction="    + encodeURI($("#conferenceJobFunction")        .attr("value"))     + "&" +
			"cu.Body=" 			 + encodeURI($("#conferenceEmailBody")			.attr("value"))     + "&" +
			"cu.State=" + encodeURI($("#newsState")[0].value) + "&";
			
		params += ($("#conferenceBodyCorpStrataReports").attr("checked") ? "cu.WantsCompanyBusinessSearches=on&" : "");
		params += ($("#conferenceSpatialSearching").attr("checked") ? "cu.WantsPropertySecuritiesRegistrationsSearches=on&" : "");
		params += ($("#conferenceNatTitlesPlansDealingsInstruments").attr("checked") ? "cu.WantsCreditTradeReferenceReports=on&" : "");
		params += ($("#conferenceCadastralMapsAerialPhoto").attr("checked") ? "cu.WantsAmlKycReports=on&" : "");
		params += ($("#conferenceSalesValuationsInfo").attr("checked") ? "cu.WantsEmployeeScreening=on&" : "");
		params += ($("#conferencePracticeManagementSolutions").attr("checked") ? "cu.WantsTitlesPlansEquitySearches=on&" : "");
		params += ($("#conferenceEConveyancingSolutions").attr("checked") ? "cu.WantsTitlesPlansEquitySearches=on&" : "");
		params += ($("#conferenceTalkingNewsletter").attr("checked") ? "cu.WantsBusinessProfessionalsNews=on&" : "");
		params += ($("#conferenceSetUp").attr("checked") ? "cu.WantsSetUp=on&" : "");
		params += ($("#conferenceCallDemo").attr("checked") ? "cu.WantsCallDemo=on&" : "");
		
	
		if (params.substr(params.length - 1, 1) == "&") {
			params = params.substr(0, params.length - 1);
		}
		
		SendRequest(params, LibtechNewsAlertMailCallback);

	}
}

function ValidateLibtechEnquiryEmail() {

	var email = $("#conferenceEmailFrom").attr("value");

	if (email == "") {
		return ShowLibtechEnquiryError();
	} else {
		if (!IsValidEmail(email)) {
			return ShowLibtechEnquiryError();
		}
	}

	$("#conferenceEmailFromError")[0].style.visibility = "hidden";
	return true;
}	

function ShowLibtechEnquiryError() {
	$("#conferenceEmailFromError")[0].style.visibility = "visible";
	return false;
}
	
function LibtechNewsAlertMailCallback(response) {
	$("#quickLibtechEnquiryLoading")[0].style.display = "none";
	$("#conferenceEnquiriesForm")[0].style.display = "none";

	if (response === "True") {
		$("#conferenceEnquiriesFormSuccess")[0].style.display = "inline-block";
	} else {
		$("#conferenceEnquiriesFormFailure")[0].style.display = "inline-block";
	}
}

/* BEGIN ALPMA(OP) ENQUIRY EMAIL - THIS IS THE ONE FOR THE ALPMA LANDING PAGE */

function SendAlpmaOpEnquiryEmail() {

	if (ValidateAlpmaOpEnquiryEmail()) {

		$("#quickAlpmaOpEnquiryButton")[0].style.display = "none";
		$("#quickAlpmaOpEnquiryLoading")[0].style.display = "inline-block";
	
		var params =
			"cu.Type=5&" +
			"cu.Name=" 			 + encodeURI($("#conferenceEmailName")			.attr("value")) 	+ "&" +
			"cu.Email=" 		 + encodeURI($("#conferenceEmailFrom")			.attr("value")) 	+ "&" +
			"cu.CompanyName="    + encodeURI($("#conferenceEmailCompanyName")   .attr("value"))     + "&" +
			"cu.PhoneNumber="    + encodeURI($("#conferencePhoneNumber")        .attr("value"))     + "&" +
			"cu.KeyContact="   	 + encodeURI($("#conferenceKeyContact")   		.attr("value"))     + "&" +
			"cu.JobFunction="    + encodeURI($("#conferenceJobFunction")        .attr("value"))     + "&" +
			"cu.Body=" 			 + encodeURI($("#conferenceEmailBody")			.attr("value"))     + "&" +
			"cu.State=" + encodeURI($("#newsState")[0].value) + "&";
			
		params += ($("#conferenceNatOnlineSearchServices").attr("checked") ? "cu.WantsOpenPracticeSoftware=on&" : "");
		params += ($("#conferenceSpatialSearching").attr("checked") ? "cu.WantsOpenPractice=on&" : "");
		params += ($("#conferenceNatTitlesPlansDealingsInstruments").attr("checked") ? "cu.WantsOpenPracticeTrainingSessions=on&" : "");
		params += ($("#conferenceCadastralMapsAerialPhoto").attr("checked") ? "cu.WantsPrecedents=on&" : "");
		params += ($("#conferenceSalesValuationsInfo").attr("checked") ? "cu.WantsOnlineSearchServices=on&" : "");
		params += ($("#conferencePracticeManagementSolutions").attr("checked") ? "cu.WantsSupportServices=on&" : "");
		params += ($("#conferenceEConveyancingSolutions").attr("checked") ? "cu.WantsSettlementStampingServices=on&" : "");
		params += ($("#conferenceTalkingNewsletter").attr("checked") ? "cu.WantsLegalProfessionalsNews=on&" : "");
		params += ($("#conferenceSetUp").attr("checked") ? "cu.WantsSetUp=on&" : "");
		params += ($("#conferenceCallDemo").attr("checked") ? "cu.WantsCallDemo=on&" : "");
		
	
		if (params.substr(params.length - 1, 1) == "&") {
			params = params.substr(0, params.length - 1);
		}
		
		SendRequest(params, AlpmaOpNewsAlertMailCallback);

	}
}

function ValidateAlpmaOpEnquiryEmail() {

	var email = $("#conferenceEmailFrom").attr("value");

	if (email == "") {
		return ShowAlpmaOpEnquiryError();
	} else {
		if (!IsValidEmail(email)) {
			return ShowAlpmaOpEnquiryError();
		}
	}

	$("#conferenceEmailFromError")[0].style.visibility = "hidden";
	return true;
}	

function ShowAlpmaOpEnquiryError() {
	$("#conferenceEmailFromError")[0].style.visibility = "visible";
	return false;
}
	
function AlpmaOpNewsAlertMailCallback(response) {
	$("#quickAlpmaOpEnquiryButton")[0].style.display = "none";
	$("#conferenceEnquiriesForm")[0].style.display = "none";

	if (response === "True") {
		$("#conferenceEnquiriesFormSuccess")[0].style.display = "inline-block";
		$("#conferenceEnquiriesFormSuccess")[0].style.visibility = "visible";
	} else {
		$("#conferenceEnquiriesFormFailure")[0].style.display = "inline-block";
		$("#conferenceEnquiriesFormFailure")[0].style.visibility = "visible";
	}
}

/* BEGIN ALPMA(GLOBALX) ENQUIRY EMAIL - THIS IS THE ONE FOR THE ALPMA LANDING PAGE */

function SendAlpmaGlobalxEnquiryEmail() {

	if (ValidateAlpmaGlobalxEnquiryEmail()) {

		$("#quickAlpmaGlobalxEnquiryButton")[0].style.display = "none";
		$("#quickAlpmaGlobalxEnquiryLoading")[0].style.display = "inline-block";
	
		var params =
			"cu.Type=6&" +
			"cu.Name=" 			 + encodeURI($("#conferenceEmailName")			.attr("value")) 	+ "&" +
			"cu.Email=" 		 + encodeURI($("#conferenceEmailFrom")			.attr("value")) 	+ "&" +
			"cu.CompanyName="    + encodeURI($("#conferenceEmailCompanyName")   .attr("value"))     + "&" +
			"cu.PhoneNumber="    + encodeURI($("#conferencePhoneNumber")        .attr("value"))     + "&" +
			"cu.KeyContact="   	 + encodeURI($("#conferenceKeyContact")   		.attr("value"))     + "&" +
			"cu.JobFunction="    + encodeURI($("#conferenceJobFunction")        .attr("value"))     + "&" +
			"cu.Body=" 			 + encodeURI($("#conferenceEmailBody")			.attr("value"))     + "&" +
			"cu.State=" + encodeURI($("#newsState")[0].value) + "&";
			
		params += ($("#conferenceNatOnlineSearchServices").attr("checked") ? "cu.WantsOnlineSearchServices=on&" : "");
		params += ($("#conferenceSpatialSearching").attr("checked") ? "cu.WantsPropertySecuritiesRegistrationsSearches=on&" : "");
		params += ($("#conferenceNatTitlesPlansDealingsInstruments").attr("checked") ? "cu.WantsSupportServices=on&" : "");
		params += ($("#conferenceCadastralMapsAerialPhoto").attr("checked") ? "cu.WantsSettlementStampingServices=on&" : "");
		params += ($("#conferenceSalesValuationsInfo").attr("checked") ? "cu.WantsPracticeManagementSolutions=on&" : "");
		params += ($("#conferencePracticeManagementSolutions").attr("checked") ? "cu.WantsAutomationServices=on&" : "");
		params += ($("#conferenceEConveyancingSolutions").attr("checked") ? "cu.WantsEConveyancingSolutions=on&" : "");
		params += ($("#conferenceTalkingNewsletter").attr("checked") ? "cu.WantsLegalProfessionalsNews=on&" : "");
		params += ($("#conferenceSetUp").attr("checked") ? "cu.WantsSetUp=on&" : "");
		params += ($("#conferenceCallDemo").attr("checked") ? "cu.WantsCallDemo=on&" : "");
		
	
		if (params.substr(params.length - 1, 1) == "&") {
			params = params.substr(0, params.length - 1);
		}
		
		SendRequest(params, AlpmaGlobalxNewsAlertMailCallback);

	}
}

function ValidateAlpmaGlobalxEnquiryEmail() {

	var email = $("#conferenceEmailFrom").attr("value");

	if (email == "") {
		return ShowAlpmaGlobalxEnquiryError();
	} else {
		if (!IsValidEmail(email)) {
			return ShowAlpmaGlobalxEnquiryError();
		}
	}

	$("#conferenceEmailFromError")[0].style.visibility = "hidden";
	return true;
}	

function ShowAlpmaGlobalxEnquiryError() {
	$("#conferenceEmailFromError")[0].style.visibility = "visible";
	return false;
}
	
function AlpmaGlobalxNewsAlertMailCallback(response) {
	$("#quickAlpmaGlobalxEnquiryButton")[0].style.display = "none";
	$("#conferenceEnquiriesForm")[0].style.display = "none";

	if (response === "True") {
		$("#conferenceEnquiriesFormSuccess")[0].style.display = "inline-block";
		$("#conferenceEnquiriesFormSuccess")[0].style.visibility = "visible";
	} else {
		$("#conferenceEnquiriesFormFailure")[0].style.display = "inline-block";
		$("#conferenceEnquiriesFormFailure")[0].style.visibility = "visible";
	}
}

