
function MM_findObj(n, d) { //v3.0
  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); 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; /*alert(x);*/ if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2]; /*alert(i+2);*/}
}
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_preloadImages() { //v3.0
 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
   var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
   if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

window.name = "WinMain"; //used instead of .opener property for popups to open URLs in the main window
function popup(theURL,theWindowName,theWidth,theHeight) {
	window.open(theURL, theWindowName,"width="+theWidth+",height="+theHeight+",scrollbars=no");
	//put 'window.self.focus' in html header of popup page
	//instead of win.focus(); here to avoid an error in Internet Explorer
}

function MM_showHideLayers() { //v3.0

  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function changeElementCssClass(element_id, css_class) {
	var x;
	if ((x=MM_findObj(element_id))!=null){
		x.className=css_class;
	}
}
function changeElementContent(element_id, content) {
	var x;
	if ((x=MM_findObj(element_id))!=null){
		x.innerHTML=content;
	}
}

function overArea() {

}

function outArea() {

}

function switchAll(ClikSearchId) {
  for (var i=0;i<Form2.elements.length;i++) {
    var e = Form2.elements[i];
    if ( (e.name != ClikSearchId) && (e.type=='checkbox')) {
		Form2.elements[i].checked = false;
    }
  }
}

function checkAllZones() {
  for (var i=0;i<document.forms[0].elements.length;i++) {
    var e = document.forms[0].elements[i];
    if ((e.type=='checkbox')&&(e.name.indexOf('zone_') > 0)) {
		document.forms[0].elements[i].checked = true;
    }
  }
}
function checkAllLines() {
  for (var i=0;i<document.forms[0].elements.length;i++) {
    var e = document.forms[0].elements[i];
    if ((e.type=='checkbox')&&(e.name.indexOf('tube') > 0)) {
		document.forms[0].elements[i].checked = true;
    }
  }
}
function flagForDelete(ClikSearchId) {
  switchAll(ClikSearchId);
  for (var i=0;i<Form2.elements.length;i++) {
    var e = Form2.elements[i];
    if ( (e.name == ClikSearchId)) {
		Form2.elements[i].checked = true;
    }
  }
}

function OpenPopupWindow(winurl, winname, winfeatures) {
	newwin = window.open(winurl,winname,winfeatures);
}

/* image swapping code */
function imagedata(url,title,height,width)
{this.url=url;					// url of image
 this.title=title;				// image title (alt text)
 this.height=height;			// image height
 this.width=width;				// image width
};

var currentimage=0;				// current displayed image
var imageresize=false;			// if the main image will resize (PhotoAlbum sets in ASPX code)

var imagearray=new Array();
/* imagedata object should be added to this array. see PhotoAlbum as an example */

// display image n (0-based) using image control ctl and optional label (title)
function DisplayImage(n)
{var ctl=document.getElementById('imgMainPhoto');
 var labelctl=document.getElementById('labelMainPhoto');
 if (ctl!=null)
 
     		
   // is image within imagedata range
   if (n>=0 && n<imagearray.length)
     {ctl.src=imagearray[n].url;
      ctl.title=imagearray[n].title;
      // optionally resize
      if (imageresize)
        {ctl.width=imagearray[n].width;
	     ctl.height=imagearray[n].height;
        }
      // optional label control  
      if (labelctl!=null)
        labelctl.innerHTML=imagearray[n].title;
	  currentimage=n;    
     };
 UpdateNavigation();
};

function UpdateNavigation()
{var pctl=document.getElementById('PrevDiv');
 var nctl=document.getElementById('NextDiv');
 if (pctl!=null) pctl.style.visibility=(imagearray.length>0)?'visible':'hidden';				
 if (nctl!=null) nctl.style.visibility=(imagearray.length>0)?'visible':'hidden';
}

function DisplayPreviousImage()
{
  if (currentimage==0)
    currentimage = imagearray.length;
	
  DisplayImage(--currentimage);
}

function DisplayNextImage()
{
  if (currentimage==imagearray.length-1)
    currentimage = -1;

   DisplayImage(++currentimage);
}

function PopupPrintWindow(url)
{var pwin=window.open(url,"printwin","height=700,width=650,resizable=yes,scrollbars=yes,menubar=yes,status=yes");
 if (navigator.appName.substring(0,8)=="Netscape")
   pwin.location=url
 pwin.focus();   
}

//left(bottom),right(bottom),left(top),right(bottom),middle(top),middle(bottom)
var images=new Array("images/tube_bottom_left.gif","images/tube_top_right.gif","images/tube_top_left.gif","images/tube_bottom_right.gif","images/tube_top_middle.gif","images/tube_bottom_middle.gif");
var pos = 0
var toplevel = false;
var bottomlevel = true;
var top=new Array("2","4","1");
var bottom=new Array("0","5","3");

function ImagePicker(){
	var tubemap = MM_findObj('tubemap');
	if(pos<0){pos = 0}else if(pos>2){pos = 2}
	if(bottomlevel ==true){
		tubemap.src = images[bottom[pos]]
	}else{
		tubemap.src = images[top[pos]]
	}	
}

function multipleChecked() {
	var x = 0
	var Form2=document.getElementById("Form2")
	//always reset the exec ind
	for (var i=0;i<Form2.elements.length;i++) {
	var e = Form2.elements[i];
		if ((e.name=='SavedResultsListViewControl:hidExec')) {
			e.value="0";
		}
	}
	//get a count of number of searches selected
	for (var i=0;i<Form2.elements.length;i++) {
		var e = Form2.elements[i];
		if ((e.type=='checkbox')&&(e.checked == true)) {
			x++;
		}
	}
	//take action
	if (x > 1){
		alert('You can only run one search at a time');
		x=0
		for (var i=0;i<Form2.elements.length;i++) {
		var e = Form2.elements[i];
			if ((e.name=='SavedResultsListViewControl:hidExec')) {
				e.value="1";
			}
		}
	}
}

function multipleEmailChecked() {
	var x = 0
	var Form1=document.getElementById("Form1")
	//always reset the exec ind
	for (var i=0;i<Form1.elements.length;i++) {
	var e = Form1.elements[i];
		if ((e.name=='hidExec')) {
			e.value="0";
		}
	}
	//get a count of number of props selected
	for (var i=0;i<Form1.elements.length;i++) {
		var e = Form1.elements[i];
		if ((e.type=='checkbox')&&(e.checked == true)) {
			x++;
		}
	}
	//take action
	if (x > 20){
		alert('You can only email twenty properties at a time');
		x=0
		for (var i=0;i<Form1.elements.length;i++) {
		var e = Form1.elements[i];
			if ((e.name=='hidExec')) {
				e.value="1";
			}
		}
	}
	if (x <=0){
		alert('Please select at least one property to email to a friend');
		x=0
		for (var i=0;i<Form1.elements.length;i++) {
		var e = Form1.elements[i];
			if ((e.name=='hidExec')) {
				e.value="1";
			}
		}
	}
}

function tubeChecked(p) {

	var x = 0
	var Form1=document.getElementById("Form1")
	
	//get a count of number of searches selected
	for (var i=0;i<Form1.elements.length;i++) {
		var e = Form1.elements[i];
		if ((e.type=='checkbox')&&(e.checked == true)) {
			x++;
		}
	}
	//take action
	if (x > 6){
		alert('A maximum of six tube stations may be included in one search');
		return;
	}else if (x ==0){
		alert('A minimum of one selected tube station is required');
		return;
	}else{ 
		if(p){
			Form1.action = Form1.action + "&pa=" + p
			Form1.submit();
		}
	}
}

function agentsChecked() {
	var x = 0
	var Form1=document.getElementById("estateagent_select_form")
	//get a count of number of searches selected
	for (var i=0;i<Form1.elements.length;i++) {
		var e = Form1.elements[i];
		if ((e.type=='checkbox')&&(e.checked == true)) {
			x++;
		}
	}
	//take action
	if (x <=0){
		alert('Please select at least one agent to contact');
	}
}

function showPasswordcontrol(nr)
{
	if (document.layers)
	{
		current = (document.layers[nr].display == 'none') ? 'block' : 'none';
		document.layers[nr].display = current;
	}
	else if (document.all)
	{
		if (typeof(document.all[nr])!= "undefined"){
			current = (document.all[nr].style.display == 'none') ? 'block' : 'none';
			document.all[nr].style.display = current;
		}
	}
	else if (document.getElementById)
	{
		vista = (document.getElementById(nr).style.display == 'none') ? 'block' : 'none';
		document.getElementById(nr).style.display = vista;
	}
}


function hidePasswordcontrol(nr)
{
	if (document.layers)
	{
		current = (document.layers[nr].display == 'none') ? 'block' : 'none';
		document.layers[nr].display = current;
	}
	else if (document.all)
	{
		if (typeof(document.all[nr])!= "undefined"){
			current = (document.all[nr].style.display == 'none') ? 'block' : 'none';
			document.all[nr].style.display = current;
		}
	}
	else if (document.getElementById)
	{
		vista = (document.getElementById(nr).style.display == 'none') ? 'block' : 'none';
		document.getElementById(nr).style.display = vista;
	}
}

