﻿$(document).ready(
    function() 
    {
        // Suggestion box
        if ($('.suggestion').length > 0)
        {
            $('.suggestion').focus(function()
            {
                $(this).css('color', '#472c02');
                $(this).css('font-style', 'normal');
            });
            $('.suggestion').blur(function(){
                $(this).css('color', '');
                $(this).css('font-style', '');
            });
        }
    
        // Occasions search box
        if ($('#tbxSearchItem').length > 0)
        {
            //set focus on searchbox
            $('#tbxSearchItem').focus();
            $('#tbxSearchItem').keypress(function(event)
            {
                if ((event.keyCode != null && event.keyCode == 13) || (event.which != null && event.which == 13))
                {
                    window.open('http://www.zomoto.nl/' + $('#tbxSearchItem').val())
                    return false;
                }
            });
        }
        
        // New cars search box
        if ($('#tbxSearchItemNew').length > 0)
        {
            $('#tbxSearchItemNew').focus();
            $('#tbxSearchItemNew').keypress(function(event)
            {
                if ((event.keyCode != null && event.keyCode == 13) || (event.which != null && event.which == 13))
                {
                    window.open('http://www.zomoto.nl/nieuw/' + $('#tbxSearchItemNew').val())
                    return false;
                }
            });
        }

        // Insurance licenseplate box
        if ($('#tbxPlateNo').length > 0)
        {
            $('#tbxPlateNo').focus();
            $('#tbxPlateNo').keypress(function(event)
            {
                if ((event.keyCode != null && event.keyCode == 13) || (event.which != null && event.which == 13))
                {
                    window.open($('#baseUrl').val() + $('#tbxPlateNo').val())
                    return false;
                }
            });
        }
        
        if ($('.autoblog-item').length > 0)
        {
            $('.autoblog-item .nav a.hover-link').mouseover(function()
            {
                //first turn off all items
                $('.autoblog-item').hide();
                //find out what we're hovering over
                //var item = $(this).html();
                //enable the item we're hovering over
                $('#autoblog-item-' + $(this).html()).show();
            });
        }
    }
);