///////////////////////////////////////////////////////////////////////////////////////////

function openPrepareCasewindow(QuotationRequestID, CompanyID)
{
var sURL;

	sURL='PrepareCase.asp';
	
	window.open(sURL + '?QuotationRequestID=' + escape(QuotationRequestID) 
		+ '&CompanyID=' + escape(CompanyID) + '&TaskWindow=Y','PREPARE','');
}	

///////////////////////////////////////////////////////////////////////////////////////////

///------------------------------------------------------------------------------------------------
function showFeeEarnerList()
{
	if (document.TForm._CaseFirm.value=='PPL')
	{ 
		eval("document.all.MHM.style.display='none';");
		eval("document.all.PPL.style.display='inline';");
	}	
	else
	{ 
		eval("document.all.PPL.style.display='none';");
		eval("document.all.MHM.style.display='inline';");
	}
}
///------------------------------------------------------------------------------------------------

///////////////////////////////////////////////////////////////////////////////////////////
///------------------------------------------------------------------------------------------------
function updatepreparedcase()
{
	document.TForm.action="../../asp/QuoteUser/UpdatePreparedCase.asp";
	document.TForm.submit();
}
///------------------------------------------------------------------------------------------------


///------------------------------------------------------------------------------------------------
function cancelcase()
{
	document.TForm.action="../../asp/QuoteUser/CancelPreparedCase.asp";
	document.TForm.submit();
}

///------------------------------------------------------------------------------------------------
function openPanelLinkedCases(Client1UDPRN, Client2UDPRN, Client1PostCode,Client2PostCode)
{
var sURL;

	sURL='PanelLinkedCaseLookup.asp';
	
	window.open(sURL + '?Client1UDPRN=' + escape(Client1UDPRN) + '&Client1PostCode=' + escape(Client1PostCode) 
		+ '&Client2UDPRN=' + escape(Client2UDPRN) + '&Client2PostCode=' + escape(Client2PostCode) + '&TaskWindow=Y'
		,'TASK','');
}
///------------------------------------------------------------------------------------------------
	
