//id对象查找
function $(id){
	return document.getElementById(id);
}
// 最小高度过滤
function minHeight(id,height){
		var object=$(id);
		if(object.offsetHeight<height){
			object.style.height=height+"px";
		}
}
// 关键字着色
function searchKey(key,searchString){
	var start=searchString.indexOf(key);
	var subst=searchString.substr(start,key.length);
	var st=searchString.substring(0,start);
	st=st+"<span style=\"color:#89b70f\">"+key+"</span>";
	st=st+searchString.substr(start+key.length,searchString.length);
	
	return st;
}
// 随机图片
function randoms(id){
	var o=$(id);

	var arPath=new Array();
	for(var i=1;i<5;i++){
		arPath[i]="/productDir/"+id+"_"+i+".jpg";
	}

	var index=Math.floor(Math.random()*4)+1;
	o.src=arPath[index];
}

// 字符串省略处理
function stfilter(id,tag,len){
	var o=eval("document.getElementById('"+id+"')");
	 
	 
	var list=eval("o.getElementsByTagName('"+tag+"')");
	
	for(var i=0;i<list.length;i++){
		var value=list[i].innerHTML;
	 
		if(value.length>len){
			
			list[i].innerHTML=value.substring(0,len)+"...";
				 
			 
		}
	}
}

// 元素节点过滤筛选
function filterElement(temp){
	 
	var nodes=new Array();
		var len=0;
		for(var i=0;i<temp.length;i++){
		 
			if(temp[i].nodeType==1){
				 
				nodes[len]=temp[i];
				len++;
			}
		}
		return nodes;
} 
// window 加载时间
function addLoadEvent(func){
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function(){
			oldonload();
			func();
		}
	}
	
}

// 鼠标滑过状态背景
function hover(id,moveC,outC,tag){
	
	var list=$(id).getElementsByTagName(tag);
	 
	for(i=0;i<list.length;i++){
		 
		list[i]
		with(list[i]){
			onmousemove=function(){
				this.style.	backgroundColor=moveC;
			}
			
			onmouseout=function(){
				this.style.	backgroundColor=outC;
			}
		}
	}
}
// URI 验证
function vectorURI(vectorURL,redirectURI){
	var URI=window.parent.window.location.href;
	var start = URI.lastIndexOf("/")+1;

	var path = URI.substring(start, URI.length);

	if(path==vectorURL){
		return true;
	}else{
		window.location.href=redirectURI;
		return false;
	}
		
}
var flag=false;
function DrawImage(ImgD,iwidth,iheight)
{
  var image=new Image();
  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;
      }
      
    }
    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 Addsite(){ 
	url = "http://www.yulinedu.com"; // 你自己的主页地址
	title = "河南雨林教育工程-雨林生物"; // 你自己的主页名称
	window.external.AddFavorite(url,title); 
}

// 屏蔽鼠标右键
if (window.Event) 
document.captureEvents(Event.MOUSEUP); 
function nocontextmenu(){ 
 event.cancelBubble = true 
 event.returnValue = false; 
 return false; 
} 
function norightclick(e){ 
 if (window.Event){ 
  if (e.which == 2 || e.which == 3) 
  return false; 
 } 
 else 
  if (event.button == 2 || event.button == 3){ 
   event.cancelBubble = true 
   event.returnValue = false; 
   return false; 
  } 
} 
