﻿  //搜索       
  $(function(){
            String.prototype.trim=function(){var reExtraSpace = /^\s*(.*?)\s+$/; return this.replace(reExtraSpace,"$1").replace(/</,"&lt;").replace(/>/,"&gt;");};
            $("#inputtxt").keydown(function(event){
               switch(event.keyCode)
               {
                case 13: Search();return false;
               }
            });
            $("#imgSearch").click(function(){
                Search();
            });
        });
        function Search()
        {
                var sKey =$("#inputtxt").val();
                sKey=sKey.trim();
                if(sKey.length==0)
                {
                    alert("搜索关键字不能为空！");
                }
                else
                {
                    window.open("../web/search.aspx?key="+escape(sKey));
                }
        }
        
        
//图片等比例缩放
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 SetHome(obj,homepageurl){
	try{
		obj.style.behavior='url(#default#homepage)';
		obj.setHomePage(homepageurl);
	}catch(e){
		if(window.netscape){
			try{
				netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
			}catch(e){
				alert("抱歉，此操作被浏览器拒绝！\n\n请在浏览器地址栏输入“about:config”并回车然后将[signed.applets.codebase_principal_support]设置为'true'");
			};
		}else{
			alert("抱歉，您所使用的浏览器无法完成此操作。\n\n您需要手动将'"+homepageurl+"'设置为首页。");
		};
	};
};
//加入收藏
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(url, title, link)
{
                        var so = new SWFObject("../images/focus.swf", "focus", "232", "198", "6", "#efefef");
                        so.addParam('wmode','transparent');
                        so.addVariable("picurl",url);
                        so.addVariable("pictext",title);
                        so.addVariable("piclink",link);
                        so.addVariable("pictime","2");
                        so.addVariable("borderwidth","232");
                        so.addVariable("borderheight","198");
                        so.addVariable("borderw","false");
                        so.addVariable("buttondisplay","true");
                        so.addVariable("textheight","15");
                        so.write("focus");
}
    //左右底对齐
        $(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); 
                                }

                              });
                           }  
//    $(function () {
//        $('p.bg marquee').marquee().mouseover(function () {
//            $(this).trigger('stop');
//        }).mouseout(function () {
//            $(this).trigger('start');
//        })
//    });
//    
//     $(function () {
//        $('div.up marquee').marquee('pointer').mouseover(function () {
//            $(this).trigger('stop');
//        }).mouseout(function () {
//            $(this).trigger('start');
//        })
//    });
    
function externallinks() { 
if (!document.getElementsByTagName) return; 
var anchors = document.getElementsByTagName('a'); 
for (var i=0; i<anchors.length; i++) { 
var anchor = anchors[i]; 
if (anchor.getAttribute('href') && 
anchor.getAttribute('rel') == 'external') 
anchor.target = '_blank'; 
} 
} 
$(function(){
externallinks();
});


