﻿// Leaseholders United AJAX
// Written by Matt Stannard 2007
//var LHU_SERVER_ADDRESS = "www.leaseholdersunited.com";
//var LHU_SERVER_ADDRESS = "127.0.0.1";
var LHU_SERVER_ADDRESS = "http://localhost:56148/2007%2001%20LHU%20New";

// var strURL = "http://www.leaseholdersunited.com/ajaxwrap/lhuwrapper.asp"
var strURL = LHU_SERVER_ADDRESS + "/ajaxwrap/lhuwrapper.asp"
var strURLLoad;
var g_dynamicWindow;



var g_strURLFindMyProperty = LHU_SERVER_ADDRESS + "/ajaxwrap/LHUAjaxFindMyProperty.asp";
var g_strURLFindMyRateableValues = LHU_SERVER_ADDRESS + "/ajaxwrap/LHUAjaxFindMyRVs.asp";
var g_strURLFindMyFloorAreas = LHU_SERVER_ADDRESS + "/ajaxwrap/LHUAjaxFindMyFloorAreas.asp";
var g_strURLFindMyReductions = LHU_SERVER_ADDRESS + "/ajaxwrap/LHUAjaxFindReductions.asp";
var g_strURLFindMy2005Reductions = LHU_SERVER_ADDRESS + "/ajaxwrap/LHUAjaxFind2005Reductions.asp";
var g_strURLFindMy2005Similar = LHU_SERVER_ADDRESS + "/ajaxwrap/LHUAjaxFindSimilar.asp";
var g_strURLFindCompareFloor = LHU_SERVER_ADDRESS + "/ajaxwrap/LHUAjaxFindCompareFloorArea.asp";
var g_strURLFindMyFloorArea2005 = LHU_SERVER_ADDRESS + "/ajaxwrap/LHUFindFloorAreaRecent.asp";

var g_intType;
var g_hWndAjaxResult;

var g_XMLHttpRequest;
var g_strWindowName;
var g_strCallbackFunctionParam;
var g_strWindowTitle;

var intFunction;

intFunction = 0;
g_intType = 0;
g_strWindowName = "";
g_strCallbackFunctionParam = "";
g_strWindowTitle = "";

// New check appeals
var g_hWndVOA1;
    var g_strLocalAuthority;
    
    function OpenVOA2(LocalAuthority)
    {
        g_strLocalAuthority = LocalAuthority;
        g_hWndVOA1 = window.open("http://ratinglists.voa.gov.uk/irl2k5/mainController?action=InitialiseApp&listYear=2005&lang=E","wVOA","height=1,width=1,location=no,menubar=no,scrollbars=no,status=no");
        window.setTimeout("CloseVOA2()",5000);
    }
    
    function CloseVOA2()
    {
      g_hWndVOA1.close();
      LoadReductions();
    }
    
    function LoadReductions()
    {
        var strURL;
        
        strURL = "../../VOA/AppealsRedirectVOA.aspx?LA=" + g_strLocalAuthority;
        
        g_hWndVOA1 = window.open(strURL,"wStatus","height=500,width=900,location=no,scrollbars=yes,menubar=no,toolbar=no,status=no,resizable=yes");
    
    }
// End check appeals

function CheckRV()
{
    var numRV;
    var numDiscount;
    var numTotal;
    
       if (document.forms[0].RV2005.value != "")
       {
           // Convert to a number
           document.getElementById("txtHint").innerHTML = "";
           
            numRV = document.forms[0].RV2005.value * 1;
           
           if (numRV <= 10000)
           {
                numDiscount = ((10000 - numRV) / 5000) * 0.5;
                numTotal = (numRV * 0.44) * numDiscount;
                
                strSpan = "We have calculated you may be eligable to a £" + numTotal + " reduction in Full Liability.";
	        }
           else
           {
                strSpan = "Sorry, it does not appear you are entitled to Small Business Rate Relief";
            }
           
	        alert(strSpan);
        }
       else
       {
        alert("You must enter your 2005 Rateable Value");
       }
}

function GetHttpRequest()
{
	var xmlhttp;

	try
	{
		xmlhttp = new XMLHttpRequest();
	}
	catch (e)
	{
		try 
		{
	  		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				alert("Your web browser does not support AJAX");
			}
		}
	}

	return(xmlhttp);
}

function StartAjax()
{	
	// document.forms[0].btnReduction.disabled = true;
	document.forms[0].txtName.value = "Starting...";
	
	g_XMLHttpRequest = GetHttpRequest();
	//strURLLoad = strURL;

	if (g_XMLHttpRequest)
	{
		document.forms[0].txtName.value = "AJAX Ready...";
		// document.forms[0].btnReduction.disabled = false;	
	}
}

