var ajax=new AJAXRequest();
function $(id) {
	return document.getElementById(id);
}
function addquote(obj,strAuthor){
	var text = $(obj).innerHTML;
	text = text.replace(/alt\=(\"|)([^\"\s]*)(\"|)/g,"> $2 <");
	text = text.replace(/\<[^\<\>]+\>/g,"\n");
	text = text.replace(/ +/g," ");
	text = text.replace(/\n+/g,"\n");
	text = text.replace(/^\n*/gm,"");
	text = text.replace(/^\s*/gm,"");
	text = text.replace(/\n*$/gm,"");
	text = text.replace(/\s*$/gm,"");
	text = text.replace(/&lt;/g,"<");
	text = text.replace(/&gt;/g,">");
	text = text.replace(/&nbsp;&nbsp;/g,"  ");
	text = text.replace(/&amp;/g,"&");
	$("word").value += "[quote="+strAuthor+"]"+text+"[/quote]";
	$("word").focus();
}


function login_user(){//会员登陆
        var myreg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
	    if(!myreg.test(getvalue("email"))){
			showbox("请正确输入Email!",0);
			document.getElementById("but_ok").innerHTML = "<input name='' type='button' class='show_ok' onclick='return hidden_box()' id='show_ok'/>";
			hidden_can();
			return false;
		}
		if(!getvalue("password")){
			showbox("请输入密码!",0);
			document.getElementById("but_ok").innerHTML = "<input name='' type='button' class='show_ok' onclick='return hidden_box()' id='show_ok'/>";
			hidden_can();
			return false;
		}

		//开始login
		var ajax=new AJAXRequest();
		ajax.get(
              "/include/doprofile.php?method=login&value="+getvalue("password")+"&name="+getvalue("email"),
               function(obj) {
				   if(obj.responseText == 1){//成功
				   check_login("login_user");
				   }
				   showbox(obj.responseText,0);
			   });
		document.getElementById("but_ok").innerHTML = "<input name='' type='button' class='show_ok' onclick='return hidden_box()' id='show_ok'/>";
		hidden_can();

}

function login_user_top(){//top会员登陆
        var myreg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
	    if(!myreg.test(getvalue("reg_email"))){
			showbox("请正确输入Email!",0);
			document.getElementById("but_ok").innerHTML = "<input name='' type='button' class='show_ok' onclick='return hidden_box()' id='show_ok'/>";
			hidden_can();
			return false;
		}
		if(!getvalue("reg_password")){
			showbox("请输入密码!",0);
			document.getElementById("but_ok").innerHTML = "<input name='' type='button' class='show_ok' onclick='return hidden_box()' id='show_ok'/>";
			hidden_can();
			return false;
		}


		//开始login
		//var ajax=new AJAXRequest();
		//ajax.get(
             // "/ucenter/doprofile.php?method=login&value="+getvalue("reg_password")+"&name="+getvalue("reg_email"),
              // function(obj) {
				  // if(obj.responseText == 1){//成功
				   //check_toplogin("login_w");
				  // }else{
                    //  showbox(obj.responseText,0);
                    //  document.getElementById("but_ok").innerHTML = "<input name='' type='button' class='show_ok' onclick='return hidden_box()' id='show_ok'/>";
		//hidden_can();
                   //}

			   //});


}

function check_login(object){
	 //开始检查用户是否登陆
		var ajax=new AJAXRequest();
		ajax.get(
              "/include/doprofile.php?method=checklogin&value",
               function(obj) {
				   
				   document.getElementById(object).innerHTML =obj.responseText;
			   });
}

//9yoho 顶部登录
function check_toplogin(object){
	 //开始检查用户是否登陆
		var ajax=new AJAXRequest();
		ajax.get(
              "/include/doprofile.php?method=checktoplogin&value",
               function(obj) {
				   //alert(obj.responseText);
				   document.getElementById(object).innerHTML =obj.responseText;
			   });
}

function show_login(){
 //alert("123123");	
 document.getElementById("login_01").style.display = "block";
  document.getElementById("login_02").style.display = "none";
  document.getElementById("login_03").style.display = "inline-block";
}

//会员退出系统
function login_out(){
	var ajax=new AJAXRequest();
		ajax.get(
              "/include/doprofile.php?method=login_out",
               function(obj) {
				   //alert(obj.responseText);
				   //document.getElementById(object).innerHTML =obj.responseText;
				   ///reloadurl();
				   check_toplogin("login_w");
			   });
}



function sum_stamp(num){//冲值邮票
     element = document.getElementById("stamp_value");
	 element1 = document.getElementById("stamp_count");
	 if(isNaN(num) || (num==0)){
	  //alert("这不是一个数字");
	  element.value = "1";
	  element1.innerHTML = "1";
	  return false;

	 }
	 element.value = num;
	 element1.innerHTML = num;
}

function check_stamp(){//冲值邮票下单
    element = document.getElementById("stamp_value");
	if(parseInt(element.value)<1 || !element.value){
	               showbox("请正确输入购买的约币数量",0);
				   document.getElementById("but_ok").innerHTML = "<input name='' type='button' class='show_ok' onclick='return hidden_box()' id='show_ok'/>";
			       hidden_can();
				   return false;
	}else{//提交表单
	   sent_order();
	}
}

//支付提交
function send_pay(num,paynum){
	var pay_result = false;
	element = document.getElementById("payid");
	element.value = num;
	if(paynum=="0"){
		document.getElementById("bankid").value="0";
	}
	ajax.postf(
              "pl",
               function(obj){
				  if(obj.responseText == 7){

					  showbox("支付方式已关闭，请选择其他的支付方式",0);

				  }else if(obj.responseText == 3){
					  showbox("不存在的支付方式",0);

				  }else if(obj.responseText == 4){
					  showbox("订单不存在",0);

				  }else if(obj.responseText == 5){
					  showbox("产品不存在",0);

				  }else if(obj.responseText == 6){
					  showbox("订单支付成功， 会员信息处理失败",0);

				  }else if(obj.responseText == 10){
					  showbox("支付成功",0);

				  }else{

					  var str = obj.responseText;
				      var reptext=str.split("||");

					  if(reptext[1]=="1"){
						document.pl.action=reptext[0];
						document.pl.submit();
					  }else{
						 showbox(reptext[0],0);
					  }

				  }
				  document.getElementById("but_ok").innerHTML = "<input name='' type='button' class='show_ok' onclick='return hidden_box()' id='show_ok'/>";
				  hidden_can();
				  return false;

               },
              "do.php",
              "POST" );

}

function pay_bank(num){
  document.getElementById("bankid").value=num;
}

//vip提交购买
function sent_vip(num){
  element = document.getElementById("shopid");
  element.value = num;
  sent_order();
}
function sent_order(){//订单提交
   ajax.postf(
              "pl",
               function(obj){
				    if(obj.responseText == 1){//下单成功
					 window.location.href="/pay/index.php";
				  }else{
					 showbox("订单生成失败",0);
					 document.getElementById("but_ok").innerHTML = "<input name='' type='button' class='show_ok' onclick='return hidden_box()' id='show_ok'/>";
					 hidden_can();
				  }
               },
              "/include/doprofile.php",
              "POST" );

}



//发送礼物
function gift_uid(userid){
	if(userid){
		document.getElementById("userid").value = userid;
	}

}

function sent_gifts1(){	 
		ajax.get(
              "/include/doprofile.php?method=countcart",
               function(obj) {
				   var str=obj.responseText;
				   var reptext=str.split("||");
				   if(reptext[1] == "1"){
					  showbox(reptext[0],0);
				      document.getElementById("but_ok").innerHTML = "<input name='' type='button' class='show_ok' onclick='return sent_gifts()' id='show_ok'/>";
			          //hidden_can();
				   }else{
					  showbox(reptext[0],0);
					  document.getElementById("but_ok").innerHTML = "<input name='' type='button' class='show_ok' onclick='return reloadurl()' id='show_ok'/>";
			      hidden_can();
				   }
			   });
}

function sent_gifts(){
	 element = document.getElementById("userid").value;
	  if(element.search("^-?\\d+$")!=0){
		showbox("请正确输入会员编号",0);
		document.getElementById("but_ok").innerHTML = "<input name='' type='button' class='show_ok' onclick='return hidden_box()' id='show_ok'/>";
		hidden_can();
        return false;
       }
	//showbox("操作进行中...",0);
	document.getElementById("but_ok").innerHTML = "<input name='' type='button' class='show_ok' onclick='return hidden_box()' id='show_ok'/>";
	hidden_can();
  	ajax.postf(
              "pl",
               function(obj){
				   var str = obj.responseText;
				   var reptext=str.split("|||");
				   if(reptext[0] == "1"){
					  showbox(reptext[1],0);
				      document.getElementById("but_ok").innerHTML = "<input name='' type='button' class='show_ok' onclick='window.location.href=\"account.php\"' id='show_ok'/>";
			          hidden_can();
				   }else{
					  showbox(reptext[1],0);
					  document.getElementById("but_ok").innerHTML = "<input name='' type='button' class='show_ok' onclick='return reloadurl()' id='show_ok'/>";
			      hidden_can();
				   }
				   
				   
                   //showbox(obj.responseText,0);
				   //document.getElementById("but_ok").innerHTML = "<input name='' type='button' class='show_ok' onclick='window.location.href=\"account.php\"' id='show_ok'/>";
			      // hidden_can();

				   },
              "/include/doprofile.php",
              "POST" );
}
//发送给指定会员
function sent_user_gifts(value){

	ajax.get(
              "/include/doprofile.php?method=sent_user&value="+value,
               function(obj) {
				   window.location.href="/newucenter/virtualmall.php";
			   });
}


//邮票购物车操作

function cart_option(value,num){
	element = document.getElementById("shop_"+value);
	ajax.get(
              "/include/doprofile.php?method=addcart&value="+value+"&num="+num,
               function(obj) {
				   if(obj.responseText == 0){//删除产品

					   element.className = "";
					}else if(obj.responseText == 1){//增加产品
						element.className = "onon";
				   }
			   });

}

//添加好友
function addfriend(userid){
	ajax.get(
              "/include/doprofile.php?method=addfriend&value="+userid,
               function(obj) {
				   var str = obj.responseText;
				   var reptext=str.split("|||");
				   if(reptext[0] == "0"){
					  showbox(reptext[1],0);
				      document.getElementById("but_ok").innerHTML = "<input name='' type='button' class='show_ok' onclick='window.location.href=\"/member/login.php\"' id='show_ok'/>";
			          hidden_can();
				   }else{
					  showbox(reptext[1],0);
					  document.getElementById("but_ok").innerHTML = "<input name='' type='button' class='show_ok' onclick='return hidden_box()' id='show_ok'/>";
			      hidden_can();
				   }
			   });

}

//打个招呼开始
function sent_chatzh(userid){

	var ajax=new AJAXRequest();

	ajax.get(
              "/dochat.php?method=sent_chat",
               function(obj) {
				     showbox(obj.responseText,0);
					 document.getElementById("but_ok").innerHTML = "<input name='' type='button' class='show_ok' onclick='return save_chat_zh("+userid+")' id='show_ok'/>";
					 hidden_can();

		});
}
 
function sent_user_link(userid){//加为联系人
	ajax.get(
              "/include/doprofile.php?method=userlink&value="+userid,
               function(obj) {
				   showbox(obj.responseText,0);
			  document.getElementById("but_ok").innerHTML = "<input name='' type='button' class='show_ok' onclick='return reloadurl()' id='show_ok'/>";
			 // hidden_ok();
			  hidden_can();
			   });
}

function make_chat(num){
  document.getElementById("yoho_chat").value = num;
}

function save_chat_zh(userid){
  var ajax=new AJAXRequest();
  var chat =document.getElementById("yoho_chat").value;
  ajax.get(
              "/dochat.php?method=save_zh&chatid="+chat+"&userid="+userid,
               function(obj) {
                     
					 var result = obj.responseText;
					 //alert(result);
					 if(result == "2"){
					   alert("注册会员才可以跟TA打招呼哦，赶快登录或注册个帐号吧。");
					   window.location.href="/member/login.php";
					   return false;
					 }else if(result == "0"){
					   alert("发送失败");
					   return false;
					}else if(result == "3"){
						alert("发送失败请选择发送的内容");
					   return false;
					}else{
					    //alert("发送成功");
						showbox(result,0);
						//hidden_box();
					    return false;
					}

		});
}

//随机更换招呼对象
function rand_chat(){
  document.getElementById("chat_rand").innerHTML="<img src='/images/lightbox-ico-loading.gif' class='load'>";
  var ajax=new AJAXRequest();
	ajax.get(
              "/dochat.php?method=rand_chat",
               function(obj) {
				document.getElementById("chat_rand").innerHTML= obj.responseText;   

		});
  
}

//打个招呼结束



//设置默认读白开始
function sent_nxdb(){
	var ajax=new AJAXRequest();
	ajax.get(
              "/dochat.php?method=sent_nxdb1",
               function(obj) {
				     document.getElementById("showbox").className = "shownxdb";
				     showbox(obj.responseText,0);
					 document.getElementById("but_ok").innerHTML = "<input name='' type='button' class='show_ok' onclick='return hidden_box()' id='show_ok'/>";
					 hidden_can();

		});
}

function make_nxdb_chat(num){
  document.getElementById("about_me").value = num;
 hidden_box();
}
//设置默认读白结束

//答谢好友开始
function sent_dxhy(userid){
	var ajax=new AJAXRequest();
	ajax.get(
              "/include/doprofile.php?method=sent_dxhy&value="+userid,
               function(obj) {
				     showbox(obj.responseText,0);
					document.getElementById("but_ok").innerHTML = "<input name='' type='button'  class='show_ok' onclick='return hidden_box()' id='show_ok'/>";
					 hidden_can();

		 });
}


//答谢好友结束


//查看信件
function readmess(newsid,status){
	element = document.getElementById("readmess");
	ajax.get(
              "/include/doprofile.php?method=readmess&value="+newsid+"&status="+status,
               function(obj) {
				  if(obj.responseText == 1){//你当前的邮票数量不够请购买邮票
				     showbox("你当前的邮票数量不够请购买邮票后阅读",0);
					 document.getElementById("but_ok").innerHTML = "<input name='' type='button' class='show_ok' onclick='return hidden_box()' id='show_ok'/>";
					 hidden_can();
				  }else{
					  window.location.href="mail_read.php?newsid="+newsid+"&status="+status;
					 //element.innerHTML = obj.responseText;
				  }

		});
}

//删除好友,拒绝关系 设置
function delfriend(value){
	document.pl_friend.method.value = value;

	ajax.postf(
              "pl_friend",
               function(obj){
				   showbox(obj.responseText,0);
			       document.getElementById("but_ok").innerHTML = "<input name='' type='button' class='show_ok' onclick='return reloadurl()' id='show_ok'/>";
			       hidden_can();
				   },
              "/include/doprofile.php?nocahe='+new Date().getTime()+'",
              "POST" );
}

function send(){//内心独白
   if(document.getElementById("about_me").value == ""){
	   showbox("请输入内心独白",0);
	   hidden_ok();
	   return false;
   }else{

	      ajax.postf(
              "pl",
               function(obj2){
				   showbox(obj2.responseText,0);
				   document.getElementById("but_ok").innerHTML = "<input name='' type='button' class='show_ok' onclick='return hidden_box()' id='show_ok'/>";
			       hidden_can();
				   },
              "/include/doprofile.php",
              "POST" );

	}
}

/*20100714 vip*/
function post_error(){//vip报错
	document.pl.method.value = "messagepost";
	var ajax=new AJAXRequest();
	      ajax.postf(
              "pl",
               function(obj2){
				   showbox(obj2.responseText,0);
				   document.getElementById("show_but").style.display = "block";
				   if(obj2.responseText == "发送成功!"){
					       document.getElementById("but_ok").innerHTML = "<input name='' type='button' class='show_ok' onclick='return reloadurl()' id='show_ok'/>";
					   }else{
						   document.getElementById("but_ok").innerHTML = "<input name='' type='button' class='show_ok' onclick='return url_turn(\"account.php\")' id='show_ok'/>";
					}
					  
			       hidden_can();
				   },
              "/include/doprofile.php",
              "POST" );
}
function check_mess_post(newsid,status){//查看信件
	var ajax=new AJAXRequest();
    ajax.get(
              "/include/doprofile.php?method=mess_post&status="+status+"&newsid="+newsid,
               function(obj){
				      var str = obj.responseText;
					  //alert(str);
				      var reptext=str.split("||");
					  if(reptext[1]=="1"){
						  //alert(reptext[0]);
						document.pl_friend.action=reptext[0];
						document.pl_friend.submit();
					  }else{
						showbox(reptext[0],0);
						document.getElementById("but_ok").innerHTML = "<input name='' type='button' class='show_ok' onclick='return hidden_box()' id='show_ok'/>";
				        hidden_can();  
					  }
				 
				 
		});
}

function post_xiaofei(newsid,status){//开始消费看信
   	var ajax=new AJAXRequest();
    ajax.get(
              "/include/doprofile.php?method=mess_xiaofei&status="+status+"&newsid="+newsid,
               function(obj){
				      var str = obj.responseText;
					  //alert(str);
				      var reptext=str.split("||");
					  if(reptext[1]=="1"){
						  //alert(reptext[0]);
						document.pl_friend.action=reptext[0];
						document.pl_friend.submit();
					  }else{
						showbox(reptext[0],0);
						document.getElementById("but_ok").innerHTML = "<input name='' type='button' class='show_ok' onclick='return hidden_box()' id='show_ok'/>";
				        hidden_can();  
					  }
				 
				 
		});
}

//通用POST单个提示提交刷新

function send_post(object,msg,typeid,divobject){//单个表单提交 控件名称   提示信息   状态0刷新  1不刷新 2不显示
var ajax=new AJAXRequest();
   if(document.getElementById(object+divobject).value == ""){
	   showbox(msg+"不能为空",0);
	   hidden_ok();
	   return false;
   }else{
         if(object == "diary_content"){
	     var str = document.getElementById(object+divobject).value;
			 if(parseInt(str.length)>150){
			 showbox("心情字数不能大于150字符",0);
			 hidden_ok();
			 return false;
			 }
	     }
	      ajax.postf(
              "pl"+divobject,
               function(obj2){
				   showbox(obj2.responseText,0);
				   if(typeid == "0"){
					  document.getElementById("but_ok").innerHTML = "<input name='' type='button' class='show_ok' onclick='return reloadurl()' id='show_ok'/>";
				   }else if(typeid == "2"){
					   document.getElementById("show_but").style.display = "none";
					  }
				   else{
					  document.getElementById("but_ok").innerHTML = "<input name='' type='button' class='show_ok' onclick='return hidden_box()' id='show_ok'/>";
					}

			       hidden_can();
				   },
              "/include/doprofile.php",
              "POST" );

	}
}


//情感学院评论、回复
function sent_ask(newsid){
ajax.get(
              "/include/doprofile.php?method=showask&value="+newsid,
               function(obj) {
					 document.getElementById("ask_"+newsid).innerHTML = obj.responseText;


		});
}

function Del_diary(blogid,num){
	showbox("是否删除？",0);
	document.getElementById("but_ok").innerHTML = "<input name='' type='button' class='show_ok' onclick='return send_deldiary("+blogid+","+num+")' id='show_ok'/>";

}

//会员中心删除心情
function send_deldiary(blogid,num){
	var url;
	if(num==1){
		url="/include/doprofile.php?method=del_diary&blogid="+blogid;
	}
	if(num==2){
		url="/include/doprofile.php?method=del_diary&commentid="+blogid;
	}
ajax.get(
		 	url,
			function(obj) {
				if(obj.responseText == 1){
				     showbox("删除成功",0);
					 //hidden_box();
					 document.getElementById("but_ok").innerHTML = "<input name='' type='button' class='show_ok' onclick='return reloadurl()' id='show_ok'/>";
					 hidden_can();
				  }else{
					 showbox("删除失败",0);
					 document.getElementById("but_ok").innerHTML = "<input name='' type='button' class='show_ok' onclick='return hidden_box()' id='show_ok'/>";
					 hidden_can();
				  }

		});
}

//日志回复提交
function send_blog(object){//控件名称
   element4 = document.getElementById("rep_"+object);
   element5 = document.getElementById("pl_"+object);
   ajax.postf(
               object,
               function(obj2){
				   element4.innerHTML = element4.innerHTML+obj2.responseText;
				   element5.value='';

				   //showbox(obj2.responseText,0);hidden_ok();
				   reloadurl();
				   },
              "/include/doprofile.php",
              "POST" );
}

//设置形象照片
function send_xxz(){
	var photopath = document.getElementById("photopath").value;
	//document.getElementById("ch_sumpic").value = photopath;
	if(!photopath){
		showbox("请选择要上传的图片",0)
		 document.getElementById("but_ok").innerHTML = "<input name='' type='button' class='show_ok' onclick='return hidden_box()' id='show_ok'/>";
		 hidden_can();
		return false;
	}else if(!checkPhoto(photopath)){
		showbox("文件格式错误",0)
		document.getElementById("but_ok").innerHTML = "<input name='' type='button' class='show_ok' onclick='return hidden_box()' id='show_ok'/>";
		hidden_can();
		return false;

	}else{//开始上传
	    showbox("文件开始上传...",0);
		document.pl.submit();//适合附件上传

	}
}


function file_rel(){
	document.getElementById("but_ok").innerHTML = "<input name='' type='button' class='show_ok' onclick='return reloadurl()' id='show_ok'/>";
	hidden_can();
}

function file_url(url){
	document.getElementById("but_ok").innerHTML = "<input name='' type='button' class='show_ok' onclick='return url_turn(\""+url+"\");' id='show_ok'/>";
	hidden_can();
}

function url_turn(url){
	window.location.href=url;
}

function file_ok(){
	document.getElementById("but_ok").innerHTML = "<input name='' type='button' class='show_ok' onclick='return hidden_box()' id='show_ok'/>";
	hidden_can();
}

//显示会员个人展示页相关设置
function show_member_photo(userid,typeid,object){
	ajax.get(
              "/include/do_member.php?method=domember&userid="+userid+"&typeid="+typeid,
               function(obj) {
				  document.getElementById(object).innerHTML = obj.responseText;
		});
}

//批量上传
function send_batch(){
	var photo_url;
	var file_alt = false;
	for(var i=1;i<4;i++){
	   photo_url = document.getElementById("photo_"+i).value;
	   if(photo_url!=""){
		   if(!checkPhoto(photo_url)){
			showbox("文件"+i+"格式错误",0)
			document.getElementById("but_ok").innerHTML = "<input name='' type='button' class='show_ok' onclick='return hidden_box()' id='show_ok'/>";
			hidden_can();
			return false;
		   }else{
		    file_alt = true;
		   }
	   }
	}
	if(!file_alt){
		showbox("请选择要上传的图片",0);
		document.getElementById("but_ok").innerHTML = "<input name='' type='button' class='show_ok' onclick='return hidden_box()' id='show_ok'/>";
			hidden_can();
		return false;
	}
	showbox("文件开始上传...",0);
	document.pl.submit();//适合附件上

}


//输出视频认证页面图片
function sent_video(){
  showbox("数据处理中...",0);
     ajax.postf(
               'video',
               function(obj){
				   var str = obj.responseText;
				   var reptext=str.split("|||");
				  if(reptext[0] == "1"){
				      showbox(reptext[1],0);
			          document.getElementById("but_ok").innerHTML = "<input name='' type='button' class='show_ok' onclick='return reloadurl()' id='show_ok'/>";
					  hidden_can();
				   }else{

				   showbox(reptext[1],0);
			       document.getElementById("but_ok").innerHTML = "<input name='' type='button' class='show_ok' onclick='return hidden_box()' id='show_ok'/>";
				   hidden_can();
				  }

				},
              "/include/doprofile.php",
              "POST" );
}

//图片显示模式
function send_mx(msg,value){
	showbox(msg,0);
	document.getElementById("but_ok").innerHTML = "<input name='' type='button' class='show_ok' onclick='return send_mxsave("+value+")' id='show_ok'/>";
	$('.show_can').show();
}
function send_mxsave(value){//发送信息

	ajax.get(
              "/include/doprofile.php?method=photomx&value="+value,
               function(obj) {
				  if(obj.responseText == 1){//你当前的邮票数量不够请购买邮票后
				     //showbox("设置成功",0);
					 hidden_box();
					 document.getElementById("but_ok").innerHTML = "<input name='' type='button' class='show_ok' onclick='return hidden_box()' id='show_ok'/>";
					 //hidden_can();
				  }else{
					 showbox("设置失败",0);
					 document.getElementById("but_ok").innerHTML = "<input name='' type='button' class='show_ok' onclick='return reloadurl()' id='show_ok'/>";
					 hidden_can();
				  }

		});

}


//裁减图片
function sent_cut(){
	 showbox("数据处理中...",0);
	 //document.setavatar.submit();//适合附件上传
     ajax.postf(
               'cut',
               function(obj){
				  // if(obj.responseText != 0){
				     showbox("操作成功",0);
			          document.getElementById("but_ok").innerHTML = "<input name='' type='button' class='show_ok' onclick='return reloadurl()' id='show_ok'/>";
					  hidden_can();
				   //}else{

				  // showbox("sorry 操作失败",0);
			      //document.getElementById("but_ok").innerHTML = "<input name='' type='button' class='show_ok' onclick='return hidden_box()' id='show_ok'/>";
				  // hidden_can();
				   //}

				},
              "doprofile.php",
              "POST" );
}

//显示内心独白
function show_about(object,value){
  ajax.get(
		  "/include/doprofile.php?method="+object+"&value="+value,
		   function(obj) {

			  //showbox(obj.responseText,0);
			  document.getElementById(object).innerHTML = obj.responseText;

		   });
}

//会员图片删除
function delphoto_alt(value){
  showbox("您确定要删除此照片吗？确定后此照片将彻底删除，无法找回。",0);
  document.getElementById("but_ok").innerHTML = "<input name='' type='button' class='show_ok' onclick='return delphoto(\""+value+"\")' id='show_ok'/>";
}
function delphoto(value){

  	ajax.get(
		  "/include/doprofile.php?method=delphoto&value="+value,
		   function(obj) {

			  showbox(obj.responseText,0);
			  document.getElementById("but_ok").innerHTML = "<input name='' type='button' class='show_ok' onclick='return reloadurl()' id='show_ok'/>";
			 // hidden_ok();
			  hidden_can();

		   });

}
//连接专家
function chat_vip(userid){
  ajax.get(
		  "/dochat.php?method=vipchat&value="+userid,
		   function(obj) {
			  var str = obj.responseText;
			  var reptext=str.split("|||");
			  if(reptext[0] == 1){//表示为是已经登录会员
			     window.open ('/chat.php?userid='+userid,'_blank');
			  }else{//没有登录会员
				  showbox(obj.responseText,0);
				  document.getElementById("but_ok").innerHTML = "<input name='' type='button' class='show_ok' onclick='return member_login("+userid+")' id='show_ok'/>";
				  hidden_can();
			  }
		   });
}
//login
function member_login(userid){
	var email = document.getElementById("email").value;
	var password = document.getElementById("password").value;
	if(!password){
	  alert("请输入密码");
	  return false;
	}
	ajax.get(
               "/dochat.php?method=checktoplogin&email="+email+"&password="+password,
		   function(obj) {
			  var str = obj.responseText;
			  var reptext=str.split("|||");
			  if(reptext[0] == 1){//表示为是已经登录会员
			      hidden_box();
			      window.open ('/chat.php?userid='+userid,'_blank');
			  }else{//没有登录会员
			      alert(reptext[1]);
			  }
		   });
}


//提问
function chat_ask(){//显示提问框

	//var askhtml = "<form id=\"ask\" name=\"ask\" method=\"post\" action=\"/dochat.php\" target=\"upload_iframe\"><div class=\"chat_ask\"><em>提问标题：</em><label><input name=\"title\" type=\"text\" id=\"title\" value=\"\" /><input name=\"method\" type=\"hidden\" id=\"method\" value=\"save_ask\" /></label><br /><em>详细内容：</em><label><textarea name=\"content\" id=\"content\"></textarea></label><iframe name=\"upload_iframe\" style=\"width: 400px; height: 100px; display: none;\"></iframe></div></form>";
	var askhtml = "<div class=\"s_info\"><form id=\"ask\" name=\"ask\" method=\"post\" action=\"/dochat.php\" target=\"upload_iframe\"><div class=\"form_title\"><span class=\"fl\">提问标题：</span><label><input name=\"title\" type=\"text\" id=\"title\" value=\"\" /><input name=\"method\" type=\"hidden\" id=\"method\" value=\"save_ask\" /></label></div><div class=\"form_center\"><span class=\"fl\">详细内容：</span> <label><textarea name=\"content\" id=\"content\"></textarea></label></div><iframe name=\"upload_iframe\" style=\"width: 400px; height: 100px; display: none;\"></iframe></form></div>";
	showbox(askhtml,0);
	document.getElementById("showbox").className = "tw_db";
	document.getElementById("but_ok").innerHTML = "<input name='' type='button' class='show_ok' onclick='return send_ask()' id='show_ok'/>";
}

function send_ask(){
	var title = document.getElementById("title").value;
	var content = document.getElementById("content").value;
	if(!title || !content){
	 alert("请输入你要提问的问题或内容");
	 return false;
	}else{
		document.ask.submit();//适合附件上传
	}
}


//改变url地址
function cr_url(url,object){
  document.getElementById(object).href=url;	
}

//诚信认证
function send_certi(object){
	showbox("<img src='/images/ajaxload.gif'>",0);
	var value = document.getElementById(object).value;
	ajax.get(
		  "/include/docertification.php?method="+object+"&value="+value,
		   function(obj) {
			  showbox(obj.responseText,0);
			  if(object=="dophone"){
				 if(obj.responseText=="手机认证成功!"){
				   document.getElementById("but_ok").innerHTML = "<input name='' type='button' class='show_ok' onclick='return reloadurl()' id='show_ok'/>"; 
				 }else{
					document.getElementById("but_ok").innerHTML = "<input name='' type='button' class='show_ok' onclick='return hidden_box()' id='show_ok'/>";  
					 }
				 
			  }else{
				document.getElementById("but_ok").innerHTML = "<input name='' type='button' class='show_ok' onclick='return hidden_box()' id='show_ok'/>"; 
			  }
			  
			 // hidden_ok();
			  hidden_can();

		   });
}
//身份证提交
function sent_uid(object){
	 showbox("<img src='/images/ajaxload.gif'",0);
     ajax.postf(
               object,
               function(obj){
				   showbox(obj.responseText,0);
			       document.getElementById("but_ok").innerHTML = "<input name='' type='button' class='show_ok' onclick='return hidden_box()' id='show_ok'/>";
				   hidden_can();
				},
              "/include/docertification.php",
              "POST" );
}
//注册时邮箱重置
function sent_emailuid(object){
   var email=document.getElementById("new_email").value;

	 showbox("<img src='/include/images/ajaxload.gif'",0);
     ajax.postf(
               object,
               function(obj){
				   showbox(obj.responseText,0);

				   if(obj.responseText == 'Email修改成功'){
						document.getElementById("mail_01").innerHTML = "若您刚才注册填写的邮箱有误，请<a href='register_4.php' >进行修改</a>,<br/>您以后登录邮箱为："+email+"&nbsp;&nbsp;&nbsp;<input type='button' onclick='gourl()' id='mail_2' value='确认邮件'/>";

				   }
			       document.getElementById("but_ok").innerHTML = "<input name='' type='button' class='show_ok' onclick='return hidden_box()' id='show_ok'/>";
				   hidden_can();
				},
              "/include/docertification.php",
              "POST" );
}
function sent_other(object){//其他认证
    var inhtml = "<div id=\"other\"><form enctype=\"multipart/form-data\"  id=\"pl\" name=\"pl\" action=\"doprofile.php\"  method=\"post\" target=\"upload_iframe\"><div><p><input type=\"file\" name=\"photopath\" id=\"photopath\"/><input type=\"button\" class=\"btn\" value=\"上传\" onclick=\"return send_xxz();\"/></p></div><input type=\"hidden\" value=\"xxzphoto\" name=\"method\" id=\"method\"/><input type=\"hidden\" value=\""+object+"\" name=\"doaction\" id=\"doaction\"/></form></div>";
	document.getElementById("file_education").innerHTML = "";
	document.getElementById("file_salary").innerHTML = "";
	document.getElementById("file_house").innerHTML = "";
	document.getElementById("file_marray").innerHTML = "";
	document.getElementById("file_other").innerHTML = "";

	document.getElementById("file_"+object).innerHTML = inhtml;

}


function show_email(){//邮箱修改样式
	document.getElementById("edit_eamil").style.display = "block";
}
function show_nemail(){//注册邮箱修改样式
	document.getElementById("edit_neamil").style.display = "block";
}

//
function reloadurl(){
	window.location.reload();//刷新页面
}



//设置图片显示模式
function sendphoto(){
    var value = document.getElementById("showvalue").value;
	element4 = document.getElementById("txtTip");
	ajax.get(
              "/include/doprofile.php?method=photo&value="+value,
               function(obj) {element4.innerHTML = obj.responseText;
			      hidden_ok();
			   });

}
function sendzyyq(){//择友要求
   if(check_num(getvalue("lookage[0]"),getvalue("lookage[1]"))=="0"){
		  alert("请正确选择年龄范围")
		  return false;
	}

		 //身高检查
if(check_num(getvalue("lookheight[0]"),getvalue("lookheight[1]"))=="0"){
		  alert("请正确选择身高范围")
		  return false;
}

	      ajax.postf(
              "pl",
               function(obj2){
				   showbox(obj2.responseText,0);
			       document.getElementById("but_ok").innerHTML = "<input name='' type='button' class='show_ok' onclick='return hidden_box()' id='show_ok'/>";
				   hidden_can();
				   },
              "/include/doprofile.php",
              "POST" );

}
///////////////////////////长度检测//////////////////////////////////////////////////
function checklength(str,min,max){
	if(String_GetLength(str)>=min&&String_GetLength(str)<=max)
		return true;
	else
		return false;
}
function String_GetLength(str){
               var i,rt=0;
               for(i=0;i<str.length;i++)
               {
                 rt++;
                 if(str.charCodeAt(i)>256)
                 rt++;
               }
               return rt;
}

//计算写信的长度
function sum_mail(object,inner,bigleng){
	var str = document.getElementById(object).value;
	var allnum = parseInt(bigleng)-parseInt(str.length);
	if(allnum<0){
	  alert("超出最大限制");
	  document.getElementById(object).value=str.substr(0, bigleng);
	  document.getElementById(inner).value = 0;
	}else{
	  document.getElementById(inner).value = allnum;
	}

}

//计算择友要求的长度
function sum_zysq(object,inner,bigleng){
	var str = document.getElementById(object).value;
	var allnum = parseInt(str.length);
	if(allnum>bigleng){
	  alert("超出最大限制");
	  document.getElementById(object).value=str.substr(0, bigleng);
	  document.getElementById(inner).value = allnum -1;
	}else{
	  document.getElementById(inner).value = allnum;

	}

}

//弹窗/////////////////////////////////////////////////////////////////////////////
function hidden_ok(){
	$('.show_ok').hide();
}
function hidden_can(){
	$('.show_can').hide();
}
function show_ok(){
	$('.show_ok').show();
}

function showTip(msg){
    $('#txtTip').html(msg);
	//document.getElementById("txtTip").innerHTML = msg;
    w = $(window);
	outH = w.height()/2 +w.scrollTop();
	outW = w.width()/2 +w.scrollLeft();
	t=outH - $("#showbox").height() / 2;
	l=outW - $("#showbox").width() / 2;
	$("#showbox").css('top',t).css('left',l).fadeIn();
}
function showbox(msg,value){
	//document.getElementById("showvalue").value = value;

	showTip(msg);
}
function hidden_box(){
  $('#showbox').hide();
  $('.show_ok').show();
  //clearphoto();
}

////////////////////////图片格式检查/////////////////////////////////////////////////////
function checkPhoto(photoPath){
	var files=/\.bmp$|\.BMP$|\.gif$|\.jpg$|\.png$|\.PNG$|\.jpeg$|\.JPEG$|\.GIF$|\.JPG$\b/;
	if(!files.test(photoPath)){
		return false;
	}
	return true;
}

function checkphototype(photoPath){
	var files=/\.bmp$|\.BMP$|\.gif$|\.jpg$|\.png$|\.PNG$|\.jpeg$|\.JPEG$|\.GIF$|\.JPG$\b/;
	if(!files.test(photoPath)){
		alert("正确");
	}else{
		alert("错误");}
}
//清除图片
function clearphoto(){
	document.getElementById("photopath").value = " ";
}
//收藏
function AddFavorite(sURL,sTitle)
{
    try
    {
        window.external.addFavorite(sURL, sTitle);
    }
    catch (e)
    {
        try
        {
            window.sidebar.addPanel(sTitle, sURL, "");
        }
        catch (e)
        {
            alert("加入收藏失败，请使用Ctrl+D进行添加");
        }
    }
}

//跳转页面


function gourl(){//url是获取的文件地址

window.location.href='register_2.php';

}




