
//等比例缩放图片
function DrawImage(ImgD,width,height){
   var image=new Image();
   image.src=ImgD.src;
   if(image.width>0 && image.height>0){
    flag=true;
    if(image.width/image.height>=width/height){
     if(image.width>width){  
     ImgD.width=width;
     ImgD.height=(image.height*width)/image.width;
     }else{
     ImgD.width=image.width;  
     ImgD.height=image.height;
     }
     ImgD.alt=image.width+"×"+image.height;
     }
    else{
     if(image.height>height){  
     ImgD.height=height;
     ImgD.width=(image.width*height)/image.height;     
     }else{
     ImgD.width=image.width;  
     ImgD.height=image.height;
     }
     ImgD.alt=image.width+"×"+image.height;
     }
    }
   } 
   
function showhide(obj) 
{
	if (obj.style.display=='block') 
	{
		obj.style.display='none';
	}
	else 
	{
		obj.style.display='block';
	}

}


function ShowHideTableWithCorrectStr(flagStr)
{
	var obj=document.getElementsByTagName("table")
	for(i in obj)
	{	
		//document.write(typeof(obj[i]));//.style.display="none";
		//document.write("table3".substring(0,5));
		var len=flagStr.length;
		if(i.substring(0,len)==flagStr)
			showhide(obj[i]);
			
			
	}
	
}


function DrawImage(ImgD,width,height){
   var image=new Image();
   image.src=ImgD.src;
   if(image.width>0 && image.height>0){
    flag=true;
    if(image.width/image.height>=width/height){
     if(image.width>width){  
     ImgD.width=width;
     ImgD.height=(image.height*width)/image.width;
     }else{
     ImgD.width=image.width;  
     ImgD.height=image.height;
     }
     ImgD.alt=image.width+"×"+image.height;
     }
    else{
     if(image.height>height){  
     ImgD.height=height;
     ImgD.width=(image.width*height)/image.height;     
     }else{
     ImgD.width=image.width;  
     ImgD.height=image.height;
     }
     ImgD.alt=image.width+"×"+image.height;
     }
    }
   } 
   
	
	function ShowSelectImg(CommonIDstr,PicPreStr,index,LabelNum)
	{
		for(var i=1;i<=LabelNum;i++)
		{	
			picPath="images_1/";
			imgSrcA=picPath+PicPreStr+i+"_A.jpg";
			imgSrcB=picPath+PicPreStr+i+"_B.jpg";
			if(i==index)
				eval("document.all."+CommonIDstr+i+".src='"+imgSrcA+"'");
			else 
			{
				eval("document.all."+CommonIDstr+i+".src='"+imgSrcB+"'");
			}
			
		}
	
	}
	
	
function ShowSelectTable(CommonTablestr,index,TableNum)
	{
		for(var i=1;i<=TableNum;i++)
		{	
			if(i==index)
				eval("document.getElementById('"+CommonTablestr+i+"').style.display='inline'");
			else 
			{
				eval("document.getElementById('"+CommonTablestr+i+"').style.display='none'");
			}
			
		}
	
	}
	


//下拉菜单函数
activateMenu=function(nav) {

    /* currentStyle restricts the Javascript to IE only */
	if (document.all && document.getElementById(nav).currentStyle) {  
		
        var navroot=document.getElementById(nav);
        
        /* Get all the list items within the menu */
        var lis=navroot.getElementsByTagName("TD");  
        for (i=0; i<lis.length; i++) {
      	  //
           /* If the LI has another menu level */
		   		j=i
		  
            if(lis[i].firstChild.tagName=="DIV"){
           		 // alert(lis[i].lastChild.tagName);
                /* assign the function to the LI */
				//alert(j);
				eval("temp"+j+"=lis[i].lastChild");
             	lis[i].onmouseover=function() {	
                
					//alert(this.tagName);
                   /* display the inner menu */
            			this.firstChild.style.display='inline';
                }
                lis[i].onmouseout=function() {                       
                    this.firstChild.style.display='none';
				  // temp.style.display="none";
                }
            }
        }
    }
}


//加入收藏
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,url){
        try{
                obj.style.behavior='url(#default#homepage)';obj.setHomePage(url);
        }
        catch(e){
                if(window.netscape) {
                        try {
                                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");  
                        }  
                        catch (e)  { 
                                alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将[signed.applets.codebase_principal_support]设置为'true'");  
                        }
                        var prefs=Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
                        prefs.setCharPref('browser.startup.homepage',url);
                 }
        }
}

