﻿//FastQuotePageScript.js

Sys.Application.add_load(page_load);
Sys.Application.add_unload(page_unload);
//virtual earth map
var vemap = null;
function page_load() {
    //$get('hiddenFieldScreenWidth').value = screen.width;
    //$get('hiddenFieldScreenHeight').value = screen.height;
    if (vemap == null && typeof VEMap != 'undefined')
        vemap = new VEMap('mapDiv');
  

    VerifySearchResults();
    
    

}

function page_unload() {
}

//handler for a landmark link click
function linkButtonLandmarkClicked(param) {
    //add random text to avoid request caching
    var param2 = param + "|" + Math.random();
    $get('tbMonitorLandmarkLinks').value = param2;
    __doPostBack('tbMonitorLandmarkLinks', '');
}

function hideMap() {


    $get("mapDiv").style.width = 1;
    $get("mapDiv").style.height = 1;


    $get("buttonCloseMap").style.display = "none";
//    //vemap = null;
    return false;
}


function showMap(latitude, longitude, zoom, topPos, leftPos) {

//    var panel = $get("panelModalMapLayer");

//    panel.style.filter = "alpha(opacity =70)";
//    panel.style.opacity = "0.7";
//    panel.style.display = "block";
//    panel.style.width = screen.width;
//    panel.style.height = screen.height;
//    panel.style.top = "0px";
//    panel.style.left = "0px";
//    panel.style.zIndex = 10000;


    var mapDiv = $get("mapDiv");
    var  buttonCloseMap =  $get("buttonCloseMap");

    mapDiv.style.width = 450;
    mapDiv.style.height = 450;
    
    if (!buttonCloseMap.style.width)
        buttonCloseMap.style.width = 80;
        
    if (topPos) {
        mapDiv.style.top = topPos;
        buttonCloseMap.style.top = parseInt(topPos, 10);
    }
    if (leftPos) {
        mapDiv.style.left = leftPos;
        buttonCloseMap.style.left = parseInt(leftPos, 10) + parseInt(mapDiv.style.width, 10) - parseInt(buttonCloseMap.style.width, 10);
    }

    buttonCloseMap.style.zIndex = 20004;
    buttonCloseMap.style.display = "block";


    vemap.onLoadMap = function() {
        AddPushpin(vemap, latitude, longitude);
        vemap.ZoomIn();
    };
   
    vemap.AttachEvent('onobliqueenter', OnObliqueEnterHandler);
    vemap.LoadMap(new VELatLong(latitude, longitude), zoom, 'r', false);
    //this removes the annoing message about bird's eye view
    if($get('MSVE_obliqueNotification'))
        $get('MSVE_obliqueNotification').innerHTML = "";



}

function AddPushpin(map, latitude, longitude, title, description) {
    map.DeleteAllShapeLayers();

    var shape = new VEShape(VEShapeType.Pushpin, new VELatLong(latitude, longitude));

    shape.SetTitle(title ? title : "");
    shape.SetDescription(description ? description : "");
    map.AddShape(shape);
}

function OnObliqueEnterHandler() {
    if (vemap.IsBirdseyeAvailable()) {
        //vemap.DeleteAllShapeLayers();
    }
}

function DateSelectionChanged(calendar) {
    var date1 = calendar.get_visibleDate();
    
}
  
  
  function VerifySearchResults() {
      var panelSearchResults = $get('panelSearchResults');
      if (panelSearchResults) {
          var left1 =  parseInt(screen.width, 10)* 2 / 3 - parseInt(panelSearchResults.style.width, 10) / 2;
          panelSearchResults.style.left = left1;
      
          var buttonContinueSearch = $get("buttonContinueSearch");
          if (buttonContinueSearch) {
              buttonContinueSearch.style.left = left1 + parseInt(panelSearchResults.style.width, 10) / 3 - parseInt(buttonContinueSearch.style.width, 10) / 2;
          }
          var buttonCloseSearch = $get("buttonCloseSearch");
          if (buttonCloseSearch) {
              buttonCloseSearch.style.left = left1 + parseInt(panelSearchResults.style.width, 10)*2 / 3 - parseInt(buttonCloseSearch.style.width , 10)/ 2; 
          }          

          
          var panelSearchResultsShadow = $get('panelSearchResultsShadow');
          panelSearchResultsShadow.style.width = screen.width-20;
          
          panelSearchResultsShadow.style.height = screen.height*3;

      }

  }
  
   function VerifyMyModalWindow(strPanel1, strPanelShadow1) {
      var panel1 = $get(strPanel1);
      if (panel1) {
          panel1.style.top = parseInt(screen.height, 10)/2 - parseInt(panel1.style.height, 10) / 2;
          panel1.style.left = parseInt(screen.width, 10) / 2 - parseInt(panel1.style.width, 10) / 2;

          var panelShadow1 = $get(strPanelShadow1);
          if (panelShadow1) {
              panelShadow1.style.width = screen.width;
              panelShadow1.style.height = screen.height * 3;
          }
      }

  }
  


function OnButtonContinue_Click()
{
    var selectionType = "option";
    var hiddenFieldSearchType = $get("hiddenFieldSearchType");
    if(hiddenFieldSearchType && hiddenFieldSearchType.value && hiddenFieldSearchType.value.length > 0)
    {
        selectionType = hiddenFieldSearchType.value;
    }
    alert("Please select a valid " + selectionType  + " or cancel to go back");
}
  
