//图片按比例缩放,可输入参数设定初始大小
/*
function resizeimg(ImgD,iwidth,iheight) {
var image=new Image();
image.src=ImgD.src;
if(image.width>0 && image.height>0){
if(image.width/image.height>= iwidth/iheight){
if(image.width>iwidth){
ImgD.width=iwidth;
ImgD.height=(image.height*iwidth)/image.width;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
ImgD.alt=image.width+"×"+image.height;
}
else{
if(image.height>iheight){
ImgD.height=iheight;
ImgD.width=(image.width*iheight)/image.height;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
ImgD.alt=image.width+"×"+image.height;
}
　　　　　ImgD.style.cursor= "pointer"; //改变鼠标指针
　　　　　ImgD.onclick = function() { window.open(ImgD.src);} //点击打开大图片
　　　　if (navigator.userAgent.toLowerCase().indexOf("ie") > -1) { //判断浏览器，如果是IE
　　　　　　ImgD.title = "请使用鼠标滚轮缩放图片，点击图片可在新窗口打开";
　　　　　　ImgD.onmousewheel = function img_zoom() //滚轮缩放
　　　　　 {
　　　　　　　　　　var zoom = parseInt(this.style.zoom, 10) || 100;
　　　　　　　　　　zoom += event.wheelDelta / 12;
　　　　　　　　　　if (zoom> 0)　this.style.zoom = zoom + "%";
　　　　　　　　　　return false;
　　　　　 }
　　　  } else { //如果不是IE
　　　　　　　     ImgD.title = "点击图片可在新窗口打开";
　　　　　　   }
}
}
*/


var FitWidth = 166; 
var FitHeight = 166; 
function ResizePic(ImgTag) 
{ 
var image = new Image(); 
image.src = ImgTag.src; 
if(image.width>0 && image.height>0){ 
if(image.width/image.height >= FitWidth/FitHeight){ 
if(image.width > FitWidth){ 
ImgTag.width = FitWidth; 
ImgTag.height = (image.height*FitWidth)/image.width; 
} 
else{ 
ImgTag.width = image.width; 
ImgTag.height = image.height; 
} 
} 
else{ 
if(image.height > FitHeight){ 
ImgTag.height = FitHeight; 
ImgTag.width = (image.width*FitHeight)/image.height; 
} 
else{ 
ImgTag.width = image.width; 
ImgTag.height = image.height; 
} 
} 
} 
} 

function ResizePic2(ImgTag){
 FitWidth = 360; 
 FitHeight = 380;
 ResizePic(ImgTag)
}
function ResizePic3(ImgTag){
 FitWidth = 150; 
 FitHeight = 135;
 ResizePic(ImgTag)
}

/*IE和Firefox下都能使用的“加入收藏”代码*/
function bookmarksite(title, url){
if (document.all)
window.external.AddFavorite(url, title);
else if (window.sidebar)
window.sidebar.addPanel(title, url, "")
}
/*设为首页*/
function setHomepage()
{
 if (document.all)
    {
   document.body.style.behavior='url(#default#homepage)';
  document.body.setHomePage('http://www.hufagolf.com');
 
    }
    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','http://www.hufagolf.com');
 }
}

/*关闭窗口*/
function CloseWin()
{
var ua=navigator.userAgent
var ie=navigator.appName=="Microsoft Internet Explorer"?true:false
if(ie){
var IEversion=parseFloat(ua.substring(ua.indexOf("MSIE ")+5,ua.indexOf(";",ua.indexOf("MSIE "))))
if(IEversion< 5.5){
var str = '<object id=noTipClose classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">'
str += '<param name="Command" value="Close"></object>';
document.body.insertAdjacentHTML("beforeEnd", str);
document.all.noTipClose.Click();
}
else{
window.opener =null;
window.close();
}
}
else{
window.close()
}
}

