﻿//Preloads the images
 if (document.images)
  {
    preload_image_object = new Image();
    // set image url
    image_url = new Array();
    image_url[0] = "/Images/commercial/leftMenuBG_ro.gif";
    image_url[1] = "/Images/holidayLets/leftMenuBG_ro.gif";
    image_url[2] = "/Images/lettings/leftMenuBG_ro.gif";
    image_url[3] = "/Images/newDevelopments/leftMenuBG_ro.gif";
    image_url[4] = "/Images/overseas/leftMenuBG_ro.gif";
    image_url[5] = "/Images/leftMenuBG_ro.gif";                

    var i = 0;
    for(i=0; i<=6; i++) 
    {
      preload_image_object.src = image_url[i];
    }
  }
  
//makes sure a  filed isnt too long in a textarea
function textCounter(field, countfield, maxlimit) 
{
  if (field.value.length > maxlimit) 
  field.value = field.value.substring(0, maxlimit);
  else 
  countfield.value = maxlimit - field.value.length;
}

//Confrims that a record is to really
//be deleted
function doCheckDelRecord()
{
  if(!confirm("Are you sure you want to delete this record?"))
  {
    return false;
  }
  else
  {
    return true;
  }
}

// Changes the images for the property.
function changeImage(theID, imgSrc, altText, theType)
{
//  if(theType==1)
//  {
    document.getElementById(theID).src = "/PropertyImages/" + imgSrc;
//  }
//  else
//  {
//    document.getElementById(theID).src = "/PropertyFloorplans/" + imgSrc;
//  }
	document.getElementById(theID).alt = altText;
}

// Changes the images for the property.
function changeAgentImage(theID, imgSrc)
{
  
  document.getElementById(theID).src = "/Images/AgentWebImages/Full/" + imgSrc;
}

//Shows the colour picker
function showPicker(theID)
{
 
  document.getElementById("BgColor").style.display = "block";
  document.getElementById("BgColor").focus();
  document.getElementById("theID").value = theID;
}

///Gets the colour and hides the picker
function pickColour(theID, tbx, theColor)
{
  var x = document.getElementById("theID").value + "Text"

  document.getElementById("BgColor").style.display = "none";
  document.getElementById(x).value = theColor;
  document.getElementById(document.getElementById("theID").value).style.backgroundColor = theColor;
  document.getElementById(document.getElementById("theID").value).style.color = theColor;
}

//Shows a sample of the Colour particular
function showSampleCP(CPID)
{
  window.open("/SampleCP.aspx?CPID=" + CPID, "SampleCP", "status=yes,toolbar=no,menubar=no,location=no");
  return false;
}
  
//Toop tip pop up box
var HelpX, HelpY, HelpText;
var ToShow, ToClear;
function DoFlyOver()
{
  if( ToClear != -1 ) window.clearTimeout( ToClear );
  FOArea.innerText = HelpText;
  FOArea.style.left = HelpX + 10;
  FOArea.style.top = HelpY + 10;
  FOArea.style.display = "block";
  ToClear = setTimeout( "ClearFlyOver()", 8000, "JAVASCRIPT" );
}
function ClearFlyOver()
{
  FOArea.style.display = "none";
}
function FlyOver( Text )
{
  HelpText = Text;
  HelpX = window.event.clientX;
  HelpY = window.event.clientY;
  ToShow = setTimeout( "DoFlyOver()", 500, "JAVASCRIPT" );
}

  function mOver(theID)
  {
    document.getElementById(theID).className = "leftMenu_ro";
  }
  
  function mOut(theID)
  {
    document.getElementById(theID).className = "leftMenu";
  }
  
