function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function openwin(url)
  {if (!window.form_cl||form_cl.closed)
   {form_cl=window.open(url,'form_cl','resizable=yes,scrollbars=yes,width=600,height=700,left=25,top=25,toolbar=no');
   }
  else
   {form_cl.close(); 
   form_cl=window.open(url,'form_cl','resizable=yes,scrollbars=yes,width=600,height=700,left=25,top=25,toolbar=no');
   }
}

function openagg(url)
  {if (!window.form_cl||form_cl.closed)
   {form_cl=window.open(url,'form_cl','resizable=yes,scrollbars=yes,width=800,height=600,left=25,top=25,toolbar=no');
   }
  else
   {form_cl.close(); 
   form_cl=window.open(url,'form_cl','resizable=yes,scrollbars=yes,width=800,height=600,left=25,top=25,toolbar=no');
   }
}

function openstage(url)
  {if (!window.form_cl||form_cl.closed)
   {form_cl=window.open(url,'form_cl','resizable=yes,scrollbars=yes,width=600,height=600,left=25,top=25,toolbar=no');
   }
  else
   {form_cl.close(); 
   form_cl=window.open(url,'form_cl','resizable=yes,scrollbars=yes,width=600,height=600,left=25,top=25,toolbar=no');
   }
}

function MM_changeProp(objName,x,theProp,theValue) { //v6.0
  var obj = MM_findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)){
    if (theValue == true || theValue == false)
      eval("obj."+theProp+"="+theValue);
    else eval("obj."+theProp+"='"+theValue+"'");
  }
}

function MM_setTextOfTextfield(objName,x,newText) { //v3.0
  var obj = MM_findObj(objName); if (obj) obj.value = newText;
}

var amount = new Array();

amount['bminprice']    = new Array();
amount['bminprice'][0] = new Array('Minimum','£100,000','£200,000','£300,000','£400,000','£500,000','£600,000','£700,000','£800,000','£900,000');
amount['bminprice'][1] = new Array('1','100000','200000','300000','400000','500000','600000','700000','800000','900000');

amount['bmaxprice']    = new Array();
amount['bmaxprice'][0] = new Array('Maximum','£200,000','£300,000','£400,000','£500,000','£600,000','£700,000','£800,000','£900,000','£1,000,000');
amount['bmaxprice'][1] = new Array('999999999','200000','300000','400000','500000','600000','700000','800000','900000','1000000');

amount['rminprice']    = new Array();
amount['rminprice'][0] = new Array('Minimum','£100','£125','£150','£175','£200','£250','£300','£400');
amount['rminprice'][1] = new Array('1','100','125','150','175','200','250','300','400');

amount['rmaxprice']    = new Array();
amount['rmaxprice'][0] = new Array('Maximum','£125','£150','£175','£200','£250','£300','£400');
amount['rmaxprice'][1] = new Array('999999999','125','150','175','200','250','300','400');


function clearAmount( box ) {
	while ( box.options.length ) box.options[0] = null;
		}

function fillAmount( box, arr ) {

	for ( i = 0; i < arr[0].length; i++ ) {
		option = new Option( arr[0][i], arr[1][i] );
		box.options[box.length] = option;
		}
		box.selectedIndex=0;
	}	

function changeAmount( box ) {

	eAmount= box.options[box.selectedIndex].value
	sAmount1 = eAmount + "minprice";
	sAmount2 = eAmount + "maxprice";
	
	amount1 = amount[sAmount1];
	amount2 = amount[sAmount2];
	
	clearAmount( box.form.minprice );
	clearAmount( box.form.maxprice );

	fillAmount( box.form.minprice, amount1 );
	fillAmount( box.form.maxprice, amount2 );

	}

