﻿/* Google Maps */

var strOffice = '<table><tr><td><img src=\"images\/map-logo.gif\" width=\"175px\" style=\"margin:5px;\" ><p>Market Place, Ely<br />Cambridgeshire, CB7 4QN<\/p><p><img src=\"images\/map-telephone.gif\" \/> (01353) 662203<\/p><p><img src=\"images\/map-email.gif\" /> <a href=\"mailto:info@archerandarcher.co.uk\">info@archerandarcher.co.uk<\/a></p><td><img src=\"images\/map-office.jpg\" width=\"175px\"\><\/td><\/tr><\/table>';
var map, map, objMarker, point, parking1, parking2, parking3, parking4, parking5;
var intParkingState = 1;

/* Set Google Map Type */

function setMap() {
    map.setMapType(G_NORMAL_MAP);
    $("#a-map").css("font-weight", "bold");
    $("#a-sat").css("font-weight", "normal");
    $("#a-hybrid").css("font-weight", "normal");
}

function setSat() {
    map.setMapType(G_SATELLITE_MAP);
    $("#a-map").css("font-weight", "normal");
    $("#a-sat").css("font-weight", "bold");
    $("#a-hybrid").css("font-weight", "normal");
}

function setHybrid() {
    map.setMapType(G_HYBRID_MAP);
    $("#a-map").css("font-weight", "normal");
    $("#a-sat").css("font-weight", "normal");
    $("#a-hybrid").css("font-weight", "bold");
}

/* Google Map Print */

function googlemapPrint() {
    var mapWindow = window.open('map.aspx', 'name', 'height=900,width=685,scrollbars=yes');
}

/* Set Parking Icons */

function setParking() {
    if (intParkingState == 1) {
        objMarker.closeInfoWindow();

        var iconParking = new GIcon(G_DEFAULT_ICON, "images/googlemap/parking.png", "")
        iconParking.shadow = 'images/googlemap/parking_shadow.png';
        iconParking.iconSize = new GSize(24, 24);
        iconParking.shadowSize = new GSize(36, 24);
        iconParking.iconAnchor = new GPoint(12, 24);
        iconParking.infoWindowAnchor = new GPoint(12, 0);
        iconParking.printImage = 'images/googlemap/parking_printImage.gif';
        iconParking.mozPrintImage = 'images/googlemap/parking_mozPrintImage.gif';
        iconParking.printShadow = 'images/googlemap/parking_printShadow.gif';
        iconParking.transparent = 'images/googlemap/parking_transparent.png';
        iconParking.imageMap = [23, 0, 23, 1, 23, 2, 23, 3, 23, 4, 23, 5, 23, 6, 23, 7, 23, 8, 23, 9, 23, 10, 23, 11, 23, 12, 23, 13, 23, 14, 23, 15, 23, 16, 23, 17, 23, 18, 23, 19, 23, 20, 23, 21, 23, 22, 23, 23, 0, 23, 0, 22, 0, 21, 0, 20, 0, 19, 0, 18, 0, 17, 0, 16, 0, 15, 0, 14, 0, 13, 0, 12, 0, 11, 0, 10, 0, 9, 0, 8, 0, 7, 0, 6, 0, 5, 0, 4, 0, 3, 0, 2, 0, 1, 0, 0];


        point = new GLatLng(52.400190, 0.261300);
        parking1 = new GMarker(point, iconParking);
        map.addOverlay(parking1);

        point = new GLatLng(52.396226, 0.268532);
        parking2 = new GMarker(point, iconParking);
        map.addOverlay(parking2);

        point = new GLatLng(52.397470, 0.266955);
        parking3 = new GMarker(point, iconParking);
        map.addOverlay(parking3);

        point = new GLatLng(52.400491, 0.267631);
        parking4 = new GMarker(point, iconParking);
        map.addOverlay(parking4);

        point = new GLatLng(52.401673, 0.266955);
        parking5 = new GMarker(point, iconParking);
        map.addOverlay(parking5);

        $("#a-parking").css("font-weight", "bold");
        intParkingState = 2;
        
    } else {
        objMarker.openInfoWindowHtml(strOffice);
        parking1.hide();
        parking2.hide();
        parking3.hide();
        parking4.hide();
        parking5.hide();
        $("#a-parking").css("font-weight", "normal");
        intParkingState = 1;
    }
}

/* Contact Page OnLoad */

