﻿function setCookie(name, value)		//cookies设置
{
	var argv = setCookie.arguments;
	var argc = setCookie.arguments.length;
	var expires = (argc > 2) ? argv[2] : null;
	if(expires!=null)
	{
		var LargeExpDate = new Date ();
		LargeExpDate.setTime(LargeExpDate.getTime() + (expires*1000*3600*24));
	}
	document.cookie = name + "=" + escape (value)+((expires == null) ? "" : ("; expires=" +LargeExpDate.toGMTString()));
}

function getCookie(Name)			//cookies读取
{
	var search = Name + "="
	if(document.cookie.length > 0) 
	{
		offset = document.cookie.indexOf(search)
		if(offset != -1) 
		{
			offset += search.length
			end = document.cookie.indexOf(";", offset)
			if(end == -1) end = document.cookie.length
			return unescape(document.cookie.substring(offset, end))
		 }
	else return ""
	  }
}

function trim(str) {
	regExp1 = /^ */;
	regExp2 = / *$/;
	return str.replace(regExp1,'').replace(regExp2,'');
}

function CheckNum(s)   
  {   
      if   (s   ==   "")   return   false;         //不允许空值   
      if   (!(s.match(/\D/)==null)){   
              alert("Please enter Numbers!");   
              return   false;}   
      return   true;   
  }

function GetN(txt) {if($("#hidnum").val() != "0")
{$("#n"+$("#hidnum").val()).css({background:"#FFE0CF"});}
else{$("#n"+$("#hidnum").val()).css({background:"white"});} 
$("#hidnum").val(txt);$("#n"+ txt).css({background:"red"});}

function SetN(f){if($("#hidnum").val() != "0"){if($("#hidAdd").val()=="+"){f.value = f.value +""+ $("#hidnum").val();CV(f);}else{f.value = $("#hidnum").val();CV(f);}}}

function Sadd(){if($("#hidAdd").val()=="+"){$("#hidAdd").val("-");$("#NumAdd").html("-");}else{$("#hidAdd").val("+");$("#NumAdd").html("+");}}

function killErrors() { 
return true; 
} 
//window.onerror = killErrors; 
function Ld(url)
{
   var e = document.createElement("script");
   e.src = url;
   e.type="text/javascript";
   document.getElementsByTagName("head")[0].appendChild(e);
}

function MouseOver(t,color)
{
    t.style.background=color;
    t.style.color="white";
}
function MouseOut(t,color)
{
    t.style.background=color;
    t.style.color="black";
}
    
var domTT_styleClass = 'domTTOverlib';
var domTT_maxWidth = false;

function tip(src, event, total, length) {
  var direction = 'north';
  //var tooltipContent = total + ' in ' + length + ': ';
  var tooltipCaption =  total + ' in ' + length;
  var tooltipContent = '<' + 'div align="center">';
  var splitAt = 0;
  for (i=0; i<pm[total][length].length; i++) {
    if (i != 0) tooltipContent += '; ';
    if (i > 0 && ((splitAt == 0 && ((i * length) % 12) < length) || (splitAt != 0 && (i % splitAt) == 0))) {
      if (splitAt == 0) splitAt = i;
      tooltipContent += '<' + 'br>';
    }
    tooltipContent += '(' + pm[total][length][i] + ')';
  }
  tooltipContent += '<' + '/div>';

  //return makeTrue(domTT_activate(src, event, 'content', tooltipContent, 'lifetime', 3000, 'delay', 1000, 'direction', direction));
  return makeTrue(domTT_activate(src, event, 'caption', tooltipCaption, 'content', tooltipContent, 'type', 'sticky', 'closeLink', '[x]', 'draggable', true, 'direction', direction));
}

var pm = new Array();
for (var i=0; i<=45; i++) {
  pm[i] = new Array();
}
pm[1][1] = new Array('1');
pm[2][1] = new Array('2');
pm[3][1] = new Array('3');
pm[4][1] = new Array('4');
pm[5][1] = new Array('5');
pm[6][1] = new Array('6');
pm[7][1] = new Array('7');
pm[8][1] = new Array('8');
pm[9][1] = new Array('9');

