$(document).ready(function(){
	$("a.community_introduct").click(function(){
		var t = this.title || $(this).text() || this.href;
		pwin("pwin", t,this.href,200,370);
		return false;
	});
	$("a.community_add_friend").click(function(){
		var t = this.title || $(this).text() || this.href;
		pwin("pwin", t,this.href,180,300);
		return false;
	});
	$("#community_add_friend1").click(function(){
		var t = this.title || $(this).text() || this.href;
		pwin("pwin", t,this.href,180,300);
		return false;
	});

	$("a._share_profile").click(function(){
		var t = this.title || $(this).text() || this.href;
		pwin("pwin", t,this.href,300,400);
		return false;
	});

	$("a.add_bookmark").click(function(){
		var t = this.title || $(this).text() || this.href;
		pwin("pwin", t,this.href,180,300);
		return false;
	});
	
	//发送信息给我的好友

	$("a.send_message").click(function(){
		var t = $(this).text() || this.href;
		if(this.title == "0") {
			alert(travel_guide_other_login());
			return false;
		}
		pwin("pwin", t,this.href,250,400);
		return false;
	})

	//删除我的好友
	$("a.delete_friend").click(function() {
		var t = this.href;
		if(confirm(travel_guide_profile_confirm_friend()) == true) {
			$.get(t);
			$(this).parents(".myfriends").remove();
			return false;
		}
		else {
			return false;
		}
	})
	$("#baoxiang").css("display","none");
	$("#friends_user_apply_description_value").keydown(function() { alert("Hello"); });
	
});



function submit_friends_user_apply(f) {
	$.post(f.action,{application: f.application.value,peer:f.peer.value},function(data){$("#friends_user_apply").html(data);pwin_hide();});
	
	$("#new_introduct").html($("#friends_user_apply_description_value").val());
	if($("#new_introduct").html().length < 1) { $("#new_introduct").html(travel_guide_profile_introduce());}
	return false;
}
//提交信息
function submit_friends_send_message() {
	var f= $("#send_message");
	if($("#text_sender").val() == "" || $("#text_message").val() == "") {
		$("#errmsg").html("主题/内容不能为空!");
	}
	else {
		$.post(f.attr("action"),{sender:$("#text_sender").val(),message:$("#text_message").val(),subject:$("#text_subject").val()}, function(data) {deal_friends(data);});
	}
	return false;
}

function deal_friends(data) {
	pwin_hide();
	alter_message("alter","提示信息","发送成功!",300,50);
	setTimeout("alter_message_hide();",2000);
}

function submit_share_profile(f) {
	var v = new Array();
	for(i=0;i<$("#my_share_profile select")[0].length;i++) {
		if ($("#my_share_profile select")[0][i].selected) {
			v[i] = $("#my_share_profile select")[0][i].value;
		}
	}
	$.post(f.action,{share_type:f.share_type.checked,share_profile_email:f.share_profile_email.value,share_content:f.share_content.value,share_msg:v.join(",")},
	function (data) {$("#my_share_profile").html(data);setTimeout("pwin_hide();",2000);});
	return false;
}

function share_profile_checkbox(checked) {

	if (checked) {
		$("#share_profile_email").hide();
		$("#share_profile_msg").show();
	} else {
		$("#share_profile_email").show();
		$("#share_profile_msg").hide();
	}
}

function Check_textarea_community(text_area){
  var string = text_area.value.toString();
  if(string.length > 5000) {
	text_area.value = text_area.value.substring(0, 5000);
  }
}

function hidden_div() {
	pwin_hide();
}

function addcomments(url){
	pwin("pwin", travel_guide_profile_comment(),url,400,600);
}
function check_comment(obj) {
	if(obj.subject.value != "" && obj.comment.value != ""){
	$.ajax({
		type: "POST",
		data: "uid="+obj.uid.value+"&uname="+obj.uname.value+"&nid="+obj.nid.value+"&subject="+obj.subject.value+"&comment="+obj.comment.value,
		url: "/community/addcomments",
		success: function(msg){
		  pwin_hide();
		  $("#showcomments").html(msg);
		}
	});
	}
	else{
		$("#pwin_content").html(travel_guide_profile_title() + $("#pwin_content").html());
	}
	return false;
}
function click2bookmark(urls,nid){
  $.ajax({
	  type: "GET",
	  url: urls,
	  success: function(){
        $("#click2bookmark_"+nid).html(travel_guide_profile_bookmark());
	  }
  })
}

function comments(link) {
  return false;
  $.ajax({
	  type: "GET",
	  url: link,
      dataType: "html",
	  success: function(data){
        document.getElementById("showcomments").innerHTML = data;
	  }
  })
}

function check_blank(obj){
  if(obj.comment.value == ""){
    alert(travel_guide_profile_dianping());
	return false;
  }
  if(obj.comment_captcha.value == "") {
	alert("验证码不能为空");
	return false;
  }
  return true;
}