	function rep_w(str)
	{
		var r_str = str.replace(/&/g,"#-donate@arswp-#").replace(/\+/g,"#-arswp@donate-#");
		return r_str;
	}

	function isNumber(oNum)
	{
		if(!oNum) return false;
		var strP=/^\d+(\.\d+)?$/;
		if(!strP.test(oNum)) return false;
		try{
			if(parseFloat(oNum)!=oNum) return false;
		}
		catch(ex)
		{
			return false;
		}
		return true;
	}
	
	function InitAjax()
	{
		var ajax=false;
		try {
			ajax = new ActiveXObject("Msxml2.XMLHTTP"); 
		}
		catch (e) {
			try { 
				ajax = new ActiveXObject("Microsoft.XMLHTTP"); 
			}
			catch (E){
				ajax = false; 
			}
		}
		if (!ajax && typeof XMLHttpRequest!='undefined'){
			ajax = new XMLHttpRequest();
		} 
		return ajax;
	}

function  Utf8ToUnicode(strUtf8)
{
	var  bstr  =  "";
	var  nTotalChars  =  strUtf8.length;                //  total  chars  to  be  processed.
	var  nOffset  =  0;                                                                                //  processing  point  on  strUtf8
	var  nRemainingBytes  =  nTotalChars;                //  how  many  bytes  left  to  be  converted
	var  nOutputPosition  =  0;
	var  iCode,  iCode1,  iCode2;                                                //  the  value  of  the  unicode.

	while  (nOffset  <  nTotalChars)
	{
		iCode  =  strUtf8.charCodeAt(nOffset);
		if  ((iCode  &  0x80)  ==  0)                                                //  1  byte.
		{
				if  (  nRemainingBytes  <  1  )                                //  not  enough  data
						break;

				bstr  +=  String.fromCharCode(iCode  &  0x7F);
				nOffset  ++;
				nRemainingBytes  -=  1;
		}
		else  if  ((iCode  &  0xE0)  ==  0xC0)                //  2  bytes
		{
				iCode1  =    strUtf8.charCodeAt(nOffset  +  1);
				if  (  nRemainingBytes  <  2 ||  (iCode1  &  0xC0)  !=  0x80  )                                //  not  enough  data
																						//  invalid  pattern
				{
						break;
				}

				bstr  +=  String.fromCharCode(((iCode  &  0x3F)  <<  6)  |  (                  iCode1  &  0x3F));
				nOffset  +=  2;
				nRemainingBytes  -=  2;
		}
		else  if  ((iCode  &  0xF0)  ==  0xE0)                //  3  bytes
		{
				iCode1  =    strUtf8.charCodeAt(nOffset  +  1);
				iCode2  =    strUtf8.charCodeAt(nOffset  +  2);
				if  (  nRemainingBytes  <  3  ||                                                //  not  enough  data
						  (iCode1  &  0xC0)  !=  0x80  ||                                //  invalid  pattern
						  (iCode2  &  0xC0)  !=  0x80  )
				{
						break;
				}

				bstr  +=  String.fromCharCode(((iCode  &  0x0F) << 12)|((iCode1  &  0x3F) << 6)|(iCode2  &  0x3F));
				nOffset  +=  3;
				nRemainingBytes  -=  3;
		}
		else                                                                                                                                //  4  or  more  bytes  --  unsupported
				break;
	}

	if  (nRemainingBytes  !=  0)
	{
		//  bad  UTF8  string.
		return  "null";
	}

	return  bstr;
} 
	function do_next()
	{
		var f = document.form1;
		var payamount  = f.payamount.value;
		var payee  = rep_w(f.payee.value);
		var comm  = rep_w(f.comm.value);

		var queryString = "m="+payamount+"&u="+payee+"&c="+comm+"&mr="+Math.random();
		var xmlHttp = InitAjax();
		xmlHttp.open("POST","donate.php?do=check","true");
		xmlHttp.onreadystatechange =	function()
		{		
			if(xmlHttp.readyState == 4)
			{
				if(xmlHttp.status == 200)
				{
					var allcon =  xmlHttp.responseText;

					if( allcon == "-1" )
					{
						alert("捐助金额和您的大名不能为空 ^_^");
					}
					else if( allcon == "-2" )
					{
						alert("捐助金额最少一元,最大一万元.");
					}
					else if( allcon == "-3" )
					{
						alert("您的大名这么长?");
					}
					else if( allcon == "-4" )
					{
						alert("捐款附言写的太长了...");
					}
					else
					{
						var str_arr = allcon.split("|^|");

						document.getElementById("donate_num").innerHTML = str_arr[1];
						document.getElementById("money_num").innerHTML = str_arr[2];

						document.form2.v_mid.value = str_arr[0];
						document.form2.v_oid.value = str_arr[1];
						document.form2.v_amount.value = str_arr[2];
						document.form2.v_moneytype.value = str_arr[3];
						document.form2.v_url.value = str_arr[4];
						document.form2.v_md5info.value = str_arr[5];
						document.form2.remark1.value = str_arr[6];
						document.form2.remark2.value = str_arr[7];

						document.getElementById('check_form').style.display = "none";
						document.getElementById('sub_form').style.display = "";
					}
				}
			}
		}
		xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;");
		xmlHttp.send(queryString);
	}

	function return_last()
	{
		document.form2.reset();
		document.getElementById('sub_form').style.display = "none";
		document.getElementById('check_form').style.display = "";
	}

	function getDonate(p)
	{
		var xmlHttp = InitAjax();

		xmlHttp.open("GET", "donate.php?do=show_donate&page="+p+"&mr="+Math.random(), true); 

		xmlHttp.onreadystatechange=function()
								{
									if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
									{
										document.getElementById("show_donate").innerHTML = xmlHttp.responseText;
									}
								}
		xmlHttp.send(null);
	}
