//***********************************************************************
//***********************************************************************
// Copyright ThinkFirst Foundation 2004
//
// The use, disclosure, reproduction, modification, transfer, or  
// transmittal of  this work for any purpose in any form or by any 
// means without the written  permission of ThinkFirst Foundation is 
// strictly prohibited.
//
// Confidential, Unpublished Property of ThinkFirst Foundation
// Use and distribution limited solely to authorized personnel.
//
// All Rights Reserved.
//
// Notice:  This file was created by Travant Solutions, Inc.  Contact
// by e-mail at info@travant.com
//
// Filename:		ThinkFirst.js
// Description:	
//
// Notes:		
//
//***********************************************************************
//***********************************************************************%>


	
// Used on the Chapter Edit screen, sets
// the State fields appropriately depending on
// whether or not we are dealing with a US or
// International chapter.
function setChapterEditCountry() {
	// 0 = United States
	if (document.forms[0].rbAddressType[0].checked) {
		document.forms[0].txtState.style.display="none";
		document.forms[0].ddlState.style.display="";
		document.forms[0].txtCountry.disabled = true;

		// Set our automatic validations
		//document.forms[0].txtPostal.tsiZip = "true";
		//document.forms[0].txtWorkPhone.tsiPhone = "true";
		//document.forms[0].txtFax.tsiPhone = "true";
	} else {
		document.forms[0].txtState.style.display="";
		document.forms[0].ddlState.style.display="none";
		document.forms[0].txtCountry.disabled = false;

		// Set our automatic validations
		document.forms[0].txtPostal.tsiZip = undefined;
		document.forms[0].txtWorkPhone.tsiPhone = undefined;
		document.forms[0].txtFax.tsiPhone = undefined;
	}
}	

// Sets the search type so we know if we're searching for
// US or International Chapters.
function SetSearchType(iSearchCode) {
	document.forms[0].hidSearchType.value = iSearchCode
	if (iSearchCode == 1) {
		document.forms[0].ddlCountry.disabled = true;
	} 
	
	if (iSearchCode == 2) {
		document.forms[0].ddlState.disabled = true;
	} 
}	

// When a search form is submitted, this checks to
// see if nay criteria has been specified.
function OnSearchFormSubmit() {
	var bErr = false;
	var szMsg = "";
	
	if ((document.forms[0].hidSearchType.value == "1") &&
		(document.forms[0].ddlState[0].selected)) {
		 bErr = true;
		 szMsg = "Please select a State to search for.";
	}

	if ((document.forms[0].hidSearchType.value == "2") &&
		(document.forms[0].ddlCountry[0].selected)) {
		 bErr = true;
		 szMsg = "Please select a Country to search for.";
	}
	
	if (bErr) {
		alert(szMsg);
		
		document.forms[0].ddlCountry.disabled = false;
		document.forms[0].ddlState.disabled = false;
		
		return false;
	}
	
	return true;
}


// Sets the Sort Field and Sort Order and then
// Submits the form to refresh the list.
function setSort(szSortField, szSortOrder) {
	document.forms[0].hidSortField.value = szSortField;
	document.forms[0].hidSortOrder.value = szSortOrder;
	document.forms[0].submit();
}
	

// Used on the Survey screen, sets
// the State fields appropriately depending on
// whether or not we are dealing with a US or
// International chapter.
var szSaveCountry = "";
var szSaveSPCountry = "";
function setSurveyCountry() {
	
	// United States
	if (document.forms[0].rbAddressType[0].checked) {
		document.forms[0].txtState.style.display="none";
		document.forms[0].ddlState.style.display="";
		document.forms[0].txtChapterState.style.display="none";
		document.forms[0].ddlChapterState.style.display="";
		document.forms[0].txtCountry.disabled = true;
		szSaveCountry = document.forms[0].txtCountry.value;
		document.forms[0].txtCountry.value = "United States";
		
		document.forms[0].txtSPState.style.display="none";
		document.forms[0].ddlSPState.style.display="";
		document.forms[0].txtSPCountry.disabled = true;
		szSaveSPCountry = document.forms[0].txtSPCountry.value;
		document.forms[0].txtSPCountry.value = "United States";

		// Set our automatic validations
		document.forms[0].ddlState.tsiRequired="true";
		document.forms[0].ddlChapterState.tsiRequired="true";
		document.forms[0].txtPostal.tsiZip = "true";
		//document.forms[0].txtWorkPhone.tsiPhone = "true";
		//document.forms[0].txtFax.tsiPhone = "true";
		document.forms[0].txtSPPostal.tsiZip = "true";

		
	// International
	} else {
		document.forms[0].txtState.style.display="";
		document.forms[0].ddlState.style.display="none";
		document.forms[0].txtChapterState.style.display="";
		document.forms[0].ddlChapterState.style.display="none";
		document.forms[0].txtCountry.disabled = false;
		document.forms[0].txtCountry.value = szSaveCountry;
		
		document.forms[0].txtSPState.style.display="";
		document.forms[0].ddlSPState.style.display="none";
		document.forms[0].txtSPCountry.disabled = false;
		document.forms[0].txtSPCountry.value = szSaveSPCountry;

		document.forms[0].ddlState.tsiRequired=undefined;
		document.forms[0].ddlChapterState.tsiRequired=undefined;
		document.forms[0].txtPostal.tsiZip = undefined;
		document.forms[0].txtWorkPhone.tsiPhone = undefined;
		document.forms[0].txtFax.tsiPhone = undefined;
		document.forms[0].txtSPPostal.tsiZip = undefined;
	}
}	

function ProductSetCCValiation() {
	// If payment is by check, remove the
	// validations
	if (document.forms[0].card[0].checked) {
		document.forms[0].cardacct.tsiRequired=undefined;	
		document.forms[0].cardmo.tsiRequired=undefined;	
		document.forms[0].cardyr.tsiRequired=undefined;	
		document.forms[0].cardname.tsiRequired=undefined;	
	// Else add them
	} else {
		document.forms[0].cardacct.tsiRequired=true;	
		document.forms[0].cardmo.tsiRequired=true;	
		document.forms[0].cardyr.tsiRequired=true;	
		document.forms[0].cardname.tsiRequired=true;	
	}
}
