#!/usr/bin/perl
print "Content-type: text/html\n\n";
require "config.idx";

print qq~
<html>
<head>
<title>The ORR Home Selling Team >> RE/MAX Real Estate Groups >> Showcase Properties</title>
~;

&header;

print qq~
<td valign="top" width="581">
	<img src="images/headers/showcase_properties.gif" width="581" height="33" alt="The ORR Home Selling Team Showcase Properties"><br><br>
<center>
<table border="0" cellpadding="0" cellspacing="0" width="580">
<tr>
<td width="580" valign="top">


<style type="text/css">

.display {
width: 579px;
background-color: white;

}

.display_box {

width: 191;
position: relative;
float: left;
margin: 1px;
background: url(images/feature_listing_bg.gif) no-repeat;
}

.display_header {
	width: 191px;
	height: 19px;
	padding-top: 5px;
	margin: 0px;
	border: 0px;
	position: relative;
        letter-spacing: -1;
	text-align:center;
	font-family: Arial; font-size: 9pt; color: #FFFFFF; font-weight: bold;
    overflow: hidden; 
}

.display_data {
width: 191;
height: 130;
margin: 0px;
border: 0px solid navy;
position: relative;
float: left;
}

.display_data .image {
position: absolute;
  top: 10px;
  left: 5px;
  height: 61;
  width: 82;
}

.display_data .vt {
position: absolute;
top: 75px;
left: 5px;
height: 20;
width: 82;
}

.display_data .price {
position: absolute;
  top: 10px;
  left: 100px;
  font-family: Tahoma; font-size: 9pt; color: green; font-weight: bold;
}

.display_data .type {
position: absolute;
  top: 25px;
  left: 100px;
  font-family: Tahoma; font-size: 8pt; color: navy; font-weight: bold;
}

.display_data .sqft {
position: absolute;
  top: 40px;
  left: 100px;
  font-family: Tahoma; font-size: 8pt; color: navy; font-weight: bold;
}

.display_data .beds {
position: absolute;
  top: 55px;
  left: 100px;
  font-family: Tahoma; font-size: 8pt; color: navy; font-weight: bold;
}

.display_data .f_baths {
position: absolute;
  top: 70px;
  left: 100px;
  font-family: Tahoma; font-size: 8pt; color: navy; font-weight: bold;
}

.display_data .h_baths {
position: absolute;
  top: 85px;
  left: 100px;
  font-family: Tahoma; font-size: 8pt; color: navy; font-weight: bold;
}

.display_data .more_info {
position: absolute;
  top: 105px;
  left: 15px;
}

.display_data .more_info img {
  margin-right: 2px;
}

h2 {
font-size: 24px;
color: white;
background-color: navy;
padding: 3px;
margin: 0px;
margin-bottom: 3px;
text-align: center;
font-family: Tahoma;
font-weight: bold;
letter-spacing: -1px;
text-decoration: none;
border-style: double;
}

.clear {
clear: both;
}




</style>
<h2>Residential Properties For Sale!</h2>
<div class="display">
~;

$ml_name = "muncieml_db1";
$ml_username = "muncieml_db1";
$ml_pass = "\@rockdb1";
$ml_host = "localhost";

use DBI;
my $dsn = "DBI:mysql:database=$ml_name;host=$ml_host";
my $dbh = DBI->connect($dsn, $ml_username, $ml_pass, {RaiseError => 1}) || die $DBI::errstr;

my $pasth = $dbh->prepare("select MLSNUM,Price,AddressNumber,AddressDirection,AddressStreet,City,Zip,Bedrooms,FullBaths,HalfBaths,TotalSqFt,VirtualTourURL FROM listings_res3 WHERE AgentID = '122' OR AgentID = '600' order by Price desc");
$pasth->execute;


