// JavaScript Document
function RegCheck(){
	var CheckMail =/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/;
	if(document.reg.username.value == ''){
		alert('请输入用户名');
		document.reg.username.focus();
		return false;
	}
	if(document.reg.username.value.length< 4 || document.reg.username.value.length>17){
		alert('请输入4-16位字符');
		document.reg.username.focus();
		return false;
	}
	
	if(document.reg.password.value == ''){
		alert('请输入密码');
		document.reg.password.focus();
		return false;
	}
	if(document.reg.password.value.length< 6 || document.reg.password.value.length> 17){
		alert('请输入6-16位字符做为您的密码');
		document.reg.password.focus();
		return false;
	}
	if(document.reg.rpassword.value == ''){
		alert('请输入确认密码');
		document.reg.rpassword.focus();
		return false;
	}
	if(document.reg.rpassword.value != document.reg.password.value){
		alert('两次密码不一样');
		document.reg.rpassword.focus();
		return false;
	}
	if(document.reg.email.value == ''){
		alert('请输入电子邮件地址');
		document.reg.email.focus();
		return false;
	}
	if(!CheckMail.test(document.reg.email.value)){
		alert('请输入正确的电子邮件地址');
		document.reg.email.focus();
		return false;
	}
		return true;
}
function ActCheck(){
	var CheckMail =/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/;
	if(document.reg.username.value == ''){
		alert('请输入用户名');
		document.reg.username.focus();
		return false;
	}
	if(document.reg.username.value.length< 4 || document.reg.username.value.length>17){
		alert('请输入4-16位字符');
		document.reg.username.focus();
		return false;
	}
	if(document.reg.email.value == ''){
		alert('请输入电子邮件地址');
		document.reg.email.focus();
		return false;
	}
	if(!CheckMail.test(document.reg.email.value)){
		alert('请输入正确的电子邮件地址');
		document.reg.email.focus();
		return false;
	}
		return true;
}
function LogCheck(){
	if(document.login.username.value == ''){
		alert('请输入用户名');
		document.login.username.focus();
		return false;
	}
	if(document.login.password.value == ''){
		alert('请输入确认密码');
		document.login.password.focus();
		return false;
	}
		return true;
}
function FogCheck(){
	var CheckMail =/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/;
	if(document.forgot.username.value == ''){
		alert('请输入用户名');
		document.forgot.username.focus();
		return false;
	}
	if(document.forgot.username.value.length< 4 || document.forgot.username.value.length>17){
		alert('请输入4-16位字符');
		document.forgot.username.focus();
		return false;
	}
	if(document.forgot.email.value == ''){
		alert('请输入电子邮件地址');
		document.forgot.email.focus();
		return false;
	}
	if(!CheckMail.test(document.forgot.email.value)){
		alert('请输入正确的电子邮件地址');
		document.forgot.email.focus();
		return false;
	}
		return true;
}
function StaCheck(){
	if(document.status.con.value == ''){
		alert('请输入您的状态！');
		document.status.con.focus();
		return false;
	}
	if(document.status.con.value.length< 10 || document.status.con.value.length>280){
		alert('请输入10-280位字符或者5－140个汉字');
		document.status.con.focus();
		return false;
	}
		return true;
}
function ComCheck(){
	if(document.coms.con.value == ''){
		alert('请输入您留言内容！');
		document.coms.con.focus();
		return false;
	}
	if(document.coms.con.value.length< 10 || document.coms.con.value.length>500){
		alert('请输入10-500位字符或者5－250个汉字');
		document.coms.con.focus();
		return false;
	}
		return true;
}
function BlogCheck(){
	if(document.blog_form.title.value == ''){
		alert('请输入博客标题');
		document.blog_form.title.focus();
		return false;
	}
	if(document.blog_form.abstruct.value == ''){
		alert('请输入博客摘要');
		document.blog_form.abstruct.focus();
		return false;
	}
	if(document.blog_form.content.value == ''){
		alert('请输入博客内容');
		document.blog_form.abstruct.focus();
		return false;
	}
		return true;
}
function addBlogCatCheck(){
	if(document.blogCat.blogCat.value == ''){
		alert('请输入博客类别名称');
		document.blogCat.blogCat.focus();
		return false;
	}
		return true;
}
function SetBCheck(){
	if(document.set_form_b.realName.value == ''){
		alert('请输入您真实姓名！');
		document.set_form_b.realName.focus();
		return false;
	}
	if(document.set_form_b.about.value.length< 10 || document.set_form_b.about.value.length>500){
		alert('请输入10-500位字符或者5－250个汉字');
		document.set_form_b.about.focus();
		return false;
	}
		return true;
}
function SetPCheck(){
	if(document.set_form_p.oldpassword.value == ''){
		alert('请输入您初始密码！');
		document.set_form_p.oldpassword.focus();
		return false;
	}
	if(document.set_form_p.newpassword.value == ''){
		alert('请输入您的新密码！');
		document.set_form_p.newpassword.focus();
		return false;
	}
	if(document.set_form_p.password.value == ''){
		alert('请输入您确认密码！');
		document.set_form_p.password.focus();
		return false;
	}
	if(document.set_form_p.newpassword.value != document.set_form_p.password.value){
		alert('两次密码不一致！');
		document.set_form_p.password.focus();
		return false;
	}
		return true;
}
//上传头像

