var index = 0;
var t;

/**
* input: (int) m 1|2
*/ 
var i, j; 
function slideShow(m)
{
	if(m==1)
	{
		var imgName = img[index];
		tmp = new String(index);
		$("#img:first img").attr({
		src: imgName,
		id: tmp.valueOf()
		}); 
		if(index == (img.length - 1)) 
		index = 0;
		else
		index++;
		
		i = setTimeout("slideShow(1)", 5000); 
	}
	else if(m==2)
	{
		var imgName2 = img2[index];
		tmp = new String(index);
		$("#img2:first img").attr({
			src: imgName2,
			id: tmp.valueOf()
		}); 
		if(index == (img2.length - 1)) 
			index = 0;
		else
			index++; 
		
		j = setTimeout("slideShow(2)", 5000); 
	}
}


$(document).ready(function(){
	slideShow(1);	
	slideShow(2);	
	//$("#control").css({visibility:"visible"});	
	//Slide 1
	$('.imgTmp').mouseover(function (e){
		var id = new String($(e.target).attr("id"));
		$("#img").html('<img src="'+img[id]+'" width="174" height="232" />');			
		$("#img:first img")
		.attr({width: "174"})
		.removeAttr("height")
		.removeAttr("style");
		clearTimeout(i);
	});
	$('.imgTmp').mouseout(function (e){ 
		slideShow(1);				
	});
	
	//Slide 2
	$('.imgTmp2').mouseover(function (e){
		var id = new String($(e.target).attr("id"));
		$("#img2").html('<img src="'+img2[id]+'" width="174" height="232" />');			
		$("#img2:first img")
		.attr({width: "174"})
		.removeAttr("height")
		.removeAttr("style");
		clearTimeout(j);
	});		
	$('.imgTmp2').mouseout(function (e){ 
		slideShow(2);				
	});
});