function loadContactPage() {

    /* Google Toolbox */

    function GMToolbox() { }

    GMToolbox.prototype = new GControl(false, false);

    GMToolbox.prototype.getDefaultPosition = function() { return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(2, 2)); };

    GMToolbox.prototype.initialize = function(gmapref) {
        var container = gmapref.getContainer();
        var divToolbox = document.createElement("div");
        divToolbox.id = "GoogleMapToolBox";
        var divText = "<table cellpadding=\"0\" cellspacing=\"0\" height=\"18px\"><tr><td class=\"td-box\"><a id=\"a-map\" href=\"javascript:setMap();\">Map<\/a><\/td>";
        divText = divText + "<td class=\"td-box\"><a id=\"a-sat\" href=\"javascript:setSat();\">Satellite<\/a><\/td>";
        divText = divText + "<td class=\"td-box\"><a id=\"a-hybrid\" href=\"javascript:setHybrid();\">Hybrid<\/a><\/td>";
        divText = divText + "<td class=\"td-blank\">&nbsp;<\/td><td class=\"td-box\"><table><tr height=\"18px\"><td valign=\"middle\"><a href=\"javascript:setParking();\" ><img src=\"images\/googlemap\/parking-small.gif\" alt=\"Parking\" height=\"16px\" width=\"16px\" \/><\/a><\/td>";
        divText = divText + "<td><a href=\"javascript:setParking();\" id=\"a-parking\">Parking<\/a><\/td><\/tr><\/table><\/td><td class=\"td-blank\">&nbsp;<\/td><td class=\"td-box\" ><table><tr><td valign=\"middle\"><a href=\"javascript:googlemapPrint();\" ><img src=\"images\/googlemap\/printer-small.gif\" alt=\"Print\" height=\"16px\" width=\"16px\" style=\"padding:0px; margin:0px;\" \/><\/a><\/td>";
        divText = divText + "<td><a href=\"javascript:googlemapPrint();\" >Print<\/a><\/td><\/tr><\/table><\/td><\/tr><\/table>";
        divToolbox.innerHTML = divText;
        container.appendChild(divToolbox);
        return divToolbox;
    }

    /* Initate Google Maps */

    if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map"));
        map.setCenter(new GLatLng(52.401234, 0.2700000000000000), 15);
        map.addControl(new GLargeMapControl());
        map.addControl(new GMToolbox());
        map.addControl(new GOverviewMapControl(new GSize(375, 250)));

        var iconOffice = new GIcon(G_DEFAULT_ICON, "images/googlemap/office.png", "")
        iconOffice.shadow = 'images/googlemap/office_shadow.png';
        iconOffice.iconSize = new GSize(32, 37);
        iconOffice.shadowSize = new GSize(51, 37);
        iconOffice.iconAnchor = new GPoint(16, 37);
        iconOffice.infoWindowAnchor = new GPoint(16, 0);
        iconOffice.printImage = 'images/googlemap/office_printImage.gif';
        iconOffice.mozPrintImage = 'images/googlemap/office_mozPrintImage.gif';
        iconOffice.printShadow = 'images/googlemap/office_printShadow.gif';
        iconOffice.transparent = 'images/googlemap/office_transparent.png';
        iconOffice.imageMap = [24, 0, 24, 1, 24, 2, 24, 3, 24, 4, 24, 5, 24, 6, 24, 7, 24, 8, 24, 9, 24, 10, 24, 11, 24, 12, 24, 13, 24, 14, 24, 15, 24, 16, 24, 17, 24, 18, 31, 19, 31, 20, 31, 21, 30, 22, 29, 23, 28, 24, 27, 25, 26, 26, 25, 27, 24, 28, 23, 29, 22, 30, 21, 31, 20, 32, 19, 33, 18, 34, 17, 35, 16, 36, 15, 36, 14, 35, 13, 34, 12, 33, 11, 32, 10, 31, 9, 30, 8, 29, 7, 28, 6, 27, 5, 26, 4, 25, 3, 24, 2, 23, 1, 22, 0, 21, 0, 20, 0, 19, 7, 18, 7, 17, 7, 16, 7, 15, 7, 14, 7, 13, 7, 12, 7, 11, 7, 10, 7, 9, 7, 8, 7, 7, 7, 6, 7, 5, 7, 4, 7, 3, 7, 2, 7, 1, 7, 0];

        var latlngOffice = new GLatLng(52.399228, 0.266877);

        objMarker = new GMarker(latlngOffice, iconOffice);
        map.addOverlay(objMarker);
        GEvent.addListener(objMarker, "click", function() { objMarker.openInfoWindowHtml(strOffice); });

        objMarker.openInfoWindowHtml(strOffice);

        setMap();

    }
}

/* Map Page OnLoad */

