// JavaScript Document
function isdigits(s)
{
	var r,re;
	re = /\d*/i; //\d表示数字,*表示匹配多个数字
	r = s.match(re);
	return (r==s)?1:0;
}
// ===================== 输入学号 只限数字 =======================//  
function IsDigit(){
	return ((event.keyCode >= 48) && (event.keyCode <= 57));
}

// ===================== 输入学号 文本框控制 ======================//
function clearMyNumText(){
	if(document.getElementById("regStep1_mynum").value == "请输入学号")
		document.getElementById("regStep1_mynum").value = "";	
}
function restoreMyNumText(){
	if(document.getElementById("regStep1_mynum").value == "")
		document.getElementById("regStep1_mynum").value = "请输入学号";	
}
// ===================== 输入文本 长度控制 ========================//
function textLength(id,length,tipid,tipstr){
	var value = htmlFliter($("#"+id).val());
	if(value.length > length){
		//openTipMsg(tipstr);
		$("#"+tipid).addClass("tipMsg").html(tipstr);
		return false;
	}
	return true;
}
//edited by hitigon
function textSpace(id,tipid,tipstr){
	var value = $("#"+id).val();
	var filter = trim(value);
	if(filter.length == 0){
		//openTipMsg(tipstr);
		$("#"+tipid).addClass("tipMsg").html(tipstr);
		return false;
	}
	return true;
}
// ===================== 输入学号 只限数字 =======================/
var isNumber = function (e) {  
	 if ($.browser.msie) {  
		 if ( ((event.keyCode > 47) && (event.keyCode < 58)) ||  
			   (event.keyCode == 8) || (event.keyCode == 13) ) {  
			 return true;  
		 } else {  
			 return false;  
		 }  
	 } else {  
		 if ( ((e.which > 47) && (e.which < 58)) ||  
			   (e.which == 8) || (e.which == 13) ) {  
			 return true;  
		 } else {  
			 return false;  
		 }  
	 }  
 } 
// ===================== 回复文本 字符转换 ========================//
function htmlFliter(str){
	//return str.replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\n/g,"<br>").replace(/ /g,"&nbsp;").replace(/\$/g,'&#36');
	return str.replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\n/g,"<br>").replace(/\$/g,'&#36');
}
function URLencode(sStr){
    return escape(sStr).replace(/\+/g, '%2B').replace(/\"/g,'%22')
		.replace(/\'/g, '%27').replace(/\//g,'%2F').replace(/\@/g,'%40');
}
// ===================== 回复文本 去掉空格 ========================//
function Ltrim(s){
	return s.replace(/^\s*/,'');
}
//added by hitigon
//去左空格;
function ltrim(s){ 
	return s.replace( /^\s*/, ""); 
} 	

//去右空格; 
function rtrim(s){ 
return s.replace( /\s*$/, "").replace(/&nbsp;/ig,""); 
} 
//去左右空格; 
function trim(s){ 
return rtrim(ltrim(s)); 
} 
// ===================== 关闭模态窗口 ========================//
function closeDialog() {
	$(window.parent.document).find('#floatBoxBg').remove();
	$(window.parent.document).find('#floatBox').remove();
}
// ===================== 关闭 tipMsg 提示信息 ========================//
function openTipMsg(html){
	if($("#tipMsg").css("display")!="none"){
		$("#tipMsg").css("display","none");
	}
	$("#tipMsg").addClass("tipMsg").html(html);
	$("#tipMsg").fadeIn("fast");
}
function closeTipMsg(){
	$("#tipMsg").fadeOut("fast");
}
//框架自动适应高度
function dialogAdaptive(id,mode,maxHeight,fix){
	var boxHeight = $(document).find("#"+id).height();
	var parentObject = $(window.parent.document).find('#myiframe');
	if (mode==0){
		parentObject.attr("scrolling","no");
		if(fix !=null && fix != ""){
			parentObject.height(fix);
		}
		else {
			parentObject.height(boxHeight);
		}
	}
	else if(mode==1){
		parentObject.attr("scrolling","auto");
		if(maxHeight != null && boxHeight > maxHeight){
			parentObject.height(maxHeight);
		}
		else {
			parentObject.height(boxHeight);
		}
	}
	
}