
    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());
      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 getNewSize(srcHeight, srcWidth, maxWidth, maxHeight)
    {
        var resizeWidth = srcWidth;
        var resizeHeight = srcHeight;

        var aspect = resizeWidth / resizeHeight;

        if (resizeWidth > maxWidth)
        {
            resizeWidth = maxWidth;
            resizeHeight = resizeWidth / aspect;
        }
        if (resizeHeight > maxHeight)
        {
            aspect = resizeWidth / resizeHeight;
            resizeHeight = maxHeight;
            resizeWidth = resizeHeight * aspect;
        }
        
        return {
            height: resizeHeight,
            width: resizeWidth
        };
    }


    function checkIcons()
    {
            $('.icon').each(function()
            {
            });
    }
    
    $('document').ready(function()
    {
        loadCurrentArtist();
        checkIcons();

	    var a = getCookie('last_artist');
        var s = getCookie('last_song');
        var i = getCookie('last_image');

        $("#artist").text(a);
        $("#song").text(s);
        $("#image").attr("src", i);
		
		$('#center img').each(function(){
    		  
              if($(this).attr("src").indexOf("http://") == -1)
              {
                return;
              }
              
              $(this).wrap('<a rel="fancybox[article]" href="' + $(this).attr("src") + '" />');
              $(this).parent().fancybox({
                title: document.title.split("-")[0],
                overlayColor: '#333'
              });
		});

    	var ma = document.getElementById('header').getElementsByTagName('A');
    	for(i=0; i<ma.length; i++)
    	{

    		if(ma[i].href.indexOf('?') > -1 && document.location.toString().indexOf(ma[i].href) > -1)
    		{
    				ma[i].style.backgroundImage = 'url(theme/kupreski/images/menu-active.png)';


    		}
    		if(document.location == 'http://www.kupreskiradio.com' | document.location == 'http://www.kupreskiradio.com/' | document.location == 'http://kupreskiradio.com/index.php')
    		{
    				ma[ma.length-1].style.backgroundImage = 'url(theme/kupreski/images/menu-active.png)';
    		}
    	}

    });
