
/**
add upload file element
*/
function addUploadFile() {
	var td = document.getElementById("upload");
	var br = document.createElement("br");
	var input = document.createElement("input");
	var button = document.createElement("input");
	var content = document.createElement("input");
	input.type = "file";
	input.name = "photo";
	input.onchange = "_display(this)";
	content.type = "textdield";
	content.name = "content";
	button.type = "button";
	button.value = "cancel";
	button.onclick = function () {
		td.removeChild(br);
		td.removeChild(input);
		td.removeChild(input);
		td.removeChild(button);
	};
	td.appendChild(br);
	td.appendChild(input);
	td.appendChild(content);
	td.appendChild(button);
}
/**
add news nextpage
*/
function nextPage() {
	var traget = document.getElementById("all");
	var content1 = document.getElementById("content");
	var temp;
	var pages = 1;
	temp = content1.cloneNode(true);
	temp.id = pages;
	for (var i = 0; i < temp.childNodes.length; i++) {
		if (temp.childNodes[i].type == "file") {
			temp.childNodes[i].name = "photo";
		}
	}
	traget.appendChild(temp);
	pages++;
}
/**
open window
*/
function openWin(f, n, w, h, s) {
	sb = s == "1" ? "1" : "0";
	l = (screen.width - w) / 2;
	t = (screen.height - h) / 2;
	sFeatures = "left=" + l + ",top=" + t + ",height=" + h + ",width=" + w + ",center=1,scrollbars=" + sb + ",status=0,directories=0,channelmode=0";
	openwin = window.open(f, n, sFeatures);
	if (!openwin.opener) {
		openwin.opener = self;
	}
	openwin.focus();
	return openwin;
}
/**
show date
*/
function showDate() {
	var today = new Date();
	var week;
	var date;
	if (today.getDay() == 0) {
		week = "\u661f\u671f\u65e5";
	}
	if (today.getDay() == 1) {
		week = "\u661f\u671f\u4e00";
	}
	if (today.getDay() == 2) {
		week = "\u661f\u671f\u4e8c";
	}
	if (today.getDay() == 3) {
		week = "\u661f\u671f\u4e09";
	}
	if (today.getDay() == 4) {
		week = "\u661f\u671f\u56db";
	}
	if (today.getDay() == 5) {
		week = "\u661f\u671f\u4e94";
	}
	if (today.getDay() == 6) {
		week = "\u661f\u671f\u516d";
	}
	date = (today.getMonth() + 1) + "\u6708" + today.getDate() + "\u65e5" + " ";
	document.write(date + week);
}
/**
change picture
*/
function _display(par) {
	temp = par.parentNode;
	var url = par.value;
	url = "file:///" + url.replace("\\", "/");
	for (var i = 0; i < par.parentNode.childNodes.length; i++) {
		if (temp.childNodes[i].tagName == "img" || temp.childNodes[i].tagName == "IMG") {
			temp.childNodes[i].src = url;
		}
	}
}
/**
statdownloadtimes
*/
var req = null;
function statTimes() {
	var id1 = document.getElementById("id").value;
	var url = "../download/statdownloadtimes.action?uploadId=" + id1;
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
	} else {
		if (window.ActiveXObject) {
			req = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	req.open("GET", url, true);
	req.send(null);
}
/**
check complainID

var req;
function validate1() {
	var idField = document.getElementById("name");
	var url = "ValidateUser.jsp?id=" + escape(idField.value);
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
	} else {
		if (window.ActiveXObject) {
			req = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	req.open("GET", url, true);
	req.onreadystatechange = callback;
	req.send(null);
}
function callback() {
	if (req.readyState == 4) {
		if (req.status == 200) {
			var msg = req.responseXML.getElementsByTagName("msg1")[0];
			setMsg(msg.childNodes[0].nodeValue);
		}
	}
}
function setMsg(msg) {
	mdiv = document.getElementById("msg1");
	if (msg == "invalid") {
		mdiv.innerHTML = "<font color='green'>u53efu4ee5u6295u8bc9u8be5u7528u6237!</font>";
	} else {
		mdiv.innerHTML = "<font color='red'>u4e0du80fdu6295u8bc9u8be5u7528u6237!</font>";
	}
}
*/
/**
change pic
*/
function display(par) {
	var p = "file://localhost/" + par;
	document.getElementById("img").src = p;
	checkUploadPType();
}
/**
request regist
*/
function freshImage1(url) {
	var xmlHttp;
	if (window.XMLHttpRequest) {
		xmlHttp = new XMLHttpRequest();
	} else {
		if (window.ActiveXObject) {
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	xmlHttp.open("post", url, true);
	xmlHttp.send();
	var result1 = document.getElementById("result");
	var result2 = document.getElementById("result2");
	xmlHttp.onreadystatechange = function () {
		if (xmlHttp.readyState == 4) {
			result1.innerHTML = xmlHttp.responseText;
			result2.innerHTML = xmlHttp.responseText;
		} else {
			result1.innerHTML = "freshing!";
			result2.innerHTML = "freshing!";
		}
	};
}
/**
choose userlogo logo  display
*/
function setHidden(num) {
	var showImage = document.getElementById("showImage");
	showImage.innerHTML = "<img  id='bigImage' src='/pktown_new/uploadDisc/local/user_logo" + num + ".jpg' height='120' width='120' alt=" + num + "'\u53f7\u5934\u50cf'/>" + "<input type='hidden' name='selectNum' value=" + num + " id='selectNum'/>";
}
/**
add matchMember
*/
function addMatchMem() {
	var matchKindI = document.getElementById("matchKind").value;
	var addMatchMem = document.getElementById("matchMember");
	if (matchKindI == "war31v1" || matchKindI == "sc1v1") {
		addMatchMem.innerHTML = "\u53c2\u8d5b\u9009\u624b\uff1a<br /><input type='text' name='match.hostFirst.userId' id='fh'/> vs <input type='text' name='match.guestFirst.userId' id='fg'/><br />";
	}
	if (matchKindI == "war32v2" || matchKindI == "sc2v2") {
		addMatchMem.innerHTML = "\u53c2\u8d5b\u9009\u624b\uff1a<br /><input type='text' name='match.hostFirst.userId' id='fh'/> vs <input type='text' name='match.guestFirst.userId' id='fg'/><br /><input type='text' name='match.hostSecond.userId' id='sh'/> vs <input type='text' name='match.guestSecond.userId' id='sg'/><br />";
	}
	if (matchKindI == "war33v3" || matchKindI == "sc3v3") {
		addMatchMem.innerHTML = "\u53c2\u8d5b\u9009\u624b\uff1a<br /><input type='text' name='match.hostFirst.userId' id='fh'/> &nbsp;&nbsp;&nbsp; <input type='text' name='match.guestFirst.userId' id='fg'/><br /><input type='text' name='match.hostSecond.userId' id='sh'/> vs <input type='text' name='match.guestSecond.userId' id='sg'/><br /><input type='text' name='match.hostThird.userId' id='th'/> &nbsp;&nbsp;&nbsp; <input type='text' name='match.guestThird.userId' id='tg'/><br />";
	}
	if (matchKindI == "dota5v5" || matchKindI == "cs5v5") {
		addMatchMem.innerHTML = "\u53c2\u8d5b\u9009\u624b\uff1a<br /><input type='text' name='match.hostFirst.userId' id='fh'/> &nbsp;&nbsp;&nbsp; <input type='text' name='match.guestFirst.userId' id='fg'/><br /><input type='text' name='match.hostSecond.userId' id='sh'/> &nbsp;&nbsp;&nbsp; <input type='text' name='match.guestSecond.userId' id='sg'/><br /><input type='text' name='match.hostThird.userId' id='th'/> vs <input type='text' name='match.guestThird.userId' id='tg'/><br /><input type='text' name='match.hostFourth.userId' id='ffh'/> &nbsp;&nbsp;&nbsp; <input type='text' name='match.guestFourth.userId' id='ffg'/><br /><input type='text' name='match.hostFifth.userId' id='fih'/> &nbsp;&nbsp;&nbsp; <input type='text' name='match.guestFifth.userId' id='fig'/><br />";
	}
}
function selCato(name, obj, n) {
	for (i = 1; i <= n; i++) {
		eval("document.getElementById('" + name + i + "').className=''");
		if (name == "n" || name == "s") {
		} else {
			eval("document.getElementById('display_" + name + "_" + i + "').style.display='none'");
		}
	}
	if (name == "mt" || name == "dt") {
		eval("document.getElementById('" + name + obj + "').className='topButtonOver'");
	} else {
		eval("document.getElementById('" + name + obj + "').className='columBarOver'");
	}
	if (name == "n" || name == "s") {
	} else {
		eval("document.getElementById('display_" + name + "_" + obj + "').style.display=''");
	}
}
function DLLRegistered(strID) {
	var o = null;
	try {
		o = new ActiveXObject(strID);
	}
	catch (e) {
		return false;
	}
	if (o != null) {
		o = null;
		return true;
	} else {
		return false;
	}
}
function selCat(name, obj, n) {
	for (i = 1; i <= n; i++) {
		eval("document.getElementById('" + name + i + "').className=''");
		if (name == "n" || name == "s") {
		} else {
			eval("document.getElementById('display_" + name + "_" + i + "').style.display='none'");
		}
	}
	if (name == "mt" || name == "dt") {
		eval("document.getElementById('" + name + obj + "').className='topButtonOver'");
	} else {
		eval("document.getElementById('" + name + obj + "').className='columnBarOver'");
	}
	if (name == "n" || name == "s") {
	} else {
		eval("document.getElementById('display_" + name + "_" + obj + "').style.display=''");
	}
}
function DLLRegistered(strID) {
	var o = null;
	try {
		o = new ActiveXObject(strID);
	}
	catch (e) {
		return false;
	}
	if (o != null) {
		o = null;
		return true;
	} else {
		return false;
	}
}
/*sidemenu*/
function getObject(objectId) {
	if (document.getElementById && document.getElementById(objectId)) {
		return document.getElementById(objectId);
	} else {
		if (document.all && document.all(objectId)) {
			return document.all(objectId);
		} else {
			if (document.layers && document.layers[objectId]) {
				return document.layers[objectId];
			} else {
				return false;
			}
		}
	}
}
function showHide(e, objname) {
	var obj = getObject(objname);
	if (obj.style.display == "none") {
		obj.style.display = "block";
		e.className = "xias";
	} else {
		obj.style.display = "none";
		e.className = "rights";
	}
}
/**
check input key
*/
function checkInputKey() {
	var keyII = document.getElementById("key").value;
	if (keyII.replace(/(^\s*)|(\s*$)/g, "") == "") {
		alert("\u8bf7\u8f93\u5165\u8981\u641c\u7d22\u7684\u7528\u6237ID");
		return false;
	}
	return true;
}
/*addfriend*/
var prox;
var proy;
var proxc;
var proyc;
function show(id) {
	/*--打开--*/
	clearInterval(prox);
	clearInterval(proy);
	clearInterval(proxc);
	clearInterval(proyc);
	var o = document.getElementById(id);
	o.style.display = "block";
	o.style.width = "1px";
	o.style.height = "1px";
	prox = setInterval(function () {
		openx(o, 300);
	}, 10);
}
function openx(o, x) {
	/*--打开x--*/
	var cx = parseInt(o.style.width);
	if (cx < x) {
		o.style.width = (cx + Math.ceil((x - cx) / 5)) + "px";
		o.style.left = "200px";
		o.style.top = "300px";
	} else {
		clearInterval(prox);
		proy = setInterval(function () {
			openy(o, 200);
		}, 10);
	}
}
function openy(o, y) {
	/*--打开y--*/
	var cy = parseInt(o.style.height);
	if (cy < y) {
		o.style.height = (cy + Math.ceil((y - cy) / 5)) + "px";
	} else {
		clearInterval(proy);
	}
}
function closeed(id) {
	/*--关闭--*/
	clearInterval(prox);
	clearInterval(proy);
	clearInterval(proxc);
	clearInterval(proyc);
	var o = document.getElementById(id);
	if (o.style.display == "block") {
		proyc = setInterval(function () {
			closey(o);
		}, 10);
	}
}
function closey(o) {
	/*--打开y--*/
	var cy = parseInt(o.style.height);
	if (cy > 0) {
		o.style.height = (cy - Math.ceil(cy / 5)) + "px";
	} else {
		clearInterval(proyc);
		proxc = setInterval(function () {
			closex(o);
		}, 10);
	}
}
function closex(o) {
	/*--打开x--*/
	var cx = parseInt(o.style.width);
	if (cx > 0) {
		o.style.width = (cx - Math.ceil(cx / 5)) + "px";
	} else {
		clearInterval(proxc);
		o.style.display = "none";
	}
}
/*积分排名*/
var LastLeftID = "";
function menuFix() {
	var obj = document.getElementById("nav").getElementsByTagName("li");
	for (var i = 0; i < obj.length; i++) {
		obj[i].onmouseover = function () {
			this.className += (this.className.length > 0 ? " " : "") + "sfhover";
		};
		obj[i].onMouseDown = function () {
			this.className += (this.className.length > 0 ? " " : "") + "sfhover";
		};
		obj[i].onMouseUp = function () {
			this.className += (this.className.length > 0 ? " " : "") + "sfhover";
		};
		obj[i].onmouseout = function () {
			this.className = this.className.replace(new RegExp("( ?|^)sfhover\\b"), "");
		};
	}
}
function DoMenu(emid) {
	var obj = document.getElementById(emid);
	obj.className = (obj.className.toLowerCase() == "expanded" ? "collapsed" : "expanded");
	if ((LastLeftID != "") && (emid != LastLeftID)) { //关闭上一个Menu
	}
	document.getElementById(LastLeftID).className = "collapsed";
	LastLeftID = emid;
}
function GetMenuID() {
	var MenuID = "";
	var _paramStr = new String(window.location.href);
	var _sharpPos = _paramStr.indexOf("#");
	if (_sharpPos >= 0 && _sharpPos < _paramStr.length - 1) {
		_paramStr = _paramStr.substring(_sharpPos + 1, _paramStr.length);
	} else {
		_paramStr = "";
	}
	if (_paramStr.length > 0) {
		var _paramArr = _paramStr.split("&");
		if (_paramArr.length > 0) {
			var _paramKeyVal = _paramArr[0].split("=");
			if (_paramKeyVal.length > 0) {
				MenuID = _paramKeyVal[1];
			}
		}
		/*
  if (_paramArr.length>0)
  {
   var _arr = new Array(_paramArr.length);
  }
  
  //取所有#后面的，菜单只需用到Menu
  //for (var i = 0; i < _paramArr.length; i++)
  {
   var _paramKeyVal = _paramArr[i].split('=');
   
   if (_paramKeyVal.length>0)
   {
    _arr[_paramKeyVal[0]] = _paramKeyVal[1];
   }  
  }
  */
	}
	if (MenuID != "") {
		DoMenu(MenuID);
	}
}
GetMenuID(); //*这两个function的顺序要注意一下，不然在Firefox里GetMenuID()不起效果
menuFix();
/*img control*/
var flage = false;
function DrawImage(ImgD, maxwidth, maxheight) {
	var image = new Image();
	image.src = ImgD.src;
	if (image.width > 0 && image.height > 0) {
		flage = true;
		if (image.width / image.height >= maxwidth / maxheight) {
			if (image.width > maxwidth) {
				ImgD.width = maxwidth;
				ImgD.height = (image.height * maxwidth) / image.width;
			} else {
				ImgD.width = image.width;
				ImgD.height = image.height;
			}
		} else {
			if (image.height > maxheight) {
				ImgD.height = maxheight;
				ImgD.width = (image.width * maxheight) / image.height;
			} else {
				ImgD.width = image.width;
				ImgD.height = image.height;
			}
		}
	}
}
/* load Logo css*/
function loadLogoCSS(logoNum) {
    logoNum= Math.random()*logoNum
    var loop=0;
    while(loop<logoNum){loop++}
    logoNum=loop;
	var fileref = document.createElement("link");
	fileref.setAttribute("rel", "stylesheet");
	fileref.setAttribute("type", "text/css");
	fileref.setAttribute("href", "/pktown_new/css/personal/logocss" + logoNum+ ".css");
	document.getElementsByTagName("head")[0].appendChild(fileref);
}

