
/*
*
*
*/
function $(id) {
  return document.getElementById(id);
}

/*
*
*
*/
function $c(type, param) {
  if ('text' == type) {
    return document.createTextNode(param);
	}
  return document.createElement(type);
}

/*
*
*
*/
function addEvent(elem, _event, func) {
	var _elem = elem;
  if ("string" == typeof(_elem)) {
    _elem = $(elem);
  }
  if (null == _elem) return;

  if (window.addEventListener) {
    _elem.addEventListener(_event, func, false);
  }	else if (window.attachEvent) {
    _elem.attachEvent("on" + _event, func);
	}
}

/*
*
*
*/
function delEvent(elem, _event, func) {
	var _elem = elem;
  if ("string" == typeof(_elem)) {
    _elem = $(elem);
  }
  if (null == _elem) return;

  if (window.removeEventListener) {
    _elem.removeEventListener(_event, func, false);
  }	else if (window.detachEvent) {
    _elem.detachEvent("on" + _event, func);
	}
}

/*
*
*
*/
function getAJAXObj() {
  var xmlHttpRequest;
  if (window.XMLHttpRequest) {
    xmlHttpRequest = new XMLHttpRequest();
  } else {
    xmlHttpRequest = new ActiveXObject("Microsoft.XMLHTTP");
  }
	return xmlHttpRequest;
}

/*
*
*
*/
function ajaxQuery(method, url, callback, content) {
  var xHR = getAJAXObj();
  xHR.open(method, url, true);
  if (callback) {
    xHR.onreadystatechange = function() {
      if (4 == xHR.readyState && 200 == xHR.status) {
        callback(xHR.responseText);
      }
    }
  }
  if ("post" == method.toLowerCase()) {
    xHR.setRequestHeader("Content-type","application/x-www-form-urlencoded");
    xHR.send(content);
  } else {
    xHR.send();
  }
}

/*
*
*
*/
function toggleRegDiv() {
	var divBG = $('coverBG');
  var chPassDiv = $('chPassDiv');
  var regDiv = $('regDiv');
  var loginDiv = $('loginDiv');
  chPassDiv.style.display = 'none';
  loginDiv.style.display = 'none';
	if ('block' == regDiv.style.display) {
    regDiv.style.display = 'none';
    divBG.style.display = 'none';
  } else {
    regDiv.style.display = 'block';
    divBG.style.display = 'block';
  }
}

/*
*
*
*/
function toggleChPassDiv() {
	var divBG = $('coverBG');
  var chPassDiv = $('chPassDiv');
  var regDiv = $('regDiv');
  var loginDiv = $('loginDiv');
  regDiv.style.display = 'none';
  loginDiv.style.display = 'none';
	if ('block' == chPassDiv.style.display) {
    chPassDiv.style.display = 'none';
    divBG.style.display = 'none';
  } else {
    chPassDiv.style.display = 'block';
    divBG.style.display = 'block';
  }
}

/*
*
*
*/
function toggleLoginDiv() {
	var divBG = $('coverBG');
  var chPassDiv = $('chPassDiv');
  var regDiv = $('regDiv');
  var loginDiv = $('loginDiv');
  regDiv.style.display = 'none';
  chPassDiv.style.display = 'none';
	if ('block' == loginDiv.style.display) {
    loginDiv.style.display = 'none';
    divBG.style.display = 'none';
  } else {
    loginDiv.style.display = 'block';
    divBG.style.display = 'block';
  }
}

var regEmailChecked = false;
var loginEmailChecked = false;

/*
*
*
*/
function regConfirmEmail() {
  var regConfirmCR = $('regConfirmCR');
  $('regSubmitBtn').disabled = true;
  if ($('regConfirm').value == $('regEmail').value) {
    regConfirmCR.style.backgroundColor = '#0F0';
    regConfirmCR.innerHTML = '√';
    if (regEmailChecked) {
      $('regTips').innerHTML = 'You can register with this E-mail.';
      $('regSubmitBtn').disabled = false;
    }
    return true;
  } else {
    regConfirmCR.style.backgroundColor = '#F00';
    regConfirmCR.innerHTML = '×';
    $('regTips').innerHTML = 'Confirm E-mail isn\'t same as register.';
    return false;
  }
}