function DoActionToButtons(frm,ActionType)
{
    var iFormElement;
    var eElement;
    
    for (iFormElement = 0; iFormElement < frm.elements.length; iFormElement++)
    {
              eElement = frm.elements[iFormElement];
              
              if (eElement.type == "button")
              {
                if (ActionType)
                {
                    eElement.disabled = true;
                }
                else
                {
                    eElement.disabled = false;
                }
              }  
    }
}
function DisableButtons(frm)
{
    g_dynamicWindow = dhtmlmodal.open("Searching","iframe","http://www.leaseholdersunited.com/search.html","Please wait...","width:500px,height:500px,resize=0,scrolling=0,center=1","recal");
    DoActionToButtons(frm,true);
}

function EnableButtons(frm)
{
    g_dynamicWindow.hide();
    DoActionToButtons(frm,false);
}

function CallbackHTTP()
{
	document.forms[0].txtName.value = "Callback occurred (" + g_XMLHttpRequest.readyState + ")...";

	if (g_XMLHttpRequest.readyState == 4 && g_XMLHttpRequest.status == 200)
	{
		if (intFunction == 1)
		{
			document.forms[0].txtName.value = "Function was 1...";
			document.forms[0].txtRet.value = "'" + intFunction + "'" + g_XMLHttpRequest.responseText;
			
			var strHTML;
			var strTable;

			var intTable;
			var intEndTable;

			strHTML = g_XMLHttpRequest.responseText;
		
			
				strTable = strHTML;
			    
                if (g_intType == 1 || g_intType == 2)
                {
                    var w;
                
                    //w = window.open("","","height=500,width=700,location=no,scrollbars=yes,menubar=no,status=no");
                    //w.document.write(strTable);
                    //w.focus();
                    
                    if (g_intType == 1) 
                    {
                        //document.getElementById("txtHint").innerHTML = "Lookup complete - your results have been shown in a new window";
                    }
                    
                    g_intType = 0;
                }
                else
                {
				    // document.getElementById("txtHint").innerHTML = strTable;
				}
			    
			    if (g_strWindowTitle == "")
			    {
			        g_strWindowTitle = "Leaseholders United";
			    }
			    
			    strTable = "<html><title>" + g_strWindowTitle + "</title><head><style type='text/css'>body, td, p, a {font-family:Verdana, font-size:8pt;}.voatext{font-size:8pt; font-family:Verdana; border-top:0px; border-right:0px; border-left:0px; border-bottom:1px dashed #C0C0C0;}table{border:1px solid #C0C0C0;}</style></head><body>" + strTable + "</body></html>";
			    
			    if (g_strWindowName == "")
			    {
			        g_strWindowName = "wResult";
			    }
			    
			    g_hWndAjaxResult = window.open(g_strWindowName,"","height=500,width=750,location=no,scrollbars=yes,menubar=no,status=no");
			    g_hWndAjaxResult.document.write(strTable);
                g_hWndAjaxResult.focus();
                g_hWndAjaxResult.moveTo(290,10);
                
				document.forms[0].btnFindMyProperty.value = "Find My Property";
				document.forms[0].btnFindMyRateableValues.value = "Find My Rateable Values";
				document.forms[0].btnFindMyFloorAreas.value = "Find My Floor Areas";
				document.forms[0].btnFindMyReductions.value = "Find Reductions";
			    document.forms[0].btnSearchForNeighbour.value = "Search for neighbours";
			    document.forms[0].btnNeighbour.value = "Go!";
			    EnableButtons(document.forms[0]);	
			
			    if (g_strCallbackFunctionParam != "")
			    {
			        eval(g_strCallbackFunctionParam);
			        g_strCallbackFunctionParam = "";
			    }

		}
		else
		{
			document.forms[0].txtName.value = "Unknown function";
		}
	}
}

function FindReductionsMyPostcode()
{
    var strPC1;
	var strPC2;
	var strStreet;
	var strProp;
	
	var strURLParams;

	strPC1 = document.forms[0].pstcode1.value;
	strPC2 = document.forms[0].pstcode2.value;
	strStreet = document.forms[0].txtStreet.value;
	strProp = document.forms[0].txtProperty.value;
	
	document.getElementById("txtHint").innerHTML = "Please wait while we contact the VOA website ...";
	
	if (strPC1 == "")
	{
		alert("The first part of your postcode is mandatory, please ensure it is entered");
		return(false);
	}

	strURLParams = "?Postcode=" + strPC1;

	strURLLoad = g_strURLFindMy2005Reductions + strURLParams;
	// alert(strURLLoad);
	intFunction = 1;
	
	document.forms[0].txtName.value = "Loading second page...";
	document.forms[0].txtURL.value  = strURLLoad;
	// document.forms[0].btnFindMyReductions.value = "Please wait ...";
	
	DisableButtons(document.forms[0]);
    
	g_XMLHttpRequest = GetHttpRequest();
	g_XMLHttpRequest.onreadystatechange = CallbackHTTP;
	g_XMLHttpRequest.open("GET",strURLLoad,true);
	document.forms[0].txtName.value = "Sending request...";
	g_XMLHttpRequest.send(null);
	document.forms[0].txtName.value = "Sent request...";
}

