﻿// JScript File


////////////////////////////////////////////////////////////////////
  //This is for Properties PushPins
////////////////////////////////////////////////////////////////////////////////////////
function GetProps() {
    map.DeleteAllShapes();
     // var PropGridViewDiv = $get('PropGridView');
    //PropGridViewDiv.innerHTML = "";    
    //  NOw Check to see if Zip or Town Has Been Checked.
if ($get('Radiotown').checked == 1) {
        town = $get('ddlTown').value;
        ziportownsearch = 1;
          ret = IDXService.GetPropertiesInfo($get('txtMin').value,$get('txtMax').value,$get('ddBeds').value,$get('ddBaths').value,'','','','', town,'',$get('ddlGarage').value,$get('ddlStyle').value,$get('ddlYearBuilt').value,$get('ddlTimeOnMarket').value,$get('ddlAcreage').value,$get('ddlSquareFeet').value, WebServiceCallBackProp, OnTimeOut, OnError);
    }
    else { 
    if ($get('RadioZip').checked == 1) {
        zipcode = $get('ddlZip').value;
        ziportownsearch = 1;
        ret = IDXService.GetPropertiesInfo($get('txtMin').value,$get('txtMax').value,$get('ddBeds').value,$get('ddBaths').value,'','','','', '',zipcode,$get('ddlGarage').value,$get('ddlStyle').value,$get('ddlYearBuilt').value,$get('ddlTimeOnMarket').value,$get('ddlAcreage').value,$get('ddlSquareFeet').value, WebServiceCallBackProp, OnTimeOut, OnError);        
    }
    else {
        ziportownsearch = 0;
        ret = IDXService.GetPropertiesInfo($get('txtMin').value,$get('txtMax').value,$get('ddBeds').value,$get('ddBaths').value,$get('TxtLat1').value,$get('TxtLng1').value,$get('TxtLat2').value,$get('TxtLng2').value, '','',$get('ddlGarage').value,$get('ddlStyle').value,$get('ddlYearBuilt').value,$get('ddlTimeOnMarket').value,$get('ddlAcreage').value,$get('ddlSquareFeet').value, WebServiceCallBackProp, OnTimeOut, OnError);           
    } 
}
//ret = IDXService.GetPropertiesInfo($get('txtMin').value,$get('txtMax').value,$get('ddBeds').value,$get('ddBaths').value,$get('TxtLat1').value,$get('TxtLng1').value,$get('TxtLat2').value,$get('TxtLng2').value, '','',$get('ddlGarage').value,$get('ddlStyle').value,$get('ddlYearBuilt').value,$get('ddlTimeOnMarket').value,$get('ddlAcreage').value,$get('ddlSquareFeet').value, WebServiceCallBackProp, OnTimeOut, OnError);


//ret = IDXService.GetPropCount($get('txtMin').value,$get('txtMax').value,$get('ddBeds').value,$get('ddBaths').value,$get('TxtLat1').value,$get('TxtLng1').value,$get('TxtLat2').value,$get('TxtLng2').value, '',''$get('ddlTown').value,$get('ddlZip').value,$get('ddlGarage').value,$get('ddlStyle').value,$get('ddlYearBuilt').value,$get('ddlTimeOnMarket').value,$get('ddlAcreage').value,$get('ddlSquareFeet').value, GetPropCountOnComplete, OnTimeOut, OnError);

// ret2 = IDXService.GetPropertiesInfo($get('txtMin').value,$get('txtMax').value,$get('ddBeds').value,$get('ddBaths').value,$get('TxtLat1').value,$get('TxtLng1').value,$get('TxtLat2').value,$get('TxtLng2').value,$get('ddlTown').value,$get('ddlZip').value,$get('ddlGarage').value,$get('ddlStyle').value,$get('ddlYearBuilt').value,$get('ddlTimeOnMarket').value,$get('ddlAcreage').value,$get('ddlSquareFeet').value,$get('ddlAcreage').value,WebServiceCallBackProp,OnTimeOut, OnError); 	
 //ByVal LPmin As String, ByVal LPMax As String, ByVal beds As String, ByVal baths As String, ByVal toplat As String, ByVal toplng As String, ByVal botlat As String, ByVal botlng As String, ByVal townid As String, ByVal Zipcode As String, ByVal garges As String, ByVal Style As String, ByVal YearsOld As String, ByVal DOM As String, ByVal acres As String, ByVal SqFt As String
 //ret2 = IDXService.GetPropertiesInfo($get('txtMin').value,$get('txtMax').value,$get('ddBeds').value,$get('ddBaths').value,$get('TxtLat1').value,$get('TxtLng1').value,$get('TxtLat2').value,$get('TxtLng2').value,$get('Townid').value,$get('Zipcode').value,WebServiceCallBackProp,OnTimeOut, OnError); 	
        var busydiv = $get('SearchingDiv');
	busydiv.style.visibility = "visible";	
}

 
function WebServiceCallBackProp(Response)
{     
    //var tableinfo = $get('Tableinfo').value;
    //var PropGridViewDiv = $get('PropGridView');
    //PropGridViewDiv.innerHTML = tableinfo;
    
    //Remove old pins
    if( pinid > 2) {
        	DeleteAllShape();
        	pinid = 1;
    }
    //You need to check for If Town is checked.
    
    
    propertyArray = Response;
    for(var i = 0;i< Response.length;i++)
    {
        
        AddPropPushPin(Response[i], i);
        //AddPropRow(Response[i], i);        
               
    }        
    var busydiv = $get('SearchingDiv');
	busydiv.style.visibility = "hidden";                                
}