while (($mlsnum,$price,$addressnumber,$addressdirection,$addressstreet,$city,$zip,$bedrooms,$fullbaths,$halfbaths,$sqft,$VirtualTourURL) = $pasth->fetchrow_array()) {

$addressstreet =~ s/County Road/CR/gi;

$price = &commas($price);

$showpicture = &image_format("thumbnail","$mlsnum");

if ($VirtualTourURL =~ /http|www|visualtour/i) { $toururl =qq~<div class="vt"><a href="$VirtualTourURL" target="_blank"><img src="images/viewvirtualtour_small.jpg" height="20" width="82" alt="Click to View Virtual Tour" border="0"></a></div>~; }

print qq~

<div class="display_box">
   <div class="display_header">$addressnumber $addressdirection $addressstreet, $city</div>
   <div class="display_data">
      <div class="image"><a href="showdetails.idx?mlsnumber=$mlsnum"><img src="$showpicture" width="82" height="61" border=0></a></div>
		$toururl
          <div class="price">\$$price</div>
          <div class="type">Residential</div>
          <div class="sqft">Sq Ft: $sqft</div>
          <div class="beds">Bedrooms: $bedrooms</div>
          <div class="f_baths">Full Baths: $fullbaths</div>
          <div class="h_baths">Half Baths: $halfbaths</div>
      <div class="more_info"><img src="images/moreinfo.gif"><a href="http://$mlsnum.ORRHomes.com">View Property Details</a></div>
   </div>
</div>

~;
$found_residential = "yes";
$toururl = "";
}
unless ($found_residential eq "yes") {
print qq~<h3>No Residential Found</h3>~;
}


print qq~
</div>
<div class="clear"></div>
<br>
<h2>Investment For Sale!</h2>
~;
my $invasth = $dbh->prepare("select MLSNUM,Price,AddressNumber,AddressDirection,AddressStreet,Address2,City,State,Zip,AgentID,TotalSqFt,Acres,EstimatedAnnualTax FROM listings_inv3 WHERE AgentID = '122' OR AgentID = '600' order by Price desc");
$invasth->execute;
while (($mlsnum,$price,$addressnumber,$addressdirection,$addressstreet,$address2,$city,$state,$zip,$agentid,$sqft,$acres,$annualtax) = $invasth->fetchrow_array()) {
	$addressstreet =~ s/County Road/CR/gi;
	$price = &commas($price);
	$showpicture = &image_format("thumbnail","$mlsnum");
	if ($VirtualTourURL =~ /http|www|visualtour/i) { $toururl =qq~<div class="vt"><a href="$VirtualTourURL" target="_blank"><img src="images/viewvirtualtour_small.jpg" height="20" width="82" alt="Click to View Virtual Tour" border="0"></a></div>~; }
	print qq~
		<div class="display_box">
		   <div class="display_header">$addressnumber $addressdirection $addressstreet, $city</div>
			   <div class="display_data">
			      <div class="image"><a href="showdetails_investment.idx?mlsnumber=$mlsnum"><img src="$showpicture" width="82" height="61" border=0></a></div>
				  $toururl
	    	      <div class="price">\$$price</div>
		          <div class="type">Commercial</div>
	              <div class="sqft">SQFT: $sqft</div>
	      	      <div class="beds">Tax: \$$annualtax</div>
	        	  <div class="f_baths">Acres: $acres</div>
		          <div class="more_info"><img src="images/moreinfo.gif"><a href="http://$mlsnum.ORRHomes.com">View Property Details</a></div>
			   </div>
		</div>
~;
$found_investment = "yes";
}
unless ($found_investment eq "yes") {
print qq~<h3>No Investments Found</h3>~;
}



