$(document).ready(function () {

    if ($("#q").val()=='')
    {
        $("#q").val('Zoeken');
    };

    $("#q").bind("focus",function(){
        if ($(this).val()=='Zoeken')
        {
            $(this).val('');
        };
    }); // end #q focus

    $("#q").bind("blur",function(){
        if ($(this).val()=='')
        {
            $(this).val('Zoeken');
        };
    }); // end #q blur


    $('a.lightbox').nyroModal({
        //debug: true,
        bgColor: '#000',
        minWidth: 470,
        minHeight: 315,
        width: 470,
        height: 315
        
    }); // end nyroModal

    $('#showallimages').click(function(e) {
        e.preventDefault();
        $('a[@rel*=image].lightbox').nyroModalManual({
            bgColor: '#000',
            minWidth: 470,
            minHeight: 315,
            width: 470,
            height: 315
        });
        return false;
    });

    $('#showallvideos').click(function(e) {
        e.preventDefault();
        $('a[@rel*=video].lightbox').nyroModalManual({
            bgColor: '#000',
            minWidth: 470,
            minHeight: 315,
            width: 470,
            height: 315
        });
        return false;
    });


    $.ifixpng('/static/global/images/transparent.gif'); 
    $('img[@src$=.png]').ifixpng();
    

    // jaja, debug voor viewtracker
    /*
    $('a.link-image-big').click(function() {
        alert('ali ali, cyaankali');
        $.get('/images/bloep/?imageid=' + this.name);
    });// end jaja
    */

}); // end document ready

// Mathijs has been dancing here...
function add_view_for(content_type_id, object_id) {
    $.get('/viewtracker/' + content_type_id + '/' + object_id+'/')
}

var player = null;
function playerReady(obj) {
    player = document.getElementById(obj['id']);
    //alert('oja');
    //alert(obj['id']);
    addListeners();
}

var tries = 2;
function addListeners() {
	if (player) { 
	    player.addViewListener("PLAY", "playListener");
	    //alert('joh');
	} else {
	    tries--;
	    if (tries > 0) setTimeout("addListeners()",100); 
	    //alert('ohoh');
	}
}
var playing = false;
function playListener(obj) {
    if (!playing) {
        playing = true;
        var code = player.getConfig().description;
        eval(code);
    }
}