function ParsePropInfo(lmlsnum, laddress, lbeds,lbaths,lsqrfeet,llistprice,lurl, pinidlcl, lclimagesArray) {
    var PopUpDesc = null;
    //alert(DescInfo.toString());
    //alert(TownName);
    var imagedom = 'img' + lmlsnum;
    //alert (imagedom);
    //PopUpDesc += "<td><tr><img id='" + imagedom +"' height='75' width='100' src='ctimages/" + lclimagesArray[0].ImageUrl + "'></tr></td>";
    //Old code that is basic
    
//    PopUpDesc = "<table><td><tr style='color:Blue;'> PinId:" + pinidlcl + "</tr></td>";
//    PopUpDesc += "<td><tr style='color:Blue;'> Mlsnum:" + lmlsnum + "</tr></td>";
//    PopUpDesc += "<td><tr style='color:Blue;'>" + laddress + "</tr></td>";
//    PopUpDesc += "<td><tr>Beds:" + lbeds + " Baths: " + lbaths +"</tr></td>";
//    PopUpDesc += "<td><tr>SqrtFeet:" + lsqrfeet +"</tr></td>";
//    PopUpDesc += "<td><tr>ListPrice: $" + llistprice + "</tr></td>";
//    PopUpDesc += "<td><tr><img id='" + imagedom + "' height='75' width='100' src='http://www.e-gurus.net/thewashingtonagency/ctimages/" + lclimagesArray[0].ImageUrl + "'></tr></td>";
//    PopUpDesc += "<td><tr>1 of" + (lclimagesArray.length+1) + "</tr></td>";
//    PopUpDesc += "<td><tr><a href='javascript:void(0);' onclick='ShowDetails("+ lmlsnum + ");'";
//    PopUpDesc += ">Show Details</a>";    
//    PopUpDesc += "</tr></td>";
//    PopUpDesc += "</table>";
    
        PopUpDesc = "<table style='padding:0px;' border='0'><tr><td rowspan='5' style=''>";
        //If there is no Image the just show blank
        if (lclimagesArray[0].ImageType == "99") {
            PopUpDesc += "<img id='" + imagedom + "' height='75' width='100' src='http://www.thewashingtonagency.net/images/too_new_105.gif'></td> <td style='width: 24px; height: 20px'>";
            }
        else {
            PopUpDesc += "<img id='" + imagedom + "' height='75' width='100' src='http://www.thewashingtonagency.net/ctimages/" + lclimagesArray[0].ImageUrl + "'></td> <td style='width: 24px; height: 20px'>";
        }
        PopUpDesc += "</td><td style='width: 108px; height: 20px; text-align: right;'>";
        PopUpDesc += llistprice;
        PopUpDesc += "</td><td rowspan='2' style='width: 58px'>";
        PopUpDesc += "</td></tr><tr><td style=''></td>";
        PopUpDesc += "<td style='width: 108px; height: 19px; text-align: right;'>";
        PopUpDesc += lbeds + " Beds" + lbaths + " Baths";
        PopUpDesc += "</td></tr><tr><td style=''>";
        PopUpDesc += "</td><td style='width: 108px; height: 19px; text-align: right;'>";
        PopUpDesc += lsqrfeet + " SqrFt";
        PopUpDesc += "</td><td rowspan='2' style='width: 58px'></td></tr><tr>";
        PopUpDesc += "<td style=''></td><td style='width: 108px; height: 19px; text-align: right;'>";
        PopUpDesc += laddress;
        PopUpDesc += "</td></tr><tr><td style=''>";
        PopUpDesc += "</td><td style='width: 108px; height: 21px'></td>";
        PopUpDesc += "<td style='width: 58px; height: 21px'></td></tr><tr>";
        PopUpDesc += "<td style='width: 146px; height: 21px; text-align: center;'>";
        PopUpDesc += "<a href='javascript:ViewDetails(\""+ lmlsnum + "\");'>View Details</a>";
        PopUpDesc += "</td><td style=''> </td>";
        PopUpDesc += "<td style='width: 108px; height: 21px'></td><td style='width: 58px; height: 21px'>";
        PopUpDesc += "</td></tr><tr><td style='width: 146px'></td><td style='width: 24px'></td><td style='width: 108px'></td><td style='width: 58px'></td></tr></table>";
    
    
//    PopUpDec = "<div class='listingBalloon lbBottomLeft' id='InfoBalloon' style='DISPLAY: inline; Z-INDEX: 30; LEFT: 100px; POSITION: absolute; TOP: 202px' ListingID='-10000'><DIV class='ListingBalloonContainer' id='ListingBalloonInner' onmouseover='javascript:clearHideTimer();' onmouseout='javascript:SetHideTimer();'>";
//    //PopUpDec = "<div class='listingBalloon lbBottomLeft'><DIV class='ListingBalloonContainer' id='ListingBalloonInner' onmouseover='javascript:clearHideTimer();' onmouseout='javascript:SetHideTimer();'>";
//    PopUpDec += "<div class='ListingImageContainer'>";
//    PopUpDec += "<table height='80' cellspacing='0' cellpadding='0' width='105' border='0'>";
//    PopUpDec += "<tbody><tr><td valign='center' align='middle'>";
//    PopUpDec += "<div id='divImageContainer'><IMG src='http://www.e-gurus.net/clonefore/images/too_new_105.gif' width='105'></div>";
//    PopUpDec += "</td></tr></tbody></table></div>";
//    PopUpDec += "<div id='divShowImageCount' style='LEFT: 10px; WIDTH: 105px; POSITION: absolute; TOP: 85px; TEXT-ALIGN: center'></div>";
//    PopUpDec += "<div class='ListingDetailLinkContainer'><A class='viewdetail' href='javascript:void(0);'>View property details</A></div>";
//    PopUpDec += "<div class='ListingInfoContainerList'><b>$532,339.40</b><br />3 Crestwood Court<br /><br />File Date:7/2/2007<br />Docket Number:F769895<br />Plaintiff:Norwest Mortgage, Inc<br>Defendant:Alan Doren; et al<br>Attorney:<br></div>";
//    PopUpDec += "<div class='ListingBalloonIcon listing'>16</div><br /><br />";
//    PopUpDec += "<div class='ListingPinOnOff' id='divPinOnOff'>";
//    PopUpDec += "<a onclick='javascript:PinOff();' href='javascript:void(0);'>";
//    PopUpDec += "<img alt='Pin Off' src='http://www.e-gurus.net/clonefore/images/PinOff.gif' border='0' /></a>";
//    PopUpDec += "</div>";
//    PopUpDec += "</div> ";
//    
return PopUpDesc;
}