/*
*
*
*/
function loginConfirm() {
  var loginPassCR = $('loginPassCR');
  $('loginSubmitBtn').disabled = true;
  if ("" != $('loginPass').value) {
    loginPassCR.style.backgroundColor = '#0F0';
    loginPassCR.innerHTML = '√';
    if (loginEmailChecked) {
      $('loginTips').innerHTML = 'You can click OK to login.';
      $('loginSubmitBtn').disabled = false;
    }
    return true;
  } else {
    loginPassCR.style.backgroundColor = '#F00';
    loginPassCR.innerHTML = '×';
    $('loginTips').innerHTML = 'Please input password.';
    return false;
  }
}

/*
*
*
*/
function chPassConfirm() {
  var oriPassChecked = false;
  var chPassOriCR = $('chPassOriCR');
  var chPassChToCR = $('chPassChToCR');
  var chPassChToConfirmCR = $('chPassChToConfirmCR');
  $('chPassSubmitBtn').disabled = true;

  if ("" != $('chPassOri').value) {
    chPassOriCR.style.backgroundColor = '#0F0';
    chPassOriCR.innerHTML = '√';
    oriPassChecked = true;
    $('chPassTips').innerHTML = '';
  } else {
    chPassOriCR.style.backgroundColor = '#F00';
    chPassOriCR.innerHTML = '×';
    $('chPassTips').innerHTML = 'Please input current password.';
  }

  if ("" != $('chPassChTo').value) {
    chPassChToCR.style.backgroundColor = '#0F0';
    chPassChToCR.innerHTML = '√';
    if ($('chPassChTo').value == $('chPassChToConfirm').value) {
      chPassChToConfirmCR.style.backgroundColor = '#0F0';
      chPassChToConfirmCR.innerHTML = '√';
      if (oriPassChecked) {
        $('chPassTips').innerHTML = 'You can click OK to change password.';
        $('chPassSubmitBtn').disabled = false;
      }
    } else {
      chPassChToConfirmCR.style.backgroundColor = '#F00';
      chPassChToConfirmCR.innerHTML = '×';
      $('chPassTips').innerHTML = 'Confirm password isn\'t same.';
    }
		
    oriPassChecked = true;
  } else {
    chPassChToCR.style.backgroundColor = '#F00';
    chPassChToCR.innerHTML = '×';
    $('chPassTips').innerHTML = 'Please input new password.';
  }

}

var lastFocusIndex = 0;
/*
*
*
*/
function jumpOperateDelBtnClick(e) {
  var e = window.event || e;
  var srcElement = e.srcElement || e.target;
  delJumpLine(srcElement.jumpIndex);
}

/*
*
*
*/
function jumpOperateAddBtnClick(e) {
  var e = window.event || e;
  var srcElement = e.srcElement || e.target;
  addJumpLine(srcElement.jumpIndex + 1);
}

/*
*
*
*/
function jumpOperatePathGetFocus(e) {
  var e = window.event || e;
  var srcElement = e.srcElement || e.target;
  if (lastFocusIndex > 0) {
    $('jumpProbDelete' + lastFocusIndex).style.visibility = 'hidden';
    $('jumpProbAdd' + lastFocusIndex).style.visibility = 'hidden';
  }
	if (operateJump.count > 1) {
    $('jumpProbDelete' + srcElement.jumpIndex).style.visibility = 'visible';
  }
	if (operateJump.count < 100) {
    $('jumpProbAdd' + srcElement.jumpIndex).style.visibility = 'visible';
  }
  lastFocusIndex = srcElement.jumpIndex;
}

/*
*
*
*/
function jumpOperateProbGetFocus(e) {
  var e = window.event || e;
  var srcElement = e.srcElement || e.target;
  if (lastFocusIndex > 0) {
    $('jumpProbDelete' + lastFocusIndex).style.visibility = 'hidden';
    $('jumpProbAdd' + lastFocusIndex).style.visibility = 'hidden';
  }
  if (operateJump.count > 1) {
    $('jumpProbDelete' + srcElement.jumpIndex).style.visibility = 'visible';
  }
  if (operateJump.count < 100) {
    $('jumpProbAdd' + srcElement.jumpIndex).style.visibility = 'visible';
  }
  lastFocusIndex = srcElement.jumpIndex;
}

/*
*
*
*/
function jumpOperatePathLostFocus(e) {
  var e = window.event || e;
  var srcElement = e.srcElement || e.target;
  operateJump.allLines[srcElement.jumpIndex - 1].path = srcElement.value;
}