function FindReductionsMyPostcodeStreet()
{
    var strPC1;
	var strPC2;
	var strStreet;
	var strProp;
	
	var strURLParams;

	strPC1 = document.forms[0].pstcode1.value;
	strPC2 = document.forms[0].pstcode2.value;
	strStreet = document.forms[0].txtStreet.value;
	strProp = document.forms[0].txtProperty.value;
	
	document.getElementById("txtHint").innerHTML = "Please wait while we contact the VOA website ...";
	
	if (strPC1 == "")
	{
		alert("The first part of your postcode is mandatory, please ensure it is entered");
		return(false);
	}

	strURLParams = "?Postcode=" + strPC1 + "&Street=" + strStreet;

	strURLLoad = g_strURLFindMy2005Reductions + strURLParams;
	// alert(strURLLoad);
	intFunction = 1;
	
	document.forms[0].txtName.value = "Loading second page...";
	document.forms[0].txtURL.value  = strURLLoad;
	// document.forms[0].btnFindMyReductions.value = "Please wait ...";
	
	DisableButtons(document.forms[0]);
    
	g_XMLHttpRequest = GetHttpRequest();
	g_XMLHttpRequest.onreadystatechange = CallbackHTTP;
	g_XMLHttpRequest.open("GET",strURLLoad,true);
	document.forms[0].txtName.value = "Sending request...";
	g_XMLHttpRequest.send(null);
	document.forms[0].txtName.value = "Sent request...";
}

function FindReductionsSimilarToMine()
{
    var strRV;
    var strURLParams;
    
    strRV = document.forms[0].BAPropertyReference.value;
	
	document.getElementById("txtHint").innerHTML = "Please wait while we contact the VOA website ...";
	
	if (strRV == "")
	{
		alert("Your BA Reference number is mandatory, please ensure it is entered");
		return(false);
	}
	
	document.forms[0].txtName.value = "Loading second page...";
	document.forms[0].txtURL.value  = strURLLoad;
	// document.forms[0].btnFindMyFloorAreas.value = "Please wait ...";
	DisableButtons(document.forms[0]);
	
    strURLParams = "?BARef=" + strRV;

	strURLLoad = g_strURLFindMy2005Similar + strURLParams;
	
	// alert(strURLLoad);
	intFunction = 1;
	
	g_XMLHttpRequest = GetHttpRequest();
	g_XMLHttpRequest.onreadystatechange = CallbackHTTP;
	g_XMLHttpRequest.open("GET",strURLLoad,true);
	document.forms[0].txtName.value = "Sending request...";
	g_XMLHttpRequest.send(null);
	document.forms[0].txtName.value = "Sent request...";
}

function FindMyReductions()
{
    var strPC1;
	var strPC2;
	var strStreet;
	var strProp;
	
	var strURLParams;

	strPC1 = document.forms[0].pstcode1.value;
	strPC2 = document.forms[0].pstcode2.value;
	strStreet = document.forms[0].txtStreet.value;
	strProp = document.forms[0].txtProperty.value;
	
	document.getElementById("txtHint").innerHTML = "Please wait while we contact the VOA website ...";
	
	if (strPC1 == "")
	{
		alert("The first part of your postcode is mandatory, please ensure it is entered");
		return(false);
	}

	strURLParams = "?Postcode=" + strPC1;

	strURLLoad = g_strURLFindMyReductions + strURLParams;
	// alert(strURLLoad);
	intFunction = 1;
	
	document.forms[0].txtName.value = "Loading second page...";
	document.forms[0].txtURL.value  = strURLLoad;
	document.forms[0].btnFindMyReductions.value = "Please wait ...";
	
	DisableButtons(document.forms[0]);
    
	g_XMLHttpRequest = GetHttpRequest();
	g_XMLHttpRequest.onreadystatechange = CallbackHTTP;
	g_XMLHttpRequest.open("GET",strURLLoad,true);
	document.forms[0].txtName.value = "Sending request...";
	g_XMLHttpRequest.send(null);
	document.forms[0].txtName.value = "Sent request...";
}

// ********************** NEW SCRIPT ********************************* //

var g_hWndVOA;
var g_strPC1;
var g_strPC2;
var g_timTimeout;
var g_strContentLocation;

var g_bShowWindow;
var g_UserID;
var g_PropertyID;
var g_BARef;


g_strContentLocation = "";

