//----------------------------------------------------------------------------------------------
// function to trigger action based on different button
//----------------------------------------------------------------------------------------------
function SubmitRequest(strButtonName){
	var theForm=document.BCBCForm;
	//alert(document.charset);
	
	//alert(document.charset);
	//document.refresh();
	//alert(document.charset);
	//alert (strButtonName);
	
	////////////////////////// JS functions for Login /////////////////////
	if (strButtonName=="checkLogin"){
		if (ValidationLogin()){
			theForm.action="BCBC-LoginChoice.asp?CommandString=checkLogin";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	/////////////////////// JS function for changing login //////////////////////////////
	else if (strButtonName=="ChangeLogin") {
		if (ValidationChangeLogin()){
			document.charset="iso-8859-1";
			theForm.action="BCBC-CHN-User-ChangeLoginChoice.asp?CommandString=ChangeLogin";
			theForm.submit();
		}
	}
	/////////////////////// JS function for changing WebMaster login //////////////////////////////
	else if (strButtonName=="ChangeWebMasterLogin") {
		if (ValidationChangeLogin()){
			document.charset="iso-8859-1";
			theForm.action="BCBC-ChangeLoginChoice.asp?CommandString=ChangeWebMasterLogin";
			theForm.submit();
		}
	}
	/////////////////////// JS function for prayer //////////////////////////////
	else if (strButtonName=="AddPrayerByName") {
		if (ValidationPrayer()){
			document.charset="iso-8859-1";
			theForm.action="BCBC-CHN-User-PrayerChoice.asp?CommandString=AddPrayerByName";
			theForm.submit();
		}
	}
	else if (strButtonName=="AddPrayerByAnonymous") {
		if (ValidationPrayer()){
			document.charset="iso-8859-1";
			theForm.action="BCBC-CHN-User-PrayerChoice.asp?CommandString=AddPrayerByAnonymous";
			theForm.submit();
		}
	}
	else if (strButtonName=="VerifyAddPrayerLogin") {
		if (ValidationLogin()){
			document.charset="iso-8859-1";
			theForm.action="BCBC-CHN-User-PrayerChoice.asp?CommandString=VerifyAddPrayerLogin";
			theForm.submit();
		}
	}
	else if (strButtonName=="VerifyEditPrayerLogin") {
		if (ValidationLogin()){
			document.charset="iso-8859-1";
			theForm.action="BCBC-CHN-User-PrayerChoice.asp?CommandString=VerifyEditPrayerLogin";
			theForm.submit();
		}
	}
	else if (strButtonName=="AddPrayerByAnonymous") {
		if (ValidationPrayer()){
			document.charset="iso-8859-1";
			theForm.action="BCBC-CHN-User-PrayerChoice.asp?CommandString=AddPrayerByAnonymous";
			theForm.submit();
		}
	}
	else if (strButtonName=="EditLogin") {
		if (ValidationPrayer()){
			document.charset="iso-8859-1";
			theForm.action="BCBC-CHN-User-PrayerChoice.asp?CommandString=EditLogin";
			theForm.submit();
		}
	}
	else if (strButtonName=="EditPrayerByName"){
		if (ValidationPrayer()){
			document.charset="iso-8859-1";
			theForm.action="BCBC-CHN-User-PrayerChoice.asp?CommandString=EditPrayerByName";
			theForm.submit();
		}
	}
	else if (strButtonName=="EditPrayerByAnonymous"){
		if (ValidationPrayer()){
			document.charset="iso-8859-1";
			theForm.action="BCBC-CHN-User-PrayerChoice.asp?CommandString=EditPrayerByAnonymous";
			theForm.submit();
		}
	}
	else if (strButtonName=="BackEditPrayer"){
		//document.charset="iso-8859-1";
		theForm.action="BCBC-CHN-User-PrayerChoice.asp?CommandString=BackEditPrayer";
		theForm.submit();
	}
	/*else if (strButtonName=="DeletePrayer"){
		var result;
		var message="Are you SURE to delete this/these prayer(s)?"
		result=confirm(message);
		if (result==true){
			theForm.action="BCBC-CHN-User-PrayerDeleteSingle.asp"
			theForm.submit();
		}
	}*/
	else if (strButtonName=="DeletePrayer"){
		var result;
		var message="Are you SURE to delete this/these prayer(s)?"
		result=confirm(message);
		if (result==true){
			theForm.action="BCBC-CHN-User-PrayerChoice.asp?CommandString=DeletePrayer"
			theForm.submit();
		}
	}
	else if (strButtonName=="DeletePrayers"){
		
		if (ValidationPrayerCheckBox()){
			var result;
			var message="Are you SURE to delete this/these prayer(s)?"
			result=confirm(message);
			if (result==true){
				theForm.action="BCBC-CHN-User-PrayerChoice.asp?CommandString=DeletePrayers"
				theForm.submit();
			}
		}
	}
	/////////////////////////// JS functions for Message Board /////////////////
	else if (strButtonName=="VerifyMsgBoardLogin") {
		if (ValidationLogin()){
			document.charset="iso-8859-1";
			theForm.action="BCBC-CHN-User-MsgBoardChoice.asp?CommandString=VerifyMsgBoardLogin";
			theForm.submit();
		}
	}
	else if (strButtonName=="VerifyReplyLogin") {
		if (ValidationLogin()){
			document.charset="iso-8859-1";
			theForm.action="BCBC-CHN-User-MsgBoardChoice.asp?CommandString=VerifyReplyLogin";
			theForm.submit();
		}
	}
	else if (strButtonName=="AddReplyMsgByName"){
		if (ValidationMsgBoardReply()){
			document.charset="iso-8859-1";
			theForm.action="BCBC-CHN-User-MsgBoardChoice.asp?CommandString=AddReplyMsgByName";
			theForm.submit();
		}
		
	}
	else if (strButtonName=="AddTopicMsgByName"){
		if (ValidationMsgBoardTopic()){
			document.charset="iso-8859-1";
			theForm.action="BCBC-CHN-User-MsgBoardChoice.asp?CommandString=AddTopicMsgByName";
			theForm.submit();
		}
	}
	else if (strButtonName=="AddReplyMsgByAnonymous"){
		if (ValidationMsgBoardReply()){
			document.charset="iso-8859-1";
			theForm.action="BCBC-CHN-User-MsgBoardChoice.asp?CommandString=AddReplyMsgByAnonymous";
			theForm.submit();
		}
		
	}
	else if (strButtonName=="AddTopicMsgByAnonymous"){
		if (ValidationMsgBoardTopic()){
			document.charset="iso-8859-1";
			theForm.action="BCBC-CHN-User-MsgBoardChoice.asp?CommandString=AddTopicMsgByAnonymous";
			theForm.submit();
		}
	}
	/////////////////////// JS function for Service //////////////////////////////
	else if (strButtonName=="VerifyServiceByPersonLogin") {
		if (ValidationLogin()){
			document.charset="iso-8859-1";
			theForm.action="BCBC-CHN-User-ServiceChoice.asp?CommandString=VerifyServiceByPersonLogin";
			theForm.submit();
		}
	}
	else if (strButtonName=="VerifyUserServingView1") {
		if (ValidationLogin()){
			document.charset="iso-8859-1";
			theForm.action="BCBC-CHN-User-ServiceChoice.asp?CommandString=VerifyUserServingView1";
			theForm.submit();
		}
	}
	else if (strButtonName=="VerifyUserServingView2") {
		if (ValidationLogin()){
			document.charset="iso-8859-1";
			theForm.action="BCBC-CHN-User-ServiceChoice.asp?CommandString=VerifyUserServingView2";
			theForm.submit();
		}
	}
	else if (strButtonName=="VerifyUserServingView3") {
		if (ValidationLogin()){
			document.charset="iso-8859-1";
			theForm.action="BCBC-CHN-User-ServiceChoice.asp?CommandString=VerifyUserServingView3";
			theForm.submit();
		}
	}
	
	////////////////////////// JS functions for Daily Devotion /////////////////////
	else if (strButtonName=="AddDevotion"){
		
		document.charset="iso-8859-1";
		theForm.action="BCBC-DailyDevotionChoice.asp?CommandString=AddDevotion";
		theForm.submit();
	}
	else if (strButtonName=="EditDevotion"){
		
		document.charset="iso-8859-1";
		theForm.action="BCBC-DailyDevotionChoice.asp?CommandString=EditDevotion";
		theForm.submit();
	}
	else if (strButtonName=="DeleteDevotion"){
		
		var result;
		var message="Are you SURE to delete this/these record(s)?"
		result=confirm(message);
		if (result==true){
			theForm.action="BCBC-DailyDevotionChoice.asp?CommandString=DeleteDevotion"
			theForm.submit();
		}
	}
	////////////////////////// JS functions for Group Activity /////////////////////
	else if (strButtonName=="AddActivity"){
		if (ValidationGroupActivity()){
			document.charset="iso-8859-1";
			theForm.action="BCBC-GroupChoice.asp?CommandString=AddActivity";
			theForm.submit();
		}
	}
	else if (strButtonName=="EditActivity"){
		if (ValidationGroupActivity()){
		document.charset="iso-8859-1";
		theForm.action="BCBC-GroupChoice.asp?CommandString=EditActivity";
		theForm.submit();
		}
	}
	else if (strButtonName=="AddNotice"){
		if (ValidationGroupNotice()){
			document.charset="iso-8859-1";
			theForm.action="BCBC-GroupChoice.asp?CommandString=AddNotice";
			theForm.submit();
		}
	}
	else if (strButtonName=="EditNotice"){
		if (ValidationGroupNotice()){
			document.charset="iso-8859-1";
			theForm.action="BCBC-GroupChoice.asp?CommandString=EditNotice";
			theForm.submit();
		}
	}
	else if (strButtonName=="DeleteActivity"){
		
		var result;
		var message="Are you SURE to delete this/these record(s)?"
		result=confirm(message);
		if (result==true){
			theForm.action="BCBC-GroupChoice.asp?CommandString=DeleteActivity"
			theForm.submit();
		}
	
	}
	else if (strButtonName=="UpdateGroupHomePage"){
		if (ValidationHomePageTheme()){
			document.charset="iso-8859-1";
			theForm.action="BCBC-GroupChoice.asp?CommandString=UpdateGroupHomePage";
			theForm.submit();
		}
	}
	else if (strButtonName=="UpdateGroupLeaderSpeech"){
		if (ValidationLeaderSpeech()){
			document.charset="iso-8859-1";
			theForm.action="BCBC-GroupChoice.asp?CommandString=UpdateGroupLeaderSpeech";
			theForm.submit();
		}
	}
	else if (strButtonName=="UpdateGroupHistory"){
		if (ValidationHistory()){
			document.charset="iso-8859-1";
			theForm.action="BCBC-GroupChoice.asp?CommandString=UpdateGroupHistory";
			theForm.submit();
		}
	}
	
	////////////////////////// JS functions for WeeklyEvent /////////////////////
	else if (strButtonName=="AddWeeklyEvent"){
		if (AddWeeklyEventValidation()){
			theForm.action="BCBC-WeeklyEventChoice.asp?CommandString=AddWeeklyEvent";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="EditWeeklyEvent"){
		if (AddWeeklyEventValidation()){
			theForm.action="BCBC-WeeklyEventChoice.asp?CommandString=EditWeeklyEvent";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="DeleteWeeklyEvent"){
		
		var result;
		var message="Are you SURE to delete this record?"
		result=confirm(message);
		if (result==true){
			theForm.action="BCBC-WeeklyEventChoice.asp?CommandString=DeleteWeeklyEvent"
			theForm.submit();
		}
	
	}
	////////////////////////// JS functions for MonthlyEvent /////////////////////
	else if (strButtonName=="AddMonthlyEvent"){
		if (AddMonthlyEventValidation()){
			theForm.action="BCBC-MonthlyEventChoice.asp?CommandString=AddMonthlyEvent";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="EditMonthlyEvent"){
		if (AddMonthlyEventValidation()){
			theForm.action="BCBC-MonthlyEventChoice.asp?CommandString=EditMonthlyEvent";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="DeleteMonthlyEvent"){
		
		var result;
		var message="Are you SURE to delete this record?"
		result=confirm(message);
		if (result==true){
			theForm.action="BCBC-MonthlyEventChoice.asp?CommandString=DeleteMonthlyEvent"
			theForm.submit();
		}
	
	}
	////////////////////////// JS functions for Event /////////////////////
	else if (strButtonName=="AddEvent"){
		if (AddEventValidation()){
			theForm.action="BCBC-EventChoice.asp?CommandString=AddEvent";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="EditEvent"){
		if (AddEventValidation()){
			theForm.action="BCBC-EventChoice.asp?CommandString=EditEvent";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="DeleteEvent"){
		
		var result;
		var message="Are you SURE to delete this record?"
		result=confirm(message);
		if (result==true){
			theForm.action="BCBC-EventChoice.asp?CommandString=DeleteEvent"
			theForm.submit();
		}
	
	}
	
	
	////////////////////////// JS functions for PastorSchedule /////////////////////
	else if (strButtonName=="AddPastorSchedule"){
		if (AddPastorScheduleValidation()){
			theForm.action="BCBC-PastorScheduleChoice.asp?CommandString=AddPastorSchedule";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="EditPastorSchedule"){
		if (AddPastorScheduleValidation()){
			theForm.action="BCBC-PastorScheduleChoice.asp?CommandString=EditPastorSchedule";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="DeletePastorSchedule"){
		
		var result;
		var message="Are you SURE to delete this record?"
		result=confirm(message);
		if (result==true){
			theForm.action="BCBC-PastorScheduleChoice.asp?CommandString=DeletePastorSchedule"
			theForm.submit();
		}
	
	}
	////////////////////////// JS functions for SundaySchool /////////////////////
	else if (strButtonName=="AddSundaySchool"){
		if (ValidationSundaySchool()){
			document.charset="iso-8859-1";
			theForm.action="BCBC-SundaySchoolChoice.asp?CommandString=AddSundaySchool";
			theForm.submit();
		}
	}
	else if (strButtonName=="EditSundaySchool"){
		if (ValidationSundaySchool()){
		document.charset="iso-8859-1";
		theForm.action="BCBC-SundaySchoolChoice.asp?CommandString=EditSundaySchool";
		theForm.submit();
		}
	}
	else if (strButtonName=="DeleteSundaySchool"){
		
		var result;
		var message="Are you SURE to delete this record?"
		result=confirm(message);
		if (result==true){
			theForm.action="BCBC-SundaySchoolChoice.asp?CommandString=DeleteSundaySchool"
			theForm.submit();
		}
	
	}
	////////////////////////// JS functions for PrayerOfWeek /////////////////////
	else if (strButtonName=="AddPrayerOfWeek"){
		
		document.charset="iso-8859-1";
		theForm.action="BCBC-PrayerOfWeekChoice.asp?CommandString=AddPrayerOfWeek";
		theForm.submit();
	}
	else if (strButtonName=="EditPrayerOfWeek"){
		
		document.charset="iso-8859-1";
		theForm.action="BCBC-PrayerOfWeekChoice.asp?CommandString=EditPrayerOfWeek";
		theForm.submit();
	}
	else if (strButtonName=="DeletePrayerOfWeek"){
		
		var result;
		var message="Are you SURE to delete this/these record(s)?"
		result=confirm(message);
		if (result==true){
			theForm.action="BCBC-PrayerOfWeekChoice.asp?CommandString=DeletePrayerOfWeek"
			theForm.submit();
		}
	
	}
	////////////////////////// JS functions for BibleVerse /////////////////////
	else if (strButtonName=="AddBibleVerse"){
		if (AddBibleVerseValidation()){
			theForm.action="BCBC-BibleVerseChoice.asp?CommandString=AddBibleVerse";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="EditBibleVerse"){
		if (AddBibleVerseValidation()){
			theForm.action="BCBC-BibleVerseChoice.asp?CommandString=EditBibleVerse";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="DeleteBibleVerse"){
		var result;
		var message="Are you SURE to delete this/these record(s)?"
		result=confirm(message);
		if (result==true){
			theForm.action="BCBC-BibleVerseChoice.asp?CommandString=DeleteBibleVerse"
			theForm.submit();
		}
	
	}
	////////////////////////// JS functions for Offering /////////////////////
	else if (strButtonName=="AddOffering"){
		if (AddOfferingValidation()){
			theForm.action="BCBC-OfferingChoice.asp?CommandString=AddOffering";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="EditOffering"){
		if (AddOfferingValidation()){
			theForm.action="BCBC-OfferingChoice.asp?CommandString=EditOffering";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="DeleteOffering"){
		
		var result;
		var message="Are you SURE to delete this/these record(s)?"
		result=confirm(message);
		if (result==true){
			theForm.action="BCBC-OfferingChoice.asp?CommandString=DeleteOffering"
			theForm.submit();
		}
	
	}
	else if (strButtonName=="AddWeeklyOffering"){
		if (AddOfferingValidation()){
			theForm.action="BCBC-OfferingChoice.asp?CommandString=AddWeeklyOffering";
			theForm.submit();
		}
	}
	else if (strButtonName=="EditWeeklyOffering"){
		if (AddOfferingValidation()){
			theForm.action="BCBC-OfferingChoice.asp?CommandString=EditWeeklyOffering";
			theForm.submit();
		}
	}
	else if (strButtonName=="DeleteWeeklyOffering"){
		
		var result;
		var message="Are you SURE to delete this/these record(s)?"
		result=confirm(message);
		if (result==true){
			theForm.action="BCBC-OfferingChoice.asp?CommandString=DeleteWeeklyOffering"
			theForm.submit();
		}
	
	}
	////////////////////////// JS functions for People /////////////////////
	else if (strButtonName=="EditUser"){
		if (ValidationEditUser()){
			theForm.action="BCBC-CHN-User-ContactInfoChoice.asp?CommandString=EditUser";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="AddPeople"){
		if (AddPeopleValidation()){
			theForm.action="BCBC-PeopleChoice.asp?CommandString=AddPeople";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="EditPeople"){
		if (AddPeopleValidation()){
			theForm.action="BCBC-PeopleChoice.asp?CommandString=EditPeople";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="EmailPassword"){
		theForm.action="BCBC-PeopleChoice.asp?CommandString=EmailPassword";
		theForm.submit();
	}
	else if (strButtonName=="DeletePeople"){
		
		var result;
		var message="Are you SURE to delete this/these record(s)?"
		result=confirm(message);
		if (result==true){
			theForm.action="BCBC-PeopleChoice.asp?CommandString=DeletePeople"
			theForm.submit();
		}
	
	}
	////////////////////////// JS functions for News /////////////////////
	else if (strButtonName=="AddNews"){
		if (AddNewsValidation()){
			theForm.action="BCBC-NewsChoice.asp?CommandString=AddNews";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="EditNews"){
		if (AddNewsValidation()){
			theForm.action="BCBC-NewsChoice.asp?CommandString=EditNews";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="DeleteNews"){
		
		var result;
		var message="Are you SURE to delete this/these record(s)?"
		result=confirm(message);
		if (result==true){
			theForm.action="BCBC-NewsChoice.asp?CommandString=DeleteNews"
			theForm.submit();
		}
	
	}
	////////////////////////// JS functions for Contact Info /////////////////////
	else if (strButtonName=="VerifyContactLogin") {
		if (ValidationLogin()){
			document.charset="iso-8859-1";
			theForm.action="BCBC-CHN-User-ContactInfoChoice.asp?CommandString=VerifyContactLogin";
			theForm.submit();
		}
	}
	////////////////////////// JS functions for Survey /////////////////////
	else if (strButtonName=="VerifySurveyLogin") {
		if (ValidationLogin()){
			document.charset="iso-8859-1";
			theForm.action="BCBC-CHN-User-SurveyChoice.asp?CommandString=VerifySurveyLogin";
			theForm.submit();
		}
	}
	else if (strButtonName=="VerifySurveyLogin") {
		if (ValidationVote()){
			document.charset="iso-8859-1";
			theForm.action="BCBC-CHN-User-SurveyChoice.asp?CommandString=VerifySurveyLogin";
			theForm.submit();
		}
	}
	else if (strButtonName=="AddSingleSurvey"){
		if (ValidationSingleAdd()){
			document.charset="iso-8859-1";
			theForm.action="BCBC-SurveyChoice.asp?CommandString=AddSingleSurvey";
			theForm.submit();
		}
	}
	else if (strButtonName=="EditSingleSurvey"){
		if (ValidationSingleAdd()){
			document.charset="iso-8859-1";
			theForm.action="BCBC-SurveyChoice.asp?CommandString=EditSingleSurvey";
			theForm.submit();
		}
	}
	else if (strButtonName=="AddMultipleSurvey"){
		if (ValidationMultipleAdd()){
			document.charset="iso-8859-1";
			theForm.action="BCBC-SurveyChoice.asp?CommandString=AddMultipleSurvey";
			theForm.submit();
		}
	}
	else if (strButtonName=="AddMultipleOption"){
		if (ValidationMultipleOptionAdd()){
			document.charset="iso-8859-1";
			theForm.action="BCBC-SurveyChoice.asp?CommandString=AddMultipleOption";
			theForm.submit();
		}
	}
	else if (strButtonName=="EditMultipleSurvey"){
		if (ValidationMultipleAdd()){
			document.charset="iso-8859-1";
			theForm.action="BCBC-SurveyChoice.asp?CommandString=EditMultipleSurvey";
			theForm.submit();
		}
	}
	else if (strButtonName=="EditInsertMultipleOption"){
		if (ValidationMultipleOptionAdd()){
			document.charset="iso-8859-1";
			theForm.action="BCBC-SurveyChoice.asp?CommandString=EditInsertMultipleOption";
			theForm.submit();
		}
	}
	else if (strButtonName=="UpdateOption"){
		if (ValidationMultipleOptionAdd()){
			document.charset="iso-8859-1";
			theForm.action="BCBC-SurveyChoice.asp?CommandString=UpdateOption";
			theForm.submit();
		}
	}
	else if (strButtonName=="DeleteSurvey"){
		
		var result;
		var message="Are you SURE to delete this/these record(s)?"
		result=confirm(message);
		if (result==true){
			theForm.action="BCBC-SurveyChoice.asp?CommandString=DeleteSurvey"
			theForm.submit();
		}
	
	}
	////////////////////////// JS functions for Worship Title and SubTitle //////////////////
	else if (strButtonName=="AddWorshipTitle"){
		if (ValidationWorshipTitle()){
			theForm.action="BCBC-WorshipChoice.asp?CommandString=AddWorshipTitle";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="EditWorshipTitle"){
		if (ValidationWorshipTitle()){
			theForm.action="BCBC-WorshipChoice.asp?CommandString=EditWorshipTitle";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="DeleteWorshipTitle"){
		
		var result;
		var message="Are you SURE to delete this/these record(s)?"
		result=confirm(message);
		if (result==true){
			theForm.action="BCBC-WorshipChoice.asp?CommandString=DeleteWorshipTitle"
			theForm.submit();
		}
	
	}
	else if (strButtonName=="AddWorshipSubTitle"){
		if (ValidationWorshipSubTitle()){
			theForm.action="BCBC-WorshipChoice.asp?CommandString=AddWorshipSubTitle";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="EditWorshipSubTitle"){
		if (ValidationWorshipSubTitle()){
			theForm.action="BCBC-WorshipChoice.asp?CommandString=EditWorshipSubTitle";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="DeleteWorshipSubTitle"){
		
		var result;
		var message="Are you SURE to delete this/these record(s)?"
		result=confirm(message);
		if (result==true){
			theForm.action="BCBC-WorshipChoice.asp?CommandString=DeleteWorshipSubTitle"
			theForm.submit();
		}
	}
	////////////////////////// JS functions for HeadCount /////////////////////
	else if (strButtonName=="AddHeadCount"){
		if (ValidationHeadCount()){
			theForm.action="BCBC-HeadCountChoice.asp?CommandString=AddHeadCount";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="EditHeadCount"){
		if (ValidationHeadCount()){
			theForm.action="BCBC-HeadCountChoice.asp?CommandString=EditHeadCount";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="DeleteHeadCount"){
		var result;
		var message="Are you SURE to delete this/these record(s)?"
		result=confirm(message);
		if (result==true){
			theForm.action="BCBC-HeadCountChoice.asp?CommandString=DeleteHeadCount"
			theForm.submit();
		}
	
	}
	////////////////////////// JS functions for Learning /////////////////////
	else if (strButtonName=="AddLearning"){
		
		if (ValidationLearning()){
			theForm.action="BCBC-LearningChoice.asp?CommandString=AddLearning";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="EditLearning"){
		
		if (ValidationLearning()){
			theForm.action="BCBC-LearningChoice.asp?CommandString=EditLearning";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="DeleteLearning"){
		var result;
		var message="Are you SURE to delete this/these record(s)?"
		result=confirm(message);
		if (result==true){
			theForm.action="BCBC-LearningChoice.asp?CommandString=DeleteLearning"
			theForm.submit();
		}
	
	}
	////////////////////////// JS functions for Links /////////////////////
	else if (strButtonName=="AddLink"){
		if (ValidationLink()){
			theForm.action="BCBC-LinkChoice.asp?CommandString=AddLink";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="EditLink"){
		if (ValidationLink()){
			theForm.action="BCBC-LinkChoice.asp?CommandString=EditLink";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="DeleteLink"){
		var result;
		var message="Are you SURE to delete this/these record(s)?"
		result=confirm(message);
		if (result==true){
			theForm.action="BCBC-LinkChoice.asp?CommandString=DeleteLink"
			theForm.submit();
		}
	
	}
	////////////////////////// JS functions for Others /////////////////////
	
	////////////////////////// JS functions for Admin Item /////////////////////
	else if (strButtonName=="AddAdminItem"){
		if (ValidationAdminItem()){
			theForm.action="BCBC-OthersChoice.asp?CommandString=AddAdminItem";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="EditAdminItem"){
		if (ValidationAdminItem()){
			theForm.action="BCBC-OthersChoice.asp?CommandString=EditAdminItem";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="DeleteAdminItem"){
		var result;
		var message="Are you SURE to delete this/these record(s)?"
		result=confirm(message);
		if (result==true){
			theForm.action="BCBC-OthersChoice.asp?CommandString=DeleteAdminItem"
			theForm.submit();
		}
	}
	////////////////////////// JS functions for Bible /////////////////////
	else if (strButtonName=="AddBible"){
		if (ValidationBible()){
			theForm.action="BCBC-OthersChoice.asp?CommandString=AddBible";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="EditBible"){
		if (ValidationBible()){
			theForm.action="BCBC-OthersChoice.asp?CommandString=EditBible";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="DeleteBible"){
		var result;
		var message="Are you SURE to delete this/these record(s)?"
		result=confirm(message);
		if (result==true){
			theForm.action="BCBC-OthersChoice.asp?CommandString=DeleteBible"
			theForm.submit();
		}
	}
	////////////////////////// JS functions for Church Room /////////////////////
	else if (strButtonName=="AddChurchRoom"){
		if (ValidationChurchRoom()){
			theForm.action="BCBC-OthersChoice.asp?CommandString=AddChurchRoom";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="EditChurchRoom"){
		if (ValidationChurchRoom()){
			theForm.action="BCBC-OthersChoice.asp?CommandString=EditChurchRoom";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="DeleteChurchRoom"){
		var result;
		var message="Are you SURE to delete this/these record(s)?"
		result=confirm(message);
		if (result==true){
			theForm.action="BCBC-OthersChoice.asp?CommandString=DeleteChurchRoom"
			theForm.submit();
		}
	}
	////////////////////////// JS functions for Cell group /////////////////////
	else if (strButtonName=="AddCellGroup"){
		if (ValidationCellGroup()){
			theForm.action="BCBC-OthersChoice.asp?CommandString=AddCellGroup";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="EditCellGroup"){
		if (ValidationCellGroup()){
			theForm.action="BCBC-OthersChoice.asp?CommandString=EditCellGroup";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="DeleteCellGroup"){
		var result;
		var message="Are you SURE to delete this/these record(s)?"
		result=confirm(message);
		if (result==true){
			theForm.action="BCBC-OthersChoice.asp?CommandString=DeleteCellGroup"
			theForm.submit();
		}
	}
	////////////////////////// JS functions for Education Level /////////////////////
	else if (strButtonName=="AddEducationLevel"){
		if (ValidationEducationLevel()){
			theForm.action="BCBC-OthersChoice.asp?CommandString=AddEducationLevel";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="EditEducationLevel"){
		if (ValidationEducationLevel()){
			theForm.action="BCBC-OthersChoice.asp?CommandString=EditEducationLevel";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="DeleteEducationLevel"){
		var result;
		var message="Are you SURE to delete this/these record(s)?"
		result=confirm(message);
		if (result==true){
			theForm.action="BCBC-OthersChoice.asp?CommandString=DeleteEducationLevel"
			theForm.submit();
		}
	}
	////////////////////////// JS functions for Link Category /////////////////////
	else if (strButtonName=="AddLinkCategory"){
		if (ValidationLinkCategory()){
			theForm.action="BCBC-OthersChoice.asp?CommandString=AddLinkCategory";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="EditLinkCategory"){
		if (ValidationLinkCategory()){
			theForm.action="BCBC-OthersChoice.asp?CommandString=EditLinkCategory";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="DeleteLinkCategory"){
		var result;
		var message="Are you SURE to delete this/these record(s)?"
		result=confirm(message);
		if (result==true){
			theForm.action="BCBC-OthersChoice.asp?CommandString=DeleteLinkCategory"
			theForm.submit();
		}
	}
	////////////////////////// JS functions for People Category /////////////////////
	else if (strButtonName=="AddPeopleCategory"){
		if (ValidationPeopleCategory()){
			theForm.action="BCBC-OthersChoice.asp?CommandString=AddPeopleCategory";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="EditPeopleCategory"){
		if (ValidationPeopleCategory()){
			theForm.action="BCBC-OthersChoice.asp?CommandString=EditPeopleCategory";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="DeletePeopleCategory"){
		var result;
		var message="Are you SURE to delete this/these record(s)?"
		result=confirm(message);
		if (result==true){
			theForm.action="BCBC-OthersChoice.asp?CommandString=DeletePeopleCategory"
			theForm.submit();
		}
	}
	////////////////////////// JS functions for Service Category /////////////////////
	else if (strButtonName=="AddService"){
		if (ValidationService()){
			theForm.action="BCBC-OthersChoice.asp?CommandString=AddService";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="EditService"){
		if (ValidationService()){
			theForm.action="BCBC-OthersChoice.asp?CommandString=EditService";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="DeleteService"){
		var result;
		var message="Are you SURE to delete this/these record(s)?"
		result=confirm(message);
		if (result==true){
			theForm.action="BCBC-OthersChoice.asp?CommandString=DeleteService"
			theForm.submit();
		}
	}
	////////////////////////// JS functions for ServiceManager Category /////////////////////
	else if (strButtonName=="AddServiceManager"){
		if (ValidationServiceManager()){
			theForm.action="BCBC-OthersChoice.asp?CommandString=AddServiceManager";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="EditServiceManager"){
		if (ValidationServiceManager()){
			theForm.action="BCBC-OthersChoice.asp?CommandString=EditServiceManager";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="DeleteServiceManager"){
		var result;
		var message="Are you SURE to delete this/these record(s)?"
		result=confirm(message);
		if (result==true){
			theForm.action="BCBC-OthersChoice.asp?CommandString=DeleteServiceManager"
			theForm.submit();
		}
	}
	////////////////////////// JS functions for Church Position Category /////////////////////
	else if (strButtonName=="AddPosition"){
		if (ValidationPosition()){
			theForm.action="BCBC-OthersChoice.asp?CommandString=AddPosition";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="EditPosition"){
		if (ValidationPosition()){
			theForm.action="BCBC-OthersChoice.asp?CommandString=EditPosition";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="DeletePosition"){
		var result;
		var message="Are you SURE to delete this/these record(s)?"
		result=confirm(message);
		if (result==true){
			theForm.action="BCBC-OthersChoice.asp?CommandString=DeletePosition"
			theForm.submit();
		}
	}
	////////////////////////// JS functions for State Category /////////////////////
	else if (strButtonName=="AddState"){
		if (ValidationState()){
			theForm.action="BCBC-OthersChoice.asp?CommandString=AddState";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="EditState"){
		if (ValidationState()){
			theForm.action="BCBC-OthersChoice.asp?CommandString=EditState";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="DeleteState"){
		var result;
		var message="Are you SURE to delete this/these record(s)?"
		result=confirm(message);
		if (result==true){
			theForm.action="BCBC-OthersChoice.asp?CommandString=DeleteState"
			theForm.submit();
		}
	}
	////////////////////////// JS functions for University /////////////////////
	else if (strButtonName=="AddUniv"){
		if (ValidationUniv()){
			theForm.action="BCBC-OthersChoice.asp?CommandString=AddUniv";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="EditUniv"){
		if (ValidationUniv()){
			theForm.action="BCBC-OthersChoice.asp?CommandString=EditUniv";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="DeleteUniv"){
		var result;
		var message="Are you SURE to delete this/these record(s)?"
		result=confirm(message);
		if (result==true){
			theForm.action="BCBC-OthersChoice.asp?CommandString=DeleteUniv"
			theForm.submit();
		}
	}
	////////////////////////// JS functions for Offering Category /////////////////////
	else if (strButtonName=="AddOfferingCategory"){
		if (ValidationOfferingCategory()){
			theForm.action="BCBC-OthersChoice.asp?CommandString=AddOfferingCategory";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="EditOfferingCategory"){
		if (ValidationOfferingCategory()){
			theForm.action="BCBC-OthersChoice.asp?CommandString=EditOfferingCategory";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="DeleteOfferingCategory"){
		var result;
		var message="Are you SURE to delete this/these record(s)?"
		result=confirm(message);
		if (result==true){
			theForm.action="BCBC-OthersChoice.asp?CommandString=DeleteOfferingCategory"
			theForm.submit();
		}
	}
}

//----------------------------------------------------------------------------------------------
// function to up and down ranking of news or others
//----------------------------------------------------------------------------------------------
function UpDown(strButtonName, Ranking){
	var theForm=document.BCBCForm;
	////////////////////////// UpDown functions for Worship /////////////////////
	if (strButtonName=="UpWorshipSubTitle"){
		theForm.action="BCBC-WorshipChoice.asp?CommandString=" + strButtonName + "&Ranking=" + Ranking;
		theForm.submit();
	}
	else if (strButtonName=="DownWorshipSubTitle"){
		theForm.action="BCBC-WorshipChoice.asp?CommandString=" + strButtonName + "&Ranking=" + Ranking;
		theForm.submit();
	}
	else if (strButtonName=="UpWorshipTitle"){
		theForm.action="BCBC-WorshipChoice.asp?CommandString=" + strButtonName + "&Ranking=" + Ranking;
		theForm.submit();
	}
	else if (strButtonName=="DownWorshipTitle"){
		theForm.action="BCBC-WorshipChoice.asp?CommandString=" + strButtonName + "&Ranking=" + Ranking;
		theForm.submit();
	}
	else if (strButtonName=="EditTitle"){
		theForm.action="BCBC-WorshipChoice.asp?CommandString=" + strButtonName + "&TitleID=" + Ranking;
		theForm.submit();
	}
	////////////////////////// UpDown functions for News /////////////////////
	else if (strButtonName=="UpNews"){
		theForm.action="BCBC-NewsChoice.asp?CommandString=" + strButtonName + "&Ranking=" + Ranking;
		theForm.submit();
	}
	else if (strButtonName=="DownNews"){
		theForm.action="BCBC-NewsChoice.asp?CommandString=" + strButtonName + "&Ranking=" + Ranking;
		theForm.submit();
	}
	////////////////////////// UpDown functions for AdminItem /////////////////////
	else if (strButtonName=="UpAdminItem"){
		theForm.action="BCBC-OthersChoice.asp?CommandString=" + strButtonName + "&Ranking=" + Ranking;
		theForm.submit();
	}
	else if (strButtonName=="DownAdminItem"){
		theForm.action="BCBC-OthersChoice.asp?CommandString=" + strButtonName + "&Ranking=" + Ranking;
		theForm.submit();
	}
	////////////////////////// UpDown functions for Bible /////////////////////
	else if (strButtonName=="UpBible"){
		theForm.action="BCBC-OthersChoice.asp?CommandString=" + strButtonName + "&Ranking=" + Ranking;
		theForm.submit();
	}
	else if (strButtonName=="DownBible"){
		theForm.action="BCBC-OthersChoice.asp?CommandString=" + strButtonName + "&Ranking=" + Ranking;
		theForm.submit();
	}
	////////////////////////// UpDown functions for ChurchRoom /////////////////////
	else if (strButtonName=="UpChurchRoom"){
		theForm.action="BCBC-OthersChoice.asp?CommandString=" + strButtonName + "&Ranking=" + Ranking;
		theForm.submit();
	}
	else if (strButtonName=="DownChurchRoom"){
		theForm.action="BCBC-OthersChoice.asp?CommandString=" + strButtonName + "&Ranking=" + Ranking;
		theForm.submit();
	}
	////////////////////////// UpDown functions for CellGroup /////////////////////
	else if (strButtonName=="UpCellGroup"){
		theForm.action="BCBC-OthersChoice.asp?CommandString=" + strButtonName + "&Ranking=" + Ranking;
		theForm.submit();
	}
	else if (strButtonName=="DownCellGroup"){
		theForm.action="BCBC-OthersChoice.asp?CommandString=" + strButtonName + "&Ranking=" + Ranking;
		theForm.submit();
	}
	////////////////////////// UpDown functions for EducationLevel /////////////////////
	else if (strButtonName=="UpEducationLevel"){
		theForm.action="BCBC-OthersChoice.asp?CommandString=" + strButtonName + "&Ranking=" + Ranking;
		theForm.submit();
	}
	else if (strButtonName=="DownEducationLevel"){
		theForm.action="BCBC-OthersChoice.asp?CommandString=" + strButtonName + "&Ranking=" + Ranking;
		theForm.submit();
	}
	////////////////////////// UpDown functions for LinkCategory /////////////////////
	else if (strButtonName=="UpLinkCategory"){
		theForm.action="BCBC-OthersChoice.asp?CommandString=" + strButtonName + "&Ranking=" + Ranking;
		theForm.submit();
	}
	else if (strButtonName=="DownLinkCategory"){
		theForm.action="BCBC-OthersChoice.asp?CommandString=" + strButtonName + "&Ranking=" + Ranking;
		theForm.submit();
	}
	////////////////////////// UpDown functions for PeopleCategory /////////////////////
	else if (strButtonName=="UpPeopleCategory"){
		theForm.action="BCBC-OthersChoice.asp?CommandString=" + strButtonName + "&Ranking=" + Ranking;
		theForm.submit();
	}
	else if (strButtonName=="DownPeopleCategory"){
		theForm.action="BCBC-OthersChoice.asp?CommandString=" + strButtonName + "&Ranking=" + Ranking;
		theForm.submit();
	}
	////////////////////////// UpDown functions for Service /////////////////////
	else if (strButtonName=="UpService"){
		theForm.action="BCBC-OthersChoice.asp?CommandString=" + strButtonName + "&Ranking=" + Ranking;
		theForm.submit();
	}
	else if (strButtonName=="DownService"){
		theForm.action="BCBC-OthersChoice.asp?CommandString=" + strButtonName + "&Ranking=" + Ranking;
		theForm.submit();
	}
	////////////////////////// UpDown functions for ServiceManager /////////////////////
	else if (strButtonName=="UpServiceManager"){
		theForm.action="BCBC-OthersChoice.asp?CommandString=" + strButtonName + "&Ranking=" + Ranking;
		theForm.submit();
	}
	else if (strButtonName=="DownServiceManager"){
		theForm.action="BCBC-OthersChoice.asp?CommandString=" + strButtonName + "&Ranking=" + Ranking;
		theForm.submit();
	}
	////////////////////////// UpDown functions for Position /////////////////////
	else if (strButtonName=="UpPosition"){
		theForm.action="BCBC-OthersChoice.asp?CommandString=" + strButtonName + "&Ranking=" + Ranking;
		theForm.submit();
	}
	else if (strButtonName=="DownPosition"){
		theForm.action="BCBC-OthersChoice.asp?CommandString=" + strButtonName + "&Ranking=" + Ranking;
		theForm.submit();
	}
	////////////////////////// UpDown functions for State /////////////////////
	else if (strButtonName=="UpState"){
		theForm.action="BCBC-OthersChoice.asp?CommandString=" + strButtonName + "&Ranking=" + Ranking;
		theForm.submit();
	}
	else if (strButtonName=="DownState"){
		theForm.action="BCBC-OthersChoice.asp?CommandString=" + strButtonName + "&Ranking=" + Ranking;
		theForm.submit();
	}
	////////////////////////// UpDown functions for University /////////////////////
	else if (strButtonName=="UpUniv"){
		theForm.action="BCBC-OthersChoice.asp?CommandString=" + strButtonName + "&Ranking=" + Ranking;
		theForm.submit();
	}
	else if (strButtonName=="DownUniv"){
		theForm.action="BCBC-OthersChoice.asp?CommandString=" + strButtonName + "&Ranking=" + Ranking;
		theForm.submit();
	}
	////////////////////////// UpDown functions for OfferingCategory /////////////////////
	else if (strButtonName=="UpOfferingCategory"){
		theForm.action="BCBC-OthersChoice.asp?CommandString=" + strButtonName + "&Ranking=" + Ranking;
		theForm.submit();
	}
	else if (strButtonName=="DownOfferingCategory"){
		theForm.action="BCBC-OthersChoice.asp?CommandString=" + strButtonName + "&Ranking=" + Ranking;
		theForm.submit();
	}
	

}












//----------------------------------------------------------------------------------------------
// function to load map animately
//----------------------------------------------------------------------------------------------
// Set AdsRotationSpeed (milliseconds)
var pause = 2500;
var shortpause = 100;

// Duration of crossfade (seconds)
var crossFadeDuration = 200;
// Specify the image files
var Pic = new Array();

// Specify the URL files
var AdsUrl = new Array();

// to add more images, just continue
// the pattern, adding to the array below
var contentimage=""
var i_image=0

Pic[0] = '../images/BCBC-Map1.gif'
Pic[1] = '../images/BCBC-Map2.gif'
Pic[2] = '../images/BCBC-Map3.gif'

var p = Pic.length;

var preLoad = new Array();
for (i = 0; i < p; i++) {
preLoad[i] = new Image();

preLoad[i].src = Pic[i];
}

// function to display text in the status bar about the current banner
function windowON()
    {
    window.status = eval('text' + sponsor);
    setTimeout("windowOFF()",2000);
    }

// function to clear the status bar message
function windowOFF()
    {
    window.status="";
    }

function fadeimage(){
	
	if (document.all) {
			
		//document.images.AdsRotation.style.filter="blendTrans(duration=2)";
			document.images.BCBCMap.style.filter="blendTrans(duration=crossFadeDuration)";
			document.images.BCBCMap.filters.blendTrans.Apply();
		}
		if (document.images.BCBCMap.src == preLoad[0].src){
			document.getElementById('BCBCArea').coords="37,105,183,250"
			document.images.BCBCMap.src = preLoad[1].src;
		}
		else if (document.images.BCBCMap.src == preLoad[1].src) {
			document.getElementById('BCBCArea').coords="0,0,310,310"
			document.images.BCBCMap.src = preLoad[2].src;
		}
		else if (document.images.BCBCMap.src == preLoad[2].src) {
			document.getElementById('BCBCArea').coords="242,140,290,183"
			document.images.BCBCMap.src = preLoad[0].src;
		}
		if (document.all) {
			document.images.BCBCMap.filters.blendTrans.Play();
		}
}

function changeimage() { 
	document.images.BCBCMap.src = preLoad[1].src;
}	

function ChangeMap() {
	if (document.layers) {
		
       changeimage();
	}
	else if (document.all) {
		
		fadeimage();

	}
}

//	Global variables

var NullString = "";
var intFirstNameLength = 12;
var intLastNameLength = 17;
var defaultEmptyOK = false;
var intSSNLength = 9;
var intTelLength =10;
var intAddressLength = 64;
var intCityLength = 22;

// whitespace characters
var whitespace = " \t\n\r";
var intZIPLength_Part1=5;
var intZIPLength_Part2=4;


//	Global functions

/************************************************************************
	IsEmpty
	Description: Checks a string if empty and returns the appropriate 
	             boolean value.
************************************************************************/
function IsEmpty( item ){   
	return ((item == null) || (item.length == 0));
}

/************************************************************************
	IsWhitespace
	Description: Checks a string it is a whiteshape and returns the
	             appropriate boolean value.
************************************************************************/
function IsWhitespace ( item ){   

	var i;

    if (IsEmpty(item)) return true;

    for (i = 0; i < item.length; i++)
    {   

        var c = item.charAt(i);

        if (whitespace.indexOf(c) == -1) return false;
    }

    return true;
}

/************************************************************************
	IsLetter
	Description: Checks input if it is a letter and returns the
	             appropriate boolean value.
************************************************************************/
function IsLetter ( item ){   
	return ( ((item >= "a") && (item <= "z")) || ((item >= "A") && (item <= "Z")) || (item == "'"));
}

/************************************************************************
	IsDigit
	Description: Returns true if character c is a digit 
************************************************************************/
function IsDigit (item){   
	return ((item >= "0") && (item <= "9"));	
}

/************************************************************************
	IsInteger
	Description: 
************************************************************************/
function IsInteger ( item ){   

	var i;

    if (IsEmpty( item )) 
		if (IsInteger.arguments.length == 1) 
			return false;
       else 
			return (IsInteger.arguments[1] == true);

    for (i = 0; i < item.length; i++){   

        var c = item.charAt(i);

        if (!IsDigit(c)) return false;
    }

    return true;
}

/************************************************************************
	IsAlphabetic
	Description: 
************************************************************************/
function IsAlphabetic ( item ){   

	var i;

    if (IsEmpty(item)) 
       if (IsAlphabetic.arguments.length == 1) 
			return false;
       else 
			return (IsAlphabetic.arguments[1] == true);

    for (i = 0; i < item.length; i++)
    {   

        var c = item.charAt(i);

        if (!(IsLetter(c)|| IsWhitespace(c)))
        return false;
    }

    return true;
}

/************************************************************************
	IsAlphanumeric
	Description: 
************************************************************************/
function IsAlphanumeric ( item ){   

	var i;

    if (IsEmpty(item)) 
		if (IsAlphanumeric.arguments.length == 1) 
			return false;
		else 
			return (IsAlphanumeric.arguments[1] == true);


    for (i = 0; i < item.length; i++){   

        var c = item.charAt(i);

        if (! (IsLetter(c) || IsDigit(c) ) )
        return false;
    }

    return true;
}

/************************************************************************
	IsFirstName
	Description: Checks a string if is a valid first name. 
************************************************************************/
function IsFirstName ( item ){
	return (item.length > 0 && item.length <= intFirstNameLength && IsAlphabetic( item));
}

/************************************************************************
	IsMiddleInitial
	Description: Checks a string if is a middle initial.
************************************************************************/
function IsMiddleInitial ( item ){
	return (item.length > 0 && item.length <= 1 && IsLetter( item));
}

/************************************************************************
	IsLastName
	Description: Checks a string if is a valid first name. 
************************************************************************/
function IsLastName ( item ){
	return (item.length > 0 && item.length <= intLastNameLength && IsAlphabetic( item));
}

/************************************************************************
	IsSSN
	Description: Checks if a string is a valid SSN and returns appropriate
	             boolean value.
************************************************************************/
function IsSSN (item){ 
	  
	if (IsEmpty(item)) 
		if (IsSSN.arguments.length == 1) 
			return false;
	else 
		return (IsSSN.arguments[1] == true);
    
    return (IsInteger(item) && item.length == intSSNLength);
}

// check the tel or fax number
function IsTel (item){ 
	  
	if (IsEmpty(item)) 
		if (IsTel.arguments.length == 1) 
			return false;
	else 
		return (IsTel.arguments[1] == true);
    
    return (IsInteger(item) && item.length == intTelLength);
}


/************************************************************************
	IsAddress
	Description: Checks if a string is a valid address and returns appropriate
	             boolean value.
************************************************************************/
function IsAddress (item){   
	if (IsEmpty(item)) 
		if (IsAddress.arguments.length == 1) 
			return false;
	else 
		return (IsAddress.arguments[1] == true);
    
    return (IsAlphanumeric(item) && item.length <= intAddressLength && item.length >= 1);
}

/************************************************************************
	IsFourDigitYear
	Description: Checks if a string is a valid four-digit year and returns 
	             the appropriate boolean value.
************************************************************************/
function IsFourDigitYear ( item ){
	return ( item.length == 4 && IsNonnegativeInteger (item));
}

/************************************************************************
	IsCity
	Description: Checks if a string is a valid city and returns 
	             the appropriate boolean value.
************************************************************************/
function IsCity ( item ){
	return ( item.length >= 1 && item.length <= intCityLength && IsAlphabetic (item));
}

// check Zip_Part1
function IsZIP1 (item){ 
	  
	if (IsEmpty(item)) 
		if (IsZIP1.arguments.length == 1) 
			return false;
	else 
		return (IsZIP1.arguments[1] == true);
    
    return (IsInteger(item) && item.length == intZIPLength_Part1);
}

// check Zip_Part2
function IsZIP2 (item){ 
	  
	if (IsEmpty(item)) 
		if (IsZIP2.arguments.length == 1) 
			return false;
	else 
		return (IsZIP2.arguments[1] == true);
    
    return (IsInteger(item) && item.length == intZIPLength_Part2);
}


/************************************************************************
	IsTwoDigitYear
	Description: Checks if a string is a valid two-digit year and returns 
	             the appropriate boolean value.
************************************************************************/
function IsTwoDigitYear ( item ){

	return ( item.length == 2 && IsNonnegativeInteger (item));

}

/************************************************************************
	IsMonth
	Description: Checks if a string is a valid month and returns 
	             the appropriate boolean value.
************************************************************************/
function IsMonth ( item ){
	return ( item <= 12 && item >= 1 && IsNonnegativeInteger(item));
}

/************************************************************************
	IsDay
	Description: Checks if a string is a valid day and returns 
	             the appropriate boolean value.
************************************************************************/
function IsDay ( item ){
	return ( item <= 31 && item >= 1 && IsNonnegativeInteger(item));
}


/************************************************************************
	IsNonnegativeInteger
	Description: 
************************************************************************/
function IsNonnegativeInteger ( item ){   

	var secondArg = false;

    if (IsNonnegativeInteger.arguments.length > 1)
        secondArg = IsNonnegativeInteger.arguments[1];

    return (IsSignedInteger(item, secondArg)
         && ( (IsEmpty(item) && secondArg)  || (parseInt (item) >= 0) ) );
}

/************************************************************************
	IsSignedInteger
	Description: 
************************************************************************/
function IsSignedInteger ( item )

{   if (IsEmpty( item )) 
       if (IsSignedInteger.arguments.length == 1) 
			return false;
       else 
			return (IsSignedInteger.arguments[1] == true);

    else {
        var startPos = 0;
        var secondArg = false;

        if (IsSignedInteger.arguments.length > 1)
            secondArg = IsSignedInteger.arguments[1];

        // skip leading + or -
        if ( (item.charAt(0) == "-") || (item.charAt(0) == "+") )
           startPos = 1;    
        return (IsInteger(item.substring(startPos, item.length), secondArg))
    }
}

/************************************************************************
	IsEmail
	Description: 
************************************************************************/
function IsEmail ( item )
{   

	if (IsEmpty(item)) 
       if (IsEmail.arguments.length == 1) 
			return false;
       else 
			return (IsEmail.arguments[1] == true);
   
    // is s whitespace?
    if (IsWhitespace(item)) 
		return false;
    
    // there must be >= 1 character before @, so we
    // start looking at character position 1 
    // (i.e. second character)
    var i = 1;
    var sLength = item.length;

    // look for @
    while ((i < sLength) && (item.charAt(i) != "@")){ 
		i++;
    }

    if ((i >= sLength) || (item.charAt(i) != "@")) 
		return false;
    else i += 2;

    // look for .
    while ((i < sLength) && (item.charAt(i) != ".")){ 
		i++;
    }

    // there must be at least one character after the .
    if ((i >= sLength - 1) || (item.charAt(i) != ".")) 
		return false;
    else 
		return true;
}

// Get checked value from radio button.

function getRadioButtonValue (radio)
{   for (var i = 0; i < radio.length; i++)
    {   if (radio[i].checked) { 
			return radio[i].value;
			break; }
    }
	return "";
}

// check some special character in a string not exceed max amount
function checkSymbol(string,findwhat,maxamount)
{
 	var sLength = string.length;
	var counter=0;
	var i=0;
    // look for symbol
    while (i < sLength){ 
		if (string.charAt(i) == findwhat)
			counter++;
		i++;
    }
	
	if (counter<=maxamount)
		return true;
	
	return false;
}

// trim a string
function trim (s)
{
var iLen = s.length;
var sOut = "";
var chr = "";

for (var i=0; i<iLen; i++)
{
chr = s.charAt (i); 
if (chr!=" ")
{
sOut = sOut + chr; 
}
}
return sOut;
}

// This function will trim leading and/or trailing spaces from a string
// arg = the value you wish to have trimmed..
// func = "left" for Ltrim(), "right" for RTrim() or "both" for Trim()

//===================================
function trimLT(arg,func) {
//===================================

	var trimvalue = "";
	arglen = arg.length;
	if (arglen < 1) return trimvalue;

	if (func == "left" || func== "both") {
		i = 0;
		pos = -1;
		while (i < arglen) {
			if (arg.charCodeAt(i) != 32 &&
!isNaN(arg.charCodeAt(i))) {
				pos = i;
				break;
			}
			i++;
		}
	}

	if (func == "right" || func== "both") {
		var lastpos = -1;
		i = arglen;
		while (i >= 0) {
			if (arg.charCodeAt(i) != 32 &&
!isNaN(arg.charCodeAt(i))) {
				lastpos = i;
				break;
			}
			i--;
		}
	}

	if (func == "left") {
			trimvalue = arg.substring(pos,arglen-1);
		}

	if (func == "right") {
		trimvalue = arg.substring(0,lastpos+1);
	}

	if (func == "both") {
		trimvalue = arg.substring(pos,lastpos + 1);
	}

	return trimvalue;

}


// fill character to meet fixed length from left with some characters
function fillCharacter (s, c, a)
{	var str=trim(s)
	var sLen=str.length;
	var newstring="";
	if (sLen!=0) {
		for (var i=0; i<a-sLen; i++) {
			newstring=newstring+c;
		}
		return str=newstring+str;
	}
	else {
		return "";
	}
}

function cleanNonLetter (s)
{	var str=s
	var sLen=str.length;
	var newstring="";
	if (sLen!=0) {
		for (var i=0; i<sLen; i++) {
			var c = str.charAt(i);
			if (!IsLetter(c)){
				c=" "
			}
			newstring=newstring+c;
		}
		return newstring;
	}
	else {
		return "";
	}
}

function autotab(obj,nextobj,mlength){
         if(!mlength) 
		 	mlength = obj.size;
         if(obj.value.length>=mlength){
                 obj.value = obj.value.substr(0,mlength);
                 nextobj.focus();
				 nextobj.select();
         }
}

// autotab code
var isNN = (navigator.appName.indexOf("Netscape")!=-1);
function autoTab(input,len, e) {
var keyCode = (isNN) ? e.which : e.keyCode; 
var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
if(input.value.length >= len && !containsElement(filter,keyCode)) {
input.value = input.value.slice(0, len);
input.form[(getIndex(input)+1) % input.form.length].focus();
}
function containsElement(arr, ele) {
var found = false, index = 0;
while(!found && index < arr.length)
if(arr[index] == ele)
found = true;
else
index++;
return found;
}
function getIndex(input) {
var index = -1, i = 0, found = false;
while (i < input.form.length && index == -1)
if (input.form[i] == input)index = i;
else i++;
return index;
}
return true;
}

// change city if choosing canadian state
function ChangeCity(city,state) {	
 	
	var statevalue=state.options[state.selectedIndex].value;
	var statecountry=statevalue.substring(statevalue.length-2,statevalue.length);
	
	if (statecountry=="CN") {
		
		var newcity=statevalue.substring(5,statevalue.length-5)
		
		eval(city + ".value='"+newcity+"'")
		state.selectedIndex=60
	}
}


// check if the value is valid date

var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(0,pos1)
	var strDay=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert("The date format should be : mm/dd/yyyy")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Please enter a valid month")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Please enter a valid day")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Please enter a valid date")
		return false
	}
	
return true
}
/*
function ValidateForm(){
	var dt=document.frmSample.txtDate
	if (isDate(dt.value)==false){
		dt.focus()
		return false
	}
    return true
 }
*/

function strReplace(str1, str2, str3) { 
  while(str1.indexOf(str2) != -1) {
   str1 = str1.replace(str2, str3);
 } 
  return str1;     
} 

/************************************************************************
	IsOfferingAmount
	Description: 
************************************************************************/
function IsOfferingAmount ( item ){   

	var i;

    if (IsEmpty( item )) 
		if (IsInteger.arguments.length == 1) 
			return false;
       else 
			return (IsInteger.arguments[1] == true);

    for (i = 0; i < item.length; i++){   

        var c = item.charAt(i);

        if (!IsDigit(c) && c!=".") return false;
    }

    return true;
}

/************************************************************************
	Open a new window
	Description: 
************************************************************************/

function NewWindow(mypage,myname,w,h,scrollbar){
LeftPosition = 75;
TopPosition = 75;
settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scrollbar+',resizable'
win = window.open(mypage,myname,settings)
if(win.window.focus){win.window.focus();}
} 

