//验证值是否有效
function fValue(obj){
	if(obj.value == ""){
		try{
			obj.focus();
		}catch(e){}
		return false;
	}else{
		return true;
	}
}
//验证email地址
function fEmail(obj){
	var pattern = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/;
	if(obj.value != "" && !(pattern.exec(obj.value))){
		obj.focus();
		return false;
	}else{
		return true;
	}
}
//验证是否是非负整数
function fNum(obj){
	var pattern = /^\d+$/;
	if(obj.value != "" && !(pattern.exec(obj.value))){
		obj.focus();
		return false;
	}else{
		return true;
	}
}
//验证url地址
function fUrl(obj){
	var pattern = /((http|ftp):\/\/)(((([\d]+\.)+){3}[\d]+(\/[\w.\/]+)?)|([a-z]\w*((\.\w+)+){2,})([\/][\w.~]*)*)/;
	if(obj.value != "" && !(pattern.exec(obj.value))){
		obj.focus();	
		return false;
	}else{
		return true;
	}
}

function fBbs(oForm){
	if (!fValue(oForm["name"])){
		alert("请输入名称");
		return false;
	}
	if (!fValue(oForm.content)){
		alert("请输入内容");
		return false;
	}
	return true;
}

function fProject(oForm,goldNeed){
	if (!fValue(oForm["gold"])){
		alert("请输入金币数");
		return false;
	}
	if(!fNum(oForm.gold)){
		alert("请正确输入金币数");
		return false;
	}
	if(!(oForm.gold.value > 0)){
		alert("请正确输入金币数");
		return false;
	}
	if(oForm.gold.value < goldNeed){
		alert("金币数小于活动必须金币数 "+goldNeed+" 金币");
		return false;
	}
	return true;
}

function fToggle(){
	_toggle(document.getElementById("detailDiv"));
	_toggle(document.getElementById("previewDiv"));
	function _toggle(obj){
		obj.style.display = obj.style.display=="none" ? "" : "none";
	}	
}