/*
*
*
*/
function jumpOperateProbLostFocus(e) {
  var e = window.event || e;
  var srcElement = e.srcElement || e.target;
  var numValue = parseInt(srcElement.value);
  if (srcElement.value != numValue + "") {
    srcElement.value = operateJump.allLines[srcElement.jumpIndex - 1].prob;
    return;
  }

  var lastValue = operateJump.allLines[srcElement.jumpIndex - 1].prob;
  operateJump.allLines[srcElement.jumpIndex - 1].prob = numValue;
  operateJump.update();

  if (operateJump.probSum > 100) {
    operateJump.allLines[srcElement.jumpIndex - 1].prob = lastValue;
    operateJump.update();
    srcElement.value = lastValue;
    alert('probability is greate then 100');
  }

  refreshProbLeft();
}


/*
*
*
*/
function createJumpLine(index) {
  var aLine = $c('tr');
  var delBtn = $c('input');
  var label = $c('text', index + '.');
  var path = $c('input');
  var prob = $c('input');
  var addBtn = $c('input');

  aLine.id = 'jumpProbLine' + index;

  delBtn.type = 'button';
  delBtn.className = 'delBtn';
  delBtn.value = '-';
  delBtn.id = 'jumpProbDelete' + index;
  delBtn.style.visibility = 'hidden';
  delBtn.jumpIndex = index;
  addEvent(delBtn, 'click', jumpOperateDelBtnClick);

  path.type = 'text';
  path.className = 'imagePath';
  path.id = 'jumpPath' + index;
  path.name = path.id;
  path.jumpIndex = index;
  addEvent(path, 'focus', jumpOperatePathGetFocus);
  addEvent(path, 'blur', jumpOperatePathLostFocus);

  prob.type = 'text';
  prob.className = 'jumpProb';
  prob.id = 'jumpProbValue' + index;
  prob.name = path.id;
  prob.jumpIndex = index;
  addEvent(prob, 'focus', jumpOperateProbGetFocus);
  addEvent(prob, 'blur', jumpOperateProbLostFocus);

  addBtn.type = 'button';
  addBtn.className = 'addBtn';
  addBtn.value = '+';
  addBtn.style.visibility = 'hidden';
  addBtn.id = 'jumpProbAdd' + index;
  addBtn.jumpIndex = index;
  addEvent(addBtn, 'click', jumpOperateAddBtnClick);

  var td = $c('td');
  td.appendChild(delBtn);
  aLine.appendChild(td);

  td = $c('td');
  td.id = 'jumpProbLabel' + index;
  td.appendChild(label);
  aLine.appendChild(td);

  td = $c('td');
  td.appendChild(path);
  aLine.appendChild(td);

  td = $c('td');
  td.appendChild(prob);
  td.appendChild($c('text', '%'));
  aLine.appendChild(td);

  td = $c('td');
  td.appendChild(addBtn);
  aLine.appendChild(td);
	
  return aLine;
}

/*
*
*
*/
function addJumpLine(index, jumpObj) {
  index = index;// | (this.jumpIndex + 1);

  if (!operateJump) {
    operateJump = new JumpClass();
  }

  if (!jumpObj) {jumpObj = {path: "", prob: 0, index: index}}
  if (!operateJump.addProb(jumpObj)) {
    alert(0);
    return;
  }

  var aLine;
  aLine = createJumpLine(operateJump.count);

  var jumpSubmitLine = $('jumpSubmitLine');
  jumpSubmitLine.parentNode.insertBefore(aLine, jumpSubmitLine);
	
  $('jumpPath' + index).focus();

  for (var i = index - 1; i < operateJump.count; i++) {
    $('jumpPath' + (i + 1)).value = operateJump.allLines[i].path;
    $('jumpProbValue' + (i + 1)).value = operateJump.allLines[i].prob;
  }
}