pm[3][2] = new Array('1,2');
pm[4][2] = new Array('1,3');
pm[5][2] = new Array('1,4',
                     '2,3');
pm[6][2] = new Array('1,5',
                     '2,4');
pm[7][2] = new Array('1,6',
                     '2,5',
                     '3,4');
pm[8][2] = new Array('1,7',
                     '2,6',
                     '3,5');
pm[9][2] = new Array('1,8',
                     '2,7',
                     '3,6',
                     '4,5');
pm[10][2] = new Array('1,9',
                      '2,8',
                      '3,7',
                      '4,6');
pm[11][2] = new Array('2,9',
                      '3,8',
                      '4,7',
                      '5,6');
pm[12][2] = new Array('3,9',
                      '4,8',
                      '5,7');
pm[13][2] = new Array('4,9',
                      '5,8',
                      '6,7');
pm[14][2] = new Array('5,9',
                      '6,8');
pm[15][2] = new Array('6,9',
                      '7,8');
pm[16][2] = new Array('7,9');
pm[17][2] = new Array('8,9');

pm[6][3] = new Array('1,2,3');
pm[7][3] = new Array('1,2,4');
pm[8][3] = new Array('1,2,5',
                     '1,3,4');
pm[9][3] = new Array('1,2,6',
                     '1,3,5',
                     '2,3,4');
pm[10][3] = new Array('1,2,7',
                      '1,3,6',
                      '1,4,5',
                      '2,3,5');
pm[11][3] = new Array('1,2,8',
                      '1,3,7',
                      '1,4,6',
                      '2,3,6',
                      '2,4,5');
pm[12][3] = new Array('1,2,9',
                      '1,3,8',
                      '1,4,7',
                      '1,5,6',
                      '2,3,7',
                      '2,4,6',
                      '3,4,5');
pm[13][3] = new Array('1,3,9',
                      '1,4,8',
                      '1,5,7',
                      '2,3,8',
                      '2,4,7',
                      '2,5,6',
                      '3,4,6');
pm[14][3] = new Array('1,4,9',
                      '1,5,8',
                      '1,6,7',
                      '2,3,9',
                      '2,4,8',
                      '2,5,7',
                      '3,4,7',
                      '3,5,6');
pm[15][3] = new Array('1,5,9',
                      '1,6,8',
                      '2,4,9',
                      '2,5,8',
                      '2,6,7',
                      '3,4,8',
                      '3,5,7',
                      '4,5,6');
pm[16][3] = new Array('1,6,9',
                      '1,7,8',
                      '2,5,9',
                      '2,6,8',
                      '3,4,9',
                      '3,5,8',
                      '3,6,7',
                      '4,5,7');
pm[17][3] = new Array('1,7,9',
                      '2,6,9',
                      '2,7,8',
                      '3,5,9',
                      '3,6,8',
                      '4,5,8',
                      '4,6,7');
pm[18][3] = new Array('1,8,9',
                      '2,7,9',
                      '3,6,9',
                      '3,7,8',
                      '4,5,9',
                      '4,6,8',
                      '5,6,7');
pm[19][3] = new Array('2,8,9',
                      '3,7,9',
                      '4,6,9',
                      '4,7,8',
                      '5,6,8');
pm[20][3] = new Array('3,8,9',
                      '4,7,9',
                      '5,6,9',
                      '5,7,8');
pm[21][3] = new Array('4,8,9',
                      '5,7,9',
                      '6,7,8');
pm[22][3] = new Array('5,8,9',
                      '6,7,9');
pm[23][3] = new Array('6,8,9');
pm[24][3] = new Array('7,8,9');

pm[10][4] = new Array('1,2,3,4');
pm[11][4] = new Array('1,2,3,5');
pm[12][4] = new Array('1,2,3,6',
                      '1,2,4,5');
pm[13][4] = new Array('1,2,3,7',
                      '1,2,4,6',
                      '1,3,4,5');
pm[14][4] = new Array('1,2,3,8',
                      '1,2,4,7',
                      '1,2,5,6',
                      '1,3,4,6',
                      '2,3,4,5');
