//提交form
function Form_Submit1(aPageName,aFormName)
{
			var ObjForm = $(aFormName);
			ObjForm.action=aPageName;
			ObjForm.method = 'post';
			ObjForm.submit();
			
}

//获取当前时间
function getDateTime()
{
	var dt=new Date();

 var str="";
 if(dt.getFullYear){
   var y,m,d,h,s;
    y=dt.getFullYear();
    m=dt.getMonth()+1;
    d=dt.getDate(); 

    if(m<10)
	{	
		month="0"+m;
    	str=""+y+"-"+month+"-"+d;
	}
	else
	{
		str=""+y+"-"+m+"-"+d;
	}
  }
  return str;
	
	}
	
function CheckMoney(aMoney,aStyle){ 
 var money = aMoney.value;

  var myReg = /^[\.]{1,}$/;
  if(myReg.test(money))
  {
	  alert("输入格式错误!");
	  return ;
  }
 var oNumberObject = new Number(money);
 aMoney.value = oNumberObject.toFixed(2);
}
//日期验证
function CheckDate(aDate,aStyle){
	var date=aDate.value;
	var patrn = /^((^((1[8-9]\d{2})|([2-9]\d{3}))([-\/\._])(10|12|0?[13578])([-\/\._])(3[01]|[12][0-9]|0?[1-9])$)|(^((1[8-9]\d{2})|([2-9]\d{3}))([-\/\._])(11|0?[469])([-\/\._])(30|[12][0-9]|0?[1-9])$)|(^((1[8-9]\d{2})|([2-9]\d{3}))([-\/\._])(0?2)([-\/\._])(2[0-8]|1[0-9]|0?[1-9])$)|(^([2468][048]00)([-\/\._])(0?2)([-\/\._])(29)$)|(^([3579][26]00)([-\/\._])(0?2)([-\/\._])(29)$)|(^([1][89][0][48])([-\/\._])(0?2)([-\/\._])(29)$)|(^([2-9][0-9][0][48])([-\/\._])(0?2)([-\/\._])(29)$)|(^([1][89][2468][048])([-\/\._])(0?2)([-\/\._])(29)$)|(^([2-9][0-9][2468][048])([-\/\._])(0?2)([-\/\._])(29)$)|(^([1][89][13579][26])([-\/\._])(0?2)([-\/\._])(29)$)|(^([2-9][0-9][13579][26])([-\/\._])(0?2)([-\/\._])(29)$))*$/;
    if(!date.match(patrn)){
	    alert('日期格式错误');
	  	$(aStyle).focus();
		$(aStyle).select();
		return false;
    }   
}  

//选中文本信息
//aInputName 为文本ID
function ClearInput(aInputName)
{
	$(aInputName).value="";
	
	
	
}

//禁止输入字母和汉字
//使用方式    如：<input type="text" style="ime-mode:disabled" onkeydown="EstopKeyDown()"/>
function EstopKeyDown()
{
   //var e =  arguments[0]||window.event;  
   var e = getEvent();
   
   var k = e.charCode||e.keyCode;   

   var eventSource = e.srcElement||e.target;     

    if ((k==46)||(k==8)||(k==189)||(k==109)||(k==190)||(k==110)|| (k>=48 && k<=57)||(k>=96 && k<=105)||(k>=37 && k<=40)) 
    {}
    else if(k==13){
		k = 9;
	}
    else{
		 if (window.event)
         	e.returnValue = false;
		 else
		 	e.preventDefault();
	}
}
//摘要自动提醒


function checkMoney(money){
	if (money.value == "0.00")
	{
		money.style.cssText = "text-align:right;color:black;";
		money.value = '';
	}
    else if (!money.value)
	{
		money.style.cssText = "text-align:right;color:#CCCCCC";
		money.value = "0.00";
	}
}
 


function checkSummary(id, SummaryText){
	if (id.value == SummaryText)
	{
		id.style.cssText = "text-align:left;font-size:11px;color:black;";
		id.value = '';
	}
    else if (!id.value)
	{
		id.style.cssText = "text-align:left;font-size:11px;color:#CCCCCC";
		id.value = SummaryText;
	}
}


function getEvent(){ 
        if(document.all)    return window.event;       
        func=getEvent.caller;           
        while(func!=null){   
            var arg0=func.arguments[0];
            if(arg0){
                if((arg0.constructor==Event || arg0.constructor ==MouseEvent)
                    || (typeof(arg0)=="object" && arg0.preventDefault && arg0.stopPropagation)){   
                    return arg0;
                }
            }
            func=func.caller;
        }
        return null;
}