function ok(){
var add01 = document.form.fsAddress01.value
var add02 = document.form.fsAddress02.value
var pcode = document.form.fsPostcode.value
var price = document.form.fsPrice.value
var ptype = document.form.fsPropertyType.value
var bed = document.form.fsBedroom.value
var bath = document.form.fsBathroom.value

if ( add01.length == 0)
{alert('Please Enter the Street Name')
form.fsAddress01.focus()
return false}

if ( add02.length == 0)
{alert('Please Enter Area - Bethnal Green, Docklands, Hackney, Clapton, London etc...')
form.fsAddress02.focus()
return false}

if ( pcode.length == 0)
{alert('Please Enter Postcode - First part only in this field')
form.fsPostcode.focus()
return false}

if ( price.length == 0)
{alert('Please Enter Price')
form.fsPrice.focus()
return false}

if ( ptype == 'LB')
{alert('Please Select Property Type')
form.fsPropertyType.focus()
return false}

if ( bed == 'LB')
{alert('Please Select the Number of Bedrooms')
form.fsBedroom.focus()
return false}

if ( bath == 'LB')
{alert('Please Select the Number of Bathrooms')
form.fsBathroom.focus()
return false}

document.body.style.cursor = "wait"; 

}

//var currentImage = '';
function previewImage01(image) {
    document.getElementById("image01Display").src = '';
    if ( image.value ) {
//        document.getElementById("image01Display").src = 'file:///'+image.value;
        document.getElementById("image01Display").style.visibility = 'hidden';
        document.getElementById("image01Display").src = 'file:///'+image.value;

        // Had to break this in to 2 functions for Firefox to work properly.
        currentImage = image;
        setTimeout('updateImage01()',1);
    }
}
function updateImage01() {
    var width = document.getElementById("image01Display").width;
    var height = document.getElementById("image01Display").height;

    if ( width > height ) {
        if ( width > 150 ) {
            newWidth = 150;
            ratio = 150 / width;
            newHeight = height * ratio;
        } else {
            newWidth = width;
            newHeight = height;
        }
    } else {
        if ( height > 112 ) {
            newHeight = 112;
            ratio = 112 / height;
            newWidth = width * ratio;
        } else {
            newWidth = width;
            newHeight = height;
        }
    }

    document.getElementById("image01Display").width = newWidth;
    document.getElementById("image01Display").height = newHeight;

    document.getElementById("image01Display").style.visibility = 'visible';

//    var imagePath = currentImage.value;
//    for (i = imagePath.length; i > 0; i--) {
//        if (imagePath.substring(i,i+1) == "\\") {
//            var imageFilename = imagePath.substring(i+1,imagePath.length);
//            var imageFilenameDisplay = imageFilename;
//            if ( imageFilename.length > 25 )
//                imageFilename = imageFilename.substring(0,15) + '...' + imageFilename.substring(imageFilename.length - 10,imageFilename.length);
//            document.getElementById(currentImage.name + "_name").innerHTML = '<a href="javascript:void(0)" title="'+imageFilenameDisplay+'" onclick="previewImage(document.forms[0].'+currentImage.name+');">'+imageFilename+'</a> <small>('+width+' x '+height+' px)</small>';
//            break;
//        }
//    }

//    document.getElementById("image01Display").src = '';
}

function previewImage02(image) {
    document.getElementById("image02Display").src = '';
    if ( image.value ) {
        document.getElementById("image02Display").style.visibility = 'hidden';
        document.getElementById("image02Display").src = 'file:///'+image.value;

        // Had to break this in to 2 functions for Firefox to work properly.
        currentImage = image;
        setTimeout('updateImage02()',1);
    }
}
function updateImage02() {
    var width = document.getElementById("image02Display").width;
    var height = document.getElementById("image02Display").height;

    if ( width > height ) {
        if ( width > 150 ) {
            newWidth = 150;
            ratio = 150 / width;
            newHeight = height * ratio;
        } else {
            newWidth = width;
            newHeight = height;
        }
    } else {
        if ( height > 112 ) {
            newHeight = 112;
            ratio = 112 / height;
            newWidth = width * ratio;
        } else {
            newWidth = width;
            newHeight = height;
        }
    }

    document.getElementById("image02Display").width = newWidth;
    document.getElementById("image02Display").height = newHeight;

    document.getElementById("image02Display").style.visibility = 'visible';
}