function FindPropertyByPostcode(strPostcode)
{
    var strPC1;
    var strPC2;
    var arrPC;
    
        
    if (strPostcode == "")
    {
        alert ("Please enter your postcode");
        return(false);
    }
    
    if (strPostcode.indexOf(" ") == -1)
    {
        alert ("Please ensure your postcode is in the form XXX YYYY i.e. SG15 ADP");
        return(false);
    }
    
    arrPC = strPostcode.split(" ");
    
    strPC1 = arrPC[0];
    strPC2 = arrPC[1];
    g_strPC1 = strPC1;
    g_strPC2 = strPC2;

    // Build the complete VOA search URL
    //g_hWndVOA = window.open("http://ratinglists.voa.gov.uk/irl2k5/mainController?action=InitialiseApp&listYear=2005&lang=E");
    if (window.opener)
    {
        window.opener.g_Data = window.open("http://ratinglists.voa.gov.uk/irl2k5/mainController?action=InitialiseApp&listYear=2005&lang=E","wData","location=no,scrollbars=yes,toolbar=no,menubar=no,width=750,height=500");
   
        if (!window.opener.g_Data)
        {
            alert("An error has occurred:\n\nThe content window could not be opened, please turn off any popup blocking software");
        }
        else
        {
            g_timTimeout = window.setTimeout("VOALoadMyProperty()",5000); 
        }
    }
    else
    {
        g_Data = window.open("http://ratinglists.voa.gov.uk/irl2k5/mainController?action=InitialiseApp&listYear=2005&lang=E","wData","location=no,scrollbars=yes,toolbar=no,menubar=no,width=750,height=500");
        g_timTimeout = window.setTimeout("VOALoadMyProperty()",5000); 
    }
    
}

function VOALoadMyProperty()
{
    //g_hWndVOA.location = "http://ratinglists.voa.gov.uk/irl2k5/mainController?action=DetailedSearchRating&nextAction=refine&pstcode1=" + g_strPC1 + "&pstcode2=" + g_strPC2 + "&street=&rv_lower=0&userref=&town=&baref=&pdesc=&nonstddesc=&composite=&sett_ind=&scatcode=&rv_lower=&rv_upper=&listYear=2005&lang=E";
    //g_hWndVOA.moveTo(290,10);
    if (window.opener)
    {
        window.opener.g_Data.location = "http://ratinglists.voa.gov.uk/irl2k5/mainController?action=DetailedSearchRating&nextAction=refine&pstcode1=" + g_strPC1 + "&pstcode2=" + g_strPC2 + "&street=&rv_lower=0&userref=&town=&baref=&pdesc=&nonstddesc=&composite=&sett_ind=&scatcode=&rv_lower=&rv_upper=&listYear=2005&lang=E";
    }
    else
    {
        g_Data.location = "http://ratinglists.voa.gov.uk/irl2k5/mainController?action=DetailedSearchRating&nextAction=refine&pstcode1=" + g_strPC1 + "&pstcode2=" + g_strPC2 + "&street=&rv_lower=0&userref=&town=&baref=&pdesc=&nonstddesc=&composite=&sett_ind=&scatcode=&rv_lower=&rv_upper=&listYear=2005&lang=E";
    }
}

function FindMyPropertyStreetPostcode(strStreet,strPostcode)
{
    g_strPC1 = strStreet;
    g_strPC2 = strPostcode;
    
    // Build the complete VOA search URL
    g_hWndVOA = window.open("http://ratinglists.voa.gov.uk/irl2k5/mainController?action=InitialiseApp&listYear=2005&lang=E");
    g_timTimeout = window.setTimeout("VOALoadMyPropertyStreetPostcode()",5000); 
}

function VOALoadMyPropertyStreetPostcode()
{
    g_hWndVOA.location = "http://ratinglists.voa.gov.uk/irl2k5/mainController?action=DetailedSearchRating&nextAction=refine&pstcode1=" + g_strPC1 + "&pstcode2=&street=" + g_strPC2 + "&rv_lower=0&userref=&town=&baref=&pdesc=&nonstddesc=&composite=&sett_ind=&scatcode=&rv_lower=&rv_upper=&listYear=2005&lang=E";
    //g_hWndVOA.moveTo(290,10);
}

function FindNeighboursDetailedAssessment()
{
    strRef = "";
    
    strRef = document.forms[0].BAPropertyReference.value;
    
    if (strRef != "")
    {
        FindMyDetailedAssessment(strRef)
    }
    else
    {
        alert ("Sorry:\n\nPlease ensure you have entered a VOA Billing Assessment Number");
    }
}

function GetReductionsMyScheme(BARef)
{
    var strURL;
    var lyrUpdate;
    
    strURL = LHU_SERVER_ADDRESS + "/ajaxwrap/LHUAjaxFindSimilar.asp?BARef=" + BARef;
    wParent = parent.window.opener;

    if (wParent.g_Compare1)
    {
	    wParent.g_Compare1.close();
        wParent.g_Compare1 = window.open(strURL,"wStatus","height=500,width=900,location=no,scrollbars=yes,menubar=no,toolbar=no,status=no");
    }
    else
    {
        wParent.g_Compare1 = window.open(strURL,"wStatus","height=500,width=900,location=no,scrollbars=yes,menubar=no,toolbar=no,status=no");
    }
    
 
    lyrUpdate = document.getElementById("lyrVOAStatus");
    
    if (lyrUpdate)
    {    
        lyrUpdate.innerHTML = "... please select an action ...";
    }

}

