// JavaScript Document


function doZoom(size)
{
	var obj=document.getElementById("zoom");
	obj.style.fontSize=size+"px";
}


function ShowHide(tname)
{
	try{
		var obj =document.getElementById(tname);
		if (obj.style.display=="none")
		{
			obj.style.display="block";
		} 
		else
		{
			//obj.style.display="none";
		}
	}
	catch(e)
	{
	}
}


function   getUrlParam(name)
{      
          var   reg   =   new   RegExp("(^|&)"+   name   +"=([^&]*)(&|$)");      
          var   r   =   window.location.search.substr(1).match(reg);      
          if   (r!=null)   return   unescape(r[2]);   return   null;      
 }  
      

function insertFlash(elm, url, w, h) {
 if (!document.getElementById(elm)) return;
 var str = '';
 str += '<object width='+ w +'" height="'+ h +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0">';
 str += '<param name="movie" value="'+ url +'">';
 str += '<param name="wmode" value="transparent">';
 str += '<param name="quality" value="autohigh">';
 str += '<param name="menu" value="false">'; 
 str += '<embed width="'+ w +'" height="'+ h +'" src="'+ url +'" quality="autohigh" wmode="opaque" type="application/x-shockwave-flash" plugspace="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed>';
 str += '</object>';
 document.getElementById(elm).innerHTML = str;
}


//关键词高亮显示
function highlight(str)
{   if(str=="")
      return;
    if(document.createRange){ 
    var range = document.createRange(); 
    }else 
    var range = document.body.createTextRange(); 
    if(range.findText){ 
        while(range.findText(str)){ 
          range.pasteHTML(range.text.fontcolor("#ff0000")); 
          range.collapse(true); 
        } 
    }else{ 
    var s,n; 
    s = window.getSelection(); 
        while(window.find(str)){ 
          
          var n = document.createElement("SPAN"); 
          n.style.color="#ff0000" 
          s.getRangeAt(0).surroundContents(n); 
        } 
    } 

}



function DrawImage(ImgD,w,h)
{
	var image=new Image();
	image.src=ImgD.src;
	if(image.width>0 && image.height>0)
	{
		if(image.width/image.height>= w/h)
		{
			if(image.width>w)
			{
			  ImgD.width=w;
			  ImgD.height=(image.height*w)/image.width;
			}
			else
			{
			  ImgD.width=image.width;
			  ImgD.height=image.height;
			}
		}
		else
		{
			if(h==0)
			{
			  if(image.width > w)
			  {
			    ImgD.width = w;
			    ImgD.height = (w/image.width)*image.height;
			  }
			  else
			  {
			    ImgD.width=image.width;
				  ImgD.height=image.height;
			  }
			}
			else
			{
			  if(image.height>h)
			  {
				  ImgD.height=h;
				  ImgD.width=(image.width*h)/image.height;
			  }
			  else
			  {
				  ImgD.width=image.width;
				  ImgD.height=image.height;
			  }
			}
		}
	}
}


function   getLen(str) {
   var totallength=0;   
   for (var i=0;i<str.length;i++)
   {
    var intCode=str.charCodeAt(i);    
    if (intCode>=0&&intCode<=128) {
     totallength=totallength+1; //非中文单个字符长度加 1
    }
    else {
     totallength=totallength+2; //中文字符长度则加 2
    }
   } //end for   
   return totallength;
   } 


function   HTMLEnCode(str)   
  {   
        var   s   =   "";   
        if   (str.length   ==   0)   return   "";   
        s=str;
        //s   =   str.replace(/&/g,   "&gt;");   
        s   =   s.replace(/</g,       "&lt;");   
        s   =   s.replace(/>/g,       "&gt;");   
        s   =   s.replace(/   /g,       "&nbsp;");   
        s   =   s.replace(/\'/g,     "&#39;");   
        s   =   s.replace(/\"/g,     "&quot;");   
        s   =   s.replace(/\n/g,     "<br>");   
        return   s;   
  }   
  function   HTMLDeCode(str)   
  {   
        var   s   =   "";   
        if   (str.length   ==   0)   return   "";   
        s=str;
        //s   =   str.replace(/&gt;/g,   "&");   
        s   =   s.replace(/&lt;/g,       "<");   
        s   =   s.replace(/&gt;/g,       ">");   
        s   =   s.replace(/&nbsp;/g,       "   ");   
        s   =   s.replace(/&#39;/g,     "\'");   
        s   =   s.replace(/&quot;/g,     "\"");   
        s   =   s.replace(/<br>/g,     "\n");   
        return   s;   
  }   

