$('document').ready(function()
{	
	var baseUrl = '/';
	var peopleIterations	= -1;
	var peopleCount			= 0;
	var peopleIDs			= Array (); 
		
	$('.alt_movies_prev').live('click',function ()
  {	  	
		Id = $(this).attr('id')

		$('#current_movie').fadeOut(100,function()
		{
			$('#current_movie').load(baseUrl+'movie/ajax', {id: Id}, function()
            {
                $('#current_movie').fadeIn(100);
            });
		}); 		
	}); 
	
	$('#current_movie_arrow_left').live('click',function ()
	{
		var page = parseInt($('#alt_movies').attr('custom:page'));
		var pages = parseInt($('#alt_movies').attr('custom:pages'));
		if (page > 1)
		{
			page -= 1; $('#alt_movies').attr('custom:page',page);	
			$('#alt_movies').load(baseUrl+'movie/pager/'+page+'/', {page: page}, function() {});
		}
	});
	
	$('#current_movie_arrow_right').live('click',function ()
	{
		var page = parseInt($('#alt_movies').attr('custom:page'));
		var pages = parseInt($('#alt_movies').attr('custom:pages'));
		if (page < pages)
		{
			page += 1; $('#alt_movies').attr('custom:page',page);
			$('#alt_movies').load(baseUrl+'movie/pager/'+page+'/', {page: page}, function() {});			
		}		
	});
    
  var interval = setInterval(function()
  {
		if (peopleIterations < 0 || peopleIterations >= peopleIDs.length)
		{
			var data	= $.ajax({ type: "GET", url: baseUrl+'onzemensen/getrandomlist', async: false }).responseText;
			peopleIDs	= data.split ('|');

			peopleIterations = 0;
		}
		
		var personID	= peopleIDs[peopleIterations++]; 		
		showPeopleInfo(personID);
  }, 4000);
	
  $('.people_img').live('click', function()
  {
		showPeopleInfo($(this).attr('id'));
    clearInterval(interval);
  });
  
    
	function getRandomPeopleId()
  {
		var return_value= $.ajax({ type: "GET", url: baseUrl+'onzemensen/getrandomid', async: false }).responseText;
    return return_value;        
  } 
    
  function showPeopleInfo(clickitem)
  {
		lidId = clickitem;
    $('#people_info').fadeOut(100, function()
    {
			$('#people_info').load(baseUrl+'onzemensen/getstatenlid', {id: lidId}, function()
      {
				$('#people_info').fadeIn(100);
      });
    });        
  }
    
	$('.news_content').live('click', function()
    {
        var el = $(this).find('a').attr('href');
		if (el!=null)
        window.location = el; 
    });
	$('.inthemedia').live('click', function()
    {
        var el = $(this).find('a').attr('href');
		if (el!=null)
        window.location = el; 
    });
	$('.column_content').live('click', function()
    {
        var el = $(this).find('a').attr('href');
		if (el!=null)
        window.location = el; 
    });
	$('#header_cont_top_cont').live('click', function()
    {
        var el = $(this).find('a').attr('href');
		if (el!=null)
        window.location = el; 
    });
	/*$('.blue_content_text').live('click', function()
    {
		var el = $(this).find('a').attr('href');
		if (el!=null)
        window.location = el; 
    });*/
});