/* Property Record Functions */
function hideAllModal()
{
  $find("ModalBehaviourMain").hide();
  $find("ModalBehaviourReserved").hide();
  $find("ModalBehaviourNoteOnly").hide();
  $find("ModalBehaviourUnderOffer").hide();
  $find("ModalBehaviourExchanged").hide();
  $find("ModalBehaviourCompleted").hide();
  $find("ModalBehaviourtLetAgreed").hide();
  $find("ModalBehaviourReserved").hide();
  
  
}

 function ShowModalReserved()
  {
    hideAllModal();
    $find("ModalBehaviourReserved").show();
    $find("ModalBehaviourMain").hide();  
  }
   
  function ShowModalNoteOnly()
  {
    hideAllModal();    
    $find("ModalBehaviourNoteOnly").show();
    $find("ModalBehaviourMain").hide();
    //document.getElementById("ctl00_ContentPlaceHolder1_PropertyRecord1_btnChangeStatus").disabled = true;
  }

  function ShowModalUnderOffer()
  {
    hideAllModal();
    $find("ModalBehaviourUnderOffer").show();
    $find("ModalBehaviourMain").hide();  
    //document.getElementById("ctl00_ContentPlaceHolder1_PropertyRecord1_btnChangeStatus").disabled = true;  
  }

  function ShowModalExchanged()
  {
    hideAllModal();
    $find("ModalBehaviourExchanged").show();
    $find("ModalBehaviourMain").hide();  
    //document.getElementById("ctl00_ContentPlaceHolder1_PropertyRecord1_btnChangeStatus").disabled = true;  
  }

  function ShowModalCompleted()
  {
    hideAllModal();
    $find("ModalBehaviourCompleted").show();
    $find("ModalBehaviourMain").hide();  
    //document.getElementById("ctl00_ContentPlaceHolder1_PropertyRecord1_btnChangeStatus").disabled = true;  
  }

  function ShowModalLetAgreed()
  {
    hideAllModal();
    $find("ModalBehaviourtLetAgreed").show();
    $find("ModalBehaviourMain").hide();  
    //document.getElementById("ctl00_ContentPlaceHolder1_PropertyRecord1_btnChangeStatus").disabled = true;  
  }
  /* Property Record Functions */
  
  /* Bishops Move Calc */
  function MM_displayStatusMsg(msgStr) { //v1.0
  status=msgStr;
  document.MM_returnValue = true;
}

var rate_0_bedroom = new Object();	//	no bedrooms selected
rate_0_bedroom[0] = "";
rate_0_bedroom[1] = "";
rate_0_bedroom[2] = "";
rate_0_bedroom[3] = "";
rate_0_bedroom[4] = "";
rate_0_bedroom[5] = "";
rate_0_bedroom[6] = "";

var rate_1_bedroom = new Object();	//	1 bedroom
rate_1_bedroom[0] = "";
rate_1_bedroom[1] = "£200 - £400";
rate_1_bedroom[2] = "£400 - £600";
rate_1_bedroom[3] = "£400 - £600";
rate_1_bedroom[4] = "£400 - £700";
rate_1_bedroom[5] = "£800 - £1100";
rate_1_bedroom[6] = "£800 - £1100";

var rate_2_bedroom = new Object();	//	2 bedrooms
rate_2_bedroom[0] = "";
rate_2_bedroom[1] = "£350 - £600";
rate_2_bedroom[2] = "£600 - £750";
rate_2_bedroom[3] = "£700 - £950";
rate_2_bedroom[4] = "£950 - £1200";
rate_2_bedroom[5] = "£1000 - £1350";
rate_2_bedroom[6] = "£1100 - £1500";

var rate_3_bedroom = new Object();	//	3 bedrooms
rate_3_bedroom[0] = "";
rate_3_bedroom[1] = "£500 - £750";
rate_3_bedroom[2] = "£600 - £900";
rate_3_bedroom[3] = "£750 - £1250";
rate_3_bedroom[4] = "£800 - £1300";
rate_3_bedroom[5] = "£1000 - £1750";
rate_3_bedroom[6] = "£1200 - £2000";

var rate_4_bedroom = new Object();	//	4 bedrooms
rate_4_bedroom[0] = "";
rate_4_bedroom[1] = "£1000 - £1500";
rate_4_bedroom[2] = "£1100 - £1600";
rate_4_bedroom[3] = "£1200 - £1800";
rate_4_bedroom[4] = "£1200 - £2000";
rate_4_bedroom[5] = "£1400 - £2200";
rate_4_bedroom[6] = "£1500 - £2500";


var rate_5_bedroom = new Object();	//	5 bedrooms
rate_5_bedroom[0] = "";
rate_5_bedroom[1] = "£1200 - £1800";
rate_5_bedroom[2] = "£1200 - £1800";
rate_5_bedroom[3] = "£1400 - £2000";
rate_5_bedroom[4] = "£1500 - £2200";
rate_5_bedroom[5] = "£1600 - £2500";
rate_5_bedroom[6] = "£2000 - £3000";

//	now get menu selections and determine which array value to display

function doUkEstimate(theForm) {
	var bedrooms = theForm.bedrooms.options[theForm.bedrooms.selectedIndex].value;
	var distance = theForm.distance.options[theForm.distance.selectedIndex].value;
	theForm.UkEstimate.value = eval("rate_" + bedrooms + "_bedroom[" + distance + "]");
	}

	/* Bishops Move Calc End */
function viewProperty(propertyID) {
  window.open("/Agents/PropertyRecord-" + propertyID + ".aspx", "PropertyRecord", "menubar=no, status=no, toolbar =no, resizable=1,scrollbars=yes", "");
}
