﻿var mapDetail = null;
var pinPoint = null;
var pinPixel = null;
var LoadMapFlag = false;
var strTitle="";

/*
function showTB(DivId,strPropertyId,strPropType)  { 
    
    blnView = false;
    LoadMapFlag = false;
    ListingDetailService.GetDetailReport(strPropertyId,strPropType,DetailSuccess, DetailFail);
           
} */

function showTB_Home_Iframe(strTitle,strURL,strListingTag)  { 

    if (blnRes800 == "true") {     
        //showProgBarOH('2');  //1 - loading Details progress bar
        //showLoadingMessage_Home('PropDetLB');
        ShowLoadingMessage_ShowPrompt('PropDetLB');
        
        fncDetailWin("SearchDetails.aspx?ListingTag=" + strListingTag ,'DetWinPrint') ;        
        //SetNormalScreen();
        SetNormalScreen_Prompt();
        //grayOut(false);
    } else {    
        //showProgBarOH('2');  //1 - loading Details progress bar
        //showLoadingMessage_Home('PropDetLB');
        //showLoadingMessage('undefined', 'PropDetLB');
        ShowLoadingMessage_ShowPrompt('PropDetLB');
        
        document.getElementById('divVideo').style.display='none';
        //document.getElementById('divMortgage').style.display='none';        

        tb_show(strTitle,strURL);
   }
}

function showTB_Home(DivId,strPropertyId,strPropType)  { 
    
    showProgBarOH('2');  //1 - loading Details progress bar
    
    blnView = false;
    LoadMapFlag = false;
    strTitle = GetTitle(strPropType);
    //ListingDetailService.GetOpenHouseDetailReport(strPropertyId,strPropType,DetailSuccess, DetailFail);
    ListingDetailService.GetDetailReport(strPropertyId,strPropType,DetailSuccess, DetailFail);      
} 

function showProgBarOH() {
    
    SetProgressBarTitle(5);
    	
	var progBar = document.getElementById("divProgressBar");
	var windowHeight = pageHeight();
	var windowWidth = pageWidth();
	var barLeft = (windowWidth + 250 ) / 2;
	var barTop = getScrollXY() + 20;
	barLeft = 0;
			
	//grayOut(true);
    
	//progBar.style.display = "block";
	progBar.style.width = "300px";
	//	progBar.style.height = "200px";
	progBar.style.backcolor = "white";
	progBar.style.position = "absolute";
	progBar.style.borderwidth = "4px";
	progBar.style.bordercolor = "Navy";
	//progBar.style.left = barLeft + "px";	
	//progBar.style.Top = barTop + "px";
progBar.style.paddingLeft = "250px";
    //progBar.style.paddingTop = barTop + "px"; //screen.height/2-250;
 
	progBar.style.display="";
	
//bar1.showBar();

}



function showTB1(DivId,strPropertyId,strPropType)  { 
    
    blnView = false;
    
    DetailSuccess1('test');
         
}    
function DetailSuccess(e){

    var strLighBoxDims ="height=530&width=955";
    if (screen.width < 1024) strLighBoxDims ="height=350&width=750";
    
    var newURL = "#TB_inline?" + strLighBoxDims + "&inlineId=popContent"; 
    
    //var strTitle  = "Res/Condo";

    $get('popContent').innerHTML = e;
    
    if (e != "") {
        //ShowHideTabPanels(strPropType);
        /*toggleDisplayOff ('gallery-area');
        toggleDisplayOff ('RoomInfo');
        toggleDisplayOff ('Map');*/
                
        document.getElementById('divVideo').style.display='none';
        //document.getElementById('divMortgage').style.display='none';
        
        tb_show(strTitle, newURL); 
                
        document.getElementById("spnOfficeName_Det").innerHTML = wordwrap(strOfficeName, 26, "<br/>\n" );        
        document.getElementById("spnRemarks").innerHTML  = convertQuotesForRemarks(strRemarks);
        ShowHideTabPanels(varPropType,varOpenHouse);
        
        HideOHProgBar();
        
    } else {
        alert('No Details');
    }
    
   // tb_show(strTitle + " Details", newURL);
    
}