function GetReductionsInMyPostcode(PostCode)
{
    var strURL;
    var lyrUpdate;
    
    strURL = LHU_SERVER_ADDRESS + "/ajaxwrap/LHUAjaxFind2005Reductions.asp?Postcode=" + PostCode;
    wParent = parent.window.opener;

    if (wParent.g_Compare1)
    {
	    wParent.g_Compare1.close();
        wParent.g_Compare1 = window.open(strURL,"wStatus","height=500,width=900,location=no,scrollbars=yes,menubar=no,toolbar=no,status=no");
    }
    else
    {
        wParent.g_Compare1 = window.open(strURL,"wStatus","height=500,width=900,location=no,scrollbars=yes,menubar=no,toolbar=no,status=no");
    }
    
 
    lyrUpdate = document.getElementById("lyrVOAStatus");
    
    if (lyrUpdate)
    {    
        lyrUpdate.innerHTML = "... please select an action ...";
    }

}

var g_hWndVOA1;
var g_strBA;

function OpenVOA()
{
    g_hWndVOA1 = window.open("http://ratinglists.voa.gov.uk/irl2k5/mainController?action=InitialiseApp&listYear=2005&lang=E","wVOA","height=1,width=1,location=no,menubar=no,scrollbars=no,status=no");
    window.setTimeout("CloseVOA()",5000);
}

function CloseVOA()
{
    g_hWndVOA1.close();
    FindMyDetailedAssessmentX();
}

function FindMyDetailedAssessment(BARef)
{
    g_strBA = BARef;
    OpenVOA();
}

function FindMyDetailedAssessmentX()
{
    var strURL;
    var lyrUpdate;
    var BARef;
    
    BARef = g_strBA;
    // parent.window.opener.g_Assessment1;
    
    // strURL = "http://" + LHU_SERVER_ADDRESS + "/ajaxwrap/LHUFrameLoader.asp?CF=parent.window.opener.VOADetailedAssessment('" + BARef + "')&SF=http://ratinglists.voa.gov.uk/irl2k5/mainController?action=InitialiseApp!listYear=2005!lang=E";
    // strURL = "http://127.0.0.1/ajaxwrap/LHUFrameLoader.asp?CF=parent.window.opener.VOADetailedAssessment('" + BARef + "')&SF=http://ratinglists.voa.gov.uk/irl2k5/mainController?action=InitialiseApp!listYear=2005!lang=E";
    strURL = LHU_SERVER_ADDRESS + "/VOA/RedirectVOA.aspx?CF=parent.window.opener.VOADetailedAssessment('" + BARef + "')&SF=http://ratinglists.voa.gov.uk/irl2k5/mainController?action=InitialiseApp!listYear=2005!lang=E";
    g_strPC1 = BARef;

    window.open(strURL,"wStatus","height=500,width=900,location=no,scrollbars=yes,menubar=no,toolbar=no,status=no,resizable=yes");
    
    //if (parent.window.opener.g_Assessment1)
    //{
    //    parent.window.opener.g_Assessment1.close();
    //    parent.window.opener.g_Assessment1 = window.open(strURL,"wStatus","height=500,width=900,location=no,scrollbars=yes,menubar=no,toolbar=no,status=no,resizable=yes");
    //}
    //else
    //{
    //    parent.window.opener.g_Assessment1 = window.open(strURL,"wStatus","height=500,width=900,location=no,scrollbars=yes,menubar=no,toolbar=no,status=no,resizable=yes");
    //}
    
    //lyrUpdate = document.getElementById("lyrVOAStatus");
    
    //if (lyrUpdate)
    //{    
    //    lyrUpdate.innerHTML = "... contacting voa website ...";
    //}

}

function VOADetailedAssessment(pRef)
{
    var lyrUpdate;
    
    lyrUpdate = document.getElementById("lyrVOAStatus");
    
    if (lyrUpdate)
    {
        lyrUpdate.innerHTML = "... navigating voa website ...";
    }
    
 
    if (parent.g_Assessment1)
    {
        g_AssWindow = parent.g_Assessment1;
    }
    else
    {
       g_AssWindow = parent.window.opener.g_Assessment1;
    }
   
    wParent = parent.window.opener;
       g_strPC1 = pRef;
    
    //wParent.g_Data.document.location.href = "http://" + LHU_SERVER_ADDRESS + "/ajaxwrap/LHUAjaxFindMyFloorAreas.asp?BARef=" + g_strPC1;
    g_AssWindow.location.href =  LHU_SERVER_ADDRESS + "/ajaxwrap/LHUAjaxFindMyFloorAreas.asp?BARef=" + g_strPC1;
    // wParent.g_Data.document.location.href = "http://www.leaseholdersunited.com/ajaxwrap/LHUAjaxFindMyFloorAreas.asp?BARef=" + g_strPC1;
    g_timTimeout = window.setTimeout("VOADetailedAssessmentPrint()",5000); 
    // g_hWndVOA.moveTo(290,10);

}

function VOADetailedAssessmentPrint()
{
    var lyrUpdate;
    var strURL;
    
    lyrUpdate = document.getElementById("lyrVOAStatus");
   
    wParent = parent.window.opener;
    
    window.open("http://ratinglists.voa.gov.uk/irl2k5/print_friendly_summary_valuation.jsp","wStatus","height=500,width=900,location=no,scrollbars=yes,menubar=no,toolbar=no,status=no");
	
    if (lyrUpdate)
    {
        lyrUpdate.innerHTML =  "... please select an action ...";
    }
    
    if (g_wndExp)
    {
        g_wndExp.focus();
    }
    
     
}