pm[15][4] = new Array('1,2,3,9',
                      '1,2,4,8',
                      '1,2,5,7',
                      '1,3,4,7',
                      '1,3,5,6',
                      '2,3,4,6');
pm[16][4] = new Array('1,2,4,9',
                      '1,2,5,8',
                      '1,2,6,7',
                      '1,3,4,8',
                      '1,3,5,7',
                      '1,4,5,6',
                      '2,3,4,7',
                      '2,3,5,6');
pm[17][4] = new Array('1,2,5,9',
                      '1,2,6,8',
                      '1,3,4,9',
                      '1,3,5,8',
                      '1,3,6,7',
                      '1,4,5,7',
                      '2,3,4,8',
                      '2,3,5,7',
                      '2,4,5,6');
pm[18][4] = new Array('1,2,6,9',
                      '1,2,7,8',
                      '1,3,5,9',
                      '1,3,6,8',
                      '1,4,5,8',
                      '1,4,6,7',
                      '2,3,4,9',
                      '2,3,5,8',
                      '2,3,6,7',
                      '2,4,5,7',
                      '3,4,5,6');
pm[19][4] = new Array('1,2,7,9',
                      '1,3,6,9',
                      '1,3,7,8',
                      '1,4,5,9',
                      '1,4,6,8',
                      '1,5,6,7',
                      '2,3,5,9',
                      '2,3,6,8',
                      '2,4,5,8',
                      '2,4,6,7',
                      '3,4,5,7');
pm[20][4] = new Array('1,2,8,9',
                      '1,3,7,9',
                      '1,4,6,9',
                      '1,4,7,8',
                      '1,5,6,8',
                      '2,3,6,9',
                      '2,3,7,8',
                      '2,4,5,9',
                      '2,4,6,8',
                      '2,5,6,7',
                      '3,4,5,8',
                      '3,4,6,7');
pm[21][4] = new Array('1,3,8,9',
                      '1,4,7,9',
                      '1,5,6,9',
                      '1,5,7,8',
                      '2,3,7,9',
                      '2,4,6,9',
                      '2,4,7,8',
                      '2,5,6,8',
                      '3,4,5,9',
                      '3,4,6,8',
                      '3,5,6,7');
pm[22][4] = new Array('1,4,8,9',
                      '1,5,7,9',
                      '1,6,7,8',
                      '2,3,8,9',
                      '2,4,7,9',
                      '2,5,6,9',
                      '2,5,7,8',
                      '3,4,6,9',
                      '3,4,7,8',
                      '3,5,6,8',
                      '4,5,6,7');
pm[23][4] = new Array('1,5,8,9',
                      '1,6,7,9',
                      '2,4,8,9',
                      '2,5,7,9',
                      '2,6,7,8',
                      '3,4,7,9',
                      '3,5,6,9',
                      '3,5,7,8',
                      '4,5,6,8');
pm[24][4] = new Array('1,6,8,9',
                      '2,5,8,9',
                      '2,6,7,9',
                      '3,4,8,9',
                      '3,5,7,9',
                      '3,6,7,8',
                      '4,5,6,9',
                      '4,5,7,8');
pm[25][4] = new Array('1,7,8,9',
                      '2,6,8,9',
                      '3,5,8,9',
                      '3,6,7,9',
                      '4,5,7,9',
                      '4,6,7,8');
pm[26][4] = new Array('2,7,8,9',
                      '3,6,8,9',
                      '4,5,8,9',
                      '4,6,7,9',
                      '5,6,7,8');
pm[27][4] = new Array('3,7,8,9',
                      '4,6,8,9',
                      '5,6,7,9');
pm[28][4] = new Array('4,7,8,9',
                      '5,6,8,9');
pm[29][4] = new Array('5,7,8,9');
pm[30][4] = new Array('6,7,8,9');

pm[15][5] = new Array('1,2,3,4,5');
pm[16][5] = new Array('1,2,3,4,6');
pm[17][5] = new Array('1,2,3,4,7',
                      '1,2,3,5,6');
pm[18][5] = new Array('1,2,3,4,8',
                      '1,2,3,5,7',
                      '1,2,4,5,6');