function createXMLHttpRequest(){
	if (window.ActiveXObject){
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");	
	}
	else if (window.XMLHttpRequest){
		xmlHttp = new XMLHttpRequest();	
	}
	if(xmlHttp.overrideMimeType){//设置MIME类别
	   xmlHttp.overrideMimeType("text/xml;charset=gb2312");
	}
 }
 
 function ajaxRequest(url, div){
 		 url=encodeURI(url);
		 createXMLHttpRequest();
		 xmlHttp.onreadystatechange = function(){ handleStateChange(div); };
		 xmlHttp.open("GET", url, true);
		 xmlHttp.send(null);
 }
 
  function ajaxPost(url, div, postStr){
 		 createXMLHttpRequest();
		 xmlHttp.open("POST", url, true);
		 xmlHttp.onreadystatechange = function(){ handleStateChange(div); };
		 xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
		 postStr = encodeURI(postStr);
  		 postStr = encodeURI(postStr);
		 xmlHttp.send(postStr);
 }
 
 
 function handleStateChange(div){
	 var obj  = new WaitingDiv();
	 
    if(xmlHttp.readyState != 4 || xmlHttp.status != 200){
		obj.setDiv(div);
		obj.setImg("./image/loadingAnimation.gif");
		obj.showWaitingDiv();
	}
	
	if (xmlHttp.readyState == 4){
	//	alert(xmlHttp.readyState);
	  // alert(xmlHttp.status);
		if (xmlHttp.status == 200 || xmlHttp.status==0){
			
			obj.hideWaitingDiv();
			var a = document.getElementById(div);
			//alert(xmlHttp.responseText);
			a.innerHTML = xmlHttp.responseText;	
			ajaxRunJavaScript(xmlHttp.responseText);
		}	
	}
 }
 
  function ajaxRunJavaScript(value){
	 var reg = /<script[^>]*>(.|\r\n)*?<\/script>/gi;
	 var js;
	 var arrmatch = value.match(reg); // xmlHttp.responseText
	 
	 if (arrmatch)
	 {
		 var len = arrmatch.length;
		 for (var h=0; h<len; h++){
			  js = arrmatch[h].replace(/<script[^>]*>/, "").replace(/<\/script>/, "");
			  eval(js);
		 }
	 }
	// eval("var oTable=document.getElementById(\"tbinfo\");for(var i=0;i<oTable.rows.length;i++){if(i%2!=0){oTable.rows[i].className=\"altrow\";}}");
  }

 function getNodes(){
	   var e = getEvent();  
	   var obj = e.srcElement|| e.target; 
	   if(obj.parentNode.tagName =="TD"){ 
			return obj.parentNode.parentNode.childNodes; 
	   } 
 }

//等待提示
function WaitingDiv() {
	
	var floatDiv = new Object();
	
	floatDiv.id = "";
	floatDiv.imgUrl = "";
	
	floatDiv.setDiv = function(id){
		floatDiv.id = id;
	}
	
	floatDiv.setImg = function(imgUrl){
		floatDiv.imgUrl = imgUrl;
	}
	
	floatDiv.showWaitingDiv = function()
	{
		if (document.getElementById("floatDiv") == null){
				var image = "<img src="+ floatDiv.imgUrl +">";
				var span = "<span id=\"disp\" style=\"color:#FFFFFF; text-align:center;\">数据加载中,请等待...</span>";
				var div =	document.createElement('div');
				
				div.id = "floatDiv";
				div.style.display = 'none';
				div.innerHTML = "<div style=\"position:relative;margin-top:20px;margin-left:40px;\">"
						+ "<table border=\"0\"><tr><td style=\"text-align:center;\">" + span + "</td></tr>"
						+ "<tr><td>"+ image + "</td></tr></table>";
				
				div.style.cssText = "border:2px solid #333333;!important; width:300px;height:100px;"
							+"position:absolute; z-index:1000; background-color:#000; filter:alpha(opacity=55); -moz-opacity:0.55; opacity:0.55;";
				
				if (floatDiv.checkDivIsExsit(floatDiv.id))
				{
					document.getElementById(floatDiv.id).appendChild(div);	
					
				}else{
					document.body.appendChild(div); 
					var de = document.documentElement;
					var w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
					var h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight;

					div.style.left = (w -div.clientWidth)/2 + 'px';
					div.style.top =  (h - div.clientHeight)/2 + 'px';
				}
		}
		document.getElementById("floatDiv").style.display='block';
	}
	
	floatDiv.hideWaitingDiv = function(){
		if (document.getElementById("floatDiv") != null) document.getElementById("floatDiv").style.display='none';
	}
	
	floatDiv.checkDivIsExsit = function(divId){
		  return document.getElementById(divId) == null ?  false :  true;	
	}
	return floatDiv;
}
 
 //显示积分提示
function ShowIntegDiv(){
var box=document.getElementById("massage_box1");
box.style.display="none";
document.getElementById('addclose').click(); 
}
function ShowIntegDiv1(){
var box=document.getElementById("massage_box1");
box.style.display="none";
document.getElementById('addgoon').click(); 
}
function ShowIntegDiv2(){
var box=document.getElementById("massage_box1");
box.style.display="none";
document.getElementById('addgoonadd').click(); 
}

//输入的只能是数字和小数点
function clearNoNum(obj) 
{ 
   obj.value = obj.value.replace(/[^\d.]/g,"");  //清除“数字”和“.”以外的字符 
   obj.value = obj.value.replace(/^\./g,"");  //验证第一个字符是数字而不是. 
   obj.value = obj.value.replace(/\.{2,}/g,"."); //只保留第一个. 清除多余的. 
   obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$","."); 
} 
