/* 鼠标切换 */
function nTabs(b, c) 
{
    if (b.className != "active") 
    {
        $("#imghmarket").attr("src","images/loading.gif")
        var d = b.parentNode.id,
        e = document.getElementById(d).getElementsByTagName("li");
        for (i = 0; i < e.length; i++) 
        {
           if (i == c)
           {
              b.className = "active";
              if(c==0)
              {
                 GetHImgUrl("HMarket");//加载沪市
              }
              if(c==1)
              {
                 GetHImgUrl("SMarket");//加载深市
              }
              if(c==2)
              {
                 GetHImgUrl("HSMarket");//加载沪深
              }
              if(c==3)
              {
                 GetHImgUrl("QZ");//加载期指
              }
              //document.getElementById(d + "_Content" + i).style.display = "block";
           } 
           else 
           {
              e[i].className = "normal";
             // document.getElementById(d + "_Content" + i).style.display = "none";
           }
        }
    }
}

/* 推荐产品弹性效果*/
function show_hide(i)
		{
			$("#div_1").slideUp("slow");	
			$("#div_2").slideUp("slow");	
			$("#div_3").slideUp("slow");	
			
			$("#div_"+i).slideDown("slow");	
			
			$("#h1_1").attr("class","close_b");
			$("#h1_2").attr("class","close_b");
			$("#h1_3").attr("class","close_b");
			
			$("#h1_"+i).attr("class","open_b");
		}
		
/* Banner */
var t = n = count = j = 0;
$(function()
{
    //加载图片
   GetHImgUrl("HMarket");//默认加载沪市
    
    var l=$("#Table1").offset().left-4;
    $("#divnews").css("margin-left",l+"px");
    
    
    $(".open div").bind("mouseover",function(){
        $(".open div").css("cursor","pointer");
    });
    
	/*Banner切换效果 start*/
	$(".bannerul").show();

	$(".banners").hide().eq(0).show();

	count = $(".bannerul li").size();
	$(".bannerimg a:first-child").show();
	$(".bannerul li:first-child").css({ "background": "#808080" }).siblings().css({ "background": "#808080" });
	$(".bannerul li").mouseover(function()
	{
		var i = $(".bannerul li").index(this);

		n = i;

		if (i >= count) return;
		
		var bannerli = $(this);

		tmout = setTimeout(function(){$(".bannerimg a").filter(":visible").fadeOut(400).parent().children().eq(i).fadeIn(1000);bannerli.css({ "background": "#880000" }).siblings().css({ "background": "#808080" });},200);		

	});

	$(".bannerul li").mouseout(function(){clearTimeout(tmout);});


	$(".bannerul li").click(function()
	{
		var i = $(".bannerul li").index(this);

		n = i;

		if (i >= count) return;
		$(".bannerimg a").fadeOut(400).parent().children().eq(i).fadeIn(1000);
		$(this).css({ "background": "#880000" }).siblings().css({ "background": "#808080" });

	});


	t = setInterval("showAuto()", 4000);
	$(".bannerimg").hover(function() { clearInterval(t) }, function() { t = setInterval("showAuto()", 4000); });
	
	$(".bannerul ul li").hover(function() { clearInterval(t) }, function() { t = setInterval("showAuto()", 4000); });

	$("#navgation>ul>li>a").mouseover(function(){ clearInterval(t); });
	$("#navgation>ul>li>a").mouseout(function(){t = setInterval("showAuto()", 4000); });

	$("#navgation>ul>li>div").mouseover(function(){ clearInterval(t); });
	$("#navgation>ul>li>div").mouseout(function(){t = setInterval("showAuto()", 4000); });
});


function GetHImgUrl(market)
{
      $.ajax({
        type: "GET",
        url:"../WebControl/Common1/CommonExec.aspx?r="+Math.random(),
        data: { Type:""+market+"" },
        dataType: "json",
        success: function (url) {
            var imgurl = eval(url);
            $("#imghmarket").attr("src",imgurl[0].URL)
        }
    });
}

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;
}