var g_wndExp;


function ViewExp()
{
    // g_wndExp = window.open("../ViewExplanation.aspx","wExp","height=500,width=700,location=no,scrollbars=yes,menubar=no,status=no,resizable=yes");
}

function FindMyScheme(BARef)
{
    var strURL;
    var lyrUpdate;
    
    strURL = LHU_SERVER_ADDRESS + "/ajaxwrap/LHUFrameLoader.asp?CF=parent.window.opener.VOAFindMyScheme&SF=http://ratinglists.voa.gov.uk/irl2k5/mainController?action=InitialiseApp!listYear=2005!lang=E";
  
     g_strPC1 = BARef;
    
    
    wParent = parent.window.opener;

    if (wParent.g_Scheme)
    {
	    wParent.g_Scheme.close();
        wParent.g_Scheme = window.open(strURL,"wStatus","height=500,width=900,location=no,scrollbars=yes,menubar=no,toolbar=no,status=no");
    }
    else
    {
        wParent.g_Scheme = window.open(strURL,"wStatus","height=500,width=900,location=no,scrollbars=yes,menubar=no,toolbar=no,status=no");    
    }
    
 
    lyrUpdate = document.getElementById("lyrVOAStatus");
    
    if (lyrUpdate)
    {    
        lyrUpdate.innerHTML = "... contacting voa website ...";
    }

}

function VOAFindMyScheme()
{
    var lyrUpdate;
    
    lyrUpdate = document.getElementById("lyrVOAStatus");
    
    if (lyrUpdate)
    {
        lyrUpdate.innerHTML = "... navigating voa website ...";
    }
    
     if (parent.g_Scheme)
    {
        g_AssWindow = parent.g_Scheme;
    }
    else
    {
       g_AssWindow = parent.window.opener.g_Scheme;
    }
    
    // wParent = parent.window.opener;
     
    g_AssWindow.document.location.href = LHU_SERVER_ADDRESS + "/ajaxwrap/LHUAjaxFindScheme.asp?BARef=" + g_strPC1;
    
    g_timTimeout = window.setTimeout("VOAFindMySchemePrint()",5000); 

}

function VOAFindMySchemePrint()
{
    var lyrUpdate;
    var strURL;
    
    lyrUpdate = document.getElementById("lyrVOAStatus");
   
    // wParent = parent.window.opener;
    
    window.open("http://ratinglists.voa.gov.uk/irl2k5/print_val_scheme.jsp","wStatus","height=500,width=900,location=no,scrollbars=yes,menubar=no,toolbar=no,status=no");
	
    if (lyrUpdate)
    {
        lyrUpdate.innerHTML =  "... please select an action ...";
    }
    
}

function ShowHelp()
{
    var strURL;
    
    strURL = "/members/BATools/BAContent.aspx";
    wParent = parent.window.opener;

    if (wParent.g_Data)
    {
	    wParent.g_Data.close();
        wParent.g_Data = window.open(strURL,"wStatus","height=500,width=900,location=no,scrollbars=yes,menubar=no,toolbar=no,status=no");
    }
    else
    {
        wParent.g_Data = window.open(strURL,"wStatus","height=500,width=900,location=no,scrollbars=yes,menubar=no,toolbar=no,status=no");    
    }
}

// ********************** END NEW SCRIPT ********************************* //

// Calls FindMyProperty AJAX
function FindProperty()
{
    var strPC1;
	var strPC2;
	var strStreet;
	var strProp;
	
	var strURLParams;

	strPC1 = document.forms[0].pstcode1.value;
	strPC2 = document.forms[0].pstcode2.value;
	strStreet = document.forms[0].txtStreet.value;
	strProp = document.forms[0].txtProperty.value;
	
	document.getElementById("txtHint").innerHTML = "Please wait while we contact the VOA website ...";
	
	if (strPC1 == "")
	{
		alert("The first part of your postcode is mandatory, please ensure it is entered");
		return(false);
	}

	strURLParams = "?Postcode=" + strPC1 + "&Street=" + strStreet + "&PropertyNumber=" + strProp;

    // Was using the wrong parameters!!!
	//strURLLoad = strURL + strURLParams;
	strURLLoad = g_strURLFindMyProperty + strURLParams;
	// alert(strURLLoad);
	intFunction = 1;
	
	g_XMLHttpRequest = GetHttpRequest();
	g_XMLHttpRequest.onreadystatechange = CallbackHTTP;
	g_XMLHttpRequest.open("GET",strURLLoad,true);
	document.forms[0].txtName.value = "Sending request...";
	g_XMLHttpRequest.send(null);
	document.forms[0].txtName.value = "Sent request...";
}

