﻿var newsCon;//新闻内容
var newsList;//新闻列表
var BP;//banner定时切换
var bflag=0;//banner标记
var bWidth;//banner宽度
var speed=6000;

var nowb_i=0;//首页业务滑动门当前索引 

var AP;//公告滑动
var an;//公告对象

$(document).ready(function(){
if(document.getElementById("add_f"))//加入收藏夹
{
	var $addf=$("#add_f");
	$addf.click(function(){addBookmark("福建省外服机构服务中心","http://www.cnfesc.com")});
}
if(document.getElementById("Banner"))//首页图片轮换
{
	bWidth=parseInt($("#Banner").css('width'));
	$("#Banner .current li").css("opacity","0.5");
	$("#Banner .current li").eq(0).css("opacity","1");
	$("#Banner .current li").bind("mouseover",bcurrent);
	BP=setInterval(Bpic,speed);
	$("#Banner").hover(bh01,bh02);
}
if($(".yw").length>0)//banner中的业务
{
	$(".yw").hover(fy01,fy02);
}

if($("#announcement").length>0)//公告
{
	an=new an_val($("#announcement .con"));
	var domhtml=$("#announcement .con").html();
	domhtml+=domhtml;
	$("#announcement .con").html(domhtml);
	AP=setInterval(APP,80);
	$("#announcement .con").hover(function()
								  {
									  clearInterval(AP);
								  },
								  function()
								  {
									  AP=setInterval(APP,80);
								  });
}
if($("#business").length>0)//业务滑动门
{
	$("#business .title li").bind("mouseover",bh);
}
if($(".news_con .con p").length>0)//获取新闻内容
{newsCon=$(".news_con .con p");}
if($(".list_detail .con li").length>0)//列表高光
{
newsList=$(".list_detail .con li");
newsList.hover(listOver,listOut);
}
if($(".dx").length>0)//非首页滑动门
{
	$(".dx li").bind("mouseover",dx);
}
if($(".gnw_btn").length>0)//国际交流菜单切换
{
	$(".g01").click(function(){$(".gn").show();$(".gw").hide();});
	$(".g02").click(function(){$(".gw").show();$(".gn").hide();});
}
});
//加入收藏夹
function addBookmark(title, url) {
        if (window.sidebar) {
            window.sidebar.addPanel(title, url, "");
        } else if (document.all) {
            window.external.AddFavorite(url, title);
        } else if (window.opera && window.print) {
            return true;
        }
}
function bh01()
{
	clearInterval(BP);
}
function bh02()
{
	BP=setInterval(Bpic,speed);
}
function bcurrent()//首页Banner小图片鼠标滑过
{
	$(".picShow").stop(true,true);
	var $this=$(this);
	bflag=Number($this.text())-1;
	$(".linow").css("opacity","0.5").removeClass("linow");
	$this.css("opacity","1").addClass("linow");
	$(".picShow").animate({left:'-'+bflag*bWidth},300);
}
function Bpic()//首页Banner定时滑动
{
	$(".picShow").stop(true,true);
	var blen=$(".picShow>li").length;
	var bn=(blen-1)*bWidth;
	var pn=parseInt($(".picShow").css('left'));
	if(pn+bn<=0)
	{
		bflag=0;
		$(".picShow").animate({left:'0'},300);
	}
	else
	{
		bflag++;
	    $(".picShow").animate({left:'-='+bWidth},300);
	}
	$(".linow").css("opacity","0.5").removeClass("linow");
	$(".current li").eq(bflag).css("opacity","1").addClass("linow");

}
//banner业务
function fy01()
{
	$(".yw .fy").stop(true,true);
	$(".yw .fy").slideDown(300);
}
function fy02()
{
	$(".yw .fy").stop(true,true);
	$(".yw .fy").slideUp(300);
}

function an_val($obj)//公告数据
{
	this.width=$obj.width();
	this.height=$obj.height();
}
function apf($obj)//公告动画滑动
{
	var l=0-parseInt($obj.css('top'));
	$obj.stop(true,true);
	if(an.height<=l)
	{   
		$obj.css('top','0');
	}
	else
	{
		$obj.animate({top:'-=1'},1);
	}
}
function APP()//公告定时
{
	apf($("#announcement .con"));
}
//首页业务滑动门
function bh()
{ 
$("#business .title").find(".nowb").removeClass("nowb");
$(this).addClass("nowb");
var i=$("#business .title li").index($(".nowb")[0]);
$("#business .con").find(".show").removeClass("show").addClass("hide");
$("#business .con .bli").eq(i).removeClass("hide").addClass("show");
}
//非首页滑动门
function dx()
{
	var n;
	switch(this.id)
	{
		case "t1":
		 n=0;break;
		case "t2":
		 n=1;break;
		case "t3":
		 n=2;break;
		case "t4":
		 n=3;break;
	}
	$(".dx_now").removeClass("dx_now");
	$(this).addClass("dx_now");
	var i=0;
	while(i<$(".dx li").length)
	{
		if(!$(".dx").parent().next().find(".clist").eq(i).hasClass("hide"))
     		 $(".dx").parent().next().find(".clist").eq(i).addClass("hide");
	    i++;
	}
	$(".dx").parent().next().find(".clist").eq(n).removeClass("hide");
}
//新闻列表高光
function listOver()
{
	$(this).css("background","#efefef url(../image/cnfesc_style_pic.png) -290px -478px no-repeat");
}
function listOut()
{
	$(this).css("background","");
}
//大字体
function bigFont()
{
	newsCon.css("font-size","24px");
}
//中字体
function normalFont()
{
	newsCon.css("font-size","18px");
}
//小字体
function smallFont()
{
	newsCon.css("font-size","14px");
}