/*
*
*
*/
function delJumpLine(index) {
  index = index | this.jumpIndex;

  $('jumpProbDelete' + index).blur();

  if (!operateJump) {
    return;
  }

  var lineID = operateJump.count;

  if (!operateJump.delProb(index)) {
    alert(0);
    return;
  }

  refreshProbLeft();

  var aLine = $('jumpProbLine' + lineID);

  var delBtn = $('jumpProbDelete' + lineID);
  var path = $('jumpPath' + lineID);
  var prob = $('jumpProbValue' + lineID);
  var addBtn = $('jumpProbAdd' + lineID);

  delEvent(delBtn, 'click', jumpOperateDelBtnClick);
  delEvent(path, 'focus', jumpOperatePathGetFocus);
  delEvent(path, 'blur', jumpOperatePathLostFocus);
  delEvent(prob, 'focus', jumpOperateProbGetFocus);
  delEvent(prob, 'blur', jumpOperateProbLostFocus);
  delEvent(addBtn, 'click', jumpOperateAddBtnClick);


  var jumpSubmitLine = $('jumpSubmitLine');
  if (lastFocusIndex > 0 & lastFocusIndex != lineID) {
    $('jumpProbDelete' + lastFocusIndex).style.visibility = 'hidden';
    $('jumpProbAdd' + lastFocusIndex).style.visibility = 'hidden';
  }
  jumpSubmitLine.parentNode.removeChild(aLine);
  lastFocusIndex = 0;

  for (var i = index - 1; i < operateJump.count; i++) {
    $('jumpPath' + (i + 1)).value = operateJump.allLines[i].path;
    $('jumpProbValue' + (i + 1)).value = operateJump.allLines[i].prob;
  }
}

/*
*
*
*/
function refreshProbLeft() {
  var probLeft = $('probLeft');
  if (operateJump) {
    if (operateJump.probSum > 70) {
      probLeft.style.color = '#F00';
    } else if (operateJump.probSum > 40) {
      probLeft.style.color = '#FF0';
    } else {
      probLeft.style.color = '#0F0';
    }

    var operatePlaneStyle = $('operatePlane').style;
    if ('none' == operatePlaneStyle.display) {
      probLeft.innerHTML = '';
    } else {
      probLeft.innerHTML = 'probability remain ' + (100 - operateJump.probSum) + '%';
    }
  }
}

/*
*
*
*/
function jumpOperateToggle() {
  var operateButtonsStyle = $('operateButtons').style;
  var operatePlaneStyle = $('operatePlane').style;
  if ('none' == operatePlaneStyle.display) {
    // start operate
    operateButtonsStyle.display = 'none';
    operatePlaneStyle.display = 'block';

  } else {
    // finish operate
    operateButtonsStyle.display = 'block';
    operatePlaneStyle.display = 'none';
    if (operateJump) {
      while (operateJump.count > 0) {
        delJumpLine(1);
      }
      operateJump = null;
    }
  }
  refreshProbLeft();
}

/*
*
*
*/
function DeleteJump(id) {
  ajaxQuery('get', 'http://wodefun.com/superjump/jumpoperate/?o=2&dt=1&dj=' + id, function(ret) {
    if ("error" == ret) {
      alert('fail');
    } else {
    
    }
  });
}

/*
*
*
*/
function PrepareModifyJump(id) {
  ajaxQuery('post', 'http://wodefun.com/superjump/jumpoperate/', function(ret) {

    if ("error" == ret) {
      alert('fail');
    } else {
      var jumpObjects = (new Function('', '{return ' + ret + '}'))();
      var i = 0;

      jumpOperateToggle();

      for (var i = 0; i < jumpObjects.length; i++) {
        addJumpLine((i + 1), jumpObjects[i]);
      }
//      operateJump.addProb({index: 1, path: 'a', prob: 3});

      operateJump.type = 1;
      operateJump.operate = 4;
      operateJump.address = id;
      refreshProbLeft();
    }
  }, 'o=3&qt=2&qj=' + id);
}