function previewImage03(image) {
    document.getElementById("image03Display").src = '';
    if ( image.value ) {
        document.getElementById("image03Display").style.visibility = 'hidden';
        document.getElementById("image03Display").src = 'file:///'+image.value;

        // Had to break this in to 2 functions for Firefox to work properly.
        currentImage = image;
        setTimeout('updateImage03()',1);
    }
}
function updateImage03() {
    var width = document.getElementById("image03Display").width;
    var height = document.getElementById("image03Display").height;

    if ( width > height ) {
        if ( width > 150 ) {
            newWidth = 150;
            ratio = 150 / width;
            newHeight = height * ratio;
        } else {
            newWidth = width;
            newHeight = height;
        }
    } else {
        if ( height > 112 ) {
            newHeight = 112;
            ratio = 112 / height;
            newWidth = width * ratio;
        } else {
            newWidth = width;
            newHeight = height;
        }
    }

    document.getElementById("image03Display").width = newWidth;
    document.getElementById("image03Display").height = newHeight;

    document.getElementById("image03Display").style.visibility = 'visible';
}

function previewImage04(image) {
    document.getElementById("image04Display").src = '';
    if ( image.value ) {
        document.getElementById("image04Display").style.visibility = 'hidden';
        document.getElementById("image04Display").src = 'file:///'+image.value;

        // Had to break this in to 2 functions for Firefox to work properly.
        currentImage = image;
        setTimeout('updateImage04()',1);
    }
}
function updateImage04() {
    var width = document.getElementById("image04Display").width;
    var height = document.getElementById("image04Display").height;

    if ( width > height ) {
        if ( width > 150 ) {
            newWidth = 150;
            ratio = 150 / width;
            newHeight = height * ratio;
        } else {
            newWidth = width;
            newHeight = height;
        }
    } else {
        if ( height > 112 ) {
            newHeight = 112;
            ratio = 112 / height;
            newWidth = width * ratio;
        } else {
            newWidth = width;
            newHeight = height;
        }
    }

    document.getElementById("image04Display").width = newWidth;
    document.getElementById("image04Display").height = newHeight;

    document.getElementById("image04Display").style.visibility = 'visible';
}

function previewImage05(image) {
    document.getElementById("image05Display").src = '';
    if ( image.value ) {
        document.getElementById("image05Display").style.visibility = 'hidden';
        document.getElementById("image05Display").src = 'file:///'+image.value;

        // Had to break this in to 2 functions for Firefox to work properly.
        currentImage = image;
        setTimeout('updateImage05()',1);
    }
}
function updateImage05() {
    var width = document.getElementById("image05Display").width;
    var height = document.getElementById("image05Display").height;

    if ( width > height ) {
        if ( width > 150 ) {
            newWidth = 150;
            ratio = 150 / width;
            newHeight = height * ratio;
        } else {
            newWidth = width;
            newHeight = height;
        }
    } else {
        if ( height > 112 ) {
            newHeight = 112;
            ratio = 112 / height;
            newWidth = width * ratio;
        } else {
            newWidth = width;
            newHeight = height;
        }
    }

    document.getElementById("image05Display").width = newWidth;
    document.getElementById("image05Display").height = newHeight;

    document.getElementById("image05Display").style.visibility = 'visible';
}

function previewImage06(image) {
    document.getElementById("image06Display").src = '';
    if ( image.value ) {
        document.getElementById("image06Display").style.visibility = 'hidden';
        document.getElementById("image06Display").src = 'file:///'+image.value;

        // Had to break this in to 2 functions for Firefox to work properly.
        currentImage = image;
        setTimeout('updateImage06()',1);
    }
}
function updateImage06() {
    var width = document.getElementById("image06Display").width;
    var height = document.getElementById("image06Display").height;

    if ( width > height ) {
        if ( width > 150 ) {
            newWidth = 150;
            ratio = 150 / width;
            newHeight = height * ratio;
        } else {
            newWidth = width;
            newHeight = height;
        }
    } else {
        if ( height > 112 ) {
            newHeight = 112;
            ratio = 112 / height;
            newWidth = width * ratio;
        } else {
            newWidth = width;
            newHeight = height;
        }
    }

    document.getElementById("image06Display").width = newWidth;
    document.getElementById("image06Display").height = newHeight;

    document.getElementById("image06Display").style.visibility = 'visible';
}