print qq~
</div>
<div class="clear"></div>
<br>
<h2>Lots & Land For Sale!</h2>
~;
my $uasth = $dbh->prepare("select MLSNUM,Price,AddressNumber,AddressDirection,AddressStreet,City,Zip,AgentID,Acres,Water,Sewer,Electric FROM listings_lan3 WHERE AgentID = '122' OR AgentID = '600' order by Price desc");
$uasth->execute;
while (($mlsnum,$price,$addressnumber,$addressdirection,$addressstreet,$city,$zip,$agentid,$acres,$water,$sewer,$electric) = $uasth->fetchrow_array()) {
	$addressstreet =~ s/County Road/CR/gi;
	$price = &commas($price);
	$showpicture = &image_format("thumbnail","$mlsnum");
	if ($VirtualTourURL =~ /http|www|visualtour/i) { $toururl =qq~<div class="vt"><a href="$VirtualTourURL" target="_blank"><img src="images/viewvirtualtour_small.jpg" height="20" width="82" alt="Click to View Virtual Tour" border="0"></a></div>~; }
		if ($water eq "") { $water = "N/A"; }
		if ($sewer eq "") { $sewer = "N/A"; }
		if ($electric eq "") { $electric = "N/A"; }
	print qq~
		<div class="display_box">
		   <div class="display_header">$addressnumber $addressdirection $addressstreet, $city</div>
			   <div class="display_data">
			      <div class="image"><a href="showdetails_land.idx?mlsnumber=$mlsnum"><img src="$showpicture" width="82" height="61" border=0></a></div>
				  $toururl
	    	      <div class="price">\$$price</div>
		          <div class="type">Lots & Land</div>
		          <div class="sqft">$acres Acres</div>
	      	      <div class="beds">Water: $water</div>
	        	  <div class="f_baths">Sewer: $sewer</div>
	              <div class="h_baths">Electric: $electric</div>
		          <div class="more_info"><img src="images/moreinfo.gif"><a href="http://$mlsnum.ORRHomes.com">View Property Details</a></div>
			   </div>
		</div>
~;
$found_land = "yes";
}
unless ($found_land eq "yes") {
print qq~<h3>No Lots & Land Found</h3>~;
}




print qq~
</div>
<div class="clear"></div>
<br>
<h2>Commercial For Sale!</h2>
~;
my $uasth = $dbh->prepare("select MLSNUM,Price,AddressNumber,AddressDirection,AddressStreet,Address2,City,State,Zip,AgentID,TotalSqFt,Stories,Acres FROM listings_com3 WHERE AgentID = '122' OR AgentID = '600' order by Price desc");
$uasth->execute;
while (($mlsnum,$price,$addressnumber,$addressdirection,$addressstreet,$address2,$city,$state,$zip,$agentid,$sqft,$stories,$acres) = $uasth->fetchrow_array()) {
	$addressstreet =~ s/County Road/CR/gi;
	$price = &commas($price);
	$showpicture = &image_format("thumbnail","$mlsnum");
	if ($VirtualTourURL =~ /http|www|visualtour/i) { $toururl =qq~<div class="vt"><a href="$VirtualTourURL" target="_blank"><img src="images/viewvirtualtour_small.jpg" height="20" width="82" alt="Click to View Virtual Tour" border="0"></a></div>~; }
	print qq~
		<div class="display_box">
		   <div class="display_header">$addressnumber $addressdirection $addressstreet, $city</div>
			   <div class="display_data">
			      <div class="image"><a href="showdetails_commercial.idx?mlsnumber=$mlsnum"><img src="$showpicture" width="82" height="61" border=0></a></div>
				  $toururl
	    	      <div class="price">\$$price</div>
		          <div class="type">Commercial</div>
	              <div class="sqft">SQFT: $sqft</div>
	      	      <div class="beds">Stories: $stories</div>
	        	  <div class="f_baths">Acres: $acres</div>
		          <div class="more_info"><img src="images/moreinfo.gif"><a href="http://$mlsnum.ORRHomes.com">View Property Details</a></div>
			   </div>
		</div>
~;
$found_commercial = "yes";
}
unless ($found_commercial eq "yes") {
print qq~<h3>No Commercial Found</h3>~;
}


$dbh->disconnect;

print qq~


</table>
</center>
</td>
~;
&footer;

sub commas {
	local($_)=@_;
	1 while s/(.*\d)(\d\d\d)/$1,$2/;
	$_;
}
