$(document).ready(function(){
	$("a.img_1").bind("mouseover", function(){
		img_switch(0);
	});

	$("a.img_1").bind("mouseout", function(){
		change = setTimeout("xchange()", 5000);
	});

	$("a.img_2").bind("mouseover", function(){
		img_switch(1);
	});

	$("a.img_2").bind("mouseout", function(){
		change = setTimeout("xchange()", 5000);
	});

	$("a.img_3").bind("mouseover", function(){
		img_switch(2);
	});

	$("a.img_3").bind("mouseout", function(){
		change = setTimeout("xchange()", 5000);
	});

	change = setTimeout("xchange()", 5000);
} 	
);

function img_switch(img){
	clearTimeout(change);
	$('img.'+imgs[current]).hide();
	current = img;
	$('img.'+imgs[img]).show();
}

function xchange(){
 	if(current < length){
 		$('img.'+imgs[current]).fadeOut("slow");
 		current++;
 		$('img.'+imgs[current]).fadeIn("slow");
 			
 	}
 	else{
 		$('img.'+imgs[current]).fadeOut("slow");
 		current = 0;
 		$('img.'+imgs[current]).fadeIn("slow");	
 	}
	change = setTimeout("xchange()", 5000);
}

var imgs = new Array('img_1', 'img_2', 'img_3');
var bgk = new Array('caro-1', 'caro-2', 'caro-3');
var length = 2;
var current = 0;
var change;