// Anti-spam Email function



function sendTo( recipient, subject ) {

  var host = location.hostname;

  if ( host.indexOf( "www" ) == 0 ) { host = host.substr( 4 ); }

  var email = recipient + "@" + host;

  if ( subject ) {

    document.write( "<a href=\"mailto:" + email + "?subject=" + subject + "\">" + email + "</a>" );

  }

  else {

    document.write( "<a href=\"mailto:" + email + "\">" + email + "</a>" );

  }

}



// Initialize Our Globals And Preload The Navigation



function init() {

  for ( i = 0; i < document.links.length; i++ ) {

    if ( document.links[ i ].focus ) { document.links[ i ].onfocus = document.links[ i ].blur; }

  }

  preloadImages( "images/nav_home-over.gif",

                 "images/nav_selling-over.gif",

                 "images/nav_order-over.gif",

                 "images/nav_buying-over.gif",

                 "images/nav_contact-over.gif" );

}



// Image Preload



var preloadFlag = false;

function preloadImages() {

  var d = document;

  if ( d.images ) {

    if ( !d.a ) { d.a = new Array(); }

    var i, j = d.a.length, arg = preloadImages.arguments;

    for ( i = 0; i < arg.length; i++ ) {

      d.a[ j ] = new Image;

      d.a[ j++ ].src = arg[ i ];

    }

    preloadFlag = true;

  }

}



// Image Rollovers



function changeImage( imgName, imgSource ) {

  if ( ( document.images ) && ( preloadFlag == true ) ) {

    document[ imgName ].src = imgSource;

  }

}



// Open Centered Virtualtour Window (External Function for Realtors)



function openVirtualTour( mlsNum ) {

  var w = 640;

  var h = 560;

  var l = ( screen.availWidth ) ? ( screen.availWidth - ( w + 12 ) ) / 2 : 0;

  var t = ( screen.availHeight ) ? ( screen.availHeight - ( h + 31 ) ) / 2 : 0;

  var opt = "height=" + h + ",width=" + w + ",top=" + t + ",left=" + l + ",status=no,scrollbars=no,resizable=no";

  //var lnk = "http://www.openhouse24-7.com/virtualtours.php?mls_num=" + mlsNum;
  var lnk = "virtualtours.php?mls_num=" + mlsNum;



  var mWin = null;

  mWin = window.open( lnk, "viewer", opt );

  if ( mWin ) {

    mWin.focus();

  }

}