$().ready(function() {
	$('.tab_nag li').click(
		function() {
			var tab = $(this).parent().attr('id');
			$('#' + tab + ' li').removeClass('sel');
			$(this).addClass('sel');
			$('#' + $('#' + tab).parent().attr('id') + ' .taby_s')
					.css('display', 'none')
			$('#' + $(this).attr('id') + '_form').css('display',
					'block');
		});

	$('#fav_art').click( function() {
		$.ajax( {
			url : '/index.php?controller=ajax&action=trackarticle',
			type : 'POST',
			data : {
				script_url : $('#script_url').val(),
				article_content : $('#article_content').html(),
				article_title : $('#article_title').html()
			},
			success : function(data) {
				$('#fav_art').html(data);
			}
		});
	});
	
	$('.tooltip').tooltip({ 
	    track: true, 
	    delay: 0, 
	    showURL: false, 
	    showBody: " - ", 
	    fade: 250 
	});
	

	
});

function getElementByClass(tagName, className) {
	var tags = document.getElementsByTagName(tagName);
	var finds = [];
	for ( var i = 0, len = tags.length; i < len; ++i) {
		if (tags[i].className.indexOf(className) != -1)
			finds.push(tags[i]);
	}
	return finds;
}

function showId(id) {
	$('#' + id).show('slow');
}

function hideId(id) {
	$('#' + id).hide('slow');
}

function showLogin() {
	if ($('#loginForm').css('display') == 'block') {
		$('#loginForm').hide('slow');
	} else {
		$('#loginForm').show('slow');
	}
	return false;
}

function showLogin1() {
	if ($('#loginForm1').css('display') == 'block') {
		$('#loginForm1').hide('slow');
	} else {
		$('#loginForm1').show('slow');
	}
	return false;
}

function addAtt()
{
	i = $('.att').size();
	i++;
	t = '<dt><label class="lbl1>">Załączniki:</label></dt><dd><input class="inp1 att" name="of'+i+'" value="" type="file" size="30" /></dd>';
	$('#attach').append(t);
}


function printPreview() {

	window.print();

}

function addWykop() {

	var wykop_url = 'http://e-prawnik.pl'+$('#script_url').val();
	var wykop_title = encodeURIComponent($('#article_title').html());
	var wykop_desc = encodeURIComponent("");
	var wykop_link = 'http://www.wykop.pl/dodaj?url=' + wykop_url + '&title=' + wykop_title + '&desc=&domain=e-prawnik.pl';
	document.location = wykop_link;
}
function addP(a) 
{
	var u = $('#script_url').val();
	var t = encodeURIComponent($('#article_title').html());
	var d = encodeURIComponent("");

	var aLink = new Array();
	aLink['twitter']  = 'http://twitter.com/home?status='+u;
	aLink['blip']     = 'http://blip.pl/dashboard?body='+t+'+'+u;
	aLink['kciuk']    = 'http://www.kciuk.pl/Dodaj-link/?'+u+'/?'+t+'/?'+d;
	aLink['sledzik']  = 'http://nasza-klasa.pl/sledzik?shout='+t+' '+u;
	aLink['gg']       = 'gg:/set_status?description='+t;
	aLink['facebook'] = 'http://www.facebook.com/share.php?u='+u;

	document.location = 'http://e-prawnik.pl/pobierz/agr/'+a+'&u='+u+'&t='+t+'&d='+d;
}

function addFb() {

	var fb_url = 'http://e-prawnik.pl'+$('#script_url').val();
	var fb_title = encodeURIComponent($('#article_title').html());
	var fb_link = 'http://www.facebook.com/share.php?u=' + fb_url + '&t=' + fb_title ;
	document.location = fb_link;
}

function addFb2() {

	
	
	var fb_url = 'http://e-prawnik.pl'+$('#script_url').val();
	var fb_title = encodeURIComponent($('#article_title').html());
	var fb_link = 'http://www.facebook.com/sharer.php?u=' + fb_url + '&t=' + fb_title ;

	$('#fb_link_ep').attr('href',fb_link);

}

function navi(gdzie)
{
if (gdzie != 0) {
document.location.href = gdzie;
}
}
