
var HomeLeaveAble=0;
var HomeStart=0;
$(document).ready(function(){

	version = parseFloat(navigator.appVersion.split("MSIE")[1]);
	if ((version >= 5.5) && (version <= 7) && (document.body.filters)) {
	}else{
		$("#HomeThumbnails").css("margin-left","220px");
		//alert("IE 6/7");
	}

	Resize();

	$("#homeBGcontent").css("marginTop",-300);
	$("#HomeThumbnails dl").css("display","none");
	$("#HomeThumbnails ul").css("position","absolute");
	$("#HomeThumbnails ul li").css("position","absolute");
	//HomeThumbnailSet();

	$("#HomeThumbnails ul li").mouseenter(function(){
		if(HomeLeaveAble==1){
			$(this).stop().animate({"marginTop":-1*$(this).height()},400);
		}
	}).mouseleave(function(){
		if(HomeLeaveAble==1){
			$(this).stop().animate({"marginTop":-162},200);
		}
	}).click(function(){
		$("body").append("<div id='homeBGoverlay'></div>");

		$("#homeBGcontent").animate({"marginTop":-300},600);

		HomeLeaveAble=0;
		TmpLength=$("#HomeThumbnails ul li").length;
		TmpObj=$(this);
		$("#HomeThumbnails ul li").animate({"marginTop":"0px"},600,"",function(){
			//HomeLeaveAble=1;
			TmpIndex = $("#HomeThumbnails ul li").index(this);
			
			if((TmpIndex+1)==TmpLength){
				HomeSrc=$(TmpObj).attr("Homeimg");
				$("#homeBG .homeBGbox img").attr("src","files/images/"+HomeSrc);
				$("#HomeThumbnails ul li").removeClass("activated");
				$(TmpObj).addClass("activated");
			}
		});
	});

	$("#homeBG .homeBGbox img").load(function(){
	});

});

$(window).resize(function() {
	Resize();
});

function HomeImageLoad(){
	$("#homeBGoverlay").remove();
	HomeThumbnailSet();
}

function Resize(){
	h = $(window).height();
	$("#homeBG .homeBGbox").height(h);
	$("#Wrap").height(h);
}

function HomeThumbnailSet(){
	Topimg = $("#HomeThumbnails li.activated").attr("Topimg");
	if(HomeStart==0){
		HomeStart=1;
		$("#homeBGcontent span").hide();
	}else{
		$("#homeBGcontent span").show();
		$("#homeBGcontent dl").html($("#HomeThumbnails li.activated dl").html());
	}

	$("#homeBGcontent img").attr("src","files/images/"+Topimg);

	$("#HomeThumbnails ul li").css("marginTop","0").css("marginLeft","0");
	TmpWidth=183;
	TmpLeft=TmpWidth*3;
	$.each($("#HomeThumbnails ul li"),function(){
		if(!$(this).hasClass("activated")){
			$(this).animate({"marginTop":"-162px"},600,"",function(){
				$(this).animate({"marginLeft":TmpLeft},800,"",function(){
					HomeLeaveAble=1;
				});
				TmpLeft-=TmpWidth;
			});
		}else{
			$("#homeBGcontent").animate({"marginTop":0},600);
		}
	});
}