/*
*
*
*/
function GotoPage(page) {
  ajaxQuery('post', 'http://wodefun.com/superjump/jumpoperate/', function(ret) {
    if ("error" == ret) {
      alert('fail');
    } else {
      var jumpObj = (new Function('', '{return ' + ret + '}'))();
      var i = 0;

      while (CurrentPageJumps.length) { CurrentPageJumps.shift();}
      if (selectJumpLine) {
        selectJumpLine.oriClass = selectJumpLine.unSelectClass;
        selectJumpLine.className = selectJumpLine.oriClass;
        $('liDelJump').style.display = 'none';
        $('liModifyJump').style.display = 'none';
        $('liJumpURL').style.display = 'none';
      }
      selectJumpLine = null;

      for (i = 0; i < jumpObj.count; i++) {
        $('userJump' + (i + 1)).innerHTML = jumpObj.data[i];
        $('userJump' + (i + 1)).style.display = 'block';
        CurrentPageJumps.push({index: i, id: jumpObj.data[i]});
      }
      for (; i < 20; i++) {
        $('userJump' + (i + 1)).style.display = 'none';
      }

      $('navCurrentPage').innerHTML = jumpObj.current + '/' + jumpObj.total;

      if (jumpObj.current > 1) {
        $('jumpsNavFirstBtn').className = 'jumpsNavEnable';
        $('jumpsNavPrevBtn').className = 'jumpsNavEnable';
        $('jumpsNavFirstBtn').href = "javascript:GotoPage(1);";
        $('jumpsNavPrevBtn').href = "javascript:GotoPage(" + (jumpObj.current - 1) + ");";
      } else {
        $('jumpsNavFirstBtn').className = 'jumpsNavDisable';
        $('jumpsNavPrevBtn').className = 'jumpsNavDisable';
        $('jumpsNavFirstBtn').href = "javascript:void(0);";
        $('jumpsNavPrevBtn').href = "javascript:void(0);";
      }

      if (jumpObj.current < jumpObj.total) {
        $('jumpsNavNextBtn').className = 'jumpsNavEnable';
        $('jumpsNavLastBtn').className = 'jumpsNavEnable';
        $('jumpsNavNextBtn').href = "javascript:GotoPage(" + (jumpObj.current + 1) + ");";
        $('jumpsNavLastBtn').href = "javascript:GotoPage(" + jumpObj.total + ");";
      } else {
        $('jumpsNavNextBtn').className = 'jumpsNavDisable';
        $('jumpsNavLastBtn').className = 'jumpsNavDisable';
        $('jumpsNavNextBtn').href = "javascript:void(0);";
        $('jumpsNavLastBtn').href = "javascript:void(0);";
      }
    }
  }, 'o=3&qt=1&qp=' + page);
}


/*
*
*
**/
var JumpProbClass = function(params) {
  this.index = params.index;
  this.path = params.path;
  this.prob = params.prob;
}

/*
*
*
**/
var JumpClass = function(params) {

  var _this = this;
  this.count = 0;
  this.type = 0;
  this.operate = 0;
  this.address = "";
  this.allLines = new Array();
  this.probSum = 0;

  this.addProb = function(probParams) {
    if ("number" != typeof(probParams.index) | probParams.index < 1 | probParams.index > _this.allLines.length + 1) return false;
    if ("string" != typeof(probParams.path) | "number" != typeof(probParams.prob) | probParams.prob < 0 ) return false;
    if (_this.probSum + probParams.prob > 100) return false;

    _this.probSum += probParams.prob;
    _this.allLines.splice(probParams.index - 1, 0, new JumpProbClass(probParams));
    _this.count = _this.allLines.length;
    for (var i = probParams.index; i < _this.allLines.length; i++) {
      _this.allLines[i].index++;
    }
    return true;
  };

  this.delProb = function(index) {
    if (index > 0 & index <=_this.allLines.length) {
      _this.probSum -= _this.allLines[index-1].prob;
      _this.allLines.splice(index - 1, 1);
      _this.count = _this.allLines.length;
      for (var i = index - 1; i < _this.allLines.length; i++) {
        _this.allLines[i].index--;
      }
      return true;
    } else {
      return false;
    }
  }
	
	this.update = function() {
    _this.count = _this.allLines.length;
    _this.probSum = 0;
    for (var i = 0; i < _this.allLines.length; i++) {
      _this.probSum += _this.allLines[i].prob;
    }
  };
}


var CurrentPageJumps = new Array();
var operateJump = null;
var selectJumpLine = null;