pm[19][5] = new Array('1,2,3,4,9',
                      '1,2,3,5,8',
                      '1,2,3,6,7',
                      '1,2,4,5,7',
                      '1,3,4,5,6');
pm[20][5] = new Array('1,2,3,5,9',
                      '1,2,3,6,8',
                      '1,2,4,5,8',
                      '1,2,4,6,7',
                      '1,3,4,5,7',
                      '2,3,4,5,6');
pm[21][5] = new Array('1,2,3,6,9',
                      '1,2,3,7,8',
                      '1,2,4,5,9',
                      '1,2,4,6,8',
                      '1,2,5,6,7',
                      '1,3,4,5,8',
                      '1,3,4,6,7',
                      '2,3,4,5,7');
pm[22][5] = new Array('1,2,3,7,9',
                      '1,2,4,6,9',
                      '1,2,4,7,8',
                      '1,2,5,6,8',
                      '1,3,4,5,9',
                      '1,3,4,6,8',
                      '1,3,5,6,7',
                      '2,3,4,5,8',
                      '2,3,4,6,7');
pm[23][5] = new Array('1,2,3,8,9',
                      '1,2,4,7,9',
                      '1,2,5,6,9',
                      '1,2,5,7,8',
                      '1,3,4,6,9',
                      '1,3,4,7,8',
                      '1,3,5,6,8',
                      '1,4,5,6,7',
                      '2,3,4,5,9',
                      '2,3,4,6,8',
                      '2,3,5,6,7');
pm[24][5] = new Array('1,2,4,8,9',
                      '1,2,5,7,9',
                      '1,2,6,7,8',
                      '1,3,4,7,9',
                      '1,3,5,6,9',
                      '1,3,5,7,8',
                      '1,4,5,6,8',
                      '2,3,4,6,9',
                      '2,3,4,7,8',
                      '2,3,5,6,8',
                      '2,4,5,6,7');
pm[25][5] = new Array('1,2,5,8,9',
                      '1,2,6,7,9',
                      '1,3,4,8,9',
                      '1,3,5,7,9',
                      '1,3,6,7,8',
                      '1,4,5,6,9',
                      '1,4,5,7,8',
                      '2,3,4,7,9',
                      '2,3,5,6,9',
                      '2,3,5,7,8',
                      '2,4,5,6,8',
                      '3,4,5,6,7');
pm[26][5] = new Array('1,2,6,8,9',
                      '1,3,5,8,9',
                      '1,3,6,7,9',
                      '1,4,5,7,9',
                      '1,4,6,7,8',
                      '2,3,4,8,9',
                      '2,3,5,7,9',
                      '2,3,6,7,8',
                      '2,4,5,6,9',
                      '2,4,5,7,8',
                      '3,4,5,6,8');
pm[27][5] = new Array('1,2,7,8,9',
                      '1,3,6,8,9',
                      '1,4,5,8,9',
                      '1,4,6,7,9',
                      '1,5,6,7,8',
                      '2,3,5,8,9',
                      '2,3,6,7,9',
                      '2,4,5,7,9',
                      '2,4,6,7,8',
                      '3,4,5,6,9',
                      '3,4,5,7,8');
pm[28][5] = new Array('1,3,7,8,9',
                      '1,4,6,8,9',
                      '1,5,6,7,9',
                      '2,3,6,8,9',
                      '2,4,5,8,9',
                      '2,4,6,7,9',
                      '2,5,6,7,8',
                      '3,4,5,7,9',
                      '3,4,6,7,8');
pm[29][5] = new Array('1,4,7,8,9',
                      '1,5,6,8,9',
                      '2,3,7,8,9',
                      '2,4,6,8,9',
                      '2,5,6,7,9',
                      '3,4,5,8,9',
                      '3,4,6,7,9',
                      '3,5,6,7,8');
pm[30][5] = new Array('1,5,7,8,9',
                      '2,4,7,8,9',
                      '2,5,6,8,9',
                      '3,4,6,8,9',
                      '3,5,6,7,9',
                      '4,5,6,7,8');
pm[31][5] = new Array('1,6,7,8,9',
                      '2,5,7,8,9',
                      '3,4,7,8,9',
                      '3,5,6,8,9',
                      '4,5,6,7,9');
