﻿
function checkFM(){
	var error=document.all.TextErrror;
	var text=document.all.myAnswerContent;
	
	if(text.value==null||text.value==""){
		error.innerHTML="请输入回答内容";
		text.focus();
		return false;
	}
	return true;
	
}
function redFM(){
	window.open("http://www.google.cn/custom?cx=002042903809931510164%3A5fiqxizab5g&ie=UTF-8&sa=%CB%D1%CB%F7&adkw=AELymgVwpnCOc5QV2mD0PVnM7PV9EKn9LtCtxLzkxik4xSgbsy4cBGFMqdvdzOxh0QXopV-wAWbU_8GqsBKy2FgHgei6hyqyze7OddCYGitGahyl8jrLmM0&cof=AH%3Aleft%3BCX%3A%25E9%2597%25AE%25E9%25A2%2598%25E5%25BA%2593%2520%25E5%2585%25A8%25E8%2583%25BD%25E5%25BC%2595%25E6%2593%258E%3BDIV%3A%23cccccc%3BFORID%3A13%3BL%3Ahttp%3A%2F%2Fwww.google.com%2Fintl%2Fzh-CN%2Fimages%2Flogos%2Fcustom_search_logo_sm.gif%3BLH%3A30%3BLP%3A1%3BVLC%3A%23551a8b%3B&hl=zh-CN&oe=UTF-8&client=google-coop&client=pub-9293116222435385&boostcse=0&q="+document.search_form.q.value);
}

function askFM(){
	var ask=document.search_form.ask.value;
	document.search_form.action="askadd";
	document.search_form.submit();
}
function highlightWord(node,word) 
{     
	// Iterate into this nodes childNodes     
	if (node.hasChildNodes)
	{         var hi_cn;       
	for (hi_cn=0;hi_cn<node.childNodes.length;hi_cn++) {    
		highlightWord(node.childNodes[hi_cn],word);   
		}   
	}
	// And do this node itself   
	if (node.nodeType == 3) { 
		// text node         
		tempNodeVal = node.nodeValue.toLowerCase();    
		tempWordVal = word.toLowerCase();      
		if (tempNodeVal.indexOf(tempWordVal) != -1)
		{             
			pn = node.parentNode;            
			if (pn.className != "searchword") 
			{                 
				// word has not already been highlighted!                 
				nv = node.nodeValue;                 
				ni = tempNodeVal.indexOf(tempWordVal);  
				// Create a load of replacement nodes               
				before = document.createTextNode(nv.substr(0,ni));    
				docWordVal = nv.substr(ni,word.length);     
				after = document.createTextNode(nv.substr(ni+word.length));     
				hiwordtext = document.createTextNode(docWordVal);       
				hiword = document.createElement("span");       
				hiword.className = "searchword";        
				hiword.appendChild(hiwordtext);       
				pn.insertBefore(before,node);         
				pn.insertBefore(hiword,node);     
				pn.insertBefore(after,node);         
				pn.removeChild(node);     
				}       
			}    
		} 
} 
function googleSearchHighlight() 
{     
	if (!document.createElement)  return;     
	ref = document.referrer;     
	if (ref.indexOf('?') == -1) return;     
	qs = ref.substr(ref.indexOf('?')+1);     
	qsa = qs.split('&');     
	for (i=0;i<qsa.length;i++) {         
		qsip = qsa[i].split('=');         
		if (qsip.length == 1) continue;         
		if (qsip[0] == 'q' || qsip[0] == 'p') { 
			// q= for Google, p= for Yahoo             
			words = unescape(decodeURIComponent(qsip[1].replace(/\+/g,' '))).split(/\s+/);             
			for (w=0;w<words.length;w++) {                 
				highlightWord(document.getElementsByTagName("body")[0],words[w]);             
				}         
			}     
		} 
	}  
 function knowkey() {
	 if(event.keyCode==13){  
		  redFM(); 
		  return;
		  } 
 }  
window.onload = googleSearchHighlight; 