/// RANDOM BACKGROUND ///

$(document).ready(function(){
	bgImageTotal=5;
	randomNumber = Math.round(Math.random()*(bgImageTotal-1))+1;
	imgPath=('/wp-content/themes/staczek/images/bg/'+randomNumber+'.jpg');
	$('body.home').css('background-image', ('url("'+imgPath+'")'));
});

/// PREVIEW IMAGE ///

      var player       =  null;
      var playlist     =  null;


      function playerReady(obj)
      {
        player = gid(obj.id);
        addListeners();
      };


      function addListeners()
      {
        playlist = player.getPlaylist();

        if(playlist.length > 0)
        {
          player.addModelListener('TIME', 'timeMonitor');
        }
        else
        {
          setTimeout("addListeners();", 100);
        }
      };


      function timeMonitor()
      {
        if(obj.position > 1)
        {
          player.sendEvent('PLAY', 'false');
        }
      };


      function gid(name)
      {
        return document.getElementById(name);
      };
      
      
/// PRETTY HOVER AND DIV CLICK ///

$(document).ready(function(){


    // Pretty Hover
    $('body.archive div.category-filmography').hover(function() {
      $(this).addClass('pretty-hover');
    }, function() {
      $(this).removeClass('pretty-hover');
    });
    $('body.archive div.category-discography').hover(function() {
      $(this).addClass('pretty-hover');
    }, function() {
      $(this).removeClass('pretty-hover');
    });
    $('body.page-template div.category-filmography').hover(function() {
      $(this).addClass('pretty-hover');
    }, function() {
      $(this).removeClass('pretty-hover');
    });
    $('body.page-template div.category-discography').hover(function() {
      $(this).addClass('pretty-hover');
    }, function() {
      $(this).removeClass('pretty-hover');
    });



    // Div Click
	$("body.archive div.category-filmography").click(function(){
	  window.location=$(this).find("a").attr("href"); return false;
	});
    // Div Click
	$("body.archive div.category-discography").click(function(){
	  window.location=$(this).find("a").attr("href"); return false;
	});
    // Div Click
	$("body.page-template div.category-filmography").click(function(){
	  window.location=$(this).find("a").attr("href"); return false;
	});
    // Div Click
	$("body.page-template div.category-discography").click(function(){
	  window.location=$(this).find("a").attr("href"); return false;
	});

});

