////////////////////////////////////////////////////////////////////////////////
// Library of global JavaScript variables and functions to be used by the     //
// Application.                                                               //
//                                                                            //
// Copyright (c) 2002 SimaTalai.com   All Rights Reserved.                    //
// With the exception of valid licensees, use of this code in any manner is   //
// expressly prohibited.                                                      //
////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////
// GLOBAL VARIABLES
////////////////////////////////////////////////////////////////////////////////
var blnIsNS = navigator.appName.indexOf("Netscape")  != -1 ? 1 : 0;
var blnIsIE = navigator.appName.indexOf("Microsoft") != -1 ? 1 : 0;

var intScreenHeight = screen.height;
     if( intScreenHeight <=  480 ) intScreenHeight =  480;
else if( intScreenHeight <=  600 ) intScreenHeight =  600;
else if( intScreenHeight <=  768 ) intScreenHeight =  768;
else if( intScreenHeight <= 1024 ) intScreenHeight = 1024;
else if( intScreenHeight <= 1050 ) intScreenHeight = 1050;
else if( intScreenHeight <= 1200 ) intScreenHeight = 1200;
else intScreenHeight = screen.height; // Resolution height is > 1200.

////////////////////////////////////////////////////////////////////////////////
// FUNCTIONS
////////////////////////////////////////////////////////////////////////////////
function centerDialog(intWidth, intHeight)
{ var strParams;
  
  if ( intHeight == 0 )  // Allows for dialog to be aligned top.
    intHeight = intScreenHeight;

  if( blnIsIE )
  { strParams += ",left=" + (screen.width - intWidth)/2;
    strParams += ",top="  + (intScreenHeight - intHeight)/2;
  }
  else if( blnIsNS )
  { strParams += ",screenX=" + (screen.width - intWidth)/2;
    strParams += ",screenY=" + (intScreenHeight - intHeight)/2;
  }
  return strParams;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
var objCalculatorDlg = null;

function openCalculator(amount)
{ var intWidth   = 400;
  var intHeight  = 460;
  var strParams  = "width=" + intWidth + ",height=" + intHeight + ",menubar=0,scrollbars=0,status=0";
      strParams += centerDialog(intWidth, intHeight);
  var strURL  = "http://www.sfpru.com/calculator.jsp";
    if(amount)
      strURL += "?purchasePrice=" + amount + ".0&popup=true";
  
  if( objCalculatorDlg == null || objCalculatorDlg.closed )
    objCalculatorDlg = open(strURL, "ID_CALCULATOR", strParams);
  else
  { objCalculatorDlg.close();
    openCalculator(amount);
  }

}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
var objPhotoDlg = null;

function openPhoto(url)
{ var intWidth   = 280;
  var intHeight  = 320;
  var strParams  = "width=" + intWidth + ",height=" + intHeight + ",menubar=0,scrollbars=0,status=0";
      strParams += centerDialog(intWidth, intHeight);
  var strURL  = "images/listings/" + url;

  if( objPhotoDlg == null || objPhotoDlg.closed )
    objPhotoDlg = open(strURL, "ID_PHOTO", strParams);
  else
  { objPhotoDlg.document.location.href = strURL;
    objPhotoDlg.focus();
  }
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
var objVideoDlg = null;

function openVideo(url)
{ var intWidth   = 540;
  var intHeight  = 350;
  var strParams  = "width=" + intWidth + ",height=" + intHeight + ",menubar=0,scrollbars=0,status=0";
      strParams += centerDialog(intWidth, intHeight);
  var strURL  = "http://media.homestore.com/" + url + ".htm";

  if( objVideoDlg == null || objVideoDlg.closed )
    objVideoDlg = open(strURL, "ID_VIDEO", strParams);
  else
  { objVideoDlg.document.location.href = strURL;
    objVideoDlg.focus();
  }
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
var objMapDlg = null;

function openMap(root)
{ var intWidth   = 475;
  var intHeight  = 415;
  var strParams  = "width=" + intWidth + ",height=" + intHeight + ",menubar=0,scrollbars=0,status=0";
      strParams += centerDialog(intWidth, intHeight);
  var strURL  =  "img/sfmap.gif" 
  if( !root ) strURL = "../" + strURL;

  if( objMapDlg == null || objMapDlg.closed )
    objMapDlg = open(strURL, "ID_MAP", strParams);
  else
    objMapDlg.focus();
}
