function checkns4() {
	if (document.layers) {
		document.write("<style>");
		document.write("BODY { margin-left: 2px }");
		document.write("</style>");
	}
}
checkns4();
NS4 = (document.layers);
IE4 = (document.all);
ver4 = (IE4);
isMac = (navigator.appVersion.indexOf("Mac") != -1);
isMenu = (IE4 && !isMac);
function popUp(){return};
function popDown(){return};
function startIt(){return};
if (!ver4) event=null;

function Init() {
          __dlg_init();
          var param = window.dialogArguments;
          if (param) {
              document.getElementById("f_url").value = param["f_url"];
          }
        };

function onOK(url) {
          // pass data back to the calling window
          var param = new Object();
          param["f_url"] = url;
          __dlg_close(param);
          return false;
        };
function onCancel() {
          __dlg_close(null);
          return false;
        };
function delEntry(entry_id) {
		if (window.confirm("是否确定删除文章？")) {
			window.location.href="del_entry.jspa?entry_id="+entry_id;
		}
	}
function approveEntry(entry_id){
		if (window.confirm("是否确定批准文章？"))
		{
			window.location.href="auth_blogContent.jspa?entryId="+entry_id;
		}
}
function vote(option,pollId,objectId)
	{
		var action = "/ajaxVote.jspa";
		var pars ="pollId="+pollId+"&option="+option+"&objectId="+objectId;
		var myAjax = new Ajax.Request(action,{method: 'post', parameters: pars, onComplete: updatePage} );
	}
function isClicked() {
    if (!clicked) { clicked = true; return true; }
    return false;
}
function NewWin(newURL,wth,hgh) {
			window.open(newURL,'','width='+wth+',height='+hgh+',left=70,top=130,scrollbars=yes');
		}
function winOpen(url){
		    window.open(url,'newwindow','height=800,width=700,scrollbars=yes');
		    return false;
		}
function selectCategory(catID, forumID) {
				window.location.replace('FORUM_LIST_'+catID+'_'+forumID+'_0_0.HTM');
		  }
function resetForum(obj){
			var topic =obj.options[obj.selectedIndex].text;
			if(topic.indexOf("---")==-1)
				obj.options[obj.selectedIndex+1].selected=true;
			else
				obj.options[obj.selectedIndex].selected=true;
		}
function doInsertAddress(el, targetEl) {
    // Look for an address book redirect
    if (el.value == '***') {
        location.href='addressbook.jspa';
    }

    // If the username is blank, return
    var username = el.value;
    if (username == '') {
        return;
    }
    // turn the current list of usernames into an array, check if the
    // specified username is already in the username list.
    var currentVal = targetEl.value;
    var usernames = currentVal.split(",");
    for (var i=0; i<usernames.length; i++) {
        if (usernames[i] == '') {
            usernames.splice(i,1);
            i--;
        }
        else {
            if (username == usernames[i].trim()) {
                return;
            }
        }
    }
    // At this point, the username was not found so add
    // the usename to the list of usernames:
    var newUsernames = username;
    for (var i=0; i<usernames.length; i++) {
        newUsernames += ", ";
        newUsernames += usernames[i];
    }
    targetEl.value = newUsernames;
    el.selectedIndex = 0;
}
function gotoeditab() {
    location.href = 'addressbook.jspa';
}
function checkForm(frm,max,min) {
	if (frm.body.value.length>500){
		alert(max);
		frm.body.focus();
		return false;
	}else if(frm.body.value.length == 0){
		alert(min);
		frm.body.focus();
		return false;
	}
	return true;
}
function delConfirm(url) {
			if (window.confirm(document.forms[1].confirmdelete.value)) {
				window.location=url+"";
			}
		}
function doSubmit(val) {
			document.forms[1].approve.value = val;
			document.forms[1].submit();
		}

	function setTabside2SPS(i){
		selectTabside2SPS(i);
	}
	function selectTabside2SPS(i){
		switch(i){
			case 1:
			document.getElementById("TabTabside2SPS1").style.display="block";
			document.getElementById("TabTabside2SPS2").style.display="none";
			break;
			case 2:
			document.getElementById("TabTabside2SPS1").style.display="none";
			document.getElementById("TabTabside2SPS2").style.display="block";
			break;
			}
	}

