//search beneficiary location scripts

function openSearch(pageURL,popWidth,popHeight)
{
	var centerWidth  = (screen.width/2)-(popWidth/2);
	var centerHeight = (screen.height/2)-(popHeight/2);
		
	var searchPopup = window.open(pageURL,'searchPopup','height='+popHeight+',width='+popWidth+',top='+centerHeight+',left='+centerWidth+',directories=no,location=no,menubar=no,resizable,status=no,toolbar=no,history=no,scrollbars');
	searchPopup.focus();
}

function validateDDSearch(searchPlace,searchCriteria,searchDDForm)
{
 	initialize_error_msgs();
	
 	validate_mandatory_tb_with_message(searchPlace,"Please enter the name of the Place");
 	validate_mandatory_tb_with_message(searchCriteria,"Please select a match criteria");
 	
	return check_display_errors(searchDDForm);
}

function returnDDLocation(ddLocation,formName)
{
	if(formName == "remitRegn")
	{
		top.opener.document.remitRegn.nearestLogisticCity.value = ddLocation;
	}
	if(formName == "viewProfile")
	{
		top.opener.document.viewProfile.nearestLogisticCity.value = ddLocation;
	}
	if(formName == "beneDlyDetailsForm")
	{
		top.opener.document.beneDlyDetailsForm.nearestLogisticCity.value = ddLocation;
	}
	window.close();
}

function returnSBILocation(sbiCode,sbiBranch,formName)
{
	if(formName == "remitRegn")
	{
		top.opener.document.remitRegn.sbiCode.value 	= sbiCode;
		top.opener.document.remitRegn.bankBranch.value  = sbiBranch;
	}
	else if(formName == "viewProfile")
	{
		top.opener.document.viewProfile.sbiCode.value 	 = sbiCode;
		top.opener.document.viewProfile.bankBranch.value = sbiBranch;
	}
	else
	{
		top.opener.document.beneDlyDetailsForm.sbiCode.value 	= sbiCode;
		top.opener.document.beneDlyDetailsForm.bankBranch.value = sbiBranch;
	}
	window.close();
}

function returnDCLocation(dcCity,dcBranch)
{
	top.opener.document.beneDlyDetailsForm.bankCity.value 	= dcCity;
	top.opener.document.beneDlyDetailsForm.bankBranch.value = dcBranch;
	window.close();
}

function returnCashLocation(cashCity,cashBranch,formName)
{
	if(formName == "remitRegn")
	{
		top.opener.document.remitRegn.nearestLogisticCity.value = cashBranch +", "+ cashCity;
	}
	else if(formName == "viewProfile")
	{
		top.opener.document.viewProfile.nearestLogisticCity.value = cashBranch +", "+ cashCity;
	}
	else
	{
		top.opener.document.beneDlyDetailsForm.nearestLogisticCity.value = cashBranch +", "+ cashCity;
	}
	window.close();
}

function returnAgentLocation(agentCity,agentName,agentLocn,formName)
{
	if(formName == "remitRegn")
	{
		top.opener.document.remitRegn.nearestLogisticCity.value = agentName +", "+ agentLocn;
	}
	else if(formName == "viewProfile")
	{
		top.opener.document.viewProfile.nearestLogisticCity.value = agentName +", "+ agentLocn;
	}
	else
	{
		top.opener.document.beneDlyDetailsForm.nearestLogisticCity.value = agentName +", "+ agentLocn;
	}
	window.close();
}

function returnUCCLocation(locationCity,locationAddr,formName)
{
	if(formName == "remitRegn")
	{
		top.opener.document.remitRegn.bankBranch.value = locationAddr;
	}
	else if(formName == "viewProfile")
	{
		top.opener.document.viewProfile.bankBranch.value = locationAddr;
	}
	else
	{
		top.opener.document.beneDlyDetailsForm.bankBranch.value = locationAddr;
	}
	
	window.close();
}