String.prototype.trim = function()	{ return this.replace(/^\s*|\s*$/g,"");	}

function deleteOnAtmCreditUnionSetting(Id,formName)
{
	if(confirm("Are you sure? you want to delete record having ID = "+Id)){
		formObj=document.getElementById(formName);
		formObj.action="CreditUnionSystemSettings.do?action=delete&creditUnionId="+Id;
		formObj.submit();
	}
}

function editOnAtmCreditUnionSetting(Id,name)
{
	formObj=document.getElementById("AtmCreditUnionSettingDashboard");
	formObj.action="CreditUnionSystemSettings.do?action=edit&creditUnionId="+Id+"&creditUnionName="+name;
	formObj.submit();
}

function insertNewAtmCreditUnionSetting()
{
	formObj=document.getElementById("AtmCreditUnionSettingDashboard");
	if(formObj.newLenderToInsert.value != undefined  && formObj.newLenderToInsert.value.trim()!=""){
		if(validateSpecialCharacters(formObj.newLenderToInsert.value,'Name')){
			formObj.action="CreditUnionSystemSettings.do?action=insert";
			formObj.submit();
		}
	}else
		alert(" You have not entered credit union name");
	
}

function updatingOnEditPage(actionTodo,formName)
{
	formObj=document.getElementById(formName);
	if(formObj.creditUnionName.value != undefined  && formObj.creditUnionName.value.trim()!=""){
		if(validateSpecialCharacters(formObj.creditUnionName.value,'Name')){
			submitAndSendToURL(actionTodo,formName);
		}
	}else
		alert(" You have not entered credit union name");
}

function submitAndSendToURL(actionTodo,formName)
{
	formObj=document.getElementById(formName);
	formObj.action=actionTodo;
	formObj.submit();
}

function validateSpecialCharacters(value, fieldName)
{
	var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?";
	var isValid=true;
	for (var i = 0; i < value.length; i++) {
	  	if (iChars.indexOf(value.charAt(i)) != -1) {
		  	alert ("Your "+fieldName+" field has special characters. \nThese are not allowed.\n Please remove them and try again.");
		  	isValid=false;
		  	break;
	  	}
	  }
	return isValid;
}

var changesIsOnPage=false;

function someChangeIsMade(){
	changesIsOnPage=true;
	//addValidation();
}

function setForAction(actionTodo,formName)
{
	formObj=document.getElementById(formName);
	formObj.action=actionTodo;
}

function setButtonClickValue(formName,action)
{
	formObj=document.getElementById(formName);
	formObj.action=action;
	//addValidation();
//	if(changesIsOnPage){
//		formObj.saveUserFlag.value="true";
//		addValidation();
//		saveUserFlag=false;
//	}
}

function comunicateStatus(messageToCommunicate){
	alert(messageToCommunicate);
}

function onChangeInQuestionPage(){

	formObj=document.getElementById("CreditUnitonSettinCreateQuestions");
	formObj.action="CreditUnionSystemSettings.do?action=fetchQuestions";
	formObj.submit();
	
}

function insetNewQuestion(){

	formObj=document.getElementById("CreditUnitonSettinCreateQuestions");
	if(formObj.newLenderToInsert.value!=undefined && formObj.newLenderToInsert.value.trim()!=""){
		formObj.action="CreditUnionSystemSettings.do?action=insertQuestion";
		formObj.submit();
	}
	else{
		alert("You have not entered Question ")
	}
}

function insetNewDocsForUpload(){

	formObj=document.getElementById("CreditUnitonSettinUploadDocs");
	if(formObj.newLenderToInsert.value!=undefined && formObj.newLenderToInsert.value.trim()!=""){
		formObj.action="CreditUnionSystemSettings.do?action=insertUploadDocs";
		formObj.submit();
	}
	else{
		alert("You have not entered Document Name ");
	}
}

function onChangeInDocsForUploadPage(){

	formObj=document.getElementById("CreditUnitonSettinUploadDocs");
	formObj.action="CreditUnionSystemSettings.do?action=fetchUploadDoc";
	formObj.submit();
	
}

