$(function(){
	$('a.newwin').attr("target","_blank");
	var anchors = $('a');
	$($('.popup'),anchors).click(function(){
		cls = $(this).attr('class');
		url = $(this).attr('href');
		w   = ((cls.match(/w:(\d+)/)||[])[1]) || 266;
		h   = ((cls.match(/h:(\d+)/)||[])[1]) || 476;
		parm = "width="+w+",height="+h+",scrollbars=0,resizable=0";
		window.open(url,'InfoWindow',parm).focus();
		return false;
	});
	$('span.email').each(function(){
		var at = / at /;
		var dot = / dot /g;
		var addr = $(this).text().replace(at,"@").replace(dot,".");
		$(this).after('<a href="mailto:'+addr+'" title="Nosūtīt vēstuli">'+addr+'</a>')
			.hover(function(){window.status="Nosūtīt vēstuli!";},function(){window.status="";});
		$(this).remove();
	});
	$('a.bookmark, a[@rel="bookmark"]').click(function(){
		return Bookmark.add(this);
	});
});
var Bookmark = {
	title   : document.title,
	url     : document.location,
	add : function (anchor){
		if (document.all) {
			window.external.AddFavorite(this.url, this.title);
		} else if (window.sidebar){
			window.sidebar.addPanel(this.title, this.url, '');
		} else if (window.opera) {
			anchor.rel = 'sidebar';
			anchor.href = '';
			return true;
		} else {
			alert('Unfortunately your browser doesn\'t support this feature. In order to bookmark this site please do so manually through your browser.');
		}
		return false;
	}
};