//允许上传的图片类型
var extensions = 'jpg,jpeg,gif,png';
//保存缩略图的地址.
var saveUrl = '/avatar/save.php';
//保存摄象头白摄图片的地址.
var cameraPostUrl = '/avatar/camera.php';
//头像编辑器flash的地址.
var editorFlaPath = '/avatar/AvatarEditor.swf';
//Download by http://www.codefans.net
function useCamera()
{
	var content = '<embed height="464" width="514" ';
	content +='flashvars="type=camera';
	content +='&postUrl='+cameraPostUrl+'?&radom=1';
	content += '&saveUrl='+saveUrl+'?radom=1" ';
	content +='pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" ';
	content +='allowscriptaccess="always" quality="high" ';
	content +='src="'+editorFlaPath+'"/>';
	document.getElementById('avatar_editor').innerHTML = content;
}
function buildAvatarEditor(pic_id,pic_path,post_type)
{
	var content = '<embed height="464" width="514"'; 
	content+='flashvars="type='+post_type;
	content+='&photoUrl='+pic_path;
	content+='&photoId='+pic_id;
	content+='&postUrl='+cameraPostUrl+'?&radom=1';
	content+='&saveUrl='+saveUrl+'?radom=1"';
	content+=' pluginspage="http://www.macromedia.com/go/getflashplayer"';
	content+=' type="application/x-shockwave-flash"';
	content+=' allowscriptaccess="always" quality="high" src="'+editorFlaPath+'"/>';
	document.getElementById('avatar_editor').innerHTML = content;
}
/**
  * 提供给FLASH的接口 ： 没有摄像头时的回调方法
  */
 function noCamera(){
	 alert("俺是小狗, 俺没有camare ：）");
 }
		
/**
 * 提供给FLASH的接口：编辑头像保存成功后的回调方法
 */
function avatarSaved(){
	alert('保存成功，哈哈');
	//window.location.href = '/profile.do';
}

 /**
  * 提供给FLASH的接口：编辑头像保存失败的回调方法, msg 是失败信息，可以不返回给用户, 仅作调试使用.
  */
 function avatarError(msg){
	 alert("上传失败了呀，哈哈");
 }

 function checkFile()
 {
	 var path = document.getElementById('Filedata').value;
	 var ext = getExt(path);
	 var re = new RegExp("(^|\\s|,)" + ext + "($|\\s|,)", "ig");
	  if(extensions != '' && (re.exec(extensions) == null || ext == '')) {
	 alert('对不起，只能上传jpg, gif, png类型的图片');
	 return false;
	 }
	 showLoading();
	 return true;
 }

 function getExt(path) {
	return path.lastIndexOf('.') == -1 ? '' : path.substr(path.lastIndexOf('.') + 1, path.length).toLowerCase();
}
  function	showLoading()
  {
	  document.getElementById('loading_gif').style.visibility = 'visible';
  }
  function hideLoading()
  {
	document.getElementById('loading_gif').style.visibility = 'hidden';
  }
function copy(uid) {
	var clipBoardContent="http://sns.phpfun.net/user.php?id="+uid; 
	//定义变量内容
	window.clipboardData.setData("Text",clipBoardContent); //赋值
	alert("复制链接成功，将此链接通过QQ，msn等发给你的好朋友吧!"); //弹出提示
}