function nextimage(lclmlsnum, lclpinid) { 
    //alert(propertyArray[lclpinid].ImagesArray[2].ImageUrl);
    var imageelementid;
    imageelementid = 'img' + lclmlsnum;
    alert(imageelementid);
    alert(propertyArray[lclpinid].ImagesArray[2].ImageUrl);
    $get(imageelementid).src = "http://www.e-gurus.net/thewashingtonagencyfinal/ctimages/" + propertyArray[lclpinid].ImagesArray[2].ImageUrl;
    //$get(imgdom).src = propertyArray[lclpinid].ImagesArray[2].ImageUrl;
}

function previmage(pinnum, imgdom, imagearray) {   
    $get(imgdom).src = imagearray[0].ImageUrl;
}


function AddPropPushPin(point, index)
{
	var shape = new VEShape(VEShapeType.Pushpin, new VELatLong(point.Latitude, point.Longitude));
	//shape.SetTitle(point.Name);

	
	shape.SetDescription(ParsePropInfo(point.mlsnum,point.StreetAddress,point.beds,point.baths,point.SqrFeet,point.ListPrice,point.imageurl, pinid,point.ImagesArray));	
	var cssClass="listing";
	//"<span style='" +
	//   "width:25px;height:15px;padding-top:6px;overflow:visible;cursor:pointer;background-image:url('images/property_icon.gif');background-repeat:no-repeat;" +
	 //   "z-index:20;font-family:Tahoma;text-align:center;vertical-align:middle;font-size:7.5pt;color:White;'>" +
	 
	// DOM code and see if it is Washington AGency to sedt Icon?
	//Cahneg Index number to be 1 based not zero.
    if (index < 10 ){
	    shape.SetCustomIcon("<img src='images/property_icon.gif' />" +
	    "<span style='font-family:Tahoma;font-size:7.5pt;position:relative; left:-16px; top:-6px;color:#FFFFFF'>" +  index + "</span>");	    	     
	    }else {
	     shape.SetCustomIcon("<img src='images/property_icon.gif' />" +
	    "<span style='font-family:Tahoma;font-size:7.5pt;position:relative; left:-18px; top:-6px;color:#FFFFFF'>" +  index + "</span>");
	    }
	pinid++;
    proplayer.AddShape(shape);
   
}

//Chnage this to Windows Manger or Right Panel
function ViewDetails(mlsnum) {
        url2 = "listingdetails.aspx?mlsnum=" + mlsnum;
    //alert(url);
    win2=document.open(url2,"The_Washington_AgencyPicture","top=5,left=5,height=600,width=800,resizable=0,menubar=0,toolbar=0,location=0,directories=0,scrollbars=1,status=0");



}
