//############################################################
//############################################################
//    getMouseLoc()
//    MouseLocation
/*
function test()
{
  if (document.layers) getMouseLoc;     //NS
  else if (document.all) getMouseLoc(); //IE
  alert(mouseLocation.x+","+mouseLocation.y);
}
*/
//    simplePreload( '01.gif', '02.gif' )
//    moveLayerToMouseLoc
//    moveLayerToMouseLoc(theLayer, offsetH, offsetV)
//    preloadImages('file.gif', 'http://www.x.com/y.gif')
//    showHideLayers(Layer1,'','show',Layer2,'','hide')
//    messageWindow(title, msg)
//    popUpWindow(URLStr, left, top, width, height)
//    toolTip(msg, fg, bg)
//    
//############################################################
//############################################################


/* 
Example:
function test()
{
  if (document.layers) getMouseLoc;     //NS
  else if (document.all) getMouseLoc(); //IE
  alert(mouseLocation.x+","+mouseLocation.y);
}
in the BODY:
<a href="#" onmouseover="test()">test</a>
*/
function Point(x,y) {  this.x = x; this.y = y; }
mouseLocation = new Point(-500,-500);
function getMouseLoc(e)
{
  if(!document.all)  //NS
  {
    mouseLocation.x = e.pageX;
    mouseLocation.y = e.pageY;
  }
  else               //IE
  {
    mouseLocation.x = event.x + document.body.scrollLeft;
    mouseLocation.y = event.y + document.body.scrollTop;
  }
  return true;
}
//NS init:
if(document.layers){ document.captureEvents(Event.MOUSEMOVE); document.onMouseMove = getMouseLoc; }


// Example:
// simplePreload( '01.gif', '02.gif' ); 
function simplePreload()
{ 
  var args = simplePreload.arguments;
  document.imageArray = new Array(args.length);
  for(var i=0; i<args.length; i++)
  {
    document.imageArray[i] = new Image;
    document.imageArray[i].src = args[i];
  }
}

// * Dependencies * 
// this function requires the following snippets:
// JavaScript/readable_MM_functions/findObj
// JavaScript/readable_MM_functions/showHideLayers
// JavaScript/events/getMouseLoc
function moveLayerToMouseLoc(theLayer, offsetH, offsetV)
{
  var obj;
  if ((findObj(theLayer))!=null)
  {
    if (document.layers)  //NS
    {
      document.onMouseMove = getMouseLoc;
      obj = document.layers[theLayer];
      obj.left = mLoc.x +offsetH;
      obj.top  = mLoc.y +offsetV;
    }
    else if (document.all)//IE
    {
      getMouseLoc();
      obj = document.all[theLayer].style;
      obj.pixelLeft = mLoc.x +offsetH;
      obj.pixelTop  = mLoc.y +offsetV;
    }
    showHideLayers(theLayer,'','show');
  }
}
// get mouse location
function Point(x,y) {  this.x = x; this.y = y; }
mLoc = new Point(-500,-500);
function getMouseLoc(e)
{
  if(!document.all)  //NS
  {
    mLoc.x = e.pageX;
    mLoc.y = e.pageY;
  }
  else               //IE
  {
    mLoc.x = event.x + document.body.scrollLeft;
    mLoc.y = event.y + document.body.scrollTop;
  }
  return true;
}
//NS init:
if(document.layers){ document.captureEvents(Event.MOUSEMOVE); document.onMouseMove = getMouseLoc; }

//Example: preloadImages('file.gif', 'http://www.x.com/y.gif');
function preloadImages()
{
  if(document.images)
  {
    if(!document.imageArray) document.imageArray = new Array();
    var i,j = document.imageArray.length, args = this.arguments;
    
    for(i=0; i<args.length; i++)
    {
      if (args[i].indexOf("#")!=0)
      {
        document.imageArray[j] = new Image;
        document.imageArray[j++].src = args[i];
      }
    }
  }
}

