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 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 checkTableForm(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 doThreadSubmit(val) {
	document.threadflatform.approve.value = val;
	document.threadflatform.submit();
}
function doScript(url) {
    window.location = url;
    return;
}

function goLogin(login_url){
	 var a = window.location.href;
	 a = encodeURIComponent(a);
	 window.location=login_url+"?fromWhere="+a;
}

function setRecommendPost(entry_id,message,title) {
	if(title==null || title==""){
		alert("请输入推荐标题！");
	}else if (window.confirm(message)) {
		window.location.href="recommend!masterRecommend.jspa?messageID="+entry_id+"&recommend=1&recommendTitle="+title;
	}
}

function cancelRecommendPost(entry_id,message) {
	if (window.confirm(message)) {
		window.location.href="recommend!masterRecommend.jspa?messageID="+entry_id+"&recommend=0";
	}
}

function sendSubmit(){
	window.open('','newWin','width=500,height=400,left=70,top=130,scrollbars=yes');
	document.fForm.target = "newWin";
	document.fForm.submit();
}

function trackJumpTo(code){
	var date=new Date();		
	var dateStr = date.getFullYear() + "-" + (date.getMonth()+1) + "-" + date.getDate();
	var trackUrl = '/images/blank.gif?' + code + '&' + dateStr + '&' + new Date().getTime();
	(new Image()).src=trackUrl;
}

function postToWb(webServer){

    var _t = encodeURI(document.title);
    var _url = encodeURIComponent(document.location);
    var _appkey = encodeURI("4d65adac398b435e8e2dc7cbf5a4f742");
    var _pic = encodeURI('');
    var _site = webServer;                   
    var _u = 'http://v.t.qq.com/share/share.php?url='+_url+'&appkey='+_appkey+'&site='+_site+'&pic='+_pic+'&title='+_t;
    window.open( _u,'', 'width=700, height=680, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, location=yes, resizable=no, status=no' );
}

function doSelectAll(isSelected){
	var ls=document.getElementsByName("targetMessageID");
	for(i=0;i<ls.length;i++){
		var temp=ls[i];
		if(temp.type=="checkbox"){
			temp.checked=isSelected;
		}
	}
}
//submit the nonRegisterSubsEnterForm
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;
	}
}
//cancel the nonRegisterSubsEnterForm emailAddr
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;
}