/***********************************************************************/
window.onload = function() {

  addEvent('logoutBtn', 'click', function() {
    ajaxQuery('post', 'http://wodefun.com/logout/', function(ret) {
      if ('OK' == ret) {
        window.location.reload();
      }
    });
  });

  addEvent('loginBtn', 'click', toggleLoginDiv);
  addEvent('loginLink', 'click', toggleLoginDiv);
  addEvent('loginCloseBtn', 'click', toggleLoginDiv);
  addEvent('loginCancelBtn', 'click', toggleLoginDiv);
	
  addEvent('chPassBtn', 'click', toggleChPassDiv);
  addEvent('chPassCloseBtn', 'click', toggleChPassDiv);
  addEvent('chPassCancelBtn', 'click', toggleChPassDiv);
	
  addEvent('regBtn', 'click', toggleRegDiv);
  addEvent('regLink', 'click', toggleRegDiv);
  addEvent('regCloseBtn', 'click', toggleRegDiv);
  addEvent('regCancelBtn', 'click', toggleRegDiv);
	
  addEvent('regEmail', 'blur', function() {
    var regEmail = $('regEmail').value;
    var regEmailCR = $('regEmailCR');
    if (!/^[0-9a-zA-Z_]([0-9a-zA-Z_]*|(\.[0-9a-zA-Z_])*)*@[0-9a-zA-Z-]([0-9a-zA-Z-]*|(\.[0-9a-zA-Z-])*)*\.[a-zA-Z]+$/.test(regEmail)) {
      $('regTips').innerHTML = 'Please input right E-mail.';
      regEmailCR.style.backgroundColor = '#F00';
      regEmailCR.innerHTML = '×';
      return;
    }

    ajaxQuery('get', 'http://wodefun.com/superjump/ajaxquery.asp?email=' + regEmail + '&random=' + new Date().getTime(), function(ret) {
      var regEmailCR = $('regEmailCR');
      if ('ey' == ret) {
        regEmailCR.style.backgroundColor = '#0F0';
        regEmailCR.innerHTML = '√';
        regEmailChecked = true;
      } else {
        regEmailCR.style.backgroundColor = '#F00';
        regEmailCR.innerHTML = '×';
        $('regTips').innerHTML = 'This E-mail is registered.';
        regEmailChecked = false;
      }
      regConfirmEmail();
    });
  });
	
  addEvent('regConfirm', 'blur', regConfirmEmail);
  addEvent('regEmail', 'keyup', function() {regEmailChecked = false;regConfirmEmail();});
  addEvent('regConfirm', 'keyup', regConfirmEmail);
  addEvent('regEmail', 'change', function() {regEmailChecked = false});

  $('regForm').onsubmit = function() {
    ajaxQuery('get', 'http://wodefun.com/register/?email=' + $('regEmail').value + '&random=' + new Date().getTime(), function(ret) {
      if ("OK" == ret) {
        toggleRegDiv();
        alert('success');
      } else {
        alert('fail');
      }
    });

    return false;
  };

  addEvent('loginEmail', 'blur', function() {
    var loginEmail = $('loginEmail').value;
    var loginEmailCR = $('loginEmailCR');
    if (!/^[0-9a-zA-Z_]([0-9a-zA-Z_]*|(\.[0-9a-zA-Z_])*)*@[0-9a-zA-Z-]([0-9a-zA-Z-]*|(\.[0-9a-zA-Z-])*)*\.[a-zA-Z]+$/.test(loginEmail)) {
      $('loginTips').innerHTML = 'Please input right E-mail.';
      loginEmailCR.style.backgroundColor = '#F00';
      loginEmailCR.innerHTML = '×';
      loginEmailChecked = false;
    } else {
      $('loginTips').innerHTML = '';
      loginEmailCR.style.backgroundColor = '#0F0';
      loginEmailCR.innerHTML = '√';
      loginEmailChecked = true;
    }
    loginConfirm();
  });

  addEvent('loginPass', 'blur', loginConfirm);
  addEvent('loginEmail', 'keyup', function() {regEmailChecked = false;loginConfirm();});
  addEvent('loginPass', 'keyup', loginConfirm);
  addEvent('loginEmail', 'change', function() {loginEmailChecked = false});

  $('loginForm').onsubmit = function() {
    ajaxQuery('post', 'http://wodefun.com/login/', function(ret) {
      if ("success" == ret) {
        //toggleLoginDiv();
        window.location.reload();
      } else {
        alert('fail');
      }
    }, 'email=' + $('loginEmail').value + '&pass=' + $('loginPass').value);

    return false;
  };

  addEvent('chPassOri', 'blur', chPassConfirm);
  addEvent('chPassOri', 'keyup', chPassConfirm);
  addEvent('chPassOri', 'change', chPassConfirm);
  addEvent('chPassChTo', 'blur', chPassConfirm);
  addEvent('chPassChTo', 'keyup', chPassConfirm);
  addEvent('chPassChTo', 'change', chPassConfirm);
  addEvent('chPassChToConfirm', 'blur', chPassConfirm);
  addEvent('chPassChToConfirm', 'keyup', chPassConfirm);
  addEvent('chPassChToConfirm', 'change', chPassConfirm);

  $('chPassForm').onsubmit = function() {
    ajaxQuery('post', 'http://wodefun.com/changepass/', function(ret) {
      if ("success" == ret) {
        toggleChPassDiv();
      } else {
        alert('fail');
      }
    }, 'ori=' + $('chPassOri').value + '&to=' + $('chPassChTo').value);

    return false;
  };

/*jump operate*/
  addEvent('createJumpBtn', 'click', function () {
    if (!operateJump) {
      operateJump = new JumpClass();
    }
    operateJump.type = 1;
    operateJump.operate = 1;
    jumpOperateToggle();
    addJumpLine(1);
  });

  if ($('jumpOperateForm')) {
    addEvent('jumpOpCancel', 'click', function() {jumpOperateToggle();});

	  $('jumpOperateForm').onsubmit = function () {

      var queryString = 'o=' + operateJump.operate + '&st=' + operateJump.type + '&jc=' + operateJump.count;

      if ('' != operateJump.address) { queryString = queryString + '&uj=' + operateJump.address;}

      for (var i = 0; i< operateJump.count; i++) {
        queryString += '&jumpProbValue' + (i + 1) + '=' + operateJump.allLines[i].prob;
        queryString += '&jumpPath' + (i + 1) + '=' + operateJump.allLines[i].path;
      }

      ajaxQuery('post', 'http://wodefun.com/superjump/jumpoperate/', function(ret) {
        if ("success" == ret) {
        } else {
          alert('fail');
        }
      }, queryString);

      jumpOperateToggle();
      return false;
    };
  }


  if ($('userJump1')) {
    for (var i = 1; i < 21; i++) {
      $('userJump' + i).lineIndex = i;
      addEvent('userJump' + i, 'mouseover', function(e) {
        var e = window.event || e;
        var srcElement = e.srcElement || e.target;
        srcElement.oriClass=srcElement.className; srcElement.className='lOver';
      });
      addEvent('userJump' + i, 'mouseout', function(e) {
        var e = window.event || e;
        var srcElement = e.srcElement || e.target;
        srcElement.className=srcElement.oriClass;
      });
      addEvent('userJump' + i, 'click', function(e) {
        var e = window.event || e;
        var srcElement = e.srcElement || e.target;
        if ('lSelect' != srcElement.oriClass) {
          srcElement.unSelectClass = srcElement.oriClass;
          srcElement.oriClass = 'lSelect';
//          $('liDelJump').style.display = 'block';
//          $('deleteJumpBtn').href = 'javascript: DeleteJump("' + CurrentPageJumps[this.lineIndex-1].id + '")';
          $('liModifyJump').style.display = 'block';
          $('modifyJumpBtn').href = 'javascript: PrepareModifyJump("' + CurrentPageJumps[srcElement.lineIndex-1].id + '")';
          $('liJumpURL').innerHTML = 'http://j.wodefun.com/' + CurrentPageJumps[srcElement.lineIndex-1].id;
          $('liJumpURL').style.display = 'block';
          if (selectJumpLine) {
            selectJumpLine.oriClass = selectJumpLine.unSelectClass;
            selectJumpLine.className = selectJumpLine.oriClass;
          }
          selectJumpLine = srcElement;
        } else {
          srcElement.oriClass = srcElement.unSelectClass;
          $('liDelJump').style.display = 'none';
          $('liModifyJump').style.display = 'none';
          $('liJumpURL').style.display = 'none';
          selectJumpLine = null;
        }
      });
    }
  }


  $('regSubmitBtn').disabled = true;
  $('loginSubmitBtn').disabled = true;
  $('chPassSubmitBtn').disabled = true;
  if ($('operatePlane')) {  $('operatePlane').style.display = 'none';}

  if ($('liDelJump')) {$('liDelJump').style.display = 'none';}
  if ($('liModifyJump')) {$('liModifyJump').style.display = 'none';}
  if ($('liJumpURL')) {$('liJumpURL').style.display = 'none';}
}

