
/* nieyong wrote to insert the question into cookie*/
/*get html tag*/
String.prototype.trim = function () {
	return this.replace(/^\s*|\s*$/g, "");
};
function v(id) {
	return document.getElementById(id);
}
function prv(id) {
	return window.parent.document.getElementById(id);
}
function vi(id) {
	return v(id).innerHTML.replace(/(^\s*)|(\s*$)/g, "");
}
function vv(id) {
	return v(id).value.replace(/(^\s*)|(\s*$)/g, "");
}


	//判断是否为数字
	function BASEisNotNum(theNum){
		
		for(var i=0;i<theNum.length;i++){
			oneNum=theNum.substring(i,i+1);
			if (oneNum<"0" || oneNum>"9")
				return false;
		}
		return true;
	}
	

	

	/*检测是否是数字*/
	function isdigit(s) {
		var r, re;
		re = /\d*/i; //d表示数字,*表示匹配多个数字
		r = s.match(re);
		return (r == s) ? 1 : 0;
	}
  	 
    //iframe 显示错误 DIV
    function iframeCloseDIV(){
  	  	var viewDIV =  document.getElementById('successDIV');
   		 viewDIV.style.display = 'none';
   		 parent.frameResize();
    }
  	    
  	    
  	    
  	    //关闭浏览器  不提示
	function close_win()    {   
		    window.opener=null;      
		    //window.opener=top;      
		    window.open("","_self");      
		    window.close();        
    }   
    
    
    
    //关闭提示
    function closeDIV(){
  	  	var viewDIV =  document.getElementById('successDIV');
   		 viewDIV.style.display = 'none';
    }
    
    
    
    //	控制iframe 的高度
	function frameResize(){
		try{		
			var cwin =  document.getElementById("ifrmain");
			var isIE =  getOs();
			if(isIE == "MSIE"){
				cwin.height = cwin.Document.body.scrollHeight;
			}else {
			    var hh1=cwin.contentWindow.document.documentElement.scrollHeight;
			    var hh2=cwin.contentWindow.document.body.scrollHeight;
			    var hh=Math.max(hh1,hh2);
			    cwin.style.height=hh+65+"px";  
			} 
		}catch(e){}	
	}
	
	
	
	function parentframeResize(){
		try{		
			var cwin =   window.parent.document.getElementById("ifrmain");
			var isIE =  getOs();
			if(isIE == "MSIE"){
				cwin.style.height = cwin.Document.body.scrollHeight;
			}else {
			    var hh1=cwin.contentWindow.document.documentElement.scrollHeight;
			    var hh2=cwin.contentWindow.document.body.scrollHeight;
			    var hh=Math.max(hh1,hh2);
			    cwin.style.height=hh+65+"px";      
			} 
		}catch(e){}	
	}
	

function replaceInt(obj){
	
	obj.value=obj.value.replace(/[^\d]/g,'')   //替换
}





// 试题   试卷   资源  首页收藏
function defaultFav(id,typ){

	var userfavs = v('userfavsID');
	v('userfavID').value = id;
	if(typ == 'mypro'){
		userfavs.action = '/profav/find.do';
	}else if(typ == 'mypaper'){
		alert(typ);
		userfavs.action = '/paperfav/find.do';
	}else if(typ == 'myres'){
		userfavs.action = '/resfav/find.do';
	}
	userfavs.submit();
	
}


//验证浏览器
 function getOs() 
{ 
    var OsObject = ""; 
    if(navigator.userAgent.indexOf("MSIE")>0) { 
         return "MSIE"; 
    } 
    if(isFirefox=navigator.userAgent.indexOf("Firefox")>0){ 
         return "Firefox"; 
    } 
    if(isSafari=navigator.userAgent.indexOf("Safari")>0) { 
         return "Safari"; 
    }  
    if(isCamino=navigator.userAgent.indexOf("Camino")>0){ 
         return "Camino"; 
    } 
    if(isMozilla=navigator.userAgent.indexOf("Gecko/")>0){ 
         return "Gecko"; 
    } 
   
} 
