var FormController = {

    init: function()
    {
        this.handleTrickyFields();
    },

    handleTrickyFields: function()
    {
        $(".trickyField").each(function(index, item) {
            var title = $(this).val();
            $(this).attr("title", title);

            $(this).focus(function() {
                if ($(this).val() == title) $(this).val("");
            });

            $(this).blur(function() {
                if ($(this).val() == "") $(this).val(title);
            });
        });
    }
}

$(document).ready(function() {
        FormController.init();
	$("a[rel='colorbox']").colorbox();
	$('a.dictionary').click(function() {
		var rel = $(this).attr('rel');
		$(this).colorbox({href:"/pl/slownik-pojec div#" + rel, width: '550px', height: '350px'});
	});
});

function writeFlash(p) {
	writeEmbed(
		'D27CDB6E-AE6D-11cf-96B8-444553540000',
		'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0',
		'application/x-shockwave-flash',
		p
	);
}

function writeEmbed(cls, cb, mt, p) {
	var h = '', n;

	h += '<object classid="clsid:' + cls + '" codebase="' + cb + '"';
	h += typeof(p.id) != "undefined" ? 'id="' + p.id + '"' : '';
	h += typeof(p.name) != "undefined" ? 'name="' + p.name + '"' : '';
	h += typeof(p.width) != "undefined" ? 'width="' + p.width + '"' : '';
	h += typeof(p.height) != "undefined" ? 'height="' + p.height + '"' : '';
	h += typeof(p.align) != "undefined" ? 'align="' + p.align + '"' : '';
	h += '>';

	for (n in p)
		h += '<param name="' + n + '" value="' + p[n] + '">';

	h += '<embed type="' + mt + '"';

	for (n in p)
		h += n + '="' + p[n] + '" ';

	h += '></embed></object>';

	document.write(h);
}