//floorplans
function previewfp01(image) {
    document.getElementById("fp01Display").src = '';
    if ( image.value ) {
        document.getElementById("fp01Display").style.visibility = 'hidden';
        document.getElementById("fp01Display").src = 'file:///'+image.value;

        // Had to break this in to 2 functions for Firefox to work properly.
        currentImage = image;
        setTimeout('updatefp01()',1);
    }
}
function updatefp01() {
    var width = document.getElementById("fp01Display").width;
    var height = document.getElementById("fp01Display").height;

    if ( width > height ) {
        if ( width > 150 ) {
            newWidth = 150;
            ratio = 150 / width;
            newHeight = height * ratio;
        } else {
            newWidth = width;
            newHeight = height;
        }
    } else {
        if ( height > 212 ) {
            newHeight = 212;
            ratio = 212 / height;
            newWidth = width * ratio;
        } else {
            newWidth = width;
            newHeight = height;
        }
    }

    document.getElementById("fp01Display").width = newWidth;
    document.getElementById("fp01Display").height = newHeight;

    document.getElementById("fp01Display").style.visibility = 'visible';
}


function previewfp02(image) {
    document.getElementById("fp02Display").src = '';
    if ( image.value ) {
        document.getElementById("fp02Display").style.visibility = 'hidden';
        document.getElementById("fp02Display").src = 'file:///'+image.value;

        // Had to break this in to 2 functions for Firefox to work properly.
        currentImage = image;
        setTimeout('updatefp02()',1);
    }
}
function updatefp02() {
    var width = document.getElementById("fp02Display").width;
    var height = document.getElementById("fp02Display").height;

    if ( width > height ) {
        if ( width > 150 ) {
            newWidth = 150;
            ratio = 150 / width;
            newHeight = height * ratio;
        } else {
            newWidth = width;
            newHeight = height;
        }
    } else {
        if ( height > 212 ) {
            newHeight = 212;
            ratio = 212 / height;
            newWidth = width * ratio;
        } else {
            newWidth = width;
            newHeight = height;
        }
    }

    document.getElementById("fp02Display").width = newWidth;
    document.getElementById("fp02Display").height = newHeight;

    document.getElementById("fp02Display").style.visibility = 'visible';
}


//Virtual Tours
function previewVT01(image) {
    document.getElementById("VT01Display").src = '';
    if ( image.value ) {
        document.getElementById("VT01Display").style.visibility = 'hidden';
        document.getElementById("VT01Display").src = 'file:///'+image.value;

        // Had to break this in to 2 functions for Firefox to work properly.
        currentImage = image;
        setTimeout('updateVT01()',1);
    }
}
function updateVT01() {
    var width = document.getElementById("VT01Display").width;
    var height = document.getElementById("VT01Display").height;

    if ( width > height ) {
        if ( width > 339 ) {
            newWidth = 339;
            ratio = 339 / width;
            newHeight = height * ratio;
        } else {
            newWidth = width;
            newHeight = height;
        }
    } else {
        if ( height > 99 ) {
            newHeight = 99;
            ratio = 99 / height;
            newWidth = width * ratio;
        } else {
            newWidth = width;
            newHeight = height;
        }
    }

    document.getElementById("VT01Display").width = newWidth;
    document.getElementById("VT01Display").height = newHeight;

    document.getElementById("VT01Display").style.visibility = 'visible';
}

function previewVT02(image) {
    document.getElementById("VT02Display").src = '';
    if ( image.value ) {
        document.getElementById("VT02Display").style.visibility = 'hidden';
        document.getElementById("VT02Display").src = 'file:///'+image.value;

        // Had to break this in to 2 functions for Firefox to work properly.
        currentImage = image;
        setTimeout('updateVT02()',1);
    }
}
function updateVT02() {
    var width = document.getElementById("VT02Display").width;
    var height = document.getElementById("VT02Display").height;

    if ( width > height ) {
        if ( width > 339 ) {
            newWidth = 339;
            ratio = 339 / width;
            newHeight = height * ratio;
        } else {
            newWidth = width;
            newHeight = height;
        }
    } else {
        if ( height > 99 ) {
            newHeight = 99;
            ratio = 99 / height;
            newWidth = width * ratio;
        } else {
            newWidth = width;
            newHeight = height;
        }
    }

    document.getElementById("VT02Display").width = newWidth;
    document.getElementById("VT02Display").height = newHeight;

    document.getElementById("VT02Display").style.visibility = 'visible';
}

