jQuery.preloadImages = function()
{
  for(var i = 0; i<arguments.length; i++)
  {
    jQuery("<img>").attr("src", arguments[i]);
  }
}

var curgroup = 1;

function next_group() {
	if(curgroup >= image_group.length - 1)
		curgroup = 0;
	else
		curgroup++;
	
	$('img.pos:eq(0)').attr('src',image_group[curgroup][0]);
	$('img.pos:eq(1)').attr('src',image_group[curgroup][1]);
	$('img.pos:eq(2)').attr('src',image_group[curgroup][2]);
	setTimeout(function(){fade_in()},2000);

}

function fade_out() {
	if(curgroup >= image_group.length - 1)
		curgroup = 0;
	else
		curgroup++;
	
	$('img.bkg:eq(0)').attr('src',image_group[curgroup][0]);
	$('img.bkg:eq(1)').attr('src',image_group[curgroup][1]);
	$('img.bkg:eq(2)').attr('src',image_group[curgroup][2]);
	$("div.homeimg .pos").fadeOut(1000);
	setTimeout(function(){next_group()},1200);
}



function fade_in() {
	$("div.homeimg .pos").fadeIn(1000);
	setTimeout(function(){fade_out()},2000);
}

$(document).ready(function() {
		setTimeout(function(){fade_out()},2000);
	});