// * Dependencies * 
// this function requires the following snippets:
// JavaScript/readable_MM_functions/findObj
//
// Accepts a variable number of arguments, in triplets as follows:
// arg 1: simple name of a layer object, such as "Layer1"
// arg 2: ignored (for backward compatibility)
// arg 3: 'hide' or 'show'
// repeat...
//
// Example: showHideLayers(Layer1,'','show',Layer2,'','hide');
function showHideLayers()
{ 
  var i, visStr, obj, args = showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3)
  {
    if ((obj = findObj(args[i])) != null)
    {
      visStr = args[i+2];
      if (obj.style)
      {
        obj = obj.style;
        if(visStr == 'show') visStr = 'visible';
        else if(visStr == 'hide') visStr = 'hidden';
      }
      obj.visibility = visStr;
    }
  }
}


function messageWindow(title, msg)
{
  var width="300", height="125";
  var left = (screen.width/2) - width/2;
  var top = (screen.height/2) - height/2;
  var styleStr = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbar=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+',top='+top+',screenX='+left+',screenY='+top;
  var msgWindow = window.open("","msgWindow", styleStr);
  var head = '<head><title>'+title+'</title></head>';
  var body = '<center>'+msg+'<br><p><form><input type="button" value="   Done   " onClick="self.close()"></form>';
  msgWindow.document.write(head + body);
}

var popUpWin=0;
function popUpWindow(URLStr, left, top, width, height)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menub ar=no,scrollbar=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}


// Example:
// onMouseOver="toolTip('tool tip text here')";
// onMouseOut="toolTip()";
// -or-
// onMouseOver="toolTip('more good stuff', '#FFFF00', 'orange')";
// onMouseOut="toolTip()"; 
/*
MOVE this to the <body>:
<div id="toolTipLayer" style="position:absolute; visibility: hidden"></div>
<script language="JavaScript"><!--
initToolTips(); //--></script>
*/
function toolTip(msg, fg, bg)
{
  if(toolTip.arguments.length < 1) // hide
  {
    if(ns4) toolTipSTYLE.visibility = "hidden";
    else toolTipSTYLE.display = "none";
  }
  else // show
  {
    if(!fg) fg = "#777777";
    if(!bg) bg = "#FFFFFF";
    var content = msg;
    //'<table border="0" cellspacing="0" cellpadding="1" bgcolor="' + fg + '"><td>' +
    //'<table border="0" cellspacing="0" cellpadding="1" bgcolor="' + bg + 
    //'"><td align="center"><font face="sans-serif" color="' + fg +
    //'" size="-2">&nbsp\;' + msg +
    //'&nbsp\;</font></td></table></td></table>';
    
    //#######  05/02/06 Alla added additional criteria : && content.indexOf("nodata")==-1
    if(ns4 && content.indexOf("nodata")==-1)
    {
      toolTipSTYLE.document.write(content);
      toolTipSTYLE.document.close();
      toolTipSTYLE.visibility = "visible";
    }
    if(ns6 && content.indexOf("nodata")==-1 )// || document.getElementById)
    {
      document.getElementById("toolTipLayer").innerHTML = content;
      toolTipSTYLE.display = "block";
    }
    if(ie4 && content.indexOf("nodata")==-1)   
    {
      document.all("toolTipLayer").innerHTML = content;
      //toolTipSTYLE.display = "block";
      document.all("toolTipLayer").style.display = "block";
//    }
//    if(ie5 && content.indexOf("nodata")==-1 )// || document.getElementById)
//    {
//      document.getElementById("toolTipLayer").innerHTML = content;
//      toolTipSTYLE.visibility = "visible";       
//    }
	// 4.23.2009 
	// MDC fixed bug in IE
	} else {
      document.all("toolTipLayer").innerHTML = content;
      //toolTipSTYLE.display = "block";
      //document.all("toolTipLayer").style.display = "block";      
      document.getElementById("toolTipLayer").style.display = "block";  
    }
  }
}
function moveToMouseLoc(e)
{
  if(ns4||ns6)
  {
    x = e.pageX;
    y = e.pageY;
  }
  else
  {
    x = event.x + document.body.scrollLeft;
    y = event.y + document.body.scrollTop;
  }
  toolTipSTYLE.left = x + offsetX;
  toolTipSTYLE.top = y + offsetY;
  return true;
}