// Handler for Find Neighbours Areas
function FindNeighboursAreas()
{
    document.forms[0].txtName.value = "Loading second page...";
	document.forms[0].txtURL.value  = strURLLoad;
	document.forms[0].btnSearchForNeighbour.value = "Please wait ...";
	DisableButtons(document.forms[0]);
    FindProperty();
}



// Handler for Find My Property Button
function FindMyProperty()
{
	document.forms[0].txtName.value = "Loading second page...";
	document.forms[0].txtURL.value  = strURLLoad;
	document.forms[0].btnFindMyProperty.value = "Please wait ...";
	DisableButtons(document.forms[0]);
    FindProperty();
}


function FindFloorAltArea(strRV)
{
    var strPC1;
	var strPC2;
	var strStreet;
	var strProp;
	var strRV;
	
	var strURLParams;

   
    strURLParams = "?BARef=" + strRV;
    
    //;
    g_strCallbackFunctionParam = "FindNeighboursAreasPopupNew();"
    
	strURLLoad = g_strURLFindCompareFloor + strURLParams;
	
	// alert(strURLLoad);
	intFunction = 1;
	g_strWindowName = "wResultAlt";
	g_strWindowTitle = "Previous Valuation - " + strRV;
	
	g_XMLHttpRequest = GetHttpRequest();
	g_XMLHttpRequest.onreadystatechange = CallbackHTTP;
	g_XMLHttpRequest.open("GET",strURLLoad,true);
	document.forms[0].txtName.value = "Sending request...";
	g_XMLHttpRequest.send(null);
	document.forms[0].txtName.value = "Sent request...";
}

// Calls AJAX function
function FindFloorArea(strRV,intType)
{
    var strPC1;
	var strPC2;
	var strStreet;
	var strProp;
	var strRV;
	
	var strURLParams;

    
    strURLParams = "?BARef=" + strRV;
    
    if (intType == 1)
    {
        g_strCallbackFunctionParam = "FindMyFloorAreas();"
        g_strWindowTitle = "Neighbours Area - " + strRV;
    }
    else
    {
        g_strWindowTitle = "Floor Area - " + strRV;
    }
    
	strURLLoad = g_strURLFindMyFloorAreas + strURLParams;
	
	
	// alert(strURLLoad);
	intFunction = 1;
	
	g_XMLHttpRequest = GetHttpRequest();
	g_XMLHttpRequest.onreadystatechange = CallbackHTTP;
	g_XMLHttpRequest.open("GET",strURLLoad,true);
	document.forms[0].txtName.value = "Sending request...";
	g_XMLHttpRequest.send(null);
	document.forms[0].txtName.value = "Sent request...";
}

function FindFloorAreaNewList(strRV)
{
    var strPC1;
	var strPC2;
	var strStreet;
	var strProp;
	var strRV;
	
	var strURLParams;

    
    strURLParams = "?BARef=" + strRV;
	strURLLoad = g_strURLFindMyFloorArea2005 + strURLParams;
	g_strWindowTitle = "Floor Area - " + strRV;
	
	// alert(strURLLoad);
	intFunction = 1;
	
	g_XMLHttpRequest = GetHttpRequest();
	g_XMLHttpRequest.onreadystatechange = CallbackHTTP;
	g_XMLHttpRequest.open("GET",strURLLoad,true);
	document.forms[0].txtName.value = "Sending request...";
	g_XMLHttpRequest.send(null);
	document.forms[0].txtName.value = "Sent request...";
}

function FindNeighboursAreasPopupNew()
{
    strRV = document.forms[0].keyNeighbourVOARef.value;
	
	// document.getElementById("txtHint").innerHTML = "Please wait while we contact the VOA website ...";
	g_intType = 2;
	
	if (strRV == "")
	{
		alert("Your neighbours BA Reference number is required, please ensure it is entered");
		return(false);
	}

	
	document.forms[0].txtName.value = "Loading second page...";
	document.forms[0].txtURL.value  = strURLLoad;
	document.forms[0].btnNeighbour.value = "Please wait ...";
	DisableButtons(document.forms[0]);
	
	FindFloorAreaNewList(strRV);
}

// Called by button
function FindNeighboursAreasPopup(intType)
{
    strRV = document.forms[0].keyNeighbourVOARef.value;
	
	// document.getElementById("txtHint").innerHTML = "Please wait while we contact the VOA website ...";
	g_intType = 2;
	
	if (strRV == "")
	{
		alert("Your neighbours BA Ref?rence number is required, please ensure it is entered");
		return(false);
	}

	
	document.forms[0].txtName.value = "Loading second page...";
	document.forms[0].txtURL.value  = strURLLoad;
	document.forms[0].btnNeighbour.value = "Please wait ...";
	DisableButtons(document.forms[0]);
	
	FindFloorArea(strRV,intType);
}

function FindCompareProperty()
{
    strRV = document.forms[0].keyNeighbourVOARef.value;
	
	// document.getElementById("txtHint").innerHTML = "Please wait while we contact the VOA website ...";
	g_intType = 2;
	
	if (strRV == "")
	{
		alert("Your neighbours BA Reference number is required, please ensure it is entered");
		return(false);
	}

	
	document.forms[0].txtName.value = "Loading second page...";
	document.forms[0].txtURL.value  = strURLLoad;
	document.forms[0].btnNeighbour.value = "Please wait ...";
	DisableButtons(document.forms[0]);
	
	FindFloorAltArea(strRV);
	
	
}

