var driversid2007Trade = {};
driversid2007Trade.MSG_DOING = "Checking Availability…";
driversid2007Trade.ERRMSG_REPEAT_DISPLAYNAME = "
Display Name has already been taken. Please choose another Display Name.";
driversid2007Trade.ERRMSG_ISSURROGATE_DISPLAYNAME = "
Characters that you entered for Display Name are not allowed. Please enter a different Display Name.";
driversid2007Trade.MSG_ENTER_DISPLAYNAME = "
Display Name is available.";
driversid2007Trade.userid = 0;
driversid2007Trade.handleName = "";
driversid2007Trade.Local = function() {
}
driversid2007Trade.urlEncoder = function(txt) {
var EncStr = encodeURIComponent(txt);
return EncStr;
}
String.prototype.trim = function() {
return this.replace(/^\s+|\s+$/g, "");
}
driversid2007Trade.validateChar = function(txt, isSign) {
for(var i = 0; i < txt.length; i++) {
var code = txt.charCodeAt(i);
if ((txt.substr(i, 1) != ' ') &&
((code >= 0x0 && code < 0x81) ||
(code == 0xf8f0) ||
(code >= 0xff61 && code < 0xffa0) ||
(code >= 0xf8f1 && code < 0xf8f4))) {
} else {
return false;
}
}
switch (isSign) {
case 1:
if (txt.match(/[^0-9_A-Za-z\.\-\+\#\/\!]+/) == null) {
return true;
} else {
return false;
}
case 2:
if (txt.match(/[^0-9_A-Za-z\.\-@\+\#\/\!]+/) == null) {
return true;
} else {
return false;
}
case 3:
if (txt.match(/[^0-9A-Za-z]+/) == null) {
return true;
} else {
return false;
}
default:
return true;
}
}
driversid2007Trade.validateMailAddressChar = function(txt) {
//if (txt.match(/\w+([-+.]|\w)*@\w+([-.]\w+)*\.\w+([-.]\w+)*[^.]$/) == null) {
if (txt.match(/\w+([-+.]|\w)*@\w+([-.]\w+)*\.\w+([-.]\w+)*[\w]$/) == null) {
return false;
} else {
return true;
}
}
driversid2007Trade.CreateHttpRequest = function() {
if ( window.ActiveXObject ) {
try {
return new ActiveXObject("Msxml2.XMLHTTP");
}
catch ( ex1 ) {
try {
return new ActiveXObject("Microsoft.XMLHTTP");
}
catch ( ex2 ) {
return null;
}
}
} else if ( window.XMLHttpRequest ) {
return new XMLHttpRequest();
} else {
return null;
}
}
driversid2007Trade.FindControl = function(id, type) {
var result = null;
var objList = document.getElementsByTagName(type);
objRegex = new RegExp(id);
objCount = 0;
for (i = 0; i < objList.length; i++) {
if (objList[i].id.match(objRegex)) {
if (objCount < 2) {
result = objList[i];
} else {
return null;
}
}
}
return result;
}
driversid2007Trade.DataCheck = function(id, txt, path, openKind) {
if (id == "HandleName") {
if (driversid2007Trade.handleName != txt) {
driversid2007Trade.DataChk_HandleName(id, txt, path, openKind);
driversid2007Trade.handleName = txt;
}
}
}
driversid2007Trade.DataChk_HandleName = function(id, txt, path, openKind) {
var doing = driversid2007Trade.FindControl("HandleName_Doing", "span");
var chkResult = driversid2007Trade.FindControl("HandleName_Result", "div");
if (doing == null || chkResult == null) {
return;
}
var trimTxt = txt.trim();
if (trimTxt.length < 1) {
chkResult.innerHTML = "";
chkResult.style.display="none";
return;
}
var httpObj = driversid2007Trade.CreateHttpRequest();
var cPath = path + "ci=" + id + "&tx=" + driversid2007Trade.urlEncoder(trimTxt) + "&i=" + driversid2007Trade.userid;
doing.innerHTML = driversid2007Trade.MSG_DOING;
chkResult.innerHTML = "";
if (openKind != null && openKind != "") {
httpObj.open(openKind, cPath, true);
} else {
if (navigator.userAgent.indexOf("MSIE") < 0) {
httpObj.open("GET", cPath, true);
} else {
httpObj.open("POST", cPath, true);
}
}
httpObj.onreadystatechange = function() {
if (httpObj.readyState == 4 && httpObj.status == 200) {
driversid2007Trade.GetHandleNameCt(httpObj, chkResult);
doing.innerHTML = "";
}
}
httpObj.send("");
}
driversid2007Trade.GetHandleNameCt = function(obj, chkResult) {
var result = obj.responseXML;
if (result == null) {
chkResult.innerHTML = "";
chkResult.style.display="none";
return;
}
var registCt = result.getElementsByTagName("registCt");
var badCt = result.getElementsByTagName("badCt");
var isSurrogate = result.getElementsByTagName("isSurrogate");
if (registCt == null || registCt.length == 0 || badCt == null || badCt.length == 0 || isSurrogate.length == 0) {
chkResult.innerHTML = "";
chkResult.style.display="none";
return;
} else {
if (parseInt(result.getElementsByTagName("registCt")[0].firstChild.nodeValue) == 0) {
if (parseInt(result.getElementsByTagName("badCt")[0].firstChild.nodeValue) == 0) {
chkResult.innerHTML = driversid2007Trade.MSG_ENTER_DISPLAYNAME;
chkResult.style.display="block";
} else {
chkResult.innerHTML = driversid2007Trade.ERRMSG_REPEAT_DISPLAYNAME;
chkResult.style.display="block";
}
} else {
chkResult.innerHTML = driversid2007Trade.ERRMSG_REPEAT_DISPLAYNAME;
chkResult.style.display="block";
}
if (parseInt(result.getElementsByTagName("isSurrogate")[0].firstChild.nodeValue) == 1) {
chkResult.innerHTML = driversid2007Trade.ERRMSG_ISSURROGATE_DISPLAYNAME;
chkResult.style.display="block";
}
}
}