﻿/// <reference path="~/jquery-1.3.2-vsdoc.js />
///<remarks>
///====================================================================
/// Name: productInfo.cs
/// Javascript function for Product Info Tab details
/// Construction Date: 04/22/2009
/// Author: Kalpana Singh
/// Last Revision Date: 
/// Last Revision By:  
/// Last Revision Change: 
/// ====================================================================
/// Copyright (c) 2009 Vail Resorts, Inc.
/// ====================================================================
///</remarks>
var qsParm = new Array();
function GetQueryStringValues() {
    var query = window.location.search.substring(1);
    var parms = query.split('&');
    for (var i = 0; i < parms.length; i++) {
        var pos = parms[i].indexOf('=');
        if (pos > 0) {
            var key = parms[i].substring(0, pos);
            var val = parms[i].substring(pos + 1);
            qsParm[key] = val;
        }
    }
}
$(document).ready(function() {
    var prodCode;
    //Get Uber Map XML - START
    $("ul.mainTabsPnB li#mapsDirection").click(function() {
        //        var fullURL = parent.document.URL;
        //        var extractURL = fullURL.substring(fullURL.indexOf('Code=') + 5, fullURL.length);
        //        var prodCode = extractURL.substring(0, extractURL.indexOf('&'));
        GetQueryStringValues();
        if (qsParm["Code"] != '') {
            prodCode = qsParm["Code"];
            if (typeof(prodCode)=='undefined')
            {
            prodCode = qsParm["code"];
            }
            $.ajax({
                type: "POST",
                url: "/vailresorts/sites/PlanningAndBooking/WebServices/ProductInfoWebService.svc/GetUberMapXML",
                data: "{\"productCode\" : \"" + prodCode + "\",\"productType\" : \"Lodging\" ,\"source\" : \"Internet\",\"showExpired\" : true}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function(msg) {
                    //Loads the Uber Map, and pass the location of the MAP XML file
                    load(msg.d);

                    //Shows the current merchant details as provided in Merchant XML
                    //Delay the ShowMerchantInfo() for some time so that map is fully loaded, to point the correct location
                    showMerchantInfo(0);
                },
                error: function(request, textStatus, errorThrown) {
                    var errMsg = getErrorMessage(xhr,status,error);
                    
                    if(errMsg==' ')
                    {
                    errMsg = "We are unable to complete your request.";
                    }
                    
                    alert(errMsg);
                }
            });
        }
    });
});


function LoadLodgingMap()
{
        $("#map").css("display","none");
        $("#divLodgingDetailMapLoad").showLoading({loadingStr: "Please wait a moment while we search for your results", autoFocus: false});
        
        GetQueryStringValues();
        if (qsParm["Code"] != '') {
            prodCode = qsParm["Code"];
            if (typeof(prodCode)=='undefined')
            {
            prodCode = qsParm["code"];
            }
      $.ajax(
      {
        type: "POST",
        async:"false",
        url: "/vailresorts/sites/PlanningAndBooking/WebServices/ProductInfoWebService.svc/GetUberMapXML",
        data: "{\"productCode\" : \"" + prodCode + "\",\"productType\" : \"Lodging\" ,\"source\" : \"Internet\",\"showExpired\" : true}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(msg) 
        { 
              
               //Loads the Uber Map, and pass the location of the MAP XML file
                //load(msg.d);
                xml = msg.d;
			    loadGMapScript();
                //Shows the current merchant details as provided in Merchant XML
                //Delay the ShowMerchantInfo() for some time so that map is fully loaded, to point the correct location
                showMerchantInfo(0);
         },
         error: function (request, textStatus, errorThrown) 
         { 
            var errMsg = getErrorMessage(xhr,status,error);

            if(errMsg==' ')
            {
                errMsg = "We are unable to complete your request.";
            }

            alert(errMsg); 
         }
      });
      }
   }
  
function ConfirmNavigation()
{
    var response = window.confirm("You would be booking a pre-configured vacation rather then the offer")
    if (response)
    {    return true;    }
    else
     {   return false;   }
}