function setCookie(c_name,value,exdays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString()+'; path=/');
document.cookie=c_name + "=" + c_value;
}
function getCookie(c_name)
{
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i<ARRcookies.length;i++)
{
  x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
  y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
  x=x.replace(/^\s+|\s+$/g,"");
  if (x==c_name)
    {
    return unescape(y);
    }
  }
}
function checkCookie()
{
var username=getCookie("username");
  if (username!=null && username!="")
  {
  alert("Welcome again " + username);
  }
else
  {
  username=prompt("Please enter your name:","");
  if (username!=null && username!="")
    {
    setCookie("username",username,365);
    }
  }
}

function getUrlVars()
{
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++)
    {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
}
$(document).ready(function(){
   $(".submenu").hide();
   $("#marquee").hide();
   $("#submenu").corner("bottom 9px");
   $(".box_content").corner("7px");

   $("#menu a").not(".link").click(function(){
      var id= $(this).attr('id');
      id = id.substring(5);
      $(".submenu").hide();
      $("#submenu_"+id).show();
      return false;
   });

   var wysokosc = $(window).height() - 28;
   $("#pasek").css('top', wysokosc+"px");
   if( getCookie('pasek') == 0 ) {
      $("#marquee").hide(500);
   } else {
      $("#marquee").show(500);
      $("#marquee").marquee();
   }

   $("#pasek_button").click(function(){
      if( $("#marquee").is(":visible") ) {
         setCookie('pasek','0',365);
         $("#marquee").hide(500);
      } else {
         setCookie('pasek','1',365);
         $("#marquee").show(500);
         $("#marquee").marquee();
      }
      return false;
   });

      var body_width = $('body').width();
      var pos_off = body_width-50 +'px';
      var pos_on_f  = body_width - 310 +'px';
      pos_off = '-300px';
      pos_on_f  = '0px';
      var pos_on_y  = body_width - 530 +'px';
      $('#facebook').css('left',pos_off);
      $('#youtube').css('left',pos_off);

   	$('#facebook').mouseover(function(){
   		$(this).stop();
   		$(this).animate({left : pos_on_f  },500);
   		$(this).css('zIndex' , '1003');
   	});
   	$('#facebook').mouseout(function(){
   		$(this).stop();
   		$(this).animate({left : pos_off },500);
   		$(this).css('zIndex' , '1001');
   	});

   if( window.location.href.indexOf('newsy') > 2 )       { $("#submenu_newsy").show(); }
   if( window.location.href.indexOf('unia_tarnow') > 2 ) { $("#submenu_unia_tarnow").show(); }
   if( window.location.href.indexOf('stadion') > 2 )     { $("#submenu_stadion").show(); }
   if( window.location.href.indexOf('ekstraliga') > 2 )  { $("#submenu_ekstraliga").show(); }
   if( window.location.href.indexOf('strefa_fana') > 2 ) { $("#submenu_strefa_fana").show(); }
   if( window.location.href.indexOf('sponsorzy') > 2 )   { $("#submenu_sponsorzy").show(); }
   if( window.location.href.indexOf('kontakt') > 2 )     { $("#submenu_kontakt").show(); }

$("#submenu_forum").show();
   // aktualnosci obrazek special przyklejony
   $("#newsy_przyklejone_img img").hide(0);
   $("#newsy_przyklejone_img img:first").show(0);

   $(".news_przyklejony").mouseover(function(){
      $("#newsy_przyklejone_img img").hide(0);
         var index = $(".news_przyklejony").index( $(this) );
         if(index == 0){ $("#newsy_przyklejone_img img:first").show(0); }
         if(index == 1){ $("#newsy_przyklejone_img img:first").next("img").show(0); }
         if(index == 2){ $("#newsy_przyklejone_img img:first").next("img").next("img").show(0); }
   });

   setInterval(function(){
      $.ajax({ url: 'http://uniatarnow.net/ajax.php',
               success: function(data){ $("#marquee").html(data); $("#marquee").marquee();  }
            });
   },60000);
   
});


