$(document).ready(function() {
  $('#logo').animate({"left": "+=1000px"}, 2500);
  $('#animation').animate({"left": "+=-300px"}, 6500);
  $('#login').fadeIn(1000);

 /*
  $('a').not('#akce ul a').click(function () {
    $.prettyPhoto.open('images/exit.png','','');
    return false;
  })
*/

  $("#backgroundImage").fadeIn(4000);
  $("#beta").click();
  $('#podmenu li').fadeIn(4000);


  function slideSwitch() {
    $('#akce li[class!="current"]').click();
  }

  $(function() {
        setInterval(slideSwitch, 7000 );
  });

    var imgWrapper = $('#plakat > img');
    imgWrapper.hide().filter(':first').show();
    $('#akce li').click(function () {
       if (this.className.indexOf('current') == -1){
       imgWrapper.hide();
       var pic = $(this).attr("name");
       imgWrapper.filter(pic).fadeIn(500);
       $('#akce li').removeClass('current');

       $('#akce li').each(function(i, el) {
          if($(el).html() != "" ) {
            $(el).html($(el).html().replace(/-on/ig, "-off"));
          }
        });

       $(this).addClass('current');
          $(this).each(function(i, el) {
            if($(el).html() != "" ) {
              $(el).html($(el).html().replace(/-off/ig, "-on"));
            }
       });
      }
    return false;
  });

  /*$('#obsah').fadeIn(4000);*/
  $('#top').fadeIn("slow");

  $("a[rel^='prettyPhoto']").prettyPhoto({
			opacity: 0.45,
			showTitle: false,
      allowresize: true,
      default_width: 290,
			default_height: 250
  });

  $("#scroller").simplyScroll({
			autoMode: 'loop'
  });

});

(function ($) {
        $.fn.cross = function (options) {
            return this.each(function (i) {
                // cache the copy of jQuery(this) - the start image
                var $$ = $(this);

                // get the target from the backgroundImage + regexp
                var target = $$.css('backgroundImage').replace(/^url|[\(\)'"]/g, '');

                // nice long chain: wrap img element in span
                $$.wrap('<span style="position: relative;"></span>')
                    // change selector to parent - i.e. newly created span
                    .parent()
                    // prepend a new image inside the span
                    .prepend('<img>')
                    // change the selector to the newly created image
                    .find(':first-child')
                    // set the image to the target
                    .attr('src', target);

                // the CSS styling of the start image needs to be handled
                // differently for different browsers
                if ($.browser.msie || $.browser.mozilla) {
                    $$.css({
                        'position' : 'absolute',
                        'left' : 0,
                        'background' : '',
                        'top' : this.offsetTop
                    });
                } else if ($.browser.opera && $.browser.version < 9.5) {
                    // Browser sniffing is bad - however opera < 9.5 has a render bug
                    // so this is required to get around it we can't apply the 'top' : 0
                    // separately because Mozilla strips the style set originally somehow...
                    $$.css({
                        'position' : 'absolute',
                        'left' : 0,
                        'background' : '',
                        'top' : "0"
                    });
                } else { // Safari
                    $$.css({
                        'position' : 'absolute',
                        'left' : 0,
                        'background' : ''
                    });
                }

                // similar effect as single image technique, except using .animate
                // which will handle the fading up from the right opacity for us
                $$.hover(function () {
                    $$.stop().animate({
                        opacity: 0
                    }, 550);
                }, function () {
                    $$.stop().animate({
                        opacity: 1
                    }, 550);
                });
            });
        };

    })(jQuery);

    $(window).bind('load', function () {
        $('img.fade').cross();
    });

	$(function() {
	    if (jQuery.browser.msie)
	        $('img[src$=.png]').each(function() {
	            this.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src="+this.src+",sizingMethod='scale')";
	            });
	});

/************** MP3 **************/
  var cacheBuster = "?t=" + Date.parse(new Date());
  var stageW = 248;//"100%";
  var stageH = 50;//"100%";
  var attributes = {};
  attributes.id = 'player';
  attributes.name = attributes.id;
  var params = {};
  params.wmode = "transparent";
  params.allowfullscreen = "true";
  params.allowScriptAccess = "always";
  params.bgcolor = "#ff6cc7";
  var flashvars = {};
  flashvars.componentWidth = stageW;
  flashvars.componentHeight = stageH;
  flashvars.pathToFiles = "player/";
  flashvars.xmlPath = "settings.xml";
  flashvars.artistName = "Dj Jayyare";
  flashvars.songName = "Retro Music Hall";
  flashvars.songURL = "dj jayyare - that sound good to me mix 2012 - preview.mp3";
  swfobject.embedSWF("player/player.swf"+cacheBuster, attributes.id, stageW, stageH, "9.0.124", "player/expressInstall.swf", flashvars, params);

/***********************************/