// Called by button
function FindMyFloorAreas()
{
	
    strRV = document.forms[0].BAPropertyReference.value;
    g_strWindowTitle = "My Floor Area - " + strRV;
	g_intType = 1;
	
	document.getElementById("txtHint").innerHTML = "Please wait while we contact the VOA website ...";
	
	if (strRV == "")
	{
		alert("Your BA Reference number is mandatory, please ensure it is entered");
		return(false);
	}
	
	document.forms[0].txtName.value = "Loading second page...";
	document.forms[0].txtURL.value  = strURLLoad;
	document.forms[0].btnFindMyFloorAreas.value = "Please wait ...";
	DisableButtons(document.forms[0]);
	
	FindFloorArea(strRV);
}

function FindMyRateableValues()
{
	var strPC1;
	var strPC2;
	var strStreet;
	var strProp;
	var strRV;
	
	var strURLParams;

    strRV = document.forms[0].BAPropertyReference.value;
	
	document.getElementById("txtHint").innerHTML = "Please wait while we contact the VOA website ...";
	
	if (strRV == "")
	{
		alert("Your BA Reference number is mandatory, please ensure it is entered");
		return(false);
	}

	strURLParams = "?BARef=" + strRV;

	strURLLoad = g_strURLFindMyRateableValues + strURLParams;
	// alert(strURLLoad);
	intFunction = 1;
	
	document.forms[0].txtName.value = "Loading second page...";
	document.forms[0].txtURL.value  = strURLLoad;
	document.forms[0].btnFindMyRateableValues.value = "Please wait ...";
	DisableButtons(document.forms[0]);
    
    
    
	g_XMLHttpRequest = GetHttpRequest();
	g_XMLHttpRequest.onreadystatechange = CallbackHTTP;
	g_XMLHttpRequest.open("GET",strURLLoad,true);
	document.forms[0].txtName.value = "Sending request...";
	g_XMLHttpRequest.send(null);
	document.forms[0].txtName.value = "Sent request...";

}

function DoSummaryHTML()
{
	var strPC1;
	var strPC2;
	var strStreet;
	var strProp;
	
	var strURLParams;

	strPC1 = document.forms[0].pstcode1.value;
	strPC2 = document.forms[0].pstcode2.value;
	strStreet = document.forms[0].txtStreet.value;
	strProp = document.forms[0].txtProperty.value;
	
	if (strPC1 == "")
	{
		alert("The first part of your postcode is mandatory, please ensure it is entered");
		return(false);
	}

	strURLParams = "?Postcode=" + strPC1 + "&Street=" + strStreet;

	strURLLoad = g_strURLFindMyProperty + strURLParams;
	// alert(strURLLoad);
	intFunction = 1;
	
	document.forms[0].txtName.value = "Loading second page...";
	document.forms[0].txtURL.value  = strURLLoad;
	document.forms[0].btnReduction.value = "Please wait ...";
	document.forms[0].btnReduction.disabled = true;

	g_XMLHttpRequest = GetHttpRequest();
	g_XMLHttpRequest.onreadystatechange = CallbackHTTP;
	g_XMLHttpRequest.open("GET",strURLLoad,true);
	document.forms[0].txtName.value = "Sending request...";
	g_XMLHttpRequest.send(null);
	document.forms[0].txtName.value = "Sent request...";

}

 function PopupGlossary(UserID,PropertyID,BARef)
{
    var strURL;
    var hWndGlos;
    
    var lyrUpdate;
    
    lyrUpdate = document.getElementById("lyrVOAStatus");
    strURL = LHU_SERVER_ADDRESS + "/ajaxwrap/LHUGlossary.aspx?UserID=" + UserID + "&PropertyID=" + PropertyID + "&BaRef=" + BARef;
    
    if (lyrUpdate)
    {    
        lyrUpdate.innerHTML = "... creating glossary please wait ...";
    }
    
    //wParent = parent.window.opener;

    //if (wParent.g_Glossary)
    //{
	//    wParent.g_Glossary.close();
    //    wParent.g_Glossary = window.open(strURL,"wStatus","height=500,width=900,location=no,scrollbars=yes,menubar=no,toolbar=no,status=no");
    //    wParent.g_Glossary.focus();
    //}
    //else
    //{
        window.open(strURL,"wGlossary","height=500,width=900,location=no,scrollbars=yes,menubar=no,toolbar=no,status=no");
        
    //}
    
     $('divSearch2').show();
    FindMyDetailedAssessment(BARef);
    
 
}

function GlossaryLoaded()
{
    var lyrUpdate;
    lyrUpdate = document.getElementById("lyrVOAStatus");
    
    if (lyrUpdate)
    {
        lyrUpdate.innerHTML = "... awaiting next action ...";
    }
}