//Given an index in the image array. Assign the thumbnails the 
//next 3 or 4 (depending on presence of floor plan) Listing images
function AssignThumbSeries(ThumbNo){
	Curr = ThumbNo * thumbs.length;
	CurrentThumb = ThumbNo;
	for(i=0; i <= thumbs.length-1; i++){
		if( Curr >= ListingImages.length ){
			document.images[thumbs[i]].src='/images/spacer.gif';
			document.images[thumbs[i]].style.visibility='hidden';
		}
		else{
			document.images[thumbs[i]].src = ListingImages[Curr].src;
			document.images[thumbs[i]].style.visibility='visible';
			Curr += 1;		
		}
		
	}
	document.getElementById('lblImgCount').innerHTML= ThumbNo+1 +' of ' + Math.ceil(ListingImages.length/thumbs.length);  		
}

function PreLoadImages(){
		ListingImages = new Array();
		for(i=0; i < PreLoadImages.arguments.length;i++){
			ListingImages[i] = new Image();
			ListingImages[i].src = PreLoadImages.arguments[i];
		}
}
	
function ShowPreviousImage(){
	if( CurrentThumb == 0 ){
		AssignThumbSeries(Math.ceil(ListingImages.length/thumbs.length)-1);
	}
	else{
		AssignThumbSeries(CurrentThumb-1);
	}

}	

function ShowNextImage(){		
	if(	CurrentThumb+1 >= Math.ceil(ListingImages.length/thumbs.length) ){
		AssignThumbSeries(0);	
	}
	else{
		AssignThumbSeries(CurrentThumb+1);
	}	
}


//Added By Woo 3/29/2006
function Nexter(){ 
	if (i < ListingImages.length-1){
		i = i+1;
	}	
	else {
		i=0;
	}
	document.getElementById('imgListingImage').src = ListingImages[i].src;
	document.getElementById('lblImgCount').innerHTML = i+1 + ' of ' + ListingImages.length;
}

function Backer(){
	if (i>0){
		i=i-1;
	}
	else {
		i=ListingImages.length-1;
	}
	document.getElementById('imgListingImage').src = ListingImages[i].src;
	document.getElementById('lblImgCount').innerHTML = i+1 + ' of ' + ListingImages.length;
}
var currentImage;
function ImgOn(obj,flag) {	
	if(currentImage==obj.id && flag!=1) return
	path = document.getElementById(obj.id).src;
	ext = path.substring(path.lastIndexOf("\."));
	var re = new RegExp (ext, 'gi') ;
	path = path.replace(re, "_f2"+ext);
	document.getElementById(obj.id).src = path; }

function ImgOff(obj,flag) {
if(currentImage==obj.id && flag!=1) return
	var re = new RegExp ('_f2', 'gi') ;
	path = document.getElementById(obj.id).src;
	path = path.replace(re, "");
	document.getElementById(obj.id).src = path; }
	
function CheckTable(DivName){
    var tmp = document.getElementById(DivName);
		elements = tmp.getElementsByTagName('*');				
		for(var i=0; i<elements.length;i++){ 
			if( elements[i].type == 'checkbox'){
				elements[i].checked = true;				
			}
		}	
	}

function CheckRegionOnLoad (county,flag)
{
    switch(county)
    {
    case 'M':
      county='Manhattan'
      break;    
    case 'B':
      county='Brooklyn'
      break;
    case 'Q':
      county='Queens'
      break;
    case 'X':
      county='Bronx'
      break;
    case 'N':      
      county='Nassau'
      break;
    case 'S':       
      county='Suffolk'
      break;
    case 'H':      
      county='Hamptons'
      break;  
    case 'NF':      
      county='North Fork'
      break;
    }
    el = document.getElementsByTagName('table');
    for(var y=0; y<el.length;y++){
        if(el[y].id.indexOf(county) >-1) {              
            document.getElementById(el[y].id).style.display='block';
            CheckTable(el[y].id)            
        }
    }
}

function getObjectHTTP()
{
    var xmlhttp = null
    if (navigator.userAgent.indexOf("MSIE")>=0)
    {
       xmlhttp = new ActiveXObject("Microsoft.XMLHTTP")
    }
    else
    {
       xmlHttp = new XMLHttpRequest()
    }
    return xmlhttp
}

function Reconnect1()
{
 var url='~/SessionRefresh.aspx.aspx'
 xmlHttp=getObjectHTTP()
 xmlHttp.open('GET', url , true) 
 xmlHttp.send(null)
}
