﻿/*-------------------------------------------
TITLE:          TKRJS.js
AUTHOR:         THEODORE KEITH RUTHERFORD
COMPANY:        Rashid & Co Solicitors
DESCRIPTION:    Main js file for the Rashid & Co website


--------------------------------------------*/

/* Slideshow functions defined below */

function sizeNewsBar() 
{
    //function can be called anytime (after the page has loaded) to resize the news sidebar to fill the length of the page
    var h = document.getElementById('contentDiv').offsetHeight;
    
    if (h >= 420) //420 is the minimum height of the page but more importantly the optimal size for 2 news boxes
    {
        document.getElementById('newsSideBar').style.height = h + "px";
    }
}

function slideSwitch() 
{
    var $active = $('#slideshow IMG.active');

    if ($active.length == 0) $active = $('#slideshow IMG:last');

    var $next = $active.next().length ? $active.next()
        : $('#slideshow IMG:first');

    $active.addClass('last-active');

    $next.css({ opacity: 0.0 })
        .addClass('active')
        .animate({ opacity: 1.0 }, 1000, function () {
            $active.removeClass('active last-active');
        });
}

function numberSwitch() {
    var $active = $('#numberSlideshow SPAN.active');

    if ($active.length == 0) 
        $active = $('#numberSlideshow SPAN:last');

    var $next = $active.next().length ? $active.next()
        : $('#numberSlideshow SPAN:first');

    $active.addClass('last-active');

    $next.css({ opacity: 0.0 })
        .addClass('active')
        .animate({ opacity: 1.0 }, 1000, function () {
            $active.removeClass('active last-active');
        });
    }

/*------------------------------------------------------------------------------------------*/    
    /* GOOGLE MAP Functions below */
    function initializeMap() {
        var info = "<div style='width:309px;'>Rashid & Co Solicitors - Head Office<br/><br/>401 Witton Road, Witton, Birmingham, B6 6SP<br/>Across the road from Ashways Supermarket.</div>";
        var latlng = new google.maps.LatLng(52.5121, -1.8860);
        var myOptions = {
            zoom: 18,
            center: latlng,
            mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

        var pos = new google.maps.LatLng(52.5121, -1.8860);
        var marker = new google.maps.Marker({
            position: pos,
            map: map,
            title: "Rashid & Co Solicitors"
        });

        google.maps.event.addListener(marker, 'click', function () {
            var infowindow = new google.maps.InfoWindow({
                content: info
            });
            infowindow.open(map, marker);
        });

    }
/*------------------------------------------------------------------------------------------*/

/* MAP Functions defined below */
var map = null;
var pinid = 0;

var pushPin = "<div><img src='/images/logoPushPin.gif' alt='Here we are' /></div>";
var infobox = "<div style='width:309px;'>Rashid & Co Solicitors<br/><br/>This is our office. 401 Witton Road, Witton, Birmingham, B6 6SP. We are across the road from Ashways Supermarket.<br/></div>";

function testAlert(id) {
    alert(id);
}

function GetMap() {
    document.getElementById("StreetMap").innerHTML = "Loading interactive map";
    map = new VEMap("StreetMap");
    map.LoadMap(new VELatLong(52.512233278045755, -1.88556343317030), 17, 'r', false);
    AddPushpin();
}

function AddPushpin() {
    var shape = new VEShape(VEShapeType.Pushpin, map.GetCenter());
    //var busStop1 = new VEShape(VEShapeType.Pushpin, new VELatLong(52.510039, -1.903072));

    //Set the icon
    shape.SetCustomIcon(pushPin);

    //Set the info box
    map.ClearInfoBoxStyles();
    shape.SetTitle("<h2>Rashid & Co Solicitors</h2>");
    shape.SetDescription(infobox);

    //Add the shape the the map
    map.AddShape(shape);
    pinid++;
}
/* END OF MAP FUNCTIONS */
