$(document).ready(function () {

    // Product Slide Box
    $('.productitem.caption').hover(function () {
        $(".cover", this).stop().animate({
            top: '0px'
        }, {
            queue: false,
            duration: 360
        });
    }, function () {
        $(".cover", this).stop().animate({
            top: '120px'
        }, {
            queue: false,
            duration: 360
        });
    });

    // Slideshow
    $('#slides').cycle({
        fx: 'fade',
        next: '#next',
        prev: '#prev',
        pager: '#nav',
        pagerAnchorBuilder: function(idx, slide) {
            return '<li><a href="#"><img src="' + slide.src + '" width="120" height="70" /></a></li>';
        }
    });

    // Slideshow Controls
    $('#slideshow').hover(

    function () {
        $('#controls').fadeIn();
    }, function () {
        $('#controls').fadeOut();
    });

    $('#product-mobile-slideshow-11, #product-mobile-slideshow-12, #product-mobile-slideshow-13, #product-mobile-slideshow-14, #product-mobile-slideshow-15, #product-mobile-slideshow-16, #product-mobile-slideshow-17').cycle({
        fx: 'fade',
		timeout: '800'
    });

    $('#product-mobile-slideshow').each(function(index) {
        $(this).cycle({
			fx:     'zoom',
			timeout: 0,
			speed:   400,
			sync:    false,
			pager:  '#nav',
			pagerAnchorBuilder: function(i) {
				if (index == 0)
					// for first slideshow, return a new anchro
					return '<a href="#">'+(i+1)+'</a>';
				// for 2nd slideshow, select the anchor created previously
				return '#nav a:eq('+i+')';
        	}
		});
    });

    jQuery(function ($) {
        $.translate(function () {
            function translateTo(destLang) {

                $('#container').translate('english', destLang, {
                    not: '#jq-translate-ui',
                    //just trans the homepage
                    fromOriginal: true,
                    //always translate from english (even after the page has been translated)   
                    start: function () {
                        $('#throbber').show()
                    },
                    // show loading icon
                    complete: function () {
                        $('#throbber').hide()
                    },
                    // hide loading icon          
                    error: function () {
                        $('#throbber').hide()
                    } // hide loading icon
                });
            }

            $('#mainNav li span').click(function () {
                var lang = $(this).attr('id');
                translateTo(lang);
                $.cookie('destLang', lang);
                return false;
            });

            var destLang = $.cookie('destLang'); //get previously translated language      
            if (destLang) //if it was set then 
            translateTo(destLang);

        });
    })

    $(function () {
        var tabContainers = $('div.tabs > div');
        tabContainers.hide().filter(':first').show();

        $('div.tabs ul.tabNavigation a').click(function () {
            tabContainers.hide();
            tabContainers.filter(this.hash).show();
            $('div.tabs ul.tabNavigation a').removeClass('selected');
            $(this).addClass('selected');
            return false;
        }).filter(':first').click();
    });

    $("a.lightbox").fancybox({
        'opacity': true,
        'transitionIn': 'fade',
        'transitionOut': 'fade',

        'overlayColor': '#000',
        'overlayOpacity': 0.5
    });



});




function initialize() {
    var latlng = new google.maps.LatLng(53.544392734715146, -2.3688840866088867);
    var settings = {
        zoom: 15,
        center: latlng,
        mapTypeControl: true,
        mapTypeControlOptions: {
            style: google.maps.MapTypeControlStyle.DROPDOWN_MENU
        },
        navigationControl: true,
        navigationControlOptions: {
            style: google.maps.NavigationControlStyle.SMALL
        },
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var map = new google.maps.Map(document.getElementById("map_canvas"), settings);
    var contentString = '<div id="content">' + '<div id="siteNotice">' + '</div>' + '<h1 id="firstHeading" class="firstHeading">Paratec</h1>';
    var infowindow = new google.maps.InfoWindow({
        content: contentString
    });

    var companyImage = new google.maps.MarkerImage('http://www.paratec.co.uk/images/logo.png', new google.maps.Size(100, 50), new google.maps.Point(0, 0), new google.maps.Point(50, 50));

    var companyShadow = new google.maps.MarkerImage('http://www.paratec.co.uk/images/logo_shadow.png', new google.maps.Size(130, 50), new google.maps.Point(0, 0), new google.maps.Point(65, 50));

    var companyPos = new google.maps.LatLng(53.544392734715146, -2.3688840866088867);

    var companyMarker = new google.maps.Marker({
        position: companyPos,
        map: map,
        icon: companyImage,
        shadow: companyShadow,
        title: "Paratec",
        zIndex: 3
    });

}
