google.load("jquery", "1.4.2", {uncompressed:true});
google.load("swfobject", "2", {uncompressed:true});

google.setOnLoadCallback(OnLoad);

function OnLoad(){
    $(document).ready(function(){

        var duLink = 'http://www.naaktbloot.nl';

        var currentLink;
        var currentPlayer=null;
        var currentFile;
        var currentImage;
        var currentModel;

        function removeOldPlayer() {busy=false;
                //$('#'+currentPlayer).replaceWith('<img src="'+currentImage+'" id="'+currentPlayer+'" class="model" />');
                $('div.stylediv').replaceWith('<img id="' + currentPlayer + '" class="model" src="http://'+currentModel+'.islive.nl/multimedia/promotie/pict001.jpg" />');
        }

        function flags(lang){
        document.search.lang.value = lang;
        document.search.submit();
        }

        function createPlayer(theLink, thePlace, theFile, theImage, theModel) {

                if (currentPlayer!=null) { removeOldPlayer(); }

                currentLink=theLink;
                currentPlayer=thePlace;
                currentFile=theFile;
                currentImage=theImage;
                currentModel = theModel;

                var flashvars = {};
                var params = {};
                var attributes = {};
                var callbackFn = 0;

                flashvars = {
                    file: theFile,
                    autostart: 'true',
                    aboutlink: 'http://www.naaktbloot.nl',
                    abouttext: 'Naakt en bloot',
                    link: theLink,
                    linktarget: '_self',
                    displayclick: 'fullscreen',
                    controlbar: 'none',
                    stretching: 'exactfit',
                    image: theImage,
                    volume: '0',
                    width:'148',
                    height:'110'
                };

                params = {
                    wmode: 'opaque',
                    menu: 'false',
                    allowscriptaccess: 'always'
                };

                attributes = {
                    id: thePlace,
                    name: thePlace
                };

                swfobject.embedSWF("http://www.wmcentral.nl/flash/jwplayer/player-licensed.swf", thePlace, "148", "110", '9.0.0', 0, flashvars, params, attributes, callbackFn);
                $('#'+thePlace).wrap('<div class="stylediv" />');
        }

        eersteFilmpje = function() {
            var eerstePlace = $('img.model:first').attr('id');
            var eersteModel = eerstePlace.substr(1);
            var eersteFile = 'http://' + eersteModel + '.islive.nl/multimedia/promotie/' + eersteModel + '_promotie.flv';
            var eersteImage = 'http://images.islive.nl/' + eersteModel + '/pictures/stylepictslive/livepict_style3_01.jpg'
            createPlayer(duLink, eerstePlace, eersteFile, eersteImage, eersteModel);
        };

        $('img.model').live('mouseenter',function(){
            var place = $(this).attr('id');
            var model = place.substr(1);
            var file = 'http://' + model + '.islive.nl/multimedia/promotie/' + model + '_promotie.flv';
            var image = 'http://images.islive.nl/' + model + '/pictures/stylepictslive/livepict_style3_01.jpg'
            //$('p#conp').replaceWith('<p id="conp">'+place+'</p>');
            createPlayer(duLink, place, file, image, model);
        });

        eersteFilmpje();


    });
}


