<!--
//导航菜单最大项
function MaxMenu(i){
	//过多菜单项变成下拉菜单开始
	var $MenuNum = i; //设置最大菜单项 
	var $menu = $('#menu>ul');
	var $MoreLi = $menu.find('> li:gt('+($MenuNum-2)+')');
	var $MoreLiNum = $menu.find('> li:gt('+($MenuNum-1)+')').length;
	if($MoreLiNum>0){
		$('<li id="MoreMenu" class="iHover"><a href="javascript:void(0);">更多</a><ul></ul></li>').appendTo('#menu>ul');
		var $MoreMenu = $('#MoreMenu>ul');
		$MoreLi.appendTo($MoreMenu);	
	}
	//过多菜单项变成下拉菜单结束
	
	//下拉菜单滤镜效果开始
	$menu.find('ul').parent().each(function(){												
			$(this).hover(
				function(){
					$(this).find('>ul').stop(true, true);
					$(this).find('>ul').slideDown(200);
					return false; //阻止冒泡
				},
				function(){
					$(this).find('>ul').slideUp(300);
				}
			);
	});
	//下拉菜单滤镜效果结束
	
	$(".iHover").hover(
		function(){
			$(this).addClass("iShow");
		},function(){
			$(this).removeClass("iShow");
		}
	);
};

//加入收藏&设置首页
function addCookie(url, name) {　
    if (document.all) {
        window.external.addFavorite(url, name)
    } else if (window.sidebar) {　window.sidebar.addPanel(name, url, "")
    }
}
function setHomepage(url) {　
    if (document.all) {
        document.body.style.behavior = 'url(#default#homepage)';
        document.body.setHomePage(url)
    } else if (window.sidebar) {
        if (window.netscape) {
            try {
                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect")
            } catch(e) {
                alert("该操作被浏览器拒绝，假如想启用该功能，请在地址栏内输入 about:config,然后将项 signed.applets.codebase_principal_support 值该为true")
            }
        }
        var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
        prefs.setCharPref('browser.startup.homepage', url)
    }
}

//在线客服
lastScrollY = 0;
function heartBeat() {
    var diffY;
    if (document.documentElement && document.documentElement.scrollTop){
    diffY = document.documentElement.scrollTop;
	}
    else if (document.body){
    diffY = document.body.scrollTop
	}
    else
    {}
    percent = .1 * (diffY - lastScrollY);
    if (percent > 0){
	percent = Math.ceil(percent);
	}
    else{
	percent = Math.floor(percent);
	}
    document.getElementById("OnlineService").style.top = parseInt(document.getElementById("OnlineService").style.top) + percent + "px";
    lastScrollY = lastScrollY + percent;
}
//-->

/**
 * 图片尺寸自适应
 * @param {Integer} maxWidth
 * @param {Integer} maxHeight
 * @param {String} src
 * 更新页面载入完毕再执行、修正小图问题
 */
jQuery.fn.fixInBoxComplete = function(maxWidth,maxHeight,src)
{
    var _imgs = jQuery(this);
	//判断浏览器类型及页面是否载入完毕
	var appname = navigator.appName.toLowerCase();
	if (appname.indexOf("netscape") == -1) {  //IE、Opera
		document.onreadystatechange = function() {
			if (document.readyState == "complete") {		
				imageSize();
			}
		}
	} else { //Firefox、Chrome
		window.onload = function() {
			imageSize();
		}
	}
	function imageSize(){
		_imgs.each(function(){
			var _img=jQuery(this);
			var _src = src?src:_img.attr("src");
			if (_src.indexOf("accessoryId=")>0 && _src.indexOf("height=")==-1){
				_img.attr("src", function(){
					return _src+"&width="+maxWidth+"&height="+maxHeight;
				});
				
			}
			var imageSizeFixerFull = new ImageSizeFixerFull(_img,maxWidth,maxHeight);
			imageSizeFixerFull.resize();
			
		});
	}
	
	var ImageSizeFixerFull = function(imageEl,maxWidth,maxHeight){
		this.resize = function(){
			var _cop  = maxWidth/maxHeight; // 最优宽高比例
			// 原始尺寸
			var _width;
			var _height;
			var _marginTop; // 内填充上
			var _marginLeft; // 内填充左
			// 修改尺寸
			var mWidth;
			var mHeight;
			// 比例
			var _copSource;
			var _copChange; // 缩略比例
			var _cImg = imageEl;// fixed:单页多图片自动缩略不均衡
			_width = _cImg.attr("width");
			_height = _cImg.attr("height");
			_marginTop = parseInt(_cImg.css("margin-top"),10) || 0;
			if (_width > maxWidth || _height > maxHeight) // 需要缩略的条件
			{
				_copSource = _width/_height; // 当前宽高比例
				// 按照比例缩略
				if (_copSource > _cop){ // 当前图片较宽
					// 将宽度缩略到限制的最宽
					mWidth = maxWidth;
					_copChange = mWidth/_width;
					mHeight = _height*_copChange;
				}else{ // 比例相符
					mHeight = maxHeight;
					_copChange = mHeight/_height;
					mWidth = _width*_copChange;
				}
				_marginTop = (maxHeight-mHeight)/2;
				_cImg.attr("width",mWidth);
				_cImg.attr("height",mHeight);
				_cImg.css("margin-top",_marginTop);
			}else { //宽高都小于最大宽高时候
				_marginTop = (maxHeight-_height)/2;
				_cImg.attr("width",_width);
				_cImg.attr("height",_height);
				_cImg.css("margin-top",_marginTop);
			}
		}
	}

    return true;
}

