// JavaScript Document
// 国际字符
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function encodeURL(url) {
	var e = window.encodeURIComponent ? encodeURIComponent : escape;
	return e(url);
}

function trim(str) {
	str = str.replace(/^\s+|\s+$/g,"");
	str = str.replace(/['"%]/g,"");
	return str;
}

function isCharAndNum(s) {
	var pattern=/^[a-zA-Z0-9]+$/; 
	if (pattern.exec(s)) {
		return true;
	}else {
		return false;
	}
}

function AJAXInteraction(url, onsuccess, onerror) {
	var req = init();
	req.onreadystatechange = processRequest;
        
	function init() {
		var temp_req = null;
		if (window.XMLHttpRequest) {
			temp_req = new XMLHttpRequest();
		} else if (window.ActiveXObject) {
			try {
				temp_req = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
				try {
					temp_req = new ActiveXObject("Msxml2.XMLHTTP");			
				} catch (e) {}
			}
		}
		if(temp_req == null) {
			alert("Sorry, your browser can't support our application.");
		}
		return temp_req;
	}
    
    function processRequest () {
      if (req.readyState == 4) {
        if (req.status == 200) {
          if (onsuccess) onsuccess(req);
        }else{
		  if (onerror) onerror(req);
		}
      }
    }

    this.doGet = function() {
	  if(req == null) return;
      req.open("GET", url, true);
      req.send(null);
    }
    
    this.doPost = function(body) {
	  if(req == null) return;
      req.open("POST", url, true);
      req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
      req.send(body);
    }
}