/*******************************************************/
/*  MOUSEOVER - A.J.Reading - v1.0.1 - 13/05/10        */
/*******************************************************/

$(document).ready( function() {
    $('input[type=image], img.hover').each( function(){ 
        // Preload
        var x = new Image();
        x.src = this.src.substring(0, this.src.length - 5) + "2.jpg";

        // Mouseover
        $(this).mouseover( function(){ 
            this.src = this.src.substring(0, this.src.length - 5) + "2.jpg"; 
        });

        // Mouseout
        $(this).mouseout( function(){
            if (this.src.substring( (this.src.length - 5) , (this.src.length) ) == "2.jpg" ) { 
                this.src = this.src.substring(0, this.src.length - 5) + "1.jpg"; 
            }
        });
    });
});


/*******************************************************/
/*  BOX ROLLOVERS                                      */
/*******************************************************/

$(document).ready( function() {
    $('div.boxhover').each( function() {
        $(this).mouseover( function() {
            $(this).css('background-position', 'top right');
        });
        $(this).mouseout( function() {
            $(this).css('background-position', 'top left');
        });
    });
});

/*******************************************************/
/*  DROPDOWN MENU - A.J.Reading - v1.0.1 - 18/05/10    */
/*******************************************************/

$(document).ready( function() {
    $('#navigation li ul').each( function() {
        $(this).css('z-index', 1000);
        $(this).parent().mouseover( function() {
            $(this).children('ul').css('display', 'block');
            var pos = $(this).position();
            $(this).children('ul').css('background-position', (-2880 - pos.left) + 'px' + ' 0px');
            //$(this).children('ul').css('left', pos.left);
            $(this).find('span').css('width', ($(this).find('li').width() - $(this).width()));
            if ($.browser.msie && $.browser.version.substr(0,1)<7) {
                $(this).find('span').css('right', -1);
            }
        });
        $(this).parent().mouseout( function() {
            $(this).children('ul').css('display', 'none');
        });
    });
});
$(document).ready(function(){
    if($('#map').length != 0) {
            googleMap({
                'container'      : 'map',
                'data'           : { 0 : {'latitude'     : 53.95406535327657,
                                          'longitude'    : -1.1027392745018005,
                                          'title'        : 'TMS Development International Limited',
                                          'infoWindow'   : '<p><strong>TMS Development International Limited</strong><br />Holgate Road<br />York<br />YO24 4FL</p>'} },
                'marker'         : '/images/common/marker.png',
                'markerWidth'    : 27,
                'markerHeight'   : 42,
                'markerPointX'   : 13,
                'markerPointY'   : 39,
                'zoom'           : 11,
                'autoCenter'     : false,
                'fluster'        : false,
                'largeNavigation': false
                });
    }
});
$(document).ready( function() {
    $('a').each( function() {
        var anchor = $(this).attr('href');
        var pdf = anchor.substring(anchor.length - 4);
        if (anchor.indexOf('http') != -1 || pdf.toLowerCase() == '.pdf') {
           $(this).click( function() {
               window.open($(this).attr('href'));
               return false;
           });
        }
    });
});
