﻿//模板头部公用js
$(document).ready(function(){
    var divMenu=document.getElementById("menu");
    var MenuList=divMenu.getElementsByTagName("li");
    for(var i=1;i<=MenuList.length;i++)
    {
	    if(MenuList[i-1].getAttribute("temid")==menuID)
		    MenuList[i-1].className="bg01";
	    else
		    MenuList[i-1].className="bg02";
    }
});
//根据cookies名称获取value
//参数:Name(cookie名称)
//return value
function GetCookie(Name) {
    var search = Name + "=";
    var returnvalue = "";
    if (document.cookie.length > 0) {
        offset = document.cookie.indexOf(search);
        if (offset != -1) { 
            offset += search.length;
            end = document.cookie.indexOf(";", offset); 
        if (end == -1)
            end = document.cookie.length;
            returnvalue=unescape(document.cookie.substring(offset,end));
        }
    }
    return returnvalue;
}
//投诉建议
function Advice()
{
    var cmyid=document.getElementById("CmyID").value;
    window.location.href=AdviceUrl+"?CmyID="+cmyid;
}
//管理员入口
function EnterAdmin()
{
    window.location.href=EnterManageUrl;
}
//添加收藏
function AddFavorite(sURL, sTitle)   
{   
	try   
	{   
		window.external.addFavorite(sURL, sTitle);   
	}   
	catch (e)   
	{   
		try   
		{   
			window.sidebar.addPanel(sTitle, sURL, "");   
		}   
		catch (e)   
		{   
			alert("加入收藏失败，请使用Ctrl+D进行添加");   
		}   
	}   
}   
//设为首页
function SetHome(obj,vrl)
{   
		try{   
				obj.style.behavior='url(#default#homepage)';obj.setHomePage(vrl);   
		}   
		catch(e){   
				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',vrl);   
				 }   
		}   
}  
//点词评论
function ProductFocus()
{
    $("#txtContent").focus();
}
//限制banner高度
function SetBannerImg(h){
        var ig = new Image();
        ig.src = this.src;
       if(ig.height>h)
       {
            $(this).attr("height",h);
       }
}
//限制logo高度
function SetLogoImg(h){
        var ig = new Image();
        ig.src = this.src;
       if(ig.height>h)
       {
            $(this).attr("height",h);
       }
}