function HideOHProgBar() {
alert('in hide');
	var progBar = document.getElementById("divProgressBar");
	
	progBar.style.display = "none";
	
	
	grayOut(false);
	
	//bar1.hideBar();


}

function ShowHideTabPanels_OpenHouse(varPropType,varOpenHouse) {

    toggleDisplayOff ('gallery-area');
    toggleDisplayOff ('Map');
        
    switch (varPropType) {
        case "RS":
            toggleDisplayOff ('RoomInfo');
            if (!(varOpenHouse.toLowerCase() == "false")) toggleDisplayOff ('OpenHouse');
            break;

        case "CO":
            toggleDisplayOff ('RoomInfo');
            if (!(varOpenHouse.toLowerCase() == "false")) toggleDisplayOff ('OpenHouse');
            break;     
    }

}


function LoadBingMap (){
    //alert('in bing=' + LoadMapFlag);
    LoadMap_Detail();
    if (!(LoadMapFlag)) LoadMapFlag = true;
    
}
function LoadMap_Detail(){
    
    if (!(LoadMapFlag)) {
        //var map = null;
        var strLatLong = document.getElementById('hidLatLong').value;
        
        var arrLatLon = strLatLong.split(",");
        
        var strLatVal = arrLatLon[0];
        var strLonVal = arrLatLon[1];
        
       //var LA = new VELatLong(42.479876,-82.901402);
        var LA = new VELatLong(arrLatLon[0],arrLatLon[1]);

        mapDetail = new VEMap('myMapDetail');

        mapDetail.SetDashboardSize(VEDashboardSize.Small);
        mapDetail.LoadMap(LA, 14, VEMapStyle.Road, false, VEMapMode.Mode2D, true, 1);

        pinPoint = mapDetail.GetCenter();
        pinPixel = mapDetail.LatLongToPixel(pinPoint);
        mapDetail.AddPushpin(pinPoint);
   }
                      
}

function LoadMap_Detail_1(){
    
    //var map = null;
    var strLatLong = document.getElementById('hidLatLong').value;
   // alert(strLatLong );
    
     var arrLatLon = strLatLong.split(",");
    
    var strLatVal = arrLatLon[0];
    var strLonVal = arrLatLon[1];
    
   //var LA = new VELatLong(42.479876,-82.901402);
    var LA = new VELatLong(arrLatLon[0],arrLatLon[1]);

    mapDetail = new VEMap('myMapDetail');

    mapDetail.SetDashboardSize(VEDashboardSize.Small);
    mapDetail.LoadMap(LA, 14, VEMapStyle.Road, false, VEMapMode.Mode2D, true, 1);

    pinPoint = mapDetail.GetCenter();
    pinPixel = mapDetail.LatLongToPixel(pinPoint);
    mapDetail.AddPushpin(pinPoint);
                      
}

function DetailSuccess1(e){

    var strLighBoxDims ="height=530&width=955";
    if (screen.width < 1024) strLighBoxDims ="height=350&width=750";
    alert(screen.width + ";" + screen.height + ";" + strLighBoxDims);
    var newURL = "#TB_inline?" + strLighBoxDims + "&inlineId=popContent"; 
    
    var strTitle  = "Res/Condo";

    //WriteHighSlideScripts();
    
    //$get('popContent').innerHTML = e;
    
    if (e != "") {
        //ShowHideTabPanels(strPropType);
        
    //LoadGalleria();
        tb_show(strTitle + " Details", newURL); 
    }
    
    tb_show(strTitle + " Details", newURL); 
    
}

function DetailFail(e) {
    //Process Request Failure
        alert(e);
}


function fncDetailWin(strURL){

    window.open(strURL,"DetailWin","toolbar=no,status=no,resizable=yes,scrollbars=yes,location=no,menubar=no,directories=no,width=" + screen.width + ",height=" + screen.height + ",top=0,left=0"); 
}
