﻿// JavaScript Document
 String.prototype.Trim = function() { return this.replace(/(^\s*)|(\s*$)/g, ""); }
 function $(id){return document.getElementById(id);}
 var $e=function(id){return document.getElementById(id);}
 var myReg=/^[a-zA-Z]([a-zA-Z0-9]*[-_.]?[a-zA-Z0-9]+)+@([\w-]+\.)+[a-zA-Z]{2,}$/;
 function showlist(CurID,ShowID){
    var o=$(CurID);
    var x=o.offsetLeft;
    var y=o.offsetTop;
    while(o=o.offsetParent){
        x+=o.offsetLeft;
        y+=o.offsetTop;
    }
	$(ShowID).style.left=x+"px";
	$(ShowID).style.top=y+23+"px";
	$(ShowID).style.display="block";
  }
  
  function hidelist(ShowID){
	 $(ShowID).style.display="none";   
   }
   
   
   function fontSize(id,size)
   {
	  switch(size){
		 case 12:
		    $(id).style.fontSize="1.2em";
			break;
		 case 14:
		    $(id).style.fontSize="1.4em";
			break;
		 case 16:
		    $(id).style.fontSize="1.6em";
			break;
	  }    
   }
   
   
   function DrawImage(id,FitWidth,FitHeight){
     ImgD=document.getElementById(id);
     var image=new Image();
     image.src=ImgD.src;
     if(image.width>0 && image.height>0){
         if(image.width/image.height>= FitWidth/FitHeight){
             if(image.width>FitWidth){
                 ImgD.width=FitWidth;
                 ImgD.height=(image.height*FitWidth)/image.width;
             }else{
                 ImgD.width=image.width; 
                ImgD.height=image.height;
             }
         } else{
             if(image.height>FitHeight){
                 ImgD.height=FitHeight;
                 ImgD.width=(image.width*FitHeight)/image.height;
             }else{
                 ImgD.width=image.width; 
                ImgD.height=image.height;
             } 
        }
      }
   }
   
   
   function Flash(flash,w,h){
	   var str='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';
	   str+=' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0"';
	   str+=' width="'+w+'" height="'+h+'">';
	   str+='<param name="movie" value="'+flash+'" />';
       str+='<param name="quality" value="high" />';
	   str+='<param name="wmode" value="transparent" />';
       str+='<embed src="'+flash+'" wmode="transparent" quality="high"';
	   str+=' pluginspage="http://www.macromedia.com/go/getflashplayer"';
	   str+=' type="application/x-shockwave-flash" width="'+w+'" height="'+h+'"></embed>';
       str+=' </object> ';       
	   document.writeln(str)
	}

 
 function toleft(demo,demo1,demo2,speed,flag){
       demo=$(demo);demo1=$(demo1);demo2=$(demo2)
       demo2.innerHTML=demo1.innerHTML
       function Marquee(){
            if(demo2.offsetWidth-demo.scrollLeft<=0){
                    demo.scrollLeft-=demo1.offsetWidth
              }else{
                    demo.scrollLeft++
              }
        }
       flag=setInterval(Marquee,speed)
       demo.onmouseover=function(){clearInterval(flag);}
       demo.onmouseout=function(){flag=setInterval(Marquee,speed);}
  }
  //向右滚动函数，demo包含demo1与demo2,speed是滚动速度，flag一个网页内有多个时设置为不同的任意字符。
 function toright(demo,demo1,demo2,speed,flag){
        demo=$(demo);demo1=$(demo1);demo2=$(demo2)
        demo2.innerHTML=demo1.innerHTML
        function Marquee(){
              if(demo.scrollLeft<=0){
                   demo.scrollLeft=demo2.offsetWidth
              }else{
                   demo.scrollLeft--
              }
        }
        flag=setInterval(Marquee,speed)
        demo.onmouseover=function(){clearInterval(flag);}
        demo.onmouseout=function(){flag=setInterval(Marquee,speed);}
  }
   
   
  function encode(datastr, bassnum) {
	var tempstr;
	var tchar;
	var newdata = "";
 
	for (var i = 0; i < datastr.length; i++)
	{
		tchar = 65535 + bassnum - datastr.charCodeAt(i);
		tchar = tchar.toString();
 
		while(tchar.length < 5)
		{
			tchar = "0" + tchar;
		}
 
		newdata = newdata + tchar;
	}
 
	return newdata;
  }