pm[32][5] = new Array('2,6,7,8,9',
                      '3,5,7,8,9',
                      '4,5,6,8,9');
pm[33][5] = new Array('3,6,7,8,9',
                      '4,5,7,8,9');
pm[34][5] = new Array('4,6,7,8,9');
pm[35][5] = new Array('5,6,7,8,9');

pm[21][6] = new Array('1,2,3,4,5,6');
pm[22][6] = new Array('1,2,3,4,5,7');
pm[23][6] = new Array('1,2,3,4,5,8',
                      '1,2,3,4,6,7');
pm[24][6] = new Array('1,2,3,4,5,9',
                      '1,2,3,4,6,8',
                      '1,2,3,5,6,7');
pm[25][6] = new Array('1,2,3,4,6,9',
                      '1,2,3,4,7,8',
                      '1,2,3,5,6,8',
                      '1,2,4,5,6,7');
pm[26][6] = new Array('1,2,3,4,7,9',
                      '1,2,3,5,6,9',
                      '1,2,3,5,7,8',
                      '1,2,4,5,6,8',
                      '1,3,4,5,6,7');
pm[27][6] = new Array('1,2,3,4,8,9',
                      '1,2,3,5,7,9',
                      '1,2,3,6,7,8',
                      '1,2,4,5,6,9',
                      '1,2,4,5,7,8',
                      '1,3,4,5,6,8',
                      '2,3,4,5,6,7');
pm[28][6] = new Array('1,2,3,5,8,9',
                      '1,2,3,6,7,9',
                      '1,2,4,5,7,9',
                      '1,2,4,6,7,8',
                      '1,3,4,5,6,9',
                      '1,3,4,5,7,8',
                      '2,3,4,5,6,8');
pm[29][6] = new Array('1,2,3,6,8,9',
                      '1,2,4,5,8,9',
                      '1,2,4,6,7,9',
                      '1,2,5,6,7,8',
                      '1,3,4,5,7,9',
                      '1,3,4,6,7,8',
                      '2,3,4,5,6,9',
                      '2,3,4,5,7,8');
pm[30][6] = new Array('1,2,3,7,8,9',
                      '1,2,4,6,8,9',
                      '1,2,5,6,7,9',
                      '1,3,4,5,8,9',
                      '1,3,4,6,7,9',
                      '1,3,5,6,7,8',
                      '2,3,4,5,7,9',
                      '2,3,4,6,7,8');
pm[31][6] = new Array('1,2,4,7,8,9',
                      '1,2,5,6,8,9',
                      '1,3,4,6,8,9',
                      '1,3,5,6,7,9',
                      '1,4,5,6,7,8',
                      '2,3,4,5,8,9',
                      '2,3,4,6,7,9',
                      '2,3,5,6,7,8');
pm[32][6] = new Array('1,2,5,7,8,9',
                      '1,3,4,7,8,9',
                      '1,3,5,6,8,9',
                      '1,4,5,6,7,9',
                      '2,3,4,6,8,9',
                      '2,3,5,6,7,9',
                      '2,4,5,6,7,8');
pm[33][6] = new Array('1,2,6,7,8,9',
                      '1,3,5,7,8,9',
                      '1,4,5,6,8,9',
                      '2,3,4,7,8,9',
                      '2,3,5,6,8,9',
                      '2,4,5,6,7,9',
                      '3,4,5,6,7,8');
pm[34][6] = new Array('1,3,6,7,8,9',
                      '1,4,5,7,8,9',
                      '2,3,5,7,8,9',
                      '2,4,5,6,8,9',
                      '3,4,5,6,7,9');
pm[35][6] = new Array('1,4,6,7,8,9',
                      '2,3,6,7,8,9',
                      '2,4,5,7,8,9',
                      '3,4,5,6,8,9');
pm[36][6] = new Array('1,5,6,7,8,9',
                      '2,4,6,7,8,9',
                      '3,4,5,7,8,9');
pm[37][6] = new Array('2,5,6,7,8,9',
                      '3,4,6,7,8,9');