function change_img()
{
 if(nn>2) nn=1;
setTimeout('setTabside2SPS('+nn+')',10000);
nn++;
 tt=setTimeout('change_img()',10000);
}

function setSearch(searchType,forum_domain,server_name) {
	if (searchType == "ART") {
		document.lsrchform.action = "http://"+server_name+"/forumsearchredirect.jsp";
		document.getElementById('searchhref').href = "http://"+server_name+"/articleAdvSearch.do";
		document.lsrchform.searchlist.selectedIndex = 0;
	} else if(searchType == "DG" || searchType == "BLOG") {		
		document.lsrchform.action = "http://"+server_name+"/forumsearchredirect.jsp";		
		document.getElementById('searchhref').href = "http://"+server_name+"/advanced-search!default.jspa";
		document.lsrchform.domain.value=forum_domain;
		if(searchType=="DG"){
			document.lsrchform.searchlist.selectedIndex = 1;
			document.getElementById("searchbar-advancedLink").style.display="";
		}else if(searchType=="BLOG"){
			document.getElementById("searchbar-advancedLink").style.display="none";
			document.lsrchform.searchlist.selectedIndex = 2;
		}
	} else {
		document.lsrchform.action = "http://"+forum_domain+"/search.jspa";
		document.getElementById('searchhref').href = "http://"+forum_domain+"/advanced-search!default.jspa";
		document.lsrchform.searchlist.selectedIndex = 1;
	}
}

function delComment(comment_id,message) {
	if (window.confirm(message)) {
		window.location.href="del_comment.jspa?comment_id="+comment_id;
	}
}

function apprComment(comment_id,entry_id,message) {
	if (window.confirm(message)) {
		window.location.href="approve_comment.jspa?comment_id="+comment_id+"&entry_id="+entry_id;
	}
}

function delEntry(entry_id,message) {
	if (window.confirm(message)) {
		window.location.href="del_entry.jspa?entry_id="+entry_id;
	}
}
function doAction(message){
	var emailAddrEl = document.nonRegisterSubsEnterForm.emailAddr;
	var reg = /^\s*([A-Za-z0-9_-]+(\.\w+)*@(\w+\.)+\w{2,3})\s*$/;
	if(emailAddrEl.value.length > 0 && reg.test(emailAddrEl.value)){
		document.nonRegisterSubsEnterForm.submit();
		return true;
	}else{
		alert(message);
		emailAddrEl.focus();
		return false;
	}
}
function doSearch(message){
	var keyword = document.searchbar_form.keyword;
	if(keyword.value.length > 0 &&keyword.value.length > 3 ){
		document.searchbar_form.submit();
		return true;
	}else{
		alert(message);
		keyword.focus();
		return false;
	}
}
function canceldefault(message){
  var emailAddrEl = document.getElementsByName("emailAddr")[0];
  var temp = emailAddrEl.value;
  var defaultV = message;
  if(temp == defaultV){
	   emailAddrEl.value="";
	   emailAddrEl.style.color = "";
  }
  return true;
}
function checkthisPost(frm,message){
	if(frm.body01.value==""){
		alert(message);
		return false;
	}
}
 function goLogin(login_url){
 var a = window.location.href;
 a = encodeURIComponent(a);
 window.location=login_url+"?fromWhere="+a;
}

function doThreadSubmit(val) {
	document.threadflatform.approve.value = val;
	document.threadflatform.submit();
}

function checkPostForm(frm,subjectnullMsg,bodynullMsg) {
	if(frm.subject.value == ""){
		alert(subjectnullMsg);
		return false;
	}
	if(frm.body.value == ""){
		alert(bodynullMsg);
		return false;
	}
}

