﻿// JavaScript Document
 String.prototype.Trim = function() { return this.replace(/(^\s*)|(\s*$)/g, ""); }
 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=$e(CurID);
    var x=o.offsetLeft;
    var y=o.offsetTop;
    while(o=o.offsetParent){
        x+=o.offsetLeft;
        y+=o.offsetTop;
    }
	$e(ShowID).style.left=x+"px";
	$e(ShowID).style.top=y+23+"px";
	$e(ShowID).style.display="block";
  }
  
  function hidelist(ShowID){
	 $e(ShowID).style.display="none";   
   }
   
   
   function fontSize(id,size)
   {
	   $e(id).style.fontSize=size;  
   }
   
   
   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;
             } 
        }
      }
   }
   
   
   var flag=false;
   function DrawImage1(ImgD,i,j){
			var image=new Image();
			var iwidth = i;  //定义允许图片宽度
            var iheight = j;  //定义允许图片高度
            image.src=ImgD.src;
            if(image.width>0 && image.height>0){
				flag=true;
				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;
			}
       }
    } 
   
   
   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=$e(demo);demo1=$e(demo1);demo2=$e(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一个网页内有多个时设置为不同的任意字符。
  //by 柳永法(yongfa365)'Blog　www.yongfa365.com
 function toright(demo,demo1,demo2,speed,flag){
        demo=$e(demo);demo1=$e(demo1);demo2=$e(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;
  }

function che()
   {
       if($e("pro").value.Trim()=="")
	   {
	      alert("请输入查询名称！");
		  $e("pro").focus();
	      return false;
	   }


   }
   function checkfrm()
   {
       if($e("input_name").value.Trim()=="")
	   {
	      alert("请输入姓名！");
		  $e("input_name").focus();
	      return false;
	   }
	   if($e("input_address").value.Trim()=="")
	   {
	      alert("请输入地址！");
		  $e("input_address").focus();
	      return false;
	   }
	   	   if($e("input_tel").value.Trim()=="")
	   {
	      alert("请输入电话！");
		  $e("input_tel").focus();
	      return false;
	   }
	   var myReg=/^[a-zA-Z]([a-zA-Z0-9]*[-_.]?[a-zA-Z0-9]+)+@([\w-]+\.)+[a-zA-Z]{2,}$/;
	   if(!myReg.test($e("input_mail").value))
	   {
		      alert("请检查您的邮箱是否正确！");
		      $e("input_mail").focus();
	          return false;
	   }
	   if($e("input_content").value.Trim()=="")
	   {
	      alert("请输入留言内容！");
		  $e("input_content").focus();
	      return false;
	   }

   }
