//----------------------------------------------------------------------------------------------
// function to trigger action based on different button
//----------------------------------------------------------------------------------------------
function SubmitRequest(strButtonName){
	var theForm=document.LFLForm;
	//alert(document.charset);
	
	//alert(document.charset);
	//document.refresh();
	//alert(document.charset);
	//alert (strButtonName);
	
	
	
	////////////////////////// JS functions for LFL Church /////////////////////
	
	if (strButtonName=="Add_Church"){
		if (ValidationChurch()){
			theForm.action="OtherChoice.asp?CommandString=Add_Church";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="Edit_Church"){
		if (ValidationChurch()){
			theForm.action="OtherChoice.asp?CommandString=Edit_Church";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="Delete_Church"){
		var result;
		var message="Are you SURE to delete this/these record(s)?"
		result=confirm(message);
		if (result==true){
			theForm.action="OtherChoice.asp?CommandString=Delete_Church"
			theForm.submit();
		}
	}
	
	
	/////////////////////////// JS Functions for Email Template //////////////
	else if (strButtonName=="Add_Email_Template"){
		//if (ValidationChurch()){
			theForm.action="OtherChoice.asp?CommandString=Add_Email_Template";
			document.charset="iso-8859-1";
			theForm.submit();
		//}
	}
	else if (strButtonName=="Edit_Email_Template"){
		//if (ValidationChurch()){
			theForm.action="OtherChoice.asp?CommandString=Edit_Email_Template";
			document.charset="iso-8859-1";
			theForm.submit();
		//}
	}
	else if (strButtonName=="Delete_Email_Template"){
		var result;
		var message="Are you SURE to delete this/these record(s)?"
		result=confirm(message);
		if (result==true){
			theForm.action="OtherChoice.asp?CommandString=Delete_Email_Template"
			theForm.submit();
		}
	}
	
	
	
	
	////////////////////////// JS functions for LFL Dorm /////////////////////
	
	else if (strButtonName=="Add_Dorm"){
		if (ValidationDorm()){
			theForm.action="OtherChoice.asp?CommandString=Add_Dorm";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="Edit_Dorm"){
		if (ValidationDorm()){
			theForm.action="OtherChoice.asp?CommandString=Edit_Dorm";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="Delete_Dorm"){
		var result;
		var message="Are you SURE to delete this/these record(s)?"
		result=confirm(message);
		if (result==true){
			theForm.action="OtherChoice.asp?CommandString=Delete_Dorm"
			theForm.submit();
		}
	}
	
	////////////////////////// JS functions for LFL Age /////////////////////
	
	else if (strButtonName=="Add_Age"){
		if (ValidationAge()){
			theForm.action="OtherChoice.asp?CommandString=Add_Age";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="Edit_Age"){
		if (ValidationAge()){
			theForm.action="OtherChoice.asp?CommandString=Edit_Age";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="Delete_Age"){
		var result;
		var message="Are you SURE to delete this/these record(s)?"
		result=confirm(message);
		if (result==true){
			theForm.action="OtherChoice.asp?CommandString=Delete_Age"
			theForm.submit();
		}
	}
	
	////////////////////////// JS functions for LFL Job /////////////////////
	
	else if (strButtonName=="Add_Job"){
		if (ValidationJob()){
			theForm.action="OtherChoice.asp?CommandString=Add_Job";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="Edit_Job"){
		if (ValidationJob()){
			theForm.action="OtherChoice.asp?CommandString=Edit_Job";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="Delete_Job"){
		var result;
		var message="Are you SURE to delete this/these record(s)?"
		result=confirm(message);
		if (result==true){
			theForm.action="OtherChoice.asp?CommandString=Delete_Job"
			theForm.submit();
		}
	}
	
	////////////////////////// JS functions for LFL Payment Type /////////////////////
	
	else if (strButtonName=="Add_Payment_Type"){
		if (ValidationPaymentType()){
			theForm.action="OtherChoice.asp?CommandString=Add_Payment_Type";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="Edit_Payment_Type"){
		if (ValidationPaymentType()){
			theForm.action="OtherChoice.asp?CommandString=Edit_Payment_Type";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="Delete_Payment_Type"){
		var result;
		var message="Are you SURE to delete this/these record(s)?"
		result=confirm(message);
		if (result==true){
			theForm.action="OtherChoice.asp?CommandString=Delete_Payment_Type"
			theForm.submit();
		}
	}
	
	////////////////////////// JS functions for LFL Assign Room /////////////////////
	
	else if (strButtonName=="Assign_Room"){
		var Registration_Fee_Received=theForm.Registration_Fee_Received.value;
		var Registration_Fee_Receivable=theForm.Registration_Fee_Receivable.value;
		
		if (Registration_Fee_Received<Registration_Fee_Receivable){
			var result;
			var message="Registration Fee Required:" + Registration_Fee_Receivable +";\nRegistration Fee Paid:" + Registration_Fee_Received +".\n\nThis family has NOT paid off the registration fee.\n\nDo you still want to assign room?"
			result=confirm(message);
			if (result==true){
				theForm.action="RoomChoice.asp?CommandString=Assign_Room"
				theForm.submit();
			}
			else {
				return false;
			}
		}
		else{
			theForm.action="RoomChoice.asp?CommandString=Assign_Room"
			theForm.submit();
		}
		
	}
	
	else if (strButtonName=="Back_CheckInView"){
	
		theForm.action="RoomChoice.asp?CommandString=Back_CheckInView"
		theForm.submit();
	}
	
	////////////////////////// JS functions for LFL WebAuth /////////////////////
	
	else if (strButtonName=="Add_WebAuth"){
		if (ValidationWebAuth()){
			theForm.action="OtherChoice.asp?CommandString=Add_WebAuth";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="Edit_WebAuth"){
		if (ValidationWebAuth()){
			theForm.action="OtherChoice.asp?CommandString=Edit_WebAuth";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="Delete_WebAuth"){
		var result;
		var message="Are you SURE to delete this/these record(s)?"
		result=confirm(message);
		if (result==true){
			theForm.action="OtherChoice.asp?CommandString=Delete_WebAuth"
			theForm.submit();
		}
	}
	////////////////////////// JS functions for LFL Room /////////////////////
	
	else if (strButtonName=="Add_Room"){
		if (ValidationRoom()){
			theForm.action="OtherChoice.asp?CommandString=Add_Room";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="Edit_Room"){
		if (ValidationRoom()){
			theForm.action="OtherChoice.asp?CommandString=Edit_Room";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="Delete_Room"){
		var result;
		var message="Are you SURE to delete this/these record(s)?"
		result=confirm(message);
		if (result==true){
			theForm.action="OtherChoice.asp?CommandString=Delete_Room"
			theForm.submit();
		}
	}
	
	////////////////////////// JS functions for LFL Group /////////////////////
	
	else if (strButtonName=="Add_Group"){
		if (ValidationGroup()){
			theForm.action="OtherChoice.asp?CommandString=Add_Group";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="Edit_Group"){
		if (ValidationGroup()){
			theForm.action="OtherChoice.asp?CommandString=Edit_Group";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="Delete_Group"){
		var result;
		var message="Are you SURE to delete this/these record(s)?"
		result=confirm(message);
		if (result==true){
			theForm.action="OtherChoice.asp?CommandString=Delete_Group"
			theForm.submit();
		}
	}
	
	////////////////////////// JS functions for LFL CoWorker /////////////////////
	
	else if (strButtonName=="Insert_Coworker"){
		theForm.action="CoworkerChoice.asp?CommandString=Insert_Coworker";
		theForm.submit();
	}
	else if (strButtonName=="Add_Coworker"){
		if (ValidationCoworker()){
			theForm.action="CoworkerChoice.asp?CommandString=Add_Coworker";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="Edit_Coworker"){
		if (ValidationCoworker()){
			theForm.action="CoworkerChoice.asp?CommandString=Edit_Coworker";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="Email_Coworker"){
		if (ValidationCoworkerCheckBox()){
			var result;
			var message="Are you SURE to email the checked coworker their username and password?"
			result=confirm(message);
			if (result==true){
				theForm.action="CoworkerChoice.asp?CommandString=Email_Coworker"
				theForm.submit();
			}
		}
	}
	else if (strButtonName=="Email_Coworker_Anything"){
		if (ValidationCoworkerCheckBox()){
			var result;
			var message="Are you SURE to email to the checked coworker(s)?"
			result=confirm(message);
			if (result==true){
				theForm.action="CoworkerChoice.asp?CommandString=Email_Coworker_Anything"
				theForm.submit();
			}
		}
	}
	else if (strButtonName=="Email_Filtered_Family_Anything"){
		if (ValidationNoticeCheckBox()){
			var result;
			var message="Are you SURE to email to the checked Family(ies)?"
			result=confirm(message);
			if (result==true){
				theForm.action="OtherChoice.asp?CommandString=Email_Filtered_Family_Anything"
				theForm.submit();
			}
		}
	}
	else if (strButtonName=="Update_Email_Coworker"){
		var result;
		var message="Are you SURE to email the checked coworker their new username and password?"
		result=confirm(message);
		if (result==true){
			theForm.action="CoworkerChoice.asp?CommandString=Update_Email_Coworker"
			document.charset="iso-8859-1";
			theForm.submit();
		}
		
	}
	else if (strButtonName=="Delete_Coworker"){
		var result;
		var message="Are you SURE to delete this/these record(s)?"
		result=confirm(message);
		if (result==true){
			theForm.action="CoworkerChoice.asp?CommandString=Delete_Coworker"
			theForm.submit();
		}
	}
	////////////////////////// JS functions for LFL Family Deletion /////////////////////
	else if (strButtonName=="DeleteFamilys"){
		
		if (ValidationFamilyCheckBox()){
			var result;
			var message="Are you SURE to delete this/these family(s)?"
			result=confirm(message);
			if (result==true){
				theForm.action="OtherChoice.asp?CommandString=DeleteFamilys"
				theForm.submit();
			}
		}
	}
	
	else if (strButtonName=="DeleteRooms"){
		
		if (ValidationFamilyCheckBox()){
			var result;
			var message="Are you SURE to delete this/these room(s)?"
			result=confirm(message);
			if (result==true){
				theForm.action="OtherChoice.asp?CommandString=DeleteRooms"
				theForm.submit();
			}
		}
	}
	
	else if (strButtonName=="UnflagEmailNotice"){
		
		if (ValidationFamilyCheckBox()){
			var result;
			var message="Are you SURE to unflag the email flag of this/these family(s)?"
			result=confirm(message);
			if (result==true){
				theForm.action="OtherChoice.asp?CommandString=UnflagEmailNotice"
				theForm.submit();
			}
		}
	}
	
	////////////////////////// JS functions for LFL Family Add FollowUp /////////////////////
	else if (strButtonName=="AddFamilys"){
		
		if (ValidationFamilyCheckBox()){
			var result;
			var message="Are you SURE to add this/these family(s)?"
			result=confirm(message);
			if (result==true){
				theForm.action="OtherChoice.asp?CommandString=AddFamilys"
				theForm.submit();
			}
		}
	}
	
	////////////////////////// JS functions for LFL Email Notice to List of Guest /////////////////////
	else if (strButtonName=="Email_Notice"){
		
		if (ValidationNoticeCheckBox()){
			var result;
			var message="Are you SURE to email this/these family(s) the notice?"
			result=confirm(message);
			if (result==true){
				theForm.action="ListChoice.asp?CommandString=Email_Notice"
				theForm.submit();
			}
		}
	}
	
	else if (strButtonName=="Send_Email_To_Attendee"){
		
		if (document.LFLForm.selectAttendee.options[document.LFLForm.selectAttendee.selectedIndex].value == "Select" ){
			alert ("Please select the attendee to email.");
			
		}
		else {
			var result;
			var message="Are you SURE to email to this/these attendee(s)?"
			result=confirm(message);
			if (result==true){
				theForm.action="OtherChoice.asp?CommandString=Send_Email_To_Attendee"
				theForm.submit();
			}
		}
	}
	
	else if (strButtonName=="Send_Email_To_Anyone"){
		
		if (ValidationEmailAnyone()){
			var result;
			var message="Are you SURE to email to this person?"
			result=confirm(message);
			if (result==true){
				theForm.action="OtherChoice.asp?CommandString=Send_Email_To_Anyone"
				theForm.submit();
			}
		}
	}
	
	else if (strButtonName=="Send_Email_To_Coworker_Anything"){
		
		if (ValidationEmailAnyone()){
			var result;
			var message="Are you SURE to email to this(these) coworker(s)?"
			result=confirm(message);
			if (result==true){
				theForm.action="CoworkerChoice.asp?CommandString=Send_Email_To_Coworker_Anything"
				theForm.submit();
			}
		}
	}
	
	else if (strButtonName=="Send_Email_To_Filtered_Family_Anything"){
		
		if (ValidationEmailAnyone()){
			var result;
			var message="Are you SURE to email to this(these) family(ies)?"
			result=confirm(message);
			if (result==true){
				theForm.action="OtherChoice.asp?CommandString=Send_Email_To_Filtered_Family_Anything"
				theForm.submit();
			}
		}
	}
	
	
	
	////////////////////////// JS functions for LFL Family Registration /////////////////////
	else if (strButtonName=="Add_Family"){
		if (ValidationFamily()){
			theForm.action="FamilyChoice.asp?CommandString=Add_Family";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="Edit_Family"){
		if (ValidationUpdateFamily()){
			theForm.action="FamilyChoice.asp?CommandString=Edit_Family";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="Admin_Edit_Family"){
		if (ValidationUpdateFamily()){
			theForm.action="ListChoice.asp?CommandString=Edit_Family";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="Delete_Family"){
		var result;
		var message="Are you SURE to delete this/these record(s)?"
		result=confirm(message);
		if (result==true){
			theForm.action="FamilyChoice.asp?CommandString=Delete_Family"
			theForm.submit();
		}
	}
	
	////////////////////////// JS functions for Admin Login /////////////////////
	else if (strButtonName=="Check_AdminLogin"){
		if (ValidationLogin()){
			theForm.action="LoginChoice.asp?CommandString=Check_AdminLogin";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	
	
	
	////////////////////////// JS functions for Coworker Login /////////////////////
	else if (strButtonName=="Check_CoworkerLogin"){
		if (ValidationLogin()){
			theForm.action="FamilyChoice.asp?CommandString=Check_CoworkerLogin";
			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 Coworker login //////////////////////////////
	else if (strButtonName=="ChangeCoworkerLogin") {
		if (ValidationChangeFirstLogin()){
			document.charset="iso-8859-1";
			theForm.action="CoworkerChangeLoginChoice.asp?CommandString=ChangeCoworkerLogin";
			theForm.submit();
		}
	}
	
	////////////////////////// JS functions for Family Login /////////////////////
	else if (strButtonName=="Check_FamilyLogin"){
		if (ValidationLogin()){
			theForm.action="FamilyChoice.asp?CommandString=Check_FamilyLogin";
			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 Family login //////////////////////////////
	else if (strButtonName=="ChangeFamilyLogin") {
		if (ValidationChangeLogin()){
			document.charset="iso-8859-1";
			theForm.action="FamilyChoice.asp?CommandString=ChangeFamilyLogin";
			theForm.submit();
		}
	}
	
	else if (strButtonName=="AdminChangeFamilyLogin") {
		if (ValidationChangeLogin()){
			document.charset="iso-8859-1";
			theForm.action="ListChoice.asp?CommandString=ChangeFamilyLogin";
			theForm.submit();
		}
	}
	
	////////////////////////// JS functions for LFL Room Assignment /////////////////////b 
	else if (strButtonName=="SelectDorm"){
		var Dorm_ID=theForm.Dorm.value;
		theForm.action="RoomAssign.asp?Dorm_ID=" + Dorm_ID
		theForm.submit();
	
		/*if (ValidationFamily()){
			theForm.action="FamilyChoice.asp?CommandString=Add_Family";
			document.charset="iso-8859-1";
			theForm.submit();
		}*/
	}
	/*else if (strButtonName=="Edit_Family"){
		if (ValidationFamily()){
			theForm.action="FamilyChoice.asp?CommandString=Edit_Family";
			document.charset="iso-8859-1";
			theForm.submit();
		}
	}
	else if (strButtonName=="Delete_Family"){
		var result;
		var message="Are you SURE to delete this/these record(s)?"
		result=confirm(message);
		if (result==true){
			theForm.action="FamilyChoice.asp?CommandString=Delete_Family"
			theForm.submit();
		}
	}*/
}

//----------------------------------------------------------------------------------------------
// function to up and down ranking of news or others
//----------------------------------------------------------------------------------------------
function UpDown(strButtonName, Ranking){
	var theForm=document.LFLForm;
	
	
	////////////////////////// UpDown functions for LFL Church /////////////////////
	if (strButtonName=="Up_Church"){
		theForm.action="OtherChoice.asp?CommandString=" + strButtonName + "&Ranking=" + Ranking;
		theForm.submit();
	}
	else if (strButtonName=="Down_Church"){
		theForm.action="OtherChoice.asp?CommandString=" + strButtonName + "&Ranking=" + Ranking;
		theForm.submit();
	}
	
	////////////////////////// UpDown functions for LFL Dorm /////////////////////
	else if (strButtonName=="Up_Dorm"){
		theForm.action="OtherChoice.asp?CommandString=" + strButtonName + "&Ranking=" + Ranking;
		theForm.submit();
	}
	else if (strButtonName=="Down_Dorm"){
		theForm.action="OtherChoice.asp?CommandString=" + strButtonName + "&Ranking=" + Ranking;
		theForm.submit();
	}
	
	////////////////////////// UpDown functions for LFL Age /////////////////////
	else if (strButtonName=="Up_Age"){
		theForm.action="OtherChoice.asp?CommandString=" + strButtonName + "&Ranking=" + Ranking;
		theForm.submit();
	}
	else if (strButtonName=="Down_Age"){
		theForm.action="OtherChoice.asp?CommandString=" + strButtonName + "&Ranking=" + Ranking;
		theForm.submit();
	}
	
	////////////////////////// UpDown functions for LFL Payment Type /////////////////////
	else if (strButtonName=="Up_Payment_Type"){
		theForm.action="OtherChoice.asp?CommandString=" + strButtonName + "&Ranking=" + Ranking;
		theForm.submit();
	}
	else if (strButtonName=="Down_Payment_Type"){
		theForm.action="OtherChoice.asp?CommandString=" + strButtonName + "&Ranking=" + Ranking;
		theForm.submit();
	}
	
	////////////////////////// UpDown functions for LFL WebAuth /////////////////////
	else if (strButtonName=="Up_WebAuth"){
		theForm.action="OtherChoice.asp?CommandString=" + strButtonName + "&Ranking=" + Ranking;
		theForm.submit();
	}
	else if (strButtonName=="Down_WebAuth"){
		theForm.action="OtherChoice.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();}
} 

/************************************************************************
	Open a new bulletin window
	Description: 
************************************************************************/


function NewBulletinWindow(mypage,myname,w,h,scrollbar){
var theForm=document.LFLForm;
var theStartDateValue=theForm.startDate.value;
//alert(theStartDateValue);
mypage=mypage+"?WeekDate="+theStartDateValue;
LeftPosition = 0;
TopPosition = 0;
settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scrollbar+',resizable'
//alert(mypage);
win = window.open(mypage,myname,settings)
if(win.window.focus){win.window.focus();}
} 

function getInteger(Str){
	var Str=trim(Str);
	var StrToNumber=0;
	if (!IsEmpty(Str)) {
		StrToNumber=parseInt(Str);
	}
	return StrToNumber;
}	