function loadMapPage() {

    /* Initate Google Maps */

    if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("div-map-top"));
        map.setCenter(new GLatLng(52.3968, 0.26701927185058593), 15);

        var iconOffice = new GIcon(G_DEFAULT_ICON, "images/googlemap/office.png", "")
        iconOffice.shadow = 'images/googlemap/office_shadow.png';
        iconOffice.iconSize = new GSize(32, 37);
        iconOffice.shadowSize = new GSize(51, 37);
        iconOffice.iconAnchor = new GPoint(16, 37);
        iconOffice.infoWindowAnchor = new GPoint(16, 0);
        iconOffice.printImage = 'images/googlemap/office_printImage.gif';
        iconOffice.mozPrintImage = 'images/googlemap/office_mozPrintImage.gif';
        iconOffice.printShadow = 'images/googlemap/office_printShadow.gif';
        iconOffice.transparent = 'images/googlemap/office_transparent.png';
        iconOffice.imageMap = [24, 0, 24, 1, 24, 2, 24, 3, 24, 4, 24, 5, 24, 6, 24, 7, 24, 8, 24, 9, 24, 10, 24, 11, 24, 12, 24, 13, 24, 14, 24, 15, 24, 16, 24, 17, 24, 18, 31, 19, 31, 20, 31, 21, 30, 22, 29, 23, 28, 24, 27, 25, 26, 26, 25, 27, 24, 28, 23, 29, 22, 30, 21, 31, 20, 32, 19, 33, 18, 34, 17, 35, 16, 36, 15, 36, 14, 35, 13, 34, 12, 33, 11, 32, 10, 31, 9, 30, 8, 29, 7, 28, 6, 27, 5, 26, 4, 25, 3, 24, 2, 23, 1, 22, 0, 21, 0, 20, 0, 19, 7, 18, 7, 17, 7, 16, 7, 15, 7, 14, 7, 13, 7, 12, 7, 11, 7, 10, 7, 9, 7, 8, 7, 7, 7, 6, 7, 5, 7, 4, 7, 3, 7, 2, 7, 1, 7, 0];    

        var latlngOffice = new GLatLng(52.39925714481339, 0.26701927185058593);

        objOffice = new GMarker(latlngOffice, iconOffice);
        map.addOverlay(objOffice);

        var iconParking = new GIcon(G_DEFAULT_ICON, "images/googlemap/parking.png", "")
        iconParking.shadow = 'images/googlemap/parking_shadow.png';
        iconParking.iconSize = new GSize(24, 24);
        iconParking.shadowSize = new GSize(36, 24);
        iconParking.iconAnchor = new GPoint(12, 24);
        iconParking.infoWindowAnchor = new GPoint(12, 0);
        iconParking.printImage = 'images/googlemap/parking_printImage.gif';
        iconParking.mozPrintImage = 'images/googlemap/parking_mozPrintImage.gif';
        iconParking.printShadow = 'images/googlemap/parking_printShadow.gif';
        iconParking.transparent = 'images/googlemap/parking_transparent.png';
        iconParking.imageMap = [23, 0, 23, 1, 23, 2, 23, 3, 23, 4, 23, 5, 23, 6, 23, 7, 23, 8, 23, 9, 23, 10, 23, 11, 23, 12, 23, 13, 23, 14, 23, 15, 23, 16, 23, 17, 23, 18, 23, 19, 23, 20, 23, 21, 23, 22, 23, 23, 0, 23, 0, 22, 0, 21, 0, 20, 0, 19, 0, 18, 0, 17, 0, 16, 0, 15, 0, 14, 0, 13, 0, 12, 0, 11, 0, 10, 0, 9, 0, 8, 0, 7, 0, 6, 0, 5, 0, 4, 0, 3, 0, 2, 0, 1, 0, 0];

        point = new GLatLng(52.400190, 0.261300);
        parking1 = new GMarker(point, iconParking);
        map.addOverlay(parking1);

        point = new GLatLng(52.396226, 0.268532);
        parking2 = new GMarker(point, iconParking);
        map.addOverlay(parking2);

        point = new GLatLng(52.397470, 0.266955);
        parking3 = new GMarker(point, iconParking);
        map.addOverlay(parking3);

        point = new GLatLng(52.400491, 0.267631);
        parking4 = new GMarker(point, iconParking);
        map.addOverlay(parking4);

        point = new GLatLng(52.401673, 0.266955);
        parking5 = new GMarker(point, iconParking);
        map.addOverlay(parking5);

        map2 = new GMap2(document.getElementById("div-map-bottom-map"));
        map2.setCenter(new GLatLng(52.39925714481339, 0.2700000000000000), 9);

        setTimeout("window.print()", 2000);
        
    }
}



/* Contact */

function closeForm() {
    tb_remove();
}

function ValidationAddress(source, args) {
    var add1 = $("#address1").val();
    var add2 = $("#address2").val();
    if (add1 != "" || add2 != "") {
        args.IsValid = true;
    }
    else { args.IsValid = false; }
}

function clearForm() {
    window.location = "contact-us.aspx";
}

function sitemapOpen() {
    var sitemapWindow = window.open('site-map.aspx', 'name', 'height=600,width=500,scrollbars=yes,location=no');
}


function accessOpen() {
    var sitemapWindow = window.open('accessibility.aspx', 'name', 'height=600,width=500,scrollbars=yes,location=no');
}

function noenter() {
    return !(window.event && window.event.keyCode == 13); }
