var t = n = count = j = 0;
$(function()
{
    var p = getposition(document.getElementById("globalsearch"));
	
	$("#bannerul").css("left", p["x"]);

	$(".banner").css("width",window.screen.width);

	$("#banner1").html("").addClass("banner1bak");

	$("#bannerul").show();

	$(".banner").hide().eq(0).show();

	count = $("#bannerul li").size();

	$("#bannerul li:first-child").css({ "background": "#666666" }).siblings().css({ "background": "#c9cacc" });
	$("#bannerul li").mouseover(function()
	{
		var i = $("#bannerul li").index(this);

		n = i;

		if (i >= count) return;
		
		var bannerli = $(this);

		tmout = setTimeout(function(){$(".banner").fadeOut("slow");$(".banner").eq(i).fadeIn("slow");bannerli.css({ "background": "#666666" }).siblings().css({ "background": "#c9cacc" });},200);		

	});

	$("#bannerul li").mouseout(function(){clearTimeout(tmout);});


	$("#bannerul li").click(function()
	{
		var i = $("#bannerul li").index(this);

		n = i;

		if (i >= count) return;
		$(".banner").fadeOut("slow");
		$(".banner").eq(i).fadeIn("slow");

		$(this).css({ "background": "#999999" }).siblings().css({ "background": "#c9cacc" });

	});

	$(".banner").click(function()
	{
		window.open($("#bannerImg a").eq(n).attr("href"), "_blank");
	});

	t = setInterval("showAuto()", 4000);
	$("#banner").hover(function() { clearInterval(t) }, function() { t = setInterval("showAuto()", 4000); });
	
	$("#bannerul ul li").hover(function() { clearInterval(t) }, function() { t = setInterval("showAuto()", 4000); });


});

function showAuto()
{
	n = n >= (count - 1) ? 0 : n + 1;
	$("#bannerul li").eq(n).trigger('click');
}

function showViewContent(){
	if ($.browser.msie && ($.browser.version == 6.0))
		{
			$(".ViewOpen").css("top","-10px");
		}
		if ($.browser.msie && ($.browser.version == 7.0))
		{
			$(".ViewOpen").css("top","-10px");
		}
		if ($.browser.msie && ($.browser.version == 8.0))
		{
			$(".ViewOpen").css("top","-10px");
		}
	
	$(".ViewOpen").fadeIn("fast");
}

function getposition(obj)
{
	var r = new Array();
	r['x'] = obj.offsetLeft;
	r['y'] = obj.offsetTop;
	while (obj = obj.offsetParent)
	{
		r['x'] += obj.offsetLeft;
		r['y'] += obj.offsetTop;
	}
	return r;
}

