// JavaScript Document
$(document).ready(function(){
	$("[over]").each(function(){
		var over = $(this).attr("over");
		var up = $(this).attr("src");
		$(this).hover(function(){
			$(this).attr("src", over);
		}, function(){
			$(this).attr("src", up);
		});
	});
	//theleft = 1163;
	thetop = 0;
	curpanel = 0;
	//panels = $(".panel").length;
	$(".panelhome").show();
	$(".panel").hide();
	$(".panel").each(function(){
		//$(this).css("margin-left", theleft+"px");
		//if($(this).attr("rel") != 'p1'){
			//$(this).css("display", "none");
		//}
		thetop = $(this).parent().parent().height();
		//theleft = theleft+$(this).parent().parent().width();
	});
	$(".bar1").each(function(){
		$(this).hover(function(){
			forcepanel($(this).attr("rel").replace("ab",""));
		});
	});
});
function over(panel){
	newsrc = $("img[rel=b"+panel+"]").attr("src").replace(".", "_over.");
	$("img[rel=b"+panel+"]").attr("src", newsrc);
}
function out(){
	$("img[rel^=b]").each(function(){
		$(this).attr("src", $(this).attr("src").replace("_over", ""));
	});
}
function forcepanel(panel){
	out();
	over(panel);
	curpanel = panel;
	//if(panel == curpanel){ return; }
	$(".panel").hide();
	$(".panel[rel=p"+curpanel+"]").show();
	
	newleft = $(".panel[rel=p"+panel+"]").css("marginLeft");
	$(".banner_inside").animate({ 'marginLeft':'-'+newleft }, 'slow',function(){
		//$(".panel[rel!=p"+panel+"]").css("display", "none");
	});
}