function closeTaskwindow(){
window.close();
}
///------------------------------------------------------------------------------------------------
function PrintPage()
{
	if (window.print) window.print();
}
///------------------------------------------------------------------------------------------------
function resubmitviewmasterquote(iquotationrequestid, quotationrefcode,mode)
{
	document.TForm.action="ViewMasterQuote.asp?QuotationrequestID=" + escape(iquotationrequestid) + "&QuotationRefCode=" + escape(quotationrefcode) ;
	document.TForm.submit();
}
///------------------------------------------------------------------------------------------------
function openInlandRevWindow()
{
	//window.open('http://www.inlandrevenue.gov.uk/so/pcode_search.htm','INLAND',
	//		'left=50,top=50,width=700,scrollbars,height=500;');
	window.open('http://www.hmrc.gov.uk/so/dar/dar-search.htm','INLAND',
			'left=50,top=50,width=700,scrollbars,height=500;');
}
///------------------------------------------------------------------------------------------------
function opentmfwebLandregWindow(LandRegOffice,BuySell)
{
var sURL;

	sURL='../../asp/PostalLookup/LandRegistryLookup.asp';
	
	window.open(sURL + '?Office=' + escape(LandRegOffice) + '&TaskWindow=Y',escape(BuySell) ,'left=50,top=50,width=600,scrollbars,height=400;');
}
///------------------------------------------------------------------------------------------------
function openLandRegistryWindow()
{
	//window.open('http://www.landregistry.gov.uk/regional/','REGISTRY',
	//		'left=50,top=50,width=700,scrollbars,height=500;');

	window.open('http://www1.landregistry.gov.uk/regional/','REGISTRY',
			'left=50,top=50,width=700,scrollbars,height=500;');
}
///------------------------------------------------------------------------------------------------
function openHipsWindow(postcode,buysell)
{
	var sURL;

	sURL='../../asp/QuoteUser/HipsLookup.asp';
	
	window.open(sURL + '?postcode=' + escape(postcode) + '&TaskWindow=Y' + '&BuySell=' + escape(buysell) ,escape(buysell)  ,'left=50,top=50,width=600,scrollbars,height=400;');

}
///------------------------------------------------------------------------------------------------
function preparecheck()
{
var sMsg = '';
var return_value = false;

	sMsg = sMsg + '\n';
	
	if (document.TForm.NoOfAutocaseCreate.value > 19)
		{
			sMsg = 'There are ' + (document.TForm.NoOfAutocaseCreate.value) + ' cases waiting to be processed. \n';
			sMsg = sMsg + 'Please clear the backlog before proceeding.';
			document.TForm.NoOfAutocaseCreate.value = 0;
			alert(sMsg);
			return false;
		}
	else
	{
		if (document.TForm.NoOfAutocaseCreate.value > 18)
			{
				sMsg = 'Warning! \n';
				sMsg = sMsg + 'There are ' + (document.TForm.NoOfAutocaseCreate.value) + ' cases waiting to be processed. \n';
				sMsg = sMsg + 'Please clear the backlog.';
				sMsg = sMsg + ' \n';
				alert(sMsg);
				sMsg = '';
			}
			
		if ((document.TForm.QuotationPaid.value !='Y')&&(document.TForm.FastExchangeForRec.value =='Y')&& (document.TForm.FreeEPC.value =='Y'))
			{
				sMsg = sMsg + 'This case qualifies for a Free EPC if Fast Exchange payment is taken prior to case create. \n';
				alert(sMsg);
				sMsg = '';
			}
		
		if (document.TForm._CaseFirm.value=='')
			{
				sMsg = 'Firm \n';
			}
		if (document.TForm._CallCentreTeam.value=='')
			{
				sMsg = sMsg + 'Call Centre Team \n';
			}
		
		if (document.TForm._CaseHandler.value=='')
			{
				sMsg = sMsg + 'Case Handler \n';
			}

		
	
		if ((document.TForm.BuyingSelling.value=='1')||(document.TForm.BuyingSelling.value=='3')||(document.TForm.BuyingSelling.value=='5'))
		{
			if (((document.TForm._AmendedPurchaseFee.value!='')&&(isNaN(document.TForm._AmendedPurchaseFee.value)==true)))
			{
				if (document.TForm._AmendedPurchaseFee.value.toUpperCase()!='NO FEE')
					{
						sMsg = sMsg + '\n If no purchase fees are to be charged then please enter No Fee ';
					}
			}
		}
		
		if ((document.TForm.BuyingSelling.value=='2')||(document.TForm.BuyingSelling.value=='3'))
		{
			if (((document.TForm._AmendedSaleFee.value!='')&&(isNaN(document.TForm._AmendedSaleFee.value)==true)))
			{
				if (document.TForm._AmendedSaleFee.value.toUpperCase()!='NO FEE')
					{
						sMsg = sMsg + '\n If no sale fees are to be charged then please enter No Fee ';
					}
			}
		}
		
		if (document.TForm.BuyingSelling.value=='4')
		{
			if (((document.TForm._AmendedRemortgageFee.value!='')&&(isNaN(document.TForm._AmendedRemortgageFee.value)==true)))
			{
				if (document.TForm._AmendedRemortgageFee.value.toUpperCase()!='NO FEE')
					{
						sMsg = sMsg + '\n If no remortgage fees are to be charged then please enter No Fee';
					}
			}
		}
		
		var semailreturn ='';    
             
		if (document.TForm._EmailAddress) 
		{

			if (document.TForm._EmailAddress.value!='')
        		{
            			semailreturn = (isvalidemail(document.TForm._EmailAddress.value))
         
            			if (semailreturn !='valid')
             			  {
                    			sMsg = sMsg +  semailreturn + '\n';
               			   }
        		}  
		}

        	
		if (document.TForm._EmailAddress_2) 
		{
        		semailreturn = '';
        		if (document.TForm._EmailAddress_2.value!='')
        		{
            			semailreturn = (isvalidemail(document.TForm._EmailAddress_2.value))
          
            			if (semailreturn !='valid')
               			{
                    			sMsg = sMsg +  semailreturn + '\n';
               			}
        		} 	
		} 
		
		if((sMsg != '') && (sMsg != '\n') && (sMsg != '\n\n'))
		{
			sMsg = 'Please complete the following fields: \n' + sMsg;
			
		}
		
		
		
		if((sMsg != '') && (sMsg != '\n') && (sMsg != '\n\n'))
		{
			alert(sMsg);
			return false;
		} 
		
		
		
		
		document.TForm.action="../../asp/QuoteUser/UpdatePreparedCase.asp";
		document.TForm.submit();					
		return true;
		
				
				
	}
}
///------------------------------------------------------------------------------------------------
function preparecheckpanel()
{
var sMsg = '';
var return_value = false;
		
		document.TForm.action="../../asp/QuoteUser/UpdatePreparedCase.asp";
		document.TForm.submit();					
		return true;
				
	
}
///////////////////////////////////////////////////////////////////////////////////////////



