function checkemail(data, allowednull)
{
  var datastr = data;
  var lefttrim = datastr.search(/\S/gi);
  
  if (lefttrim == -1) {
    if (allowednull) {
      return 1;
    } else {
      alert("请输入一个正确的E-mail地址！");
      return -1;
    }
  }
  var myRegExp = /[a-z0-9](([a-z0-9]|[_\-\.][a-z0-9])*)@([a-z0-9]([a-z0-9]|[_\-][a-z0-9])*)((\.[a-z0-9]([a-z0-9]|[_\-][a-z0-9])*)*)/gi;
  var answerind = datastr.search(myRegExp);
  var answerarr = datastr.match(myRegExp);
  
  if (answerind == 0 && answerarr[0].length == datastr.length)
  {
    return 0;
  }
  
  alert("请输入一个正确的E-mail地址！");
  return -1;
}
function form1_onsubmit() {
if(form1.username.value.length<=0)
{window.alert('用户名不能为空\n   请重新输入！')
return false;
}
if(form1.password.value.length<=0)
{
window.alert('密码未输入！')
form1.password.focus();
return false;
}
if(form1.title.value.length<=0)
{window.alert('标题不能为空\n   请重新输入！')
return false;
}
if(form1.content.value.length<=0)
{window.alert('简介不能为空\n   请重新输入！')
return false;
}
return true;
}


function form2_onsubmit() {
if(form2.username.value.length<=0)
{window.alert('用户名不能为空\n   请重新输入！')
form2.username.focus();
return false;
}
if(form2.password.value.length<=0)
{
window.alert('密码未输入！')
form2.password.focus();
return false;
}
if(form2.password.value!=form2.password2.value)
{window.alert('两次输入的密码不同\n    请重新输入！')
return false;
}
return true;
}
function confirmdel(id)
{
var qwords = "Are you sure to delete?"
if (confirm(qwords))
self.location.href = "del.php?id="+id;
}
function confirmdeluser()
{
var qwords = "Are you sure to delete user?"
if (confirm(qwords))
form1.method.value="del";
form1.submit();
}
function confirmmark(id)
{
var qwords = "set as bidding success?"
if (confirm(qwords))
self.location.href = "mark.php?id="+id;
}
function switcheditor(m,n,j) {
	if (document.getElementById(m).style.visibility == "hidden") {

		var isOpera = (navigator.userAgent.indexOf("Opera") > 0) ;

		// Check if the browser is compatible with the Editor:
		//- Internet Explorer 5 or above
		var isCompatible = (!isOpera && navigator.appName == 'Microsoft Internet Explorer') ;
		if (isCompatible) {
			var browserVersion = navigator.appVersion.match(/MSIE (.\..)/)[1] ;
			isCompatible = (browserVersion >= 5) ;
		}

		if (!isCompatible) {
			alert("对不起，只有IE5.0及以上版本的浏览器才能正常使用可视化在线HTML编辑器");
		} else {
			document.getElementById(m).style.visibility = "visible";
			document.getElementById(m).style.display = "block";
			document.getElementById(n).value = TextToHtml(document.getElementById(n).value);
			document.getElementById(n).style.display = "none";
			document.getElementById(m).src = "/fckeditor/fckeditor.html?FieldName=" + n + "&Toolbar=Simple";
			document.getElementById(j).value="PlainText";
			document.getElementById(j).disabled=true;
		}
	} else {
		document.getElementById(m).src = "about:blank";
		document.getElementById(m).style.visibility = "hidden";
		document.getElementById(m).style.display = "none";
		document.getElementById(n).style.display = "block";
		document.getElementById(n).value = HtmlToText(fckiframe.document.getElementById('objContent').DOM.body.innerHTML);
		document.getElementById(j).value="HTMLEdit";
	}
}
function TextToHtml(s) { 
	s = s.replace(/\r\n/g,'<BR>');
	s = s.replace(/\n/g,'<BR>');
	return s;
}
function HtmlToText(s) { 
	s = s.replace(/<BR>/g,'\n');
	return s;
}

function submit_convert(m) {
	if (document.getElementById(m).style.display == "block")
	{
		document.getElementById(m).value = TextToHtml(document.getElementById(m).value);
	}
	return true;
}

function submit_convert2(m) {

	if (document.getElementById(m).value.length > 0)
 {

		document.getElementById(m).value = TextToHtml(document.getElementById(m).value);

	}

	return true;

}