function confirmprepareaccess(doneby,ondate)
{
    var message = '';
    
    message = 'This quote is being prepared by ' + doneby + ' on ' + ondate + '\n';
    message = message + 'Do you want to continue?';
    var return_value = confirm(message);

    if ( return_value == true )
        {
			return true;
        }
    else
        {
			return false;
        }
}
///////////////////////////////////////////////////////////////////////////////////////////
function confirmcreateaccess(doneby,ondate)
{
    var message = '';
    
    message = 'This quote is in the procees of being created by ' + doneby + ' on ' + ondate + '\n';
    message = message + 'Do you want to continue?';
    var return_value = confirm(message);

    if ( return_value == true )
        {
			return true;
        }
    else
        {
			return false;
        }
}
///////////////////////////////////////////////////////////////////////////////////////////
function EnsureSelectUserName(){
var sMsg = '';

	sMsg = sMsg + '\n';
	if((document.TForm1._CallCentreStaffName.value)=='')
		{
			sMsg = 'Please enter your Call Centre User Name \n';
			alert(sMsg);
			return false;
				}
	else
		{
			return true;
		}	
}		

///////////////////////////////////////////////////////////////////////////////////////////
function CheckSelectCriteria(){
var sMsg = '';

	sMsg = sMsg + '\n';
	if(document.TForm1.DateFrom.value=='' || document.TForm1.DateTo.value=='')
		{
			sMsg = 'Please enter a Date Range \n';
			alert(sMsg);
			return false;
				}
	else { 
		
		return true;}
}

///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
function ResetSearchCriteria(){
var sMsg = '';

	//document.TForm1.LegalType.value = "";
	document.TForm1.DateFrom.value = "";
	document.TForm1.DateTo.value = "";
	//document.TForm1.Status.value = "";
	document.TForm1.SearchPortalID.value = "";
	return true;
}
///////////////////////////////////////////////////////////////////////////////////////////
///------------------------------------------------------------------------------------------------
function openbranchlookup(agentname,staffname)
{
var sURL;
	
	sURL='../../asp/Xit2/BranchLookup.asp';
	
	window.open(sURL + '?branch=' + escape(agentname) + '&staffname=' + escape(staffname) + '&TaskWindow=Y','TASK','');
}
///------------------------------------------------------------------------------------------------
function instruction()
{
var sURL;
	
	if (document.TForm1._Introducercode.value=='')
	{
		alert('Please make sure you have a valid Introducer Code/MHM Branch');
		return false;
	}
	else
	{	
		return true;
	}
}
///------------------------------------------------------------------------------------------------

function checkmatterno()
{
var sURL;
	
	if ((document.TForm2._DeclineReason.value!='')||(document.TForm2._DeclineReasonEnter.value!=''))
	{
		alert('Please clear the decline reason');
		return false;
	}
	
	if (document.TForm2._ConveyancerID.value=='')
	{
		alert('Please enter the matter number');
		return false;
	}
	else
	{	
		return true;
	}
}

///------------------------------------------------------------------------------------------------
function resubmit(id,portalid,legalssold,status,quotationrefcode)
{
	if (document.TForm1._CurrentIntroCode.value != document.TForm1._Introducercode.value)
	{
		document.TForm1.action="InstructionDetail.asp?ID=" + escape(id) + "&Portalid=" + escape(portalid) + "&legalssold=" + escape(legalssold) + "&status=" + escape(status) + "&quotationrefcode=" + escape(quotationrefcode);
		document.TForm1.submit();
	}
	else
	{
		return false;
	}
}

///------------------------------------------------------------------------------------------------
function resubmitack(id,portalid,legalssold,status,quotationrefcode)
{
	document.TForm1.action="InstructionDetail.asp?ID=" + escape(id) + "&Portalid=" + escape(portalid) + "&legalssold=" + escape(legalssold) + "&status=" + escape(status) + "&quotationrefcode=" + escape(quotationrefcode);
	document.TForm1.submit();
	
}
///------------------------------------------------------------------------------------------------
function submitaccept()
{
	if (document.TForm1._ConveyancerID.value=='')
	{
		alert('Please enter the matter number');
		return false;
	}
	
	//-- To trim the form field.
	var str;
	str = document.TForm1._ConveyancerID.value;
	document.TForm1._ConveyancerID.value = str.replace(/^\s+/g, '').replace(/\s+$/g, '');
	//--
	if ((document.TForm1._ConveyancerID.value)!=(document.TForm1._PrevConveyancerID.value))
	{
		alert('The matter number you have entered has not been validated');
		return false;
	}
	
	document.TForm1.action="AcknowledgeAccept.asp";
	document.TForm1.submit();
	
}
///------------------------------------------------------------------------------------------------
function submitchange()
{
	if (document.TForm.ConveyancerID.value=='')
	{
		alert('Please enter the Conveyancer ID/ Matter Number');
		return false;
	}
	
	//-- To trim the form field.
	var str;
	str = document.TForm.ConveyancerID.value;
	document.TForm.ConveyancerID.value = str.replace(/^\s+/g, '').replace(/\s+$/g, '');
	//--
	if ((document.TForm.ConveyancerID.value)!=(document.TForm.PrevConveyancerID.value))
	{
		alert('The matter number you have entered has not been validated');
		return false;
	}
	if ((document.TForm.ConveyancerID.value)==(document.TForm.OrigConveyancerID.value))
	{
		alert('The matter number you have entered is the same as the original matter number.');
		return false;
	}
	var return_value = confirm ('You are about to change the Acknowledged portal \n do you want to proceed? \n' );
		if ( return_value == true )
        {
			document.TForm.action="ChangeAcknowledge.asp";
			document.TForm.submit();
        }
		else
        {
			return false;
        }
	
	
}
///------------------------------------------------------------------------------------------------
function submitdeclinexit2()
{
var sURL;
	
	if (document.TForm1._ConveyancerID.value!='')
	{
		alert('Please clear out the matter number');
		return false;
	}
	
	if ((document.TForm1._DeclineReason.value=='') && (document.TForm1._DeclineReasonEnter.value==''))
	{
		alert('Please enter a reason for declining');
		return false;
	}
	document.TForm1.action="AcknowledgeDecline.asp";
	document.TForm1.submit();
	
}
///------------------------------------------------------------------------------------------------
function abortportal(noduplicates,abortportals)
{
var sURL;
	
	if (noduplicates < 2)
	{ 
		alert ('Portal ' + portalid + ' cannot be aborted. Duplicate ACCEPT acknowledgements do not exist for this portal.');
		return false;
	}
	else
	{
		
		var return_value = confirm ('You will be aborting portal(s) ' + abortportals );
		if ( return_value == true )
        {
			document.TForm1.action="AbortPortal.asp?PortalIDs=" + abortportals;
			document.TForm1.submit();
        }
		else
        {
			return false;
        }
    }
}
        
//-------------------------------------------------------------------------------------------------------------

function openacknowledgementwindow(portalid)
{
var sURL;

	sURL='../../asp/Xit2/PortalStatus.asp';
	
	window.open(sURL + '?PortalID=' + escape(portalid) + '&TaskWindow=Y','Acknowledgement','');
}	
//-------------------------------------------------------------------------------------------------------------

function closewindow()
{
	window.close();
}	

///------------------------------------------------------------------------------------------------
function checkportalstatus()
{

	
	if (document.TForm.PortalID.value=='')
		{
			alert('Please enter a Portal ID');
			return false;
		}
	else
		{	
			return true;
		}
}