pm[38][6] = new Array('3,5,6,7,8,9');
pm[39][6] = new Array('4,5,6,7,8,9');

pm[28][7] = new Array('1,2,3,4,5,6,7');
pm[29][7] = new Array('1,2,3,4,5,6,8');
pm[30][7] = new Array('1,2,3,4,5,6,9',
                      '1,2,3,4,5,7,8');
pm[31][7] = new Array('1,2,3,4,5,7,9',
                      '1,2,3,4,6,7,8');
pm[32][7] = new Array('1,2,3,4,5,8,9',
                      '1,2,3,4,6,7,9',
                      '1,2,3,5,6,7,8');
pm[33][7] = new Array('1,2,3,4,6,8,9',
                      '1,2,3,5,6,7,9',
                      '1,2,4,5,6,7,8');
pm[34][7] = new Array('1,2,3,4,7,8,9',
                      '1,2,3,5,6,8,9',
                      '1,2,4,5,6,7,9',
                      '1,3,4,5,6,7,8');
pm[35][7] = new Array('1,2,3,5,7,8,9',
                      '1,2,4,5,6,8,9',
                      '1,3,4,5,6,7,9',
                      '2,3,4,5,6,7,8');
pm[36][7] = new Array('1,2,3,6,7,8,9',
                      '1,2,4,5,7,8,9',
                      '1,3,4,5,6,8,9',
                      '2,3,4,5,6,7,9');
pm[37][7] = new Array('1,2,4,6,7,8,9',
                      '1,3,4,5,7,8,9',
                      '2,3,4,5,6,8,9');
pm[38][7] = new Array('1,2,5,6,7,8,9',
                      '1,3,4,6,7,8,9',
                      '2,3,4,5,7,8,9');
pm[39][7] = new Array('1,3,5,6,7,8,9',
                      '2,3,4,6,7,8,9');
pm[40][7] = new Array('1,4,5,6,7,8,9',
                      '2,3,5,6,7,8,9');
pm[41][7] = new Array('2,4,5,6,7,8,9');
pm[42][7] = new Array('3,4,5,6,7,8,9');

pm[36][8] = new Array('1,2,3,4,5,6,7,8');
pm[37][8] = new Array('1,2,3,4,5,6,7,9');
pm[38][8] = new Array('1,2,3,4,5,6,8,9');
pm[39][8] = new Array('1,2,3,4,5,7,8,9');
pm[40][8] = new Array('1,2,3,4,6,7,8,9');
pm[41][8] = new Array('1,2,3,5,6,7,8,9');
pm[42][8] = new Array('1,2,4,5,6,7,8,9');
pm[43][8] = new Array('1,3,4,5,6,7,8,9');
pm[44][8] = new Array('2,3,4,5,6,7,8,9');

pm[45][9] = new Array('1,2,3,4,5,6,7,8,9');


function d(str, p) {
  if(str == null || str.length < 8) {
    alert("length is too short.");
    return;
  }
  if(p == null || p.length <= 0) {
    alert("Please enter a p");
    return;
  }
  var prand = "";
  for(var i=0; i<p.length; i++) {
    prand += p.charCodeAt(i).toString();
  }
  var sPos = Math.floor(prand.length / 5);
  var mult = parseInt(prand.charAt(sPos) + prand.charAt(sPos*2) + prand.charAt(sPos*3) + prand.charAt(sPos*4) + prand.charAt(sPos*5));
  var incr = Math.round(p.length / 2);
  var modu = Math.pow(2, 31) - 1;
  var salt = parseInt(str.substring(str.length - 8, str.length), 16);
  str = str.substring(0, str.length - 8);
  prand += salt;
  while(prand.length > 10) {
    prand = (parseInt(prand.substring(0, 10)) + parseInt(prand.substring(10, prand.length))).toString();
  }
  prand = (mult * prand + incr) % modu;
  var e_chr = "";
  var e_str = "";
  for(var i=0; i<str.length; i+=2) {
    e_chr = parseInt(parseInt(str.substring(i, i+2), 16) ^ Math.floor((prand / modu) * 255));
    e_str += String.fromCharCode(e_chr);
    prand = (mult * prand + incr) % modu;
  }
  return e_str;
}

