// JavaScript Document

function RndNum(n){    
do{    
	var rnd=Math.floor(Math.random()*100);    
	var num=rnd;    
	}while(rnd>n)    
	return num;
} 

function showNoPic(o){
	o.src = "/Images/NoPic" + (RndNum(9)+1) + ".gif"
}

var flag=false; 
function DrawImage(ImgD,MaxWidth,MaxHeight){ 
	var image=new Image(); 
	//var MaxWidth = 120
	//var MaxHeight = 120
	image.src=ImgD.src; 
	if(image.width>0 && image.height>0){ 
		flag=true; 
		if(image.width/image.height>= MaxWidth/MaxHeight){ 
			if(image.width>MaxWidth){
				ImgD.width=MaxWidth; 
				ImgD.height=(image.height*MaxWidth)/image.width; 
			}else{ 
				ImgD.width=image.width;
				ImgD.height=image.height; 
			} 
			//ImgD.alt=image.width+"x"+image.height; 
		} 
		else{ 
			if(image.height>MaxHeight){
			ImgD.height=MaxHeight; 
			ImgD.width=(image.width*MaxHeight)/image.height; 
			}else{ 
			ImgD.width=image.width;
			ImgD.height=image.height; 
			} 
			//ImgD.alt=image.width+"x"+image.height; 
		} 
	}
}

function SetWinHeight(obj){
	var win=obj;
	if (document.getElementById){
		if (win && !window.opera){
			if (win.contentDocument && win.contentDocument.body.offsetHeight) 
			win.height = win.contentDocument.body.offsetHeight; 
			else if(win.Document && win.Document.body.scrollHeight)
			win.height = win.Document.body.scrollHeight;
		}
	}
}

//    onload=function(){ 
//        fHl(document.body, '文件|的',true,'search.asp?keyword='); 
//        这里的body是指高亮body里面的内容。
//        fHl(document.body, '希望|愁怨', false, '/'); 
//        fHl(document.getElementById('at_main'), '独自|飘过|悠长', true, 'search.asp?keyword='); 
//        这里的'at_main'是指高亮id='at_main'的div里面的内容。search.asp?keyword=指给关键字加的链接地址，我这里加了一个参数，在后面要用到。可以是任意的地址。
//    } 
/*----------------------------------------*\ 
 * 使用 javascript HTML DOM 高亮显示页面特定字词 By shawl.qiu 
 * 参数说明: 
 * o: 对象, 要进行高亮显示的对象. 
 * flag: 字符串, 要进行高亮的词或多个词, 使用 竖杠(|) 分隔多个词 . 
 * rndColor: 布尔值, 是否随机显示文字背景色与文字颜色, true 表示随机显示. 
 * url: URI, 是否对高亮的词添加链接.  
\*----------------------------------------*/ 
//--------begin function fHl(o, flag, rndColor, url)------------------// 
function fHl(o, flag, rndColor, url){
	if(flag==''){return false}
	var bgCor=fgCor=''; 
	if(rndColor!=''){ 
		//bgCor=fRndCor(10, 20); 
		//fgCor=fRndCor(230, 255); 
		bgCor = 'white'
		fgCor = rndColor
	} else { 
		bgCor='white'; 
		fgCor='red'; 
	} 
	var re=new RegExp(flag, 'i'); 
	for(var i=0; i<o.childNodes.length; i++){     
		var o_=o.childNodes[i]; 
		var o_p=o_.parentNode; 
		if(o_.nodeType==1) { 
			fHl(o_, flag, rndColor, url);                 
		 } else if (o_.nodeType==3) { 
			//if(!(o_p.nodeName=='A')){ 
				if(o_.data.search(re)==-1)continue; 
				var temp=fEleA(o_.data, flag); 
				o_p.replaceChild(temp, o_); 
			//} 
		}  // shawl.qiu script 
	} 
	//------------------------------------------------ 
	function fEleA(text, flag){ 
		//var style=' style="background-color:'+bgCor+';color:'+fgCor+';" ' 
		var style=' style="color:'+fgCor+';" ' 
		var o=document.createElement('span'); 
		var str=''; 
		var re=new RegExp('('+flag+')', 'gi'); 
		if(url){ 
			str=text.replace(re, '<a href="'+url+ 
			'$1"'+style+' target=_blank >$1</a>'); //这里是给关键字加链接，红色的$1是指上面链接地址后的具体参数。
		} else { 
			str=text.replace(re, '<span '+style+'>$1</span>'); //不加链接时显示
		} 
		o.innerHTML=str; 
		return o; 
	}     // shawl.qiu script 
	//------------------------------------------------ 
	function fRndCor(under, over){ 
		if(arguments.length==1){ 
			var over=under; 
				under=0; 
		}else if(arguments.length==0){ 
			var under=0; 
			var over=255; 
		} 
		var r=fRandomBy(under, over).toString(16); 
			r=padNum(r, r, 2); 
		var g=fRandomBy(under, over).toString(16); 
			g=padNum(g, g, 2); 
		var b=fRandomBy(under, over).toString(16); 
			b=padNum(b, b, 2); 
			//defaultStatus=r+' '+g+' '+b 
		return '#'+r+g+b; 
		function fRandomBy(under, over){ 
			switch(arguments.length){ 
				case 1: return parseInt(Math.random()*under+1); 
				case 2: return parseInt(Math.random()*(over-under+1) + under); 
				default: return 0; 
			} 
		} // shawl.qiu script 
		function padNum(str, num, len){ 
			var temp='' 
			for(var i=0; i<len;temp+=num, i++); 
			return temp=(temp+=str).substr(temp.length-len); 
		} // shawl.qiu script 
	} 
} // shawl.qiu script 
//--------end function fHl(o, flag, rndColor, url)--------------------// 