//渐变出场
jQuery.fn.ListShow = function(ShowTime,AnimateTime,obj){ //参数分别为：显示速度、渐变动画速度、对象元素
	var List = jQuery(this);
	var LiLength = List.find(obj).length;
	var LiPage = 0;
	List.find(obj+':nth-child(6n+6)').addClass('last');
	
	List.find(obj).css({
		visibility:'hidden'
	});

	Interval = setInterval(iShow,ShowTime);

	function iShow(){
		var n = LiPage-1;
		if(LiPage>LiLength){
			clearInterval(Interval);
		}
		LiPageClickold(List.find(obj+':eq('+(n)+')'),1);	
		LiPage++;
	}
	
	function LiPageClickold(obj,diaphaneity){
		obj.css({
			visibility:'visible',
			opacity: "0"
		});
		obj.animate({
			opacity: diaphaneity
		},AnimateTime);
	}
}

//Title信息提示框
jQuery.fn.TitleInfoBox = function(SiteName,SiteInfo,opacity){ //参数分别为：网站名称标识、网站简介标识、背景透明度（1为不透明）
	var LinkList = jQuery(this);
	var Info;
	var ImgAlt;
	LinkList.find('li.text').appendTo(LinkList);
	LinkList.find('li').mouseover(function(e){
		var InfoArr = new Array();
		Info = $(this).find('a').attr("title");
		ImgAlt = $(this).find('a img').attr("alt");
		InfoArr = Info.split("|");
		$(this).find('a').attr("title","");
		$(this).find('a img').attr("alt","");
		$('body').append('<div class="InfoBox"></div>');
		if(SiteName === "" && SiteInfo ==="" ) {
			$('.InfoBox').html(InfoArr[0]);
		}else {
			$('.InfoBox').html('<span class="title">'+SiteName+'：</span>'+InfoArr[0]+'<br /><span class="title">'+SiteInfo+'：</span>'+InfoArr[1]);
		}
		$('.InfoBox').css({
			display: 'block',
			top: (e.pageY+20),
			left: (e.pageX+10),
			opacity: '0'
		}).animate({
			opacity: opacity
		},500);
	}).mousemove(function(e){
		$('.InfoBox').css({
			top: (e.pageY+20),
			left: (e.pageX+10)
		});
	}).mouseout(function(e){
		$('.InfoBox').remove();
		$(this).find('a').attr("title",Info);
		$(this).find('a img').attr("alt",ImgAlt);
	});
}

//留言切换
var GuestbookHeight;
$(function(){
	GuestbookHeight = $('.GuestBookList').height();
});
function GuestBookList(e){
	var BookList = $('.GuestBookList');
	var BookForm = $('.GuestBookForm');
	BookList.stop(true,true);
	if(e==='yes'){
		$('.BookFormBtn').removeClass('iShow');
		$('.BookListBtn').addClass('iShow');
		BookList.animate({
			height: GuestbookHeight,
			opacity:"1"
		});
	}else {
		$('.BookListBtn').removeClass('iShow');
		$('.BookFormBtn').addClass('iShow');
		BookList.animate({
			height: '0',
			opacity:"0"
		});
	}
}

//友情链接切换
var LinkListHeight;
$(function(){
	LinkListHeight = $('.LinkListBox').height();
});
function LinkList(e){
	var LinkList = $('.LinkListBox');
	var LinkForm = $('.LinkFormBox');
	if(e==='yes'){
		$('.FormBtn').removeClass('iShow');
		$('.ListBtn').addClass('iShow');
		LinkList.animate({
			height: LinkListHeight,
			opacity: "1"
		});
		LinkForm.animate({
			height: '0',
			opacity: "0"
		})
	}else {
		$('.FormBtn').addClass('iShow');
		$('.ListBtn').removeClass('iShow');
		LinkForm.animate({
			height: '360',
			opacity: "1"
		})
		LinkList.animate({
			height: '0',
			opacity: "0"
		})
	}
}
