window.onerror=function(){return true;}
$(function(){
//首页幻灯相关
$(".sliding").fadeIn(3000).find('.sliding-box').css({"opacity":".7"}).animate({"top":'92px'},600);
$(".sliding-box").hover(function(){$(this).stop(true).animate({"top":'0px'},200)},function(){$(this).stop(true).animate({"top":'92px'},300)});

$(".flip").css({"opacity":".7"}).fadeIn(3000);

//首页底部标签
$('.index_tab_links a').each(function(i){
    $(this).mouseover(function(){
        $('.index_tab_links a').removeClass('on');
        $(this).addClass('on');
        $('.tab_sub').hide();
        $('.tab_sub').eq(i).show();
    })
});
//hd
(function (){
	var a=$('#hd>a'),b=$('#hd img'),t=10000,l=b.length,e=Math.floor(l*Math.random()),d='',targ;
	if(l>1){
	for(i=1;i<l+1;i++){
        targ = a[i-1].target ? ' target="'+a[i-1].target+'"' : '';
        d+='<a href="'+a[i-1].href+'"'+targ+'>' + i + '</a>';
	}
	$('<div id="tab_btns" class="tab_btns"></div>').html(d).appendTo('#hd');
	a.hide();
	var c=$('#tab_btns a');
	e=0;//注释掉此行，随机展示
	a.eq(e).show();
	
	$color=b.eq(e).attr("bgc");
		if($color=='')$color="#C9C9C9";
		$("#main").stop(true).animate({"backgroundColor":""+$color+""},100);
		
	//c.css({'opacity':'0.6'});
	c.eq(e).addClass('on');
	//.html(a.eq(e).attr('title'))
	s=setInterval(f=function(){e++;if(e>=l){e=0;};w(e);},t);
	var w=function(n){
		for(var i=l-1;i>=0;i--){
			c.eq(i).removeClass('on');
			a.eq(i).hide();
			}
		c.eq(n).addClass('on');
		b.eq(n).fadeIn('slow');
		//if(a.eq(n).attr('title'))c.eq(n).html(a.eq(n).attr('title'));
		a.eq(n).show();
		$color=b.eq(n).attr("bgc");
		if($color=='')$color="#C9C9C9";
		$("#main").stop(true).animate({"backgroundColor":""+$color+""},100);
		};
	c.each(function(i){
		$(this).data('i',i);
		$(this)
		.mouseover(function(){clearInterval(s);w($(this).data('i'));})
		//.click(function(){return false;})
		.focus(function(){this.blur();})
		.mouseout(function(){e=$(this).data('i');s=setInterval(f=function(){e++;if(e>=l){e=0;};w(e);},t);});
		})
		}
	})()
	
$.getScript('/i/js/jQuery.mouseDelay.min.js',function(){
    //submenu
    $("#menu li").each(function(i){
        $('.sub-nav').eq(i).appendTo(this);
        $(this).mouseDelay().hover(
            function(){
                $(this).find('a').addClass("on");
                $(this).find('.sub-nav').slideDown(200);
            },
            function(){
                $(this).find('a').removeClass("on");
                $(this).find('.sub-nav').slideUp(200);
            }
        );
    });

    //地区
    $('#diqu').mouseDelay().hover(function(){
            if($("#diqu-info").html()!='')$("#diqu-info").show();
            else
            $.ajax({
            url: '/area.html',
            success: function(data){
            $("#diqu-info").html(data).show();
            },
            cache: true
            });
        },function(){
        });
        
    function closeBox(e){
        e=e||window.event;
        var obj=e.srcElement?e.srcElement:e.target
        var sel=document.getElementById("diqu-info");
        if(obj!=document.getElementById("diqu")){
                $('#diqu-info').hide();
        }
    }

    document.onclick=function(e){
        e=e||window.event;
        closeBox(e)
    }
        
});

//左侧树开关
    //$(".left-menu").each(function(){$(this).find("a").click(function(){$(this).parent().find("ul").slideToggle('fast')})});
    $(".left-menu").each(function() {$(this).children().click(function(e) {$(this).parent().find("ul").slideToggle('fast');if (e && e.stopPropagation) {e.stopPropagation();} else {window.event.cancelBubble = true;}})});
    
//banner开关
    $('<a id="switch_button" class="png_bg" href="javascript:;" style="position:absolute;top:6px;right:6px;width:24px;height:19px;background:url(/i/images/updown.png) no-repeat;"></a>').appendTo(".content").click(function(){
        $("#top_img").slideToggle('normal',function(d){
            if($.cookie("banner")){
                $.cookie("banner",null);
                $("#switch_button").css("background-position","0 0");
            }else{
                $.cookie("banner","abc",{expires: 7});
                $("#switch_button").css("background-position","0 -19px");
            }
        })
    });
    
//订阅
//$(".link-4").bind("click",open_subscription);
//收藏金和
function addfavorite(surl,stitle)
{
    try
    {
        window.external.addfavorite(surl,stitle);
    }
    catch (e)
    {
        try
        {
            window.sidebar.addpanel(stitle,surl,"");
        }
        catch (e)
        {
            alert("加入收藏失败，请使用ctrl+d进行添加");
        }
    }
}

//载入JS
    $.getScript('/i/js/jquery.cookie.js',function(){
        if($.cookie("banner"))$("#switch_button").css("background-position","0 -19px");
    });
    
}); //$(function(){})

$.getScript('/i/js/jquery.color.js');
$.getScript('/i/js/artDialog/iframeTools.js');
$.getScript('/i/js/jquery.scrollTo.js');


function open_business(id){
    var type;
    switch (id){
        case 2:
            type="申请试用";
            break;
        case 3:
            type="在线购买";
            break;
        case 4:
            type="马上体验";
            break;
        default:
            type="我要留言";
            break;
    }
    art.dialog.open("/business/?type="+id,{
        id:"business",
        title:type,
        ok:function(iframeWin, topWin){
                    iframeWin.document.getElementById('dosubmit').click();
                    return false;
                },
        cancel:function(){},
        width:"706px",
        height:"415px",
        resize:false
    });
}
function open_subscription(){
    art.dialog.open("/api.php?m=get&f=subscription",{
        id:"win",
        title:"邮件订阅",
        ok:function(iframeWin, topWin){
                    iframeWin.document.getElementById('dosubmit').click();
                    return false;
                },
        cancel:function(){},
        width:"300px",
        height:"150px"
    });
}



