﻿
//programmatically add onload events for both site softscroll and google maps
window.onload = function () {
    initialize();
    SoftScroll.init();
};

window.onunload = function () {
    GUnload();
};



//Google maps
function initialize() {
    if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("googleMap"));
        //location to set as default landing
        map.setCenter(new GLatLng(51.4618219, -0.2099474), 15);
        //pinpoint marker location on the map
        var point = new GLatLng(51.4618219, -0.2099474);
        map.addOverlay(new GMarker(point));
        map.setUIToDefault();
    }
}


function formatText(index, panel) {
    return index + "";
}


$(document).ready(function () {


    //home page slideshow
    $('.anythingSlider').anythingSlider({
        easing: "easeInOutExpo",
        autoPlay: false,
        delay: 3000,
        startStopped: false,
        animationTime: 600,
        hashTags: true,
        buildNavigation: true,
        pauseOnHover: true,
        startText: "Go",
        stopText: "Stop",
        navigationFormatter: formatText
    });

    $("#slide-jump").click(function () {
        $('.anythingSlider').anythingSlider(6);
    });

    //client logos fade in/out
    $('.slideshow').cycle({
        fx: 'fade'
    });

    //sliding boxes
    $('.boxgrid.slidedown').hover(function () {
        $(".cover", this).stop().animate({ top: '-260px' }, { queue: false, duration: 300 });
    }, function () {
        $(".cover", this).stop().animate({ top: '0px' }, { queue: false, duration: 300 });
    });



    //pullout contact form
    $('.contactForm-slideout').tabSlideOut({
        tabHandle: '.handle',
        pathToTabImage: '../images/btn-leave-message2.png',
        imageHeight: '175px',
        imageWidth: '34px',
        tabLocation: 'left',
        speed: 300,
        action: 'click',
        topPos: '200px',
        leftPos: '0px',
        fixedPosition: true
    });



    //open/close validation form, clear error messages when form's closed
    $("#formTab").click(function (event) {
        event.preventDefault();
       /* $("#overlay-background").toggle();*/
		$("#arrow1").toggle();
		$("#arrow2").toggle();
        $('label').hide();
        $('input').removeClass('error');
        $('textarea').removeClass('error');

        return false;
    });


    //validate contact form
    $("#contactForm").validate({
        rules: {
            name: "required",
            email: {
                required: true,
                email: true
            },

            message: {
                required: true
            }
        }
    });


   

    

});




//clear/re-populate default text in form fields
function onBlur(el) {
    if (el.value == '') {
        el.value = el.defaultValue;
        el.style.color = '#cccccc';
    }

}
function onFocus(el) {
    if (el.value == el.defaultValue) {
        el.value = '';
        el.style.color = '#333333';
    }
}