function jumptoPage( pagesize, pagecnt, url, suffix){
  	var pageno = document.getElementById('pageno').value;
    if(pageno=="0"||pageno==""||pageno < 0)
    	pageno = "1";
    else{
		if(pageno > pagecnt)
			pageno = pagecnt;
 	}
 	var start = (pageno-1) * pagesize;
    url = url + start + suffix;

	document.location.href=url;
}

function gotoPage( pagesize, pagecnt, url, suffix){
  	var pageno = document.getElementById('pageno').value;
    if(pageno=="0"||pageno==""||pageno < 0)
    	pageno = "1";
    else{
		if(pageno > pagecnt)
			pageno = pagecnt;
 	}
 	var start = (pageno-1) * pagesize;
    url = url + start + suffix;

	document.location.href=url;
}

function updatePage(xmlHttp)
{
	if (xmlHttp.readyState == 4)
	{
  		if (xmlHttp.status == 200)
  		{
  			var xmlobj = xmlHttp.responseXML;
  			var status = xmlobj.getElementsByTagName("result")[0].getElementsByTagName("status")[0].firstChild.data;
			var objectType= xmlobj.getElementsByTagName("result")[0].getElementsByTagName("objectType")[0].firstChild.data;
			var objectId = xmlobj.getElementsByTagName("result")[0].getElementsByTagName("objectId")[0].firstChild.data;
			var optionCount = xmlobj.getElementsByTagName("result")[0].getElementsByTagName("count")[0].getElementsByTagName("optionCount")[0].firstChild.data;
			var totalCount = xmlobj.getElementsByTagName("result")[0].getElementsByTagName("count")[0].getElementsByTagName("totalCount")[0].firstChild.data;
			var voteTotalCount = xmlobj.getElementsByTagName("result")[0].getElementsByTagName("count")[0].getElementsByTagName("voteTotalCount")[0].firstChild.data;
			var pollId= xmlobj.getElementsByTagName("result")[0].getElementsByTagName("pollId")[0].firstChild.data;

			if(status == "alreadyVoted")
			{
				alert(alreadyVotedMsg);
				return;
			}
			else if(status =="succVoted")
			{
				alert(succVotedMsg);
			}
			else if(status=="postOwner")
			{
				alert(postOwnerMsg);
				return;
			}
			else if(status=="blogOwner")
			{
				alert(blogOwnerMsg);
				return;
			}
			else
			{
				alert(elseMsg);
				return;
			}
			if(pollId==arenaPollId){
			  window.self.location.reload();
			}else if(objectType==pollTypePOST){

				for(var i=0;i<optionCount;i++)
				{
					var count = xmlobj.getElementsByTagName("result")[0].getElementsByTagName("count")[0].getElementsByTagName("voteCount"+i)[0].firstChild.data;
					document.getElementById(objectId+"_"+i).innerHTML = "( "+count + " )";
					if(i==0 && count>0){
						document.getElementById(objectId+"_"+i).style.color="red";
					}
				}
			}else if(objectType==objectTypeBlog){
				var count = xmlobj.getElementsByTagName("result")[0].getElementsByTagName("count")[0].getElementsByTagName("voteCount0")[0].firstChild.data;
				document.getElementById("cnt").innerHTML = "( "+count + " )";
			}else if(objectType == topicType){
					for(var i =0 ;i<optionCount;i++){
						var voteCount= xmlobj.getElementsByTagName("result")[0].getElementsByTagName("count")[0].getElementsByTagName("voteCount"+i)[0].firstChild.data;
							document.getElementById(objectId+"_"+i).innerHTML = voteCount ;
						var percent = (voteCount == 0 ? 0.0 :(voteCount/voteTotalCount)*100.0);

		                        var width=0;
		                        if(voteCount>0)
		                        {
		                        	width=((voteCount/voteTotalCount)*258.0);

		                        }
		               document.getElementById(i+"_per").innerHTML = Math.round(percent)+"%";
					   document.getElementById(i+"_width").width = width;
					   document.getElementById(i+"_num").innerHTML = "( "+voteCount + topicPKNumMsg ;
					}
				}
			}
		}
}

