// automatische MouseOvers, this = DOM object $(this) = jQuery object
function initMouseOvers() {
    $("A.MOImg IMG").each(function (i) {
        var img = this;

        var extensionIndex = img.src.lastIndexOf('.');
        var path = img.src.substr(0, extensionIndex);
        var extension = img.src.substring(extensionIndex, img.src.length);

        // preload MOimgs
        var MO = new Image();
        MO.src = path + '_O' + extension; // Arie style: _O

        //alert($(this).parent().attr('href'));
        var anchor = $(this).parent();
        anchor.mouseover(function() {
            img.src = MO.src;
            }
        );

        anchor.mouseout(function() {
            img.src = path + extension;
            }
        );
    });
}

$(document).ready(function() {
    initMouseOvers();
    
    //show hide news_image
    $('.shNewsImg').click(function() {
		var src = 'http://www.linteloo.nl/uploads/'+$(this).attr('alt');
		$('#BigNewsImg').attr('src', src);
		$('.big_news_img').toggle();
        return false;
    });
	
    // show/ hide dealers per provincie
    $('UL.provinces LI A').click(function() {
    	var type = $(this).attr('title');
    	$('DIV.agent').hide();
    	$('DIV.provs').hide();
    	$('DIV.'+type).show();
    	$('UL.provinces LI A').css('font-weight', 'normal');
    	$(this).css('font-weight', 'bold');
    	return false;
    });
    
    // show hide landen per continent
    $('DIV.box160semi').click(function() {
    	$(this).next('DIV.box160list').toggle();
    	return false;
    });
    
    // show/hide van productnamen in thumbboxes:
    $('DIV.prod_thumb A').mouseover(function() {
        $(this).children('SPAN.h3').show();
    });
    
    $('DIV.prod_thumb A').mouseout(function() {
        $(this).children('SPAN.h3').hide();
    });
    
    // show/hide hometxtjes
    $('DIV.homebox A').mouseover(function() {
        $(this).children('SPAN').show();
    });
    $('DIV.homebox A').mouseout(function() {
    	$(this).children('SPAN').hide();
    });
    
    // openen van de funcnavs
    $('A.anim1').click(function() {
        var open = $('#slide1').is(":hidden");
        $('.funcdiv')
            .slideUp('fast')
            .animate({opacity: 1.0}, 280)
            if (open == 1) {
                $('#slide1').slideDown('fast');
            } else {
                $('#slide1').slideUp('fast');
            }
        }
    );

    $('A.anim2,A.toContact').click(function() {
        var open = $('#slide2').is(":hidden");
        $('.funcdiv')
            .slideUp('fast')
            .animate({opacity: 1.0}, 280)
            if (open == 1) {
                $('#slide2').slideDown('fast');
            } else {
                $('#slide2').slideUp('fast');
            }
        return false;
        }
    );

     $('A.anim3').click(function() {
        var open = $('#slide3').is(":hidden");
        $('.funcdiv')
            .slideUp('normal')
            .animate({opacity: 1.0}, 280)
            if (open == 1) {
                $('#slide3').slideDown('fast');
            } else {
                $('#slide3').slideUp('fast');
            }
        }
    );
    
    $('.close').click(function() {
        $('.funcdiv').slideUp('fast');
    });
});
