////winopen
function openWin(url, width, height){
	try{
	var left = (screen.width - width) / 2;
	var top = (screen.height - height) / 2;
	var param = 'resizable=0, scrollbars=yes, width=' + width + ', height=' + height + ', left=' + left + ', top=' + top;
	window.open(url, '_blank', param);
	}catch(e){
	;
	}
	return false;
}
function showMenu(aobj){
	openWin(aobj.href, 540, 450);
	return false;
}
function showPicture(aobj){
	openWin(aobj.href, 540, 450);
	return false;
}
function showNews(aobj){
	openWin(aobj.href, 540, 450);
	return false;
}

////write comment
function openCmtForm(a,b){
  var aa=document.getElementById(a);
  var bb=document.getElementById(b)
  aa.style.display="none";
  bb.style.display="block";
}
function closeCmtForm(a,b){
  var aa=document.getElementById(a);
  var bb=document.getElementById(b)
  aa.style.display="block";
  bb.style.display="none";
}

function addComment(form){
  form.Send.disabled = true;
	
  postName=form.postName.value;
  divEditor=window.HTMLEditorBox.document.getElementById("divEditor");
  sourceEditor=window.HTMLEditorBox.document.getElementById("sourceEditor");
  editorBody=window.HTMLEditorBox.HtmlEditor.document.body;
  postContent=(divEditor.style.display=="none" ? sourceEditor.value : editorBody.innerHTML);
  if (postName==null||postName==''){
    alert("Please type your name");
	form.postName.focus();
    form.Send.disabled = false;
    return false;
  }
  if(editorBody.innerHTML=='<DIV></DIV>' || editorBody.innerHTML=='<DIV> </DIV>') {
	alert('Please type comment content');
    form.Send.disabled = false;
	return false;
  }

  myurl="AddComment.asp?action=add&postName="+postName+"&postContent="+postContent;
  retCode=openUrl(myurl);
  switch(retCode){
  case "-2":
    alert('error');break;
  case "1":
    alert('ok');
	window.location.reload();
	break;
  case "0":
    alert('no ok');
  }
  return;
}

function openUrl(url){
  var objxml=new ActiveXObject("Microsoft.XMLHttp")
  objxml.open("GET",url,false);
  objxml.send();
  retInfo=objxml.responseText;
  if (objxml.status=="200"){
  return retInfo;
  }
  else{
  return "-2";
  }
}
