(function($) {
	$(function(){
        $('a[href=/media]').click(function(e) {
            e.preventDefault()
            openShadowbox('http://www.dieselmotorfiets.nl/youtube.php', 'iframe', 'Media')
        });

        $('a[href=/weblog]').click(function(e) {
            e.preventDefault()
            openShadowbox('http://trackdieselpoweredmotorfietsen.blogspot.com', 'iframe', 'Weblog')
        });

        Shadowbox.init();

        $('a[href^=\\"]').each(function() {
            ($(this).attr('href', $(this).attr('href').replace('\"', '').replace('\"', '')));
        });

        $('button.nieuwsbrief').bind('click', function(e) {
            var error = ''
            if ($('#voornaam').attr('value') == '') error += 'Vul alstublieft uw voornaam in.\n';
            if ($('#achternaam').attr('value') == '') error += 'Vul alstublieft uw achternaam in.\n';
            if ($('#email').attr('value') == '') error += 'Vul alstublieft uw e-mailadres in.\n';
            if ($('#land').attr('value') == '') error += 'Vul alstublieft uw land in.\n';
            if (error != '') {
                alert(error); return false;
            }
            return true;
        });

        $('button.contact').bind('click', function(e) {
            var error = ''
            if ($('#naam').attr('value') == '') error += 'Vul alstublieft uw naam in.\n';
            if ($('#adres').attr('value') == '') error += 'Vul alstublieft uw adres in.\n';
            if ($('#postcode').attr('value') == '') error += 'Vul alstublieft uw postcode in.\n';
            if ($('#plaats').attr('value') == '') error += 'Vul alstublieft uw plaats in.\n';
            if ($('#land').attr('value') == '') error += 'Vul alstublieft uw land in.\n';
            if ($('#email').attr('value') == '') error += 'Vul alstublieft uw e-mailadres in.\n';
            if ($('#telefoon').attr('value') == '') error += 'Vul alstublieft uw telefoon in.\n';
            if ($('#bericht').attr('value') == '') error += 'Vul alstublieft een bericht in.\n';
            if (error != '') {
                alert(error); return false;
            }
            return true;
        });

        if(top != self) {
            $($('#languages')[0]).click(function() {
                top.location = 'http://www.dieselmotorfiets.nl';
            });

            $('#weblogLink').click(function() {
                console.log('ja');
                //window.open('http://translate.google.com/translate?hl=en&sl=nl&tl=en&u=http%3a%2f%2ftrackdieselpoweredmotorfietsen.blogspot.com%2f', 'Blog');
            });
        }
	});
})(jQuery);

var openShadowbox = function(url, player, title){
    var width
    if (url == 'http://trackdieselpoweredmotorfietsen.blogspot.com') {
        width = 850
    } else {
        width = 600
    }

    Shadowbox.open({
        content: url,
        player:  'iframe',
        title:   title,
        'width' :   width
    });
};
