﻿var geocoder;
var map;
var mapOverlay;

$(document).ready(function() {
    $('#pane').jScrollPane({showArrows:false,reinitialiseOnImageLoad:true});
    $("#siteStart").hide();
    $("#siteEnd").show();
    $("#siteEnd").fadeOut(2000);
    $("#siteStart").fadeIn(2000);
    var pathName = getPath();
    $('a[href="'+pathName+'"]').css({"color":"#841a5d"});
    $('a[href="'+pathName+'"]').css({"font-weight":"bold"});
});

function getPath()
{
    var wp = window.location.href;
    var path = wp.lastIndexOf('/');
    var tp =wp.substring(path+1);
    var tand = tp.lastIndexOf('&');
    if (tand> 0) tp = tp.substring(0,tand);
    return tp;
}

function GetGallery(id)
{
   $(".thumbs").empty();
   $(".thumbs").css({"left":"10px"});
   $(".thumbs").css({"top":"890px"});
   $(".thumbs").css({"height":"250px"});
      $.ajax({
        type: "POST",
        url: "WRData.asmx/GetGallery",
        data: "{id:'"+ id +"'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(results) {
           var tmp = results.d;

           $.each(tmp.Images, function(i, item){
              $(".thumbs").append('<a href="showfile.ashx?id='+ item.FileName +'" title="'+ item.FileDesc +'&nbsp;"><img style="width:75px;height:57px" src="showfile.ashx?id='+ item.FileName +'" alt="'+item.FileName+'" /></a>');
           });
          if ($(".thumbs a")) {
            $(".thumbs a").overlay({target: '#gallery', expose: '#000'})
             .gallery({ speed: 800, autohide: false});
          }
        }
     });
} 



function mapInit(lat, lng){
  var centerCoord =new google.maps.LatLng(lat,lng);
  geocoder = new google.maps.Geocoder();
  var mapOptions = {	
    zoom: 14,
    draggable: true, 
    scaleControl:true,
    mapTypeControl:false,
    navigationControl:true, 
    navigationControlOptions: {style: google.maps.NavigationControlStyle.ZOOM_PAN},
    scrollwheel: true,
    center: centerCoord,mapTypeId: google.maps.MapTypeId.HYBRID
  }
  map = new google.maps.Map(document.getElementById("ShowMap"), mapOptions);
}

        
function formatCurrency(num) {
  num = num.toString().replace(/\$|\,/g,'');
  if(isNaN(num))
    num = "0";
  sign = (num == (num = Math.abs(num)));
  num = Math.floor(num*100+0.50000000001);
  cents = num%100;
  num = Math.floor(num/100).toString();
  if(cents<10)
     cents = "0" + cents;
  for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
     num = num.substring(0,num.length-(4*i+3))+','+
  num.substring(num.length-(4*i+3));
  return (((sign)?'':'-') + '$' + num + '.' + cents);
}