function popularArticleSetTab(i){
    popularArticleSelectTab(i);
  }
	function popularArticleSelectTab(i){
		switch(i){
			case 1:
			document.getElementById("PopularArticleTabCon1").style.display="block";
			document.getElementById("PopularArticleTabCon2").style.display="none";
			break;
			case 2:
			document.getElementById("PopularArticleTabCon1").style.display="none";
			document.getElementById("PopularArticleTabCon2").style.display="block";
			break;
		}
}


function doScript(url) {
    window.location = url;
    return;
}
function sendSubmit(){
		window.open('','newWin','width=500,height=400,left=70,top=130,scrollbars=yes');
		document.fForm.target = "newWin";
		document.fForm.submit();
	}
function gotoPage(pagecnt,query,suffix){
	var pageno = Number(document.getElementById('pageno').value);			
   if(pageno=="0"||pageno==""||pageno < 0){
	pageno = "1";
   }else{
	if(Number(pageno) > Number(pagecnt))
		pageno = pagecnt;
  }
  var url = query+pageno+suffix;	
  document.location.href=url;
}
function gotoPostPage(pagesize,pagecnt,url,query){
	var pageno = Number(document.getElementById('pageno').value);
    if(pageno=="0"||pageno==""||pageno < 0)
	pageno = "1";
    else{
		if(Number(pageno) > Number(pagecnt))
			pageno = pagecnt;
	}
	var start = (pageno-1) * pagesize;
	var url = url.replace(/{start}/,start);
	url = url+"&"+query;
	document.location.href=url;
}	
function checkreply(){
  if(document.form1.content.value.length==0||document.form1.content.value.length>128){
    alert("评论内容不能为空或者大于128个字符！");
	document.form1.content.focus();
	return false;
  }
  if(document.form1.checkCode.value.length==0){
    alert("请输入验证码！");
	document.form1.checkCode.focus();
	return false;
  }
  return true;
}
function checknewsreply(){
  if(document.form1.content.value.length==0||document.form1.content.value.length>512){
    alert("评论内容不能为空或者大于512个字符！");
	document.form1.content.focus();
	return false;
  }
  if(document.form1.checkCode.value.length==0){
    alert("请输入验证码！");
	document.form1.checkCode.focus();
	return false;
  }
  return true;
}
function nopublic(){
  this.location.href="http://www.21eic.com/login.asp";
}
function xstooltip_findPosX(obj) 
	{
	  var curleft = 0;
	  if (obj.offsetParent) 
	  {
		while (obj.offsetParent) 
			{
				curleft += obj.offsetLeft
				obj = obj.offsetParent;
			}
		}
		else if (obj.x)
			curleft += obj.x;
		return curleft;
	}

	function xstooltip_findPosY(obj) 
	{
		var curtop = 0;
		if (obj.offsetParent) 
		{
			while (obj.offsetParent) 
			{
				curtop += obj.offsetTop
				obj = obj.offsetParent;
			}
		}
		else if (obj.y)
			curtop += obj.y;
		return curtop;
	}

	function xstooltip_show(tooltipId, parentId, posX, posY)
	{
		it = document.getElementById(tooltipId);
		
		if ((it.style.top == '' || it.style.top == 0) 
			&& (it.style.left == '' || it.style.left == 0))
		{
			// need to fixate default size (MSIE problem)
			it.style.width = it.offsetWidth + 'px';
			it.style.height = it.offsetHeight + 'px';
			
			img = document.getElementById(parentId); 
		
			// if tooltip is too wide, shift left to be within parent 
			if (posX + it.offsetWidth > img.offsetWidth) posX = img.offsetWidth - it.offsetWidth;
			if (posX < 0 ) posX = 0; 
			
			x = xstooltip_findPosX(img) + posX;
			y = xstooltip_findPosY(img) + posY;
			
			it.style.top = y + 'px';
			it.style.left = x + 'px';
		}
		
		it.style.visibility = 'visible'; 
	}

	function xstooltip_hide(id)
	{
		it = document.getElementById(id); 
		it.style.visibility = 'hidden'; 
	}
