$(document).ready(function() {
	// antibot stuff 
	var mDefaultHost = "vespojenios.cz";
	$("span.mBox").each(function() {
		var mData = $(this).attr('title').split(' ');
		var mName = mData[0];
		var mHost = (mData.length == 2) ? mData[1] : mDefaultHost;
		var mSelf = mName+'@'+mHost;
		$(this).replaceWith("<a href=\"mailto:"+mSelf+"\">"+(($(this).text() == '') ? mSelf : $(this).text())+"</a> ");
	});
	
	// link and div scrubber fix
	$("a").bind("focus",function(){ if(this.blur) this.blur(); });
	
	// _blank classed anchros open in new window
	$("a._blank").bind("click",function(){ window.open(this.href); return false; });

	// _preparing classed anchros alert message
	$("a._preparing").bind("click",function(){ alert('Obsah odkazovaného dokumentu je v příprave.'); return false; });
	
	// width:100% + scroll bug fix
	var fullWidth = 980;
    if($(window).width() < fullWidth) { $('div.full-width').css('width',fullWidth+'px'); }
    $(window).bind('resize', function() {
        var newWidth = $(window).width();
        if(newWidth < fullWidth) {
            $('div.full-width').css('width',fullWidth+'px');
        } else {
            $('div.full-width').css('width','100%');
        }
    });
    
    // unbind opening _blank classed anchors in new window 
    // and activate lightbox galleries
    // Note: lightbox is automaticly applied on all anchors having
    //       rel='lightbox-*' so we do choose the adepts that occure
    //       in galleries but doesn`t have rel attribute set...
    $(".gallery a").each(function() {
    	var link = $(this);
    	if(link.attr('rel').length == 0)
    		link.attr('rel','lightbox-common')
    })    
    // ...and get them together under one common gallery
    $(".gallery a[rel='lightbox-common']").unbind().lightbox();
});
