(function($){$.fn.lavaLamp=function(o){o=$.extend({fx:"linear",speed:500,click:function(){}},o||{});return this.each(function(){var b=$(this),noop=function(){},$back=$('<li class="back"><div class="left"></div></li>').appendTo(b),$li=$("li",this),curr=$("li.current-cat",this)[0]||$($li[0]).addClass("current-cat")[0];$li.not(".back").hover(function(){move(this)},noop);$(this).hover(noop,function(){move(curr)});$li.click(function(e){setCurr(this);return o.click.apply(this,[e,this])});setCurr(curr);function setCurr(a){$back.css({"left":a.offsetLeft+"px","width":a.offsetWidth+"px"});curr=a};function move(a){$back.each(function(){$(this).dequeue()}).animate({width:a.offsetWidth,left:a.offsetLeft},o.speed,o.fx)}})}})(jQuery)

/*控制滚动条滚动插件*/
	jQuery.fn.scrollTo = function(speed) {
		var targetOffset = $(this).offset().top;
		$('html,body').stop().animate({scrollTop: targetOffset}, speed);
		return this;
	};
$(function(){
		/*导航*/
		$(".nava").click(function(){
			var target_id = $(this).attr("href");
			$(target_id).scrollTo(500);
			return false;
		});
	});
/*回到顶部*/
$(function(){
$(".goto a").click(function(){
			$("body").scrollTo(500);
			return false;
		});
/*回到顶部跟随滚动条滚动*/
		var gotoscroll = $(".goto").offset().top;
		$(window).scroll(function (){
			$(".goto").css("width","25px");
			var offsetTop = gotoscroll + $(window).scrollTop() +"px";
			$(".goto").animate({top : offsetTop },{ duration:500 , queue:false });
			if($(window).scrollTop() == 0){$(".goto").hide();}else{$(".goto").show();}
			});})

$(function(){$(".lavaLamp").lavaLamp({ fx: "backout", speed: 400 })});


function setHomepage(pageURL) {
    if (document.all) {
        document.body.style.behavior='url(#default#homepage)';
        document.body.setHomePage(pageURL);
    }
    else {
            try { //IE
                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
            } catch (e) {
    try{ //Firefox
     var prefs = Components.classes['@mozilla.org/preferences-service;1']
.getService(Components. interfaces.nsIPrefBranch);
     prefs.setCharPref('browser.startup.homepage',pageURL);
    } catch(e) {
                alert( "您的浏览器不支持该操作，请使用浏览器菜单手动设置." );
    }
            }
    }
}


function AddFavorite(sURL, sTitle) {
    try { //IE
        window.external.addFavorite(sURL, sTitle);
    } catch (e) {
        try { //Firefox
            window.sidebar.addPanel(sTitle, sURL, "");
        } catch (e) {
   try{//Chrome无法自动收藏，用创建快应用程序的捷方式来替代。
    createShortcut();
   } catch(e){
    alert("您的浏览器不支持自动加入收藏，请使用浏览器菜单手动设置.");  
   }
        }
    }
}
