﻿  //搜索
  $(function(){
            String.prototype.trim=function(){var reExtraSpace = /^\s*(.*?)\s+$/; return this.replace(reExtraSpace,"$1").replace(/</,"&lt;").replace(/>/,"&gt;");};
            $("#searchText").keydown(function(event){
               switch(event.keyCode)
               {
                case 13: Search();break;
               }
            });
            $("#imgSearch").click(function(){
                Search(0);
            });
             $("#img1Search").click(function(){
                Search(1);
            });
        });
        function Search(flag)
        {
                var sKey =$("#searchText").val();
                sKey=sKey.trim();
                sKey=sKey.replace(/^\s*(\S+)\s*$/,"$1").replace(/</,"&lt;").replace(/>/,"&gt;");
                if(sKey.length==0||sKey=="请输入查询关键字")
                {
                    alert("搜索关键字不能为空！");
                }
                else
                {
                    window.open("../web/search.aspx?key="+escape(sKey)+"&flag="+flag);
                }
        }
        
        
//图片等比例缩放
function DrawImage(objImg,maxWidth,maxHeight){ 
        var img = new Image(); 
            img.src = objImg.src; 
        var hRatio; 
        var wRatio; 
        var Ratio = 1; 
        var w = img.width; 
        var h = img.height; 
            wRatio = maxWidth / w; 
            hRatio = maxHeight / h; 
        if(maxWidth ==0 && maxHeight==0)
        { 
            Ratio = 1; 
        }
        else if(maxWidth==0)
        { 
              if (hRatio<1) 
                 Ratio = hRatio; 
        }
        else if (maxHeight==0)
        { 
            if (wRatio<1) 
                Ratio = wRatio; 
        }
        else if (wRatio<1 || hRatio<1)
        { 
            Ratio = (wRatio<=hRatio?wRatio:hRatio); 
        } 
        if (Ratio<1)
        { 
            w = w * Ratio; 
            h = h * Ratio; 
        } 
        
        objImg.height = h; 
        objImg.width = w;

        if(h<=maxHeight)
        {
                  objImg.style.paddingTop=(maxHeight-h)/2;
                  objImg.style.paddingBottom=(maxHeight-h)/2;
        }
        if(w<=maxWidth)
        {
                objImg.style.paddingLeft=(maxWidth-w)/2;
                objImg.style.paddingRight=(maxWidth-w)/2;
        }
}
//<img onload="DrawImage(this,140,120)" src="ss.jpg"/>



//加入收藏 设为主页
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 AddFavorite(sURL, sTitle)
{
    try
    {
        window.external.addFavorite(sURL, sTitle);
    }
    catch (e)
    {
        try
        {
            window.sidebar.addPanel(sTitle, sURL, "");
        }
        catch (e)
        {
            alert("加入收藏失败，请使用Ctrl+D进行添加");
        }
    }
}
    //翻滚图片js
    function CreateFlash(idad, swfurl, wad, had, vs){
    var str = "<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0\" width=\"" + wad + "\" height=\"" + had + "\" id=\"" + idad + "\" align=\"middle\">";
    str += "<param name=\"allowScriptAccess\" value=\"always\">";
    str += "<param name=\"quality\" value=\"high\">";
    str += "<param name=\"movie\" value=\"" + swfurl + "\">";
    str += '<param name=\"wmode\" value=\"transparent\">';
    str += "<param name=\"flashvars\" value=\"" + vs + "\">";
    str += "<embed src=\"" + swfurl + "\" flashvars=\"" + vs + "\" wmode=\"transparent\" quality=\"high\" width=\"" + wad + "\" height=\"" + had + "\" name=\"" + idad + "\" align=\"middle\" allowScriptAccess=\"always\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\">";
    str += "</object>";
    document.write(str);
    }
    //左右底对齐
        $(function(){
        if($("#left").height()>=$("#right").height())
        {
            $("#right").height($("#left").height());
            }
            else
            {
                $("#left").height($("#right").height());
            }
        })  
        //取投票的选值
         function GetValue()
                           {
                              $("input[name*='RadioButtonList1']").each(function(i)
                              {
                                if(this.checked==true)
                                {
                                  
                                window.open("ViewVote.aspx?id="+this.value); 
                                }

                              });
                           }  
