function externalLinks() 
{
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i < anchors.length; i++) 
	{
		var anchor = anchors[i];
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external")
			anchor.target = "_blank";
	}
}

//var informations = new Informations();

$(document).ready(function()
{	
	externalLinks();
	
	$('.pane .search .button').click(function(){
		
		if($('.pane .radio :checked').val() == 'interplan.pl')
		{
			$('#search').attr('action', 'http://interplan.pl/');
			$('#search').append($('.pane .search .q').clone(true));
			$('#search').attr('method', 'get');
			$('#search').attr('target', '_blank');
		}
		else if($('.pane .radio :checked').val() == 'plocman.pl')
		{
			$('#search').attr('action', '/szukaj/szukaj/strona/1');
			$('#search').append($('.pane .search .q').clone(true));
			$('#search').attr('method', 'post');
			$('#search').attr('target', '_self');
		}
		else if($('.pane .radio :checked').val() == 'google.pl')
		{
			//$('#search').attr('action', 'http://interplan.pl/');
			//$('#search').append($('.pane .search .q').clone(true));
		}
		$('#search').submit();
		$('#search').html('');
	});
	
	$('#header .map .shortcut h5 a').click(function(){
	   $('#header .map .shortcut-pane').show();
	});
	
	$('#header .map .shortcut-pane > a').click(function(){
	  $(this).parent().hide();
	});
	
	$('#left-panel .header li').click(function(){
		var id = $(this).parent().parent().attr('id');
		$('#' + id + ' .body > li').hide();
		$('#' + id + ' .header > li').removeClass('current');
		$(this).addClass('current');
		$('#' + $(this).attr('id').split('head').join('pane')).show();
		/*
		switch($(this).attr('id').split('head-').join(''))
		{
			case '112':
				informations.read('112', '5,6', 6, 0);
			break;
			case 'informacje':
				informations.read('informacje', '1,2,7,8', 6, 0);
			break;
			case 'sport':
				informations.read('sport', '3,4', 6, 0);
			break;
		}
		*/
	});
	
	$('.flash').each(function(){	
		var vars = {};
		$(this).children('object').children('param').each(function(){
			vars[$(this).attr('name')] = $(this).val();
		});
		$(this).children('object').remove();
		$(this).flash(vars);
	});
	
	$(".facebook-slider").hover(function() {
		$(".facebook-slider").stop(true, false).animate({right:"0"},"medium");
	},function() {
		$(".facebook-slider").stop(true, false).animate({right:"-302px"},"medium");
	}, 500);
	
	var open = false;
	$(".okazcjeplock-slider").click(function() {
		if(!open)
	    {
	        $(".okazcjeplock-slider").stop(true, false).animate({ right: "0" }, "medium");
	        open = true;
	    }
	    else
	    {
	        $(".okazcjeplock-slider").stop(true, false).animate({ right: "-263" }, "medium");
	        open = false;
	    }
	});
	
});

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', analitics]);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

/*
function Informations()
{
	this.read = function(name, cats, inside, how)
	{
		$.ajax({
			url: "/ajax/left-panel/cats/" + cats + "/inside/" + inside + "/how/" + how,
			success: function(result){
				
				$('#left-panel .body #pane-' + name + ' .news').html(result);
				$('#left-panel .body #pane-' + name + ' .news li').hover(
					function(){
						$(this).addClass('selected');
						var id = $(this).children('a').attr('id').split('left-panel-news-').join('');
						if(!$(this).children('a').hasClass('not-egsist'))
							$('#left-panel .body #pane-' + name + ' img').attr('src', '/img_news/' + id + '_a.jpg');
						else
							$('#left-panel .body #pane-' + name + ' img').attr('src', '/images/left-panel/' + $(this).children('a').attr('rel') + '.gif');
					}, 
					function(){
						$(this).removeClass('selected');
					}
				);
			}
		});
	};
};
*/