function previewVT03(image) {
    document.getElementById("VT03Display").src = '';
    if ( image.value ) {
        document.getElementById("VT03Display").style.visibility = 'hidden';
        document.getElementById("VT03Display").src = 'file:///'+image.value;

        // Had to break this in to 2 functions for Firefox to work properly.
        currentImage = image;
        setTimeout('updateVT03()',1);
    }
}
function updateVT03() {
    var width = document.getElementById("VT03Display").width;
    var height = document.getElementById("VT03Display").height;

    if ( width > height ) {
        if ( width > 339 ) {
            newWidth = 339;
            ratio = 339 / width;
            newHeight = height * ratio;
        } else {
            newWidth = width;
            newHeight = height;
        }
    } else {
        if ( height > 99 ) {
            newHeight = 99;
            ratio = 99 / height;
            newWidth = width * ratio;
        } else {
            newWidth = width;
            newHeight = height;
        }
    }

    document.getElementById("VT03Display").width = newWidth;
    document.getElementById("VT03Display").height = newHeight;

    document.getElementById("VT03Display").style.visibility = 'visible';
}

function previewVT04(image) {
    document.getElementById("VT04Display").src = '';
    if ( image.value ) {
        document.getElementById("VT04Display").style.visibility = 'hidden';
        document.getElementById("VT04Display").src = 'file:///'+image.value;

        // Had to break this in to 2 functions for Firefox to work properly.
        currentImage = image;
        setTimeout('updateVT04()',1);
    }
}
function updateVT04() {
    var width = document.getElementById("VT04Display").width;
    var height = document.getElementById("VT04Display").height;

    if ( width > height ) {
        if ( width > 339 ) {
            newWidth = 339;
            ratio = 339 / width;
            newHeight = height * ratio;
        } else {
            newWidth = width;
            newHeight = height;
        }
    } else {
        if ( height > 99 ) {
            newHeight = 99;
            ratio = 99 / height;
            newWidth = width * ratio;
        } else {
            newWidth = width;
            newHeight = height;
        }
    }

    document.getElementById("VT04Display").width = newWidth;
    document.getElementById("VT04Display").height = newHeight;

    document.getElementById("VT04Display").style.visibility = 'visible';
}

function previewVT05(image) {
    document.getElementById("VT05Display").src = '';
    if ( image.value ) {
        document.getElementById("VT05Display").style.visibility = 'hidden';
        document.getElementById("VT05Display").src = 'file:///'+image.value;

        // Had to break this in to 2 functions for Firefox to work properly.
        currentImage = image;
        setTimeout('updateVT05()',1);
    }
}
function updateVT05() {
    var width = document.getElementById("VT05Display").width;
    var height = document.getElementById("VT05Display").height;

    if ( width > height ) {
        if ( width > 339 ) {
            newWidth = 339;
            ratio = 339 / width;
            newHeight = height * ratio;
        } else {
            newWidth = width;
            newHeight = height;
        }
    } else {
        if ( height > 99 ) {
            newHeight = 99;
            ratio = 99 / height;
            newWidth = width * ratio;
        } else {
            newWidth = width;
            newHeight = height;
        }
    }

    document.getElementById("VT05Display").width = newWidth;
    document.getElementById("VT05Display").height = newHeight;

    document.getElementById("VT05Display").style.visibility = 'visible';
}

function previewVT06(image) {
    document.getElementById("VT06Display").src = '';
    if ( image.value ) {
        document.getElementById("VT06Display").style.visibility = 'hidden';
        document.getElementById("VT06Display").src = 'file:///'+image.value;

        // Had to break this in to 2 functions for Firefox to work properly.
        currentImage = image;
        setTimeout('updateVT06()',1);
    }
}
function updateVT06() {
    var width = document.getElementById("VT06Display").width;
    var height = document.getElementById("VT06Display").height;

    if ( width > height ) {
        if ( width > 339 ) {
            newWidth = 339;
            ratio = 339 / width;
            newHeight = height * ratio;
        } else {
            newWidth = width;
            newHeight = height;
        }
    } else {
        if ( height > 99 ) {
            newHeight = 99;
            ratio = 99 / height;
            newWidth = width * ratio;
        } else {
            newWidth = width;
            newHeight = height;
        }
    }

    document.getElementById("VT06Display").width = newWidth;
    document.getElementById("VT06Display").height = newHeight;

    document.getElementById("VT06Display").style.visibility = 'visible';
}
