// (c) 2008 by Thinker 

function showAlert(msg)
{
	$('#alert span').empty().append(msg);
	$('#alert').absCenter().show();
}

function showMsg(msg)
{ $('#msgbox').html(msg).absCenter().show().fadeOut(2500); }

function setupDefaults()
{
	$("button").hover(
		function(){
			dy=$(this).attr('rollover');
			if(dy) $(this).css({backgroundPosition:"0 "+dy+"px"});
		},
		function(){
			dy=$(this).attr('rollover');
			if(dy) $(this).css({backgroundPosition:"0 0"});
		}
	);
}
function anilogo() 
{ 
 $('.logo').animate({backgroundPosition:Math.round(Math.random()*100-50)+' 0'}, 
  3000,
  function(){setTimeout(anilogo,2500)}) 
}
function anifirefly()
{
  logo.maxx=$('.logo').width()-24;    
  //logo.maxy=$('.logo').height()-24;
  
  var $f=$('.logo').find('.firefly1, .firefly2, .firefly3');
  var e=$f[Math.floor($f.length*Math.random())];
  var p=$(e).position();
  p.left=Math.min(logo.maxx, p.left+Math.random()*500-250);
  p.top=Math.min(logo.maxy, p.top+Math.random()*500-250);
  
  $(e).animate(p,5000);
}

var logo={};
$(document).ready(function () {
	$('#alert button').click(function() {
		$('#alert').hide();
	});
	
	// ajax
	$().ajaxError(function(event, request, settings){
  	showAlert('Nie można było połączyć się z serverem');
		$('#ajaxWait').hide();
 	});
	$().ajaxStart(function() {
		$('#ajaxWait').absCenter().show();
	}).ajaxStop(function() {
		$('#ajaxWait').hide();
		setupDefaults();
	});
	$.browser.msie6 = $('#ie6warn').length;

  setTimeout(anilogo,2000);
  if($('.logo').css('backgroundImage').indexOf('night')>0) {
    logo.maxx=$('.logo').width()-24;    
    logo.maxy=99;//$('.logo').height()-24;
    for(var i=0; i<25; i++)    
      $('<div class=firefly'+(Math.ceil(0.001+Math.random()*2.99))+'></div>').css({left:Math.random()*logo.maxx,top:Math.random()*logo.maxy}).appendTo('.logo');
    setInterval(anifirefly,500);
  }
  
  hero={lvl:999,prof:''};
  $('.itemborder>IMG[stats]').attr('tip', function(){
    var st=$(this).attr('stats').split('||');
    return itemTip({name:st[0],stat:st[1],cl:st[2],pr:st[3]});
  });
});
function isset(x)
{ return typeof(x)!='undefined'; }
function mp(x) // changes 5 to +5, -5 to -5
{	if(x>0) return '+'+x; else return x; }


