/*
(function($){$.fn.touchwipe=function(settings){var config={min_move_x:20,wipeLeft:function(){alert("left");},wipeRight:function(){alert("right");},preventDefaultEvents:true};if(settings)$.extend(config,settings);this.each(function(){var startX;var isMoving=false;function cancelTouch(){this.removeEventListener('touchmove',onTouchMove);startX=null;isMoving=false;}function onTouchMove(e){if(config.preventDefaultEvents){e.preventDefault();}if(isMoving){var x=e.touches[0].pageX;var dx=startX-x;if(Math.abs(dx)>=config.min_move_x){cancelTouch();if(dx>0){config.wipeLeft();}else{config.wipeRight();}}}}function onTouchStart(e){if(e.touches.length==1){startX=e.touches[0].pageX;isMoving=true;this.addEventListener('touchmove',onTouchMove,false);}}this.addEventListener('touchstart',onTouchStart,false);});return this;};})(jQuery);
*/

$(document).ready(function ()
{
    $(function ()
    {
        if (typeof GoogleMapShow == 'function')
        {
            GoogleMapShow();
        }

        function BillboardGoLeft()
        {
            $('#billboard ul').animate( { left: '-960px' }, 750, 'swing', function ()
            {
                var t = $('#billboard ul');
                $(t).css( { left: '0' } );
                $(t).find('li:first').appendTo(t);
            });
        }
        function BillboardGoRight()
        {
            var t = $('#billboard ul');
            $(t).css( { left: '-960px' } );
            $(t).find('li:last').prependTo(t);
            $('#billboard ul').animate( { left: '0' }, 750, 'swing', function ()
            {
            });
        }
        $('#btngoleft').click( function () { BillboardGoLeft(); return false; });
        $('#btngoright').click( function () { BillboardGoRight(); return false; });
        /*
		$("#billboard li").touchwipe(
        {
             wipeLeft: function() { BillboardGoLeft(); },
             wipeRight: function() { BillboardGoRight(); },
             min_move_x: 20,
             preventDefaultEvents: true
        });
		*/
		$('#billboard a').each( function (i)
		{
			var bt = $(this).append("<div class='bottomthird'><b>" + $(this).attr("title") + "</b><br />" + $(this).find('img').attr("title") + "</div>");
			$(this).attr("title", "")
			$(this).find('img').attr("title", "")
			var bh = $(this).height();
			var boh = $(this).find('.bottomthird').outerHeight();
			var nh = bh - boh;
			$(this).find('.bottomthird').css( { top: bh + 'px', bottom: 'auto' } );
			$(this).hover(
			function ()
			{
				$(this).find('.bottomthird').animate(
				{
					top: nh + 'px'
				}, 400, 'swing' );
			},
			function ()
			{
				$(this).find('.bottomthird').animate(
				{
					top: bh + 'px'
				}, 400, 'swing' );
			});
		});

        $('.gallery a').lightBox(
        {
            imageBlank: '/_images/lightbox-blank.gif',
            imageLoading: '/_images/lightbox-ico-loading.gif',
            imageBtnClose: '/_images/lightbox-btn-close.gif',
            imageBtnPrev: '/_images/lightbox-btn-prev.gif',
            imageBtnNext: '/_images/lightbox-btn-next.gif'
        });
        $('#gallery li a').lightBox(
        {
            imageBlank: '/_images/lightbox-blank.gif',
            imageLoading: '/_images/lightbox-ico-loading.gif',
            imageBtnClose: '/_images/lightbox-btn-close.gif',
            imageBtnPrev: '/_images/lightbox-btn-prev.gif',
            imageBtnNext: '/_images/lightbox-btn-next.gif'
        });
		
		var intMatches = 0;
		intMatches = intMatches + parseInt($(".right:contains('Tel:')").length, 10);
		intMatches = intMatches + parseInt($(".right:contains('Fax:')").length, 10);
		if (intMatches === 2) {
			$('.right').append("<a href='mailto:info@signsdirect-midlands.co.uk'>info@signsdirect-midlands.co.uk</a>");
		}
    });
});
