//json2.js
if(!this.JSON){this.JSON={};}
(function(){function f(n){return n<10?'0'+n:n;}
if(typeof Date.prototype.toJSON!=='function'){Date.prototype.toJSON=function(key){return isFinite(this.valueOf())?this.getUTCFullYear()+'-'+
f(this.getUTCMonth()+1)+'-'+
f(this.getUTCDate())+'T'+
f(this.getUTCHours())+':'+
f(this.getUTCMinutes())+':'+
f(this.getUTCSeconds())+'Z':null;};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf();};}
var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==='string'?c:'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);})+'"':'"'+string+'"';}
function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==='object'&&typeof value.toJSON==='function'){value=value.toJSON(key);}
if(typeof rep==='function'){value=rep.call(holder,key,value);}
switch(typeof value){case'string':return quote(value);case'number':return isFinite(value)?String(value):'null';case'boolean':case'null':return String(value);case'object':if(!value){return'null';}
gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==='[object Array]'){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||'null';}
v=partial.length===0?'[]':gap?'[\n'+gap+
partial.join(',\n'+gap)+'\n'+
mind+']':'['+partial.join(',')+']';gap=mind;return v;}
if(rep&&typeof rep==='object'){length=rep.length;for(i=0;i<length;i+=1){k=rep[i];if(typeof k==='string'){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}else{for(k in value){if(Object.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}
v=partial.length===0?'{}':gap?'{\n'+gap+partial.join(',\n'+gap)+'\n'+
mind+'}':'{'+partial.join(',')+'}';gap=mind;return v;}}
if(typeof JSON.stringify!=='function'){JSON.stringify=function(value,replacer,space){var i;gap='';indent='';if(typeof space==='number'){for(i=0;i<space;i+=1){indent+=' ';}}else if(typeof space==='string'){indent=space;}
rep=replacer;if(replacer&&typeof replacer!=='function'&&(typeof replacer!=='object'||typeof replacer.length!=='number')){throw new Error('JSON.stringify');}
return str('',{'':value});};}
if(typeof JSON.parse!=='function'){JSON.parse=function(text,reviver){var j;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==='object'){for(k in value){if(Object.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v;}else{delete value[k];}}}}
return reviver.call(holder,key,value);}
cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return'\\u'+
('0000'+a.charCodeAt(0).toString(16)).slice(-4);});}
if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,'@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']').replace(/(?:^|:|,)(?:\s*\[)+/g,''))){j=eval('('+text+')');return typeof reviver==='function'?walk({'':j},''):j;}
throw new SyntaxError('JSON.parse');};}}());
//end of json2.js
//设置顶层菜单项
function SetCurrentMenuItem(menuid){
	return;
	var obj=document.getElementsByName("menuid");
	if (obj && obj[menuid])
	{
		obj[menuid].className = "current";
	}
}

//设定Cookie值
function SetCookie(name, value,expires)
{
	var expdate = new Date();
	expdate.setTime(expdate.getTime() + ( expires * 1000 ));
	document.cookie = name + "=" + escape (value) + "; expires="+ expdate.toGMTString();
}

//删除Cookie
function DelCookie(name)
{
	var exp = new Date();
	exp.setTime (exp.getTime() - 1);
	var cval = GetCookie (name);
	document.cookie = name + "=" + cval + "; expires="+ exp.toGMTString();
}

//获得Cookie的原始值
function GetCookie(name)
{
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen)
	{
	var j = i + alen;
	if (document.cookie.substring(i, j) == arg)
		return GetCookieVal (j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break;
	}
	return "";
}

//获得Cookie解码后的值
function GetCookieVal(offset)
{
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
		endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}

// succ="succ" 表示成功
function ShowPopUpDiv(succ,title,dispbuf){
	document.getElementById("popupdiv").style.left = ((document.body.scrollWidth-350)/2) + "px";
		var yScroll = ($.browser.safari) ? document.body.scrollTop : document.documentElement.scrollTop;
	var screenheight = document.documentElement.clientHeight;
	document.getElementById("popupdiv").style.top = (yScroll + (screenheight-250)/2)+"px";
	document.getElementById("popuptitlediv").innerHTML = "<h3>" + title + "</h3>";
	
	if ($.browser.msie && $.browser.version < 7)
	{
		var iframe = $("<iframe />");
		iframe.attr("id", "popUpShadow");
		iframe.css("-moz-opacity","0");
		iframe.css("filter","alpha(opacity=0)");
		iframe.css("position","absolute");
		iframe.css("width","376");
		iframe.css("height","300");
		iframe.css("z-index","-1");

		$("#popupdiv").prepend(iframe);
	}

	if (succ=="succ")
	{
		document.getElementById("popupdetaildiv").className = "succeed";
	}
	else{
		document.getElementById("popupdetaildiv").className = "fail";
	}
	document.getElementById("popupdetaildiv").innerHTML="<p>" + dispbuf + "</p>";
	document.getElementById("popupdiv").style.display = "block";
}

//检查 email 格式
function IsEmail(strg){ 
     if(!(strg.indexOf("@")>2 && strg.indexOf(".")>1)) return false; 
     if(strg.indexOf("@",strg.indexOf("@")+1)>0)  return false; 
     var strarray=new Array("@@" , "@." , "..") 
     for(i=0;i<strarray.length;i++) 
       if(strg.indexOf(strarray[i])>0) return false; 
     for(i=0;i<strg.length;i++) 
       if(strg.substr(i,1)<="," || strg.substr(i,1)=="/" || (strg.substr(i,1)>="["&&strg.substr(i,1)<="") || strg.substr(i,1)=="`" || (strg.substr(i,1)>=":"&&strg.substr(i,1)<="?") || strg.substr(i,1)>="{") return false; 
     return true 
} 
// add bookmark
function addBookmark(url, title){
	if (window.sidebar) { 
		window.sidebar.addPanel(title, url,""); 
	} else if( document.all ) {
		window.external.AddFavorite( url, title);
	} else if( window.opera && window.print ) {
		alert(g_addbookmark_opera);
	} else if( window.openDatabase ) {
		alert(g_addbookmark_safari);
	} else {
		return true;
	}

}

function ShowPeople(id){
	var turl ="people.php?id=" + id;
	var wnd=window.open(turl,"gypsii");
	if (wnd)
	{
		wnd.focus();
	}
}

function ShowPoi(id){
	var turl ="poi.php?id=" + id;
	var wnd=window.open(turl,"gypsii");
	if (wnd)
	{
		wnd.focus();
	}
}

function ShowPlace(id){

	if (id=="" || id=="-1")
	{
		return;
	}
	var turl ="place.php?id=" + id;
	var wnd=window.open(turl,"gypsii");
	if (wnd)
	{
		wnd.focus();
	}

}


function ShowPeople_ex(id){
	window.location.href="people.php?id=" + id;
}

function ShowPoi_ex(id){
	window.location.href="poi.php?id=" + id;
}

function ShowPlace_ex(id){
	if (id=="" || id=="-1")
	{
		return;
	}
	window.location.href="place.php?id=" + id;
}

function sendMsg(id,mid)
{
	if (id)
	{
		window.location.href = 'write.php?id='+ id +'&mid='+ mid;
	}
}

function showUnLogin()
{
	var o = $("#img_box");

	if (o)
	{
		o.html('not login');
	}
}

function ShowFooterMenu(){
	if (document.getElementById("footermenudiv"))
	{
		var yScroll = document.documentElement.scrollTop;
		var screenheight = document.documentElement.clientHeight;
		var t = yScroll + screenheight - 50 ;
		if (t > document.body.clientHeight)
		{
			t = document.body.clientHeight;
		}
		document.getElementById("footermenudiv").style.top = t  + "px";//垂直浮动
	}
}

function InputOnFocus(objInput){
	 objInput.className="input_text input_current";
}
function InputOnblur(objInput){
	 objInput.className="input_text";
}	
function onClick(obj)
{
	var patNode=obj.parentNode;
	var chieldNodes=patNode.childNodes;
	for(var i=0;i<chieldNodes.length;i++)
	{chieldNodes[i].className="";}
	obj.className="current";
}
//显示loading iconsize 图片尺寸大小 1 20*20   2 50*50
function ShowLoading(obj,iconsize){
	if (iconsize==2)
	{
		obj.innerHTML="<center><img src='images/\public/\loading2.gif'></center>";
	}
	else
		obj.innerHTML="<center><img src='images/\public/\loading1.gif'></center>";
}

function foucsText(id,txt)
{
	var o = $("#" + id);
	if (o)
	{
		o.focus(function() {
			if (o.val() == txt)
			{
				o.val('');
			}
		}).blur(function() {
			if (o.val() == '')
			{
				o.val(txt);
			}
		});
	}
}

function checkAll(id,c)
{
	var cb = $("#" + c);

	if (!cb)
	{
		return;
	}

	$("input[name='"+ id +"']").each(function() {
		if (cb.attr("checked"))
		{
			$(this).attr("checked", true);
		}
		else
		{
			$(this).attr("checked", false);
		}
		
	});
}

function introduceToFriend(){
	document.getElementById("msgcontent").value=location.href;
	document.getElementById("writemsgfrm").submit();
}

function feedback(is_display){
	document.getElementById("feedback").style.left = ((document.body.scrollWidth-550)/2) + "px";
	cleanfbresult();
	if(is_display){
		document.getElementById("feedback").style.display = "";
		document.getElementById("fb_result").style.display = "none";
	}else
		document.getElementById("feedback").style.display = "none";
}

function cleanFeedBack(){
	obj=document.getElementById('backinfo');
	obj2=document.getElementById('fb_result');
	if (obj)
	{
		obj.value="";
	}
	if (obj2)
		obj2.style.display="none";
}

function submitfeedback(){
	obj2=document.getElementById('fb_result');
	obj2.style.display="";
	
	var backinfo = $("#backinfo").val();

	if (backinfo == '' || backinfo==g_default_feedback)
	{
		alert(g_feedback_content_empty);
		return;
	}

	if(confirm(g_add_feedback_confirm)){
		var url = 'request/index.php?time='+Math.random();
	//var url = "feedback.php";
		var jsonarr = {cmd:"public_feedback",data:{backinfo:document.getElementById("backinfo").value}};
		var jsontxt = JSON.stringify(jsonarr);
				$.ajax({
				type:'get',
				url:url,
				data:{json:jsontxt},
			//data:{backinfo:document.getElementById("backinfo").value},
				timeout:90000,
				beforeSend:function(){
					ShowLoading(document.getElementById("fb_result"),2);
				},
				success:function(text){
					var o = eval("("+text+")");
					
					if (o.data == '0')
					{
						ShowPopUpDiv("fail",g_notice,g_feedback_content_empty);
					}
					else
					{
						document.getElementById("fb_result").innerHTML = o.data;

						document.getElementById("fb_buttons").innerHTML = '<a class="btn_small" href="javascript:void(0)" onclick="feedback(false);"><span>关闭</span></a>';
						
						$("#backinfo").val('');
						var si = window.setTimeout(function(){
								$("#feedback").hide();
							},
							2000);
						
					}
				},
				complete:function(){
				},
				error:function(text){
					var o = eval("("+text+")");
					document.getElementById("fb_result").innerHTML  = o.data;
				}
		});	
	}
}

function submithelpfeedback(){
	var backinfo = $("#backinfo");
	if ($.trim(backinfo.val()) == '' || $.trim(backinfo.val()) == g_default_feedback)
	{
		ShowPopUpDiv('fail','',g_add_feedback);
		return;
	}
	if(confirm(g_add_feedback_confirm)){
		var url = 'request/index.php?time='+Math.random();
	//var url = "help_feedback_proc.php";
		var jsonarr = {cmd:"help_feedbackproc",data:{backinfo:document.getElementById("backinfo").value}};
		var jsontxt = JSON.stringify(jsonarr);
				$.ajax({
				type:'get',
				url:url,
				data:{json:jsontxt},
			//data:{backinfo:document.getElementById("backinfo").value},
				timeout:90000,
				beforeSend:function(){
				},
				success:function(text){
					var o = eval("("+text+")");
					ShowPopUpDiv("succ",g_notice,o.data);
					if(o.data=='添加成功！！'){
						$("#backinfo").val('');
						foucsText('backinfo',"反馈信息");
					}
				},
				complete:function(){
				},
				error:function(text){
				}
		});	
	}
}

function cleanfbresult(){
	document.getElementById("fb_buttons").innerHTML = '<a class="btn_small" href="javascript:void(0)" onclick="submitfeedback();"><span>'+g_buttons_confirm+'</span></a><a class="btn_small" href="javascript:void(0)" onclick="feedback(false);"><span>'+g_buttons_cancel+'</span></a>';
}

function showLoading()
{
	if ($("#layer_loading").length > 0)
	{
		$("#layer_loading").is(":hidden") ? $("#layer_loading").show() : $("#layer_loading").hide();
	}
	else
	{
		var yScroll = document.documentElement.scrollTop;
		var screenheight = document.documentElement.clientHeight;
		var t = yScroll + screenheight - 240;
		if (t > document.body.clientHeight)
		{
			t = document.body.clientHeight;
		}

		$("body").append("<div class=\"layer_loading\" id=\"layer_loading\"><img src=\"images/public/load2.gif\"/></div>");
		$("#layer_loading").css("left",(($(document).width())/2-(parseInt(200)/2))+"px").css("top",t +"px");

		$("#layer_loading").show();
	}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function GetNewsList(pageno){	
	var url = 'request/index.php?time='+Math.random();
	//var url = "getnewslist.php";
		var jsonarr = {cmd:"news_getlist",data:{pageno:pageno}};
		var jsontxt = JSON.stringify(jsonarr);
	$.ajax({
		type:'get',
		url:url,
		data:{json:jsontxt},
			//data:{pageno:pageno},
		timeout:90000,
		beforeSend:function(){
		},
		success:function(text){
			var o = eval("("+text+")");
			document.getElementById("the_news").innerHTML = o.data;
		},
		complete:function(){
		},
		error:function(text){
		}
	});	
}

function validUpload(file,type)
{
	var ext_only = new Array('gif','jpg','jpeg','png');
	var ext_all = new Array('asf','3gp','jpg','jpeg','gif','tif','png','avi','flv','wmv','mpg','dat','mp4','ami','rma','wav','wma','mid','bmp','mp3');
	var ext = Array();

	var len = 0;
	var flag = false;
	var val = '';
	var arr = Array();
	
	if (!file)
	{
		return;
	}

	ext = type == 'all'  ? ext_all : ext_only;

	val = file.value.toLowerCase();

	if (val != '')
	{
		arr = val.split(".");
		val = arr[1];
	}

	if (val != '')
	{
		for (var i=0;i<ext.length ;i++ )
		{
			if (val == ext[i])
			{
				flag = true;
				break;
			}
		}
	}

	return flag;
}

//tpl.js import

var g_mark_people  = "";
g_mark_people += "<div class=\"talkbc\"></div>";
g_mark_people += "<div class=\"talk\">";
g_mark_people += "	<div class=\"close_map\">"+g_close+"</div>";
g_mark_people += "	<div class=\"left_img\"><div class=\"img_box\"><a href=\"javascript:ShowPeople('#user_id#');\" style=\"position:relative;\"><img src=\"#thumbnail_url#\" width=\"48\" height=\"48\" /></a></div></div>";
g_mark_people += "	<div class=\"right_info\">";
g_mark_people += "		<strong><a href=\"javascript:ShowPeople('#user_id#');\">#display_name#</a></strong>";
g_mark_people += "		<p>"+g_distance+": #distance#<br/>"+g_age+": #age#<br/>"+g_gender+": #gender#</p>";
g_mark_people += "		<p>"+g_address+":<a href=\"javascript:;\" title=\"#address#\">#address_cut#</a></p>";
g_mark_people += "	</div>";
g_mark_people += "</div>";
g_mark_people += "<br />";

var g_mark_place  = "";
g_mark_place += "<div class=\"talkbc\"></div>";
g_mark_place += "<div class=\"talk talk_place\">";
g_mark_place += "	<div class=\"close_map\">"+g_close+"</div>";
g_mark_place += "	<div class=\"left_img\"><div class=\"img_box\"><a href=\"javascript:ShowPlace('#place_id#');\" style=\"position:relative;\"><img src=\"#thumbnail_url#\" width=\"64\" height=\"64\"></a></div></div>";
g_mark_place += "	<div class=\"right_info\">";
g_mark_place += "		<strong><a href=\"javascript:ShowPlace('#place_id#');\" style=\"position:relative;\">#name#</a></strong>";
g_mark_place += "		<p><strong><a href=\"javascript:ShowPeople('#user_id#');\">#display_name#</a></strong><br />"+g_createat+": #creation_datetime#</p>";
g_mark_place += "		<p>"+g_address+":<a href=\"javascript:;\" title=\"#address#\">#address_cut#</a></p>";
g_mark_place += "	</div>";
g_mark_place += "</div>";
g_mark_place += "<br />";

var g_mark_index_people  = "";
g_mark_index_people += "<div class=\"talkbc\"></div>";
g_mark_index_people += "<div class=\"talk\">";
g_mark_index_people += "	<div class=\"close_map\">"+g_close+"</div>";
g_mark_index_people += "	<div class=\"left_img\"><div class=\"img_box\"><a href=\"javascript:ShowPeople('#user_id#');\" style=\"position:relative;\"><img src=\"#thumbnail_url#\" width=\"48\" height=\"48\" /></a></div></div>";
g_mark_index_people += "	<div class=\"right_info\">";
g_mark_index_people += "		<strong><a href=\"javascript:ShowPeople('#user_id#');\">#display_name#</a></strong>";
g_mark_index_people += "		<p>"+g_distance+": #distance#<br/>"+g_age+": #age#<br/>"+g_gender+": #gender#</p>";
g_mark_index_people += "	</div>";
g_mark_index_people += "</div>";
g_mark_index_people += "<br />";

var g_mark_index_place  = "";
g_mark_index_place += "<div class=\"talkbc\"></div>";
g_mark_index_place += "<div class=\"talk talk_place\">";
g_mark_index_place += "	<div class=\"close_map\">"+g_close+"</div>";
g_mark_index_place += "	<div class=\"left_img\"><div class=\"img_box\"><a href=\"javascript:ShowPlace('#place_id#');\" style=\"position:relative;\"><img src=\"#thumbnail_url#\" width=\"64\" height=\"64\"></a></div></div>";
g_mark_index_place += "	<div class=\"right_info\">";
g_mark_index_place += "		<strong><a href=\"javascript:ShowPlace('#place_id#');\" style=\"position:relative;\">#name#</a></strong>";
g_mark_index_place += "		<p><strong><a href=\"javascript:ShowPeople('#user_id#');\">#display_name#</a></strong><br />"+g_createat+": #creation_datetime#</p>";
g_mark_index_place += "	</div>";
g_mark_index_place += "</div>";
g_mark_index_place += "<br />";

var g_mark_poi  = "";
g_mark_poi += "<div class=\"talkbc\"></div>";
g_mark_poi += "<div class=\"talk talk_place\">";
g_mark_poi += "	<div class=\"close_map\">"+g_close+"</div>";
g_mark_poi += "	<div class=\"left_img\"><div class=\"img_box\"><a href=\"javascript:ShowPoi('#place_id#');\"><img src=\"#thumbnail_url#\" width=\"64\" height=\"64\" /></a></div></div>";
g_mark_poi += "	<div class=\"right_info\">";
g_mark_poi += "		<strong>#name#</strong>";
g_mark_poi += "	</div>";
g_mark_poi += "</div>";
g_mark_poi += "<br />";


var g_event_comment = "";
g_event_comment += "<div class=\"comment clear\">";
g_event_comment += "    <div class=\"left_img\"><div class=\"img_box img_32\"><a href=\"javascript:ShowPeople('#uid#');\"><img src=\"#thumbnail_url#\" width=\"32\" height=\"32\" /></a></div></div>";
g_event_comment += "    <div class=\"right_info\">";
g_event_comment += "        <p><a href=\"javascript:ShowPeople('#uid#');\">#display_name#</a>&nbsp;#creation_datetime#</p>";
g_event_comment += "        <p>#description#</p>";
g_event_comment += "    </div>";
g_event_comment += "</div>";


var g_people_comment = "";
g_people_comment  = "";
g_people_comment += "	<li>";
g_people_comment += "		<div class=\"left_img\"><div class=\"img_box img_48\"><img src=\"#thumbnail_url#\" width=\"48\" height=\"48\" /></div></div>";
g_people_comment += "		<div class=\"right_info\">";
g_people_comment += "			<p><a href=\"javascript:ShowPeople('#uid#');\">#display_name#</a>&nbsp;"+g_say+": </p>";
g_people_comment += "			<p>#comment#</p>";
g_people_comment += "		</div>";
g_people_comment += "		<div class=\"time\">#creation_datetime#&nbsp;&nbsp;&nbsp;<!--<a href=\"\" class=\"ico_public ico_bj\"></a>--></div>";
g_people_comment += "	</li>";
g_people_comment += "	<br />";


var g_place_detail_comment = "";
g_place_detail_comment += "<li id=\"place_detail_comment_#uid#'\">";
g_place_detail_comment += "    <div class=\"left_img\"><div class=\"img_box img_48\"><img height=\"48\" width=\"48\" src=\"#thumbnail_url#\"/></div></div>";
g_place_detail_comment += "    <div class=\"right_info\">";
g_place_detail_comment += "        <p><a href=\"javascript:ShowPeople('#uid#');\">#display_name#</a>&nbsp;"+g_say+": </p>";
g_place_detail_comment += "        <p>#description#</p>";
g_place_detail_comment += "    </div>";
g_place_detail_comment += "    <div class=\"time\">#creation_datetime#   <!--<a href=\"\" class=\"ico_public ico_bj\"></a>--></div>";
g_place_detail_comment += "</li><br />";
//end of tpl.js

if(!(typeof GOverlay == 'undefined' || !GOverlay)){//check if gmap.js exists
//cusOverlay.js import
var listener = Array();
var CusOverlay = function(latlng_,icon_,display_,tips_,clickParam_,type_) {
	this.tips = tips_;
	this.clickParam = clickParam_;
	this.icon = icon_;
	this.display = display_;
	this.latlng = latlng_;
	this.type = type_;
};

CusOverlay.prototype = new GOverlay();

CusOverlay.prototype.initialize = function(map_) {
	switch (this.type)
	{
		case "1":
			this.type_1(map_);
			break;
		case "2":
			this.type_2(map_);
			break;
		default :
			this.type_1(map_);
	}

};

CusOverlay.prototype.remove = function() {
	this.tips.parentNode.removeChild(this.tips);
};

CusOverlay.prototype.copy = function() {
	return new (this.latlng,this.tips);
};

CusOverlay.prototype.redraw = function(force) {
	if (force) 
	{
		var p = this.map.fromLatLngToDivPixel(this.latlng);
		this.tips.style.left = ((p.x) - 40) + "px";
		this.tips.style.top = ((p.y) - 160) + "px";
	}
};

CusOverlay.prototype.type_1 = function(map_) {
	
	//为所有标记创建指定阴影、图标尺寸灯的基础图标
	var baseIcon = new GIcon(G_DEFAULT_ICON);
	baseIcon.image = "images/public/" + this.icon;
	//baseIcon.shadow = "images/public/" + this.shadow;
	baseIcon.iconSize = GSize({width:30,height:30});
	baseIcon.shadowSize = GSize({width:30,height:30});
	
	//设置 GMarkerOptions 对象
	markerOptions = { icon:baseIcon };    
	var marker_ = new GMarker(this.latlng, markerOptions);
	map_.addOverlay(marker_);
	this.marker = marker_;
	var latlng__ = this.latlng;

	//创建tips div
	var tips_ = document.createElement("div");
	tips_.innerHTML = this.tips;
	tips_.style.position = "absolute";
	tips_.style.display = 'none';
	map_.getPane(G_MAP_FLOAT_PANE).appendChild(tips_);
	this.tips = tips_;
	this.map = map_;

	//点击tips时触发事件
	$(".close_map").click(function(){
			tips_.style.display = 'none';
	});

	GEvent.addDomListener(marker_, "click", function() {
		map_.panTo(latlng__);
		for (var i=0;i<listener.length;i++)
		{
			listener[i].style.display = 'none';
		}

		listener[listener.length] = tips_;
		tips_.style.display = 'block';
	});

	GEvent.addDomListener(marker_, "mouseout", function() {
		listener[listener.length] = tips_;
		//tips_.style.display = 'none';
	});
}

CusOverlay.prototype.type_2 = function(map_) {

	//为所有标记创建指定阴影、图标尺寸灯的基础图标
	var baseIcon = new GIcon(G_DEFAULT_ICON);
	baseIcon.image = "images/public/" + this.icon;
	//baseIcon.shadow = "images/public/" + this.shadow;
	baseIcon.iconSize = GSize({width:30,height:30});
	baseIcon.shadowSize = GSize({width:30,height:30});
	
	//设置 GMarkerOptions 对象
	markerOptions = { icon:baseIcon };    
	var marker_ = new GMarker(this.latlng, markerOptions);
	map_.addOverlay(marker_);
	this.marker = marker_;
	
	//创建tips div
	var tips_ = document.createElement("div");
	tips_.innerHTML = this.tips;
	tips_.style.position = "absolute";
	tips_.style.display = this.display;
	map_.getPane(G_MAP_FLOAT_PANE).appendChild(tips_);
	this.tips = tips_;
	this.map = map_;

}
//end of cusOverlay.js
}

//map.js import
var map = {};

map = {
	init: function(div,lat,lng,zoom){
		if (GBrowserIsCompatible()) 
		{	
			gmap2 = new GMap2(document.getElementById(div));
			gmap2.addControl(new GSmallMapControl());
			gmap2.setCenter(new GLatLng(lat,lng), zoom);
		}
	},
	
	setZoom:function(bounds){
		gmap2.setZoom(gmap2.getBoundsZoomLevel(bounds));
	},
			
	setCenter:function(bounds){
		gmap2.setCenter(bounds.getCenter());
	},

	geo: function(address){
		var json = '';
		geocoder = new GClientGeocoder();
		map.clear();

		if (address && geocoder)
		{
			geocoder.getLatLng(
				address, 
				function(point){
					if (point)
					{
						json = 0;
						
						var baseIcon = new GIcon(G_DEFAULT_ICON);
						baseIcon.image = "images/public/ico_logo.gif";
						//baseIcon.iconSize = new GSize(34, 34);
						markerOptions = { icon:baseIcon};

						var lat = point.lat();
						var lng = point.lng();
						var icon = 'nail_person.png';
						var display = 'none';
						var clickParam = 1;
						
						map.center(lat,lng);
						var marker = new GMarker(point,markerOptions);
						gmap2.addOverlay(marker);
						//map.marked(lat,lng,icon,display,tips,clickParam);
					}
				}
			);
		}
	},

	marked: function(lat,lng,icon,display,tips,clickParam,type){
		if (lat)
		{
			var latlng = new GLatLng(lat,lng);
			gmap2.addOverlay(new CusOverlay(latlng,icon,display,tips,clickParam,type));
		}
	
	},
	
	markFriend: function(obj,lat,lng,display,clickParam,type){
		if (lat)
		{
			var latlng = new GLatLng(lat,lng);
			var str = map.getFriendTpl();

			var display = 'block';
			var tips = map.replaced(obj,str);
			var icon = 'nail_person.png';

			gmap2.addOverlay(new CusOverlay(latlng,icon,display,tips,clickParam,type));
		}
	},

	getPlaceTpl: function(){
		return g_mark_place;
	},
	
	getFriendTpl: function(){
		return g_mark_people;
	},
	
	getPoiTpl: function() {
		return g_mark_poi;
	},
	
	markPlace: function(obj,lat,lng,display,clickParam,type){
		if (lat)
		{
			var latlng = new GLatLng(lat,lng);
			var str = map.getPlaceTpl();

			var tips = map.replaced(obj,str);
			var icon = 'nail_blue.png';

			//map.clear();
			//map.center(lat,lng);
			gmap2.addOverlay(new CusOverlay(latlng,icon,display,tips,clickParam,type));
		}
	},

	markIndexPlace: function(obj,lat,lng,display,clickParam,type){
		if (lat)
		{
			var latlng = new GLatLng(lat,lng);
			var str = g_mark_index_place;

			var tips = map.replaced(obj,str);
			var icon = 'nail_blue.png';

			gmap2.addOverlay(new CusOverlay(latlng,icon,display,tips,clickParam,type));
		}
	},

	markIndexFriend: function(obj,lat,lng,display,clickParam,type){
		if (lat)
		{
			var latlng = new GLatLng(lat,lng);
			var str = g_mark_index_people;

			var display = 'block';
			var tips = map.replaced(obj,str);
			var icon = 'nail_person.png';

			gmap2.addOverlay(new CusOverlay(latlng,icon,display,tips,clickParam,type));
		}
	},

	markPoi: function(obj,lat,lng,display,clickParam,type){
		if (lat)
		{
			var latlng = new GLatLng(lat,lng);
			var str = map.getPoiTpl();

			var tips = map.replaced(obj,str);
			var icon = 'nail_blue.png';

			//map.clear();
			//map.center(lat,lng);
			gmap2.addOverlay(new CusOverlay(latlng,icon,display,tips,clickParam,type));
		}
	},

	markSelf: function(lat,lng) {
		map.center(lat,lng);
		map.clear();
		var latlng = new GLatLng(lat,lng);
		var baseIcon = new GIcon(G_DEFAULT_ICON);
		baseIcon.image = "images/public/nail_red.png";
		baseIcon.iconSize = new GSize(25, 25);
		baseIcon.shadow = "";
		markerOptions = {
			icon:baseIcon,
			draggable: false
		};
		var marker = new GMarker(latlng, markerOptions);
		gmap2.addOverlay(marker);
	},

	closed: function(lat,lng){
	},
	
	added: function(lat,lng){
		map.center(lat,lng);
		
		var latlng = new GLatLng(lat,lng);
		var baseIcon = new GIcon(G_DEFAULT_ICON);
		baseIcon.image = "images/public/nail_red.png";
		baseIcon.iconSize = new GSize(25, 25);
		baseIcon.shadow = "";
		markerOptions = {
			icon:baseIcon,
			draggable: true
		};
		var marker = new GMarker(latlng, markerOptions);
		gmap2.addOverlay(marker);
	},
	
	move: function(lat,lng) {
		map.center(lat,lng);
		map.clear();
		var latlng = new GLatLng(lat,lng);
		var baseIcon = new GIcon(G_DEFAULT_ICON);
		baseIcon.image = "images/public/nail_red.png";
		baseIcon.iconSize = new GSize(25, 25);
		baseIcon.shadow = "";
		markerOptions = {
			icon:baseIcon,
			draggable: true
		};
		var marker = new GMarker(latlng, markerOptions);
		gmap2.addOverlay(marker);

        GEvent.addListener(marker, "dragstart", function() {
			marker.closeInfoWindow();
        });

        GEvent.addListener(marker, "dragend", function() {
			var la = $("#lat");
			var ln = $("#lng");

			if (la && ln)
			{
				$("#lat").val(marker.getLatLng().lat());
				$("#lng").val(marker.getLatLng().lng());
			}

        });
	},

	center: function(lat,lng){
		if (lat)
		{
			var latlng = new GLatLng(lat,lng);
			gmap2.setCenter(latlng, gmap2.getZoom());
		}
		
	},

	clear: function(){
		gmap2.clearOverlays();
	},
	
	//array {'[key]':val} replace key => val
	replaced: function(obj,res){

		var ret = '';

		if (res != '')
		{
			if (obj.length <= 0 || obj.length === 'undefined')
			{
				$.each(obj, function(k, v) {
					var strs = res;
					var keys = '#' + k + '#';
					var re = eval('/' + keys + '/g');
					if (v)
					{
						strs = strs.replace(re,v);
					}
					else
						strs = strs.replace(re,'');
					
				});
			}
			else
			{
				$(obj).each(function(){
					var o = this;
					var strs = res;
					$.each(o, function(k, v) {
						var keys = '#' + k + '#';
						var re = eval('/' + keys + '/g');
						if (v)
						{
							strs = strs.replace(re,v);
						}
						else
							strs = strs.replace(re,'');
						
					});
					
					ret += strs;
				});
			}
		}

		return ret;
	}

};
//end of map.js

//app.js import
var app = {};

app = {
	init: function(){
	},

	mark: function(id,type){
		if (id && type)
		{
			var url = 'request/index.php?time='+Math.random();
	//var url = 'list.php?action=mark&id='+ id +'&type='+ type;

		var jsonarr = {cmd:"public_mark",data:{id:id,type:type}};
		var jsontxt = JSON.stringify(jsonarr);
			$.ajax({
				type:'get',
				url:url,
				data:{json:jsontxt},
			//data:data,
				timeout:90000,
				beforeSend:function(){
				},
				success:function(str){
					var o = eval("("+str+")");

					if (o.data == '')
					{
						return;
					}

					var obj = o.data;
					map.clear();
					if (!obj)
					{
						return;
					}
					map.center(obj.latitude,obj.longitude);
					
					// type 1:place,2:people
					if (type == '1')
					{
						var data = [{
							name:obj.name,
							thumbnail_url:obj.thumbnail_url,
							user_id:obj.user_id,
							place_id:obj.place_id,
							display_name:obj.display_name,
							creation_datetime:obj.creation_datetime,
							address:obj.address,
							address_cut:obj.address_cut
						}];
						
						map.markPlace(data,obj.latitude,obj.longitude,'block',0,'');
					}
					else if (type == '2')
					{						
						var data = [{
							thumbnail_url:obj.thumbnail_url,
							user_id:obj.user_id,
							display_name:obj.display_name,
							distance:obj.distance,
							birthday:obj.birthday,
							gender:obj.gender,
							age:obj.age
						}];
						map.markFriend(data,obj.latitude,obj.longitude,'block',0,'');
					}
				},
				complete:function(){
				},
				error:function(){

				}
			});
		}
	},
	//ntype=1 表示只要6个 ntype=2要7个， css 不一样
	placelist: function(nlat,nlon,curpage,ntype){
		var url = 'request/index.php?time='+Math.random();
	//var url = 'list.php?action=placelist&lat='+ nlat + '&lon=' + nlon + '&curpage='+ curpage + "&ntype=" + ntype;

		//显示current class
		$("#home_people").removeClass("current");
		$("#home_place").addClass("current");

		var jsonarr = {cmd:"place_list",data:{lat:nlat,lon:nlon,curpage:curpage,ntype:ntype}};
		var jsontxt = JSON.stringify(jsonarr);
		$.ajax({
			type:'get',
			url:url,
			data:{json:jsontxt},
			timeout:90000,
			beforeSend:function(){
				
			},
			success:function(str){
				var o = eval("("+str+")");
				if (!o.data)
				{
					return;
				}

				var o = o.data;
				var obj = o.list;
				var reval  = "";
				
				if (!obj)
				{
					return;
				}

				var havepoint = false;
				bounds = new GLatLngBounds();
				bounds.extend(new GLatLng(nlat,nlon));  
				for (var i=0;i<obj.length ;i++ )
				{	
					var lat = obj[i].place_summary['latitude'];
					var lng = obj[i].place_summary['longitude'];
					if (lat!="")
					{
						havepoint = true;
						bounds.extend(new GLatLng(lat,lng));    
					}
					var display = 'none';
					var clickParam = '0';
					var data = [{
								name:obj[i].place_summary['name'],
								thumbnail_url:obj[i].place_summary['thumbnail_url'],
								user_id:obj[i].creator_summary['user_id'],
								place_id:obj[i].place_summary['id'],
								display_name:obj[i].creator_summary['display_name'],
								creation_datetime:obj[i]['creation_datetime'],
								address:obj[i]['address'],
								address_cut:obj[i]['address_cut']
							}];

					//map.center(lat,lng);
					map.markPlace(data,lat,lng,display,clickParam,'');
				}
				if (havepoint)
				{
					map.setZoom(bounds);
					map.setCenter(bounds);
				}
			},
			complete:function(){
			},
			error:function(){
			}
		});
	},
	
	peoplelist: function(nlat,nlon,curpage,ntype){
		var url = 'request/index.php?time='+Math.random();
	//var url = 'list.php?action=peoplelist&lat='+ nlat + '&lon=' + nlon +'&curpage='+ curpage + "&ntype=" + ntype;

		//显示current class
		$("#home_people").addClass("current");
		$("#home_place").removeClass("current");

		var jsonarr = {cmd:"people_peoplelist",data:{lat:nlat,lon:nlon,curpage:curpage,ntype:ntype}};
		var jsontxt = JSON.stringify(jsonarr);
		$.ajax({
			type:'get',
			url:url,
			data:{json:jsontxt},
			timeout:90000,
			beforeSend:function(){
				
			},
			success:function(str){
				var o = eval("("+str+")");
				if (!o.data)
				{
					return;
				}

				var o = o.data;
				var obj = o.list;
				var reval  = "";
				
				if (!obj)
				{
					return;
				}

				//加载到地图
				var havepoint = false;
				bounds = new GLatLngBounds();
				bounds.extend(new GLatLng(nlat,nlon));  
				for (var i=0;i<obj.length ;i++ )
				{
					var lat = obj[i].user_summary['latitude'];
					var lng = obj[i].user_summary['longitude'];
					if (lat!="")
					{
						havepoint = true;
						bounds.extend(new GLatLng(lat,lng));    
					}
					var display = 'none';
					var clickParam = '0';
					var data = [{
								thumbnail_url : obj[i].user_summary['thumbnail_url'],
								user_id : obj[i].user_summary['user_id'],
								display_name : obj[i].user_summary['display_name'],
								distance : obj[i]['distance'],
								age : obj[i]['age'],
								gender : obj[i]['gender'],
								address:obj[i]['address'],
								address_cut:obj[i]['address_cut']
							}];

					//map.center(lat,lng);
					map.markFriend(data,lat,lng,display,clickParam,'');
				}
				if (havepoint)
				{
					map.setZoom(bounds);
					map.setCenter(bounds);
				}
			},
			complete:function(){
			},
			error:function(){
			}
		});
	},
	
	placepeoplelist: function(nlat,nlon,curpage,ntype){
		var url = 'request/index.php?time='+Math.random();
	//var url = 'request/index.php?time='+Math.random();
		var jsonarr = {cmd:"home_peopleplacelist",data:{lat:nlat,lon:nlon,curpage:curpage,ntype:ntype}};
		var jsontxt = JSON.stringify(jsonarr);
		$.ajax({
			type:'GET',
			url:url,
			data:{json:jsontxt},
			//data:{json:'{"cmd":"home_peopleplacelist","data":{"lat":"'+ nlat + '","lon":"' + nlon + '","curpage":"'+ curpage + '","ntype":"'+ ntype + '"}}'},
			timeout:90000,
			beforeSend:function(){
				
			},
			success:function(str){
				var o = eval("("+str+")");
				if (!o.data)
				{
					return;
				}

				var objplace = o.data.placelist;
				var objpeople = o.data.peoplelist;
				var reval  = "";
				var minlat = 100000;
				var minlon = 100000;
				var maxlat = -100000;
				var maxlon = -100000;

				var havepoint = false;
				bounds = new GLatLngBounds();
				bounds.extend(new GLatLng(nlat,nlon));  
				for (var i=0;i<objplace.length ;i++ )
				{	
					if (objplace[i].place_summary['latitude'])
					{
						var lat = objplace[i].place_summary['latitude'];
						var lng = objplace[i].place_summary['longitude'];
						if (parseFloat(lat) < minlat)
						{
							minlat= parseFloat(lat)
						}
						if (parseFloat(lng) < minlon)
						{
							minlon= parseFloat(lng)
						}
						if (parseFloat(lat) > maxlat)
						{
							maxlat= parseFloat(lat)
						}
						if (parseFloat(lng) > maxlon)
						{
							maxlon= parseFloat(lng)
						}
						havepoint = true;
						bounds.extend(new GLatLng(lat,lng));    
					}
					var display = 'none';
					var clickParam = '0';
					var data = [{
								name:objplace[i].place_summary['name'],
								thumbnail_url:objplace[i].place_summary['thumbnail_url'],
								user_id:objplace[i].creator_summary['user_id'],
								place_id:objplace[i].place_summary['id'],
								display_name:objplace[i].creator_summary['display_name'],
								creation_datetime:objplace[i]['creation_datetime'],
								address:objplace[i]['address'],
								address_cut:objplace[i]['address_cut']
							}];

					//map.center(lat,lng);
					map.markPlace(data,lat,lng,display,clickParam,'');
				}
			
				for (var i=0;i<objpeople.length ;i++ )
				{
					if (objpeople[i].user_summary['latitude'])
					{
						var lat = objpeople[i].user_summary['latitude'];
						var lng = objpeople[i].user_summary['longitude'];
						havepoint = true;
						bounds.extend(new GLatLng(lat,lng));  
						if (parseFloat(lat) < minlat)
						{
							minlat= parseFloat(lat)
						}
						if (parseFloat(lng) < minlon)
						{
							minlon= parseFloat(lng)
						}
						if (parseFloat(lat) > maxlat)
						{
							maxlat= parseFloat(lat)
						}
						if (parseFloat(lng) > maxlon)
						{
							maxlon= parseFloat(lng)
						}
					}
					var display = 'none';
					var clickParam = '0';
					var data = [{
								thumbnail_url : objpeople[i].user_summary['thumbnail_url'],
								user_id : objpeople[i].user_summary['user_id'],
								display_name : objpeople[i].user_summary['display_name'],
								distance : objpeople[i]['distance'],
								age : objpeople[i]['age'],
								gender : objpeople[i]['gender'],
								address:objplace[i]['address'],
								address_cut:objplace[i]['address_cut']
							}];

					//map.center(lat,lng);
					map.markFriend(data,lat,lng,display,clickParam,'');
				}

				if (havepoint)
				{
					var nheight=Math.abs(maxlat-minlat);
					var nwidth=Math.abs(maxlon-minlon)
					if (nheight<0.00001 || nwidth<0.00001)
					{
						map.center(nlat,nlon);
					}
					else{
						map.setZoom(bounds);
						map.setCenter(bounds);
					}
				}
			},
			complete:function(){
			},
			error:function(){
			}
		});
	},
	
	comment: function(id,curpage,type){

		var url = 'request/index.php?time='+Math.random();
	//var url = 'list.php?action=comment&id='+ id +'&curpage='+ curpage + '&type=' + type;
		var jsonarr = {cmd:"comment_list",data:{id:id,curpage:curpage,type:type}};
		var jsontxt = JSON.stringify(jsonarr);
		$.ajax({
			type:'get',
			url:url,
			data:{json:jsontxt},
			timeout:90000,
			beforeSend:function(){
				ShowLoading(document.getElementById('comment_list'),2);
			},
			success:function(str){
				var o = eval("("+str+")");
				if (CheckValidSession(o,document.getElementById('comment_list'))){
				document.getElementById('comment_list').innerHTML=o.data;
				}
			},
			complete:function(){
			},
			error:function(){
			}
		});
	},
	//添加留言(@type 2:对钉友,1:对足迹,3:对状态(微博) 4 POI;
	commentAdd: function(id,type,divid){
		var url = 'request/index.php?time='+Math.random();
	//var url = 'list.php?action=commentAdd';
		var content = $("#content").val();
		if (cTrim(content)=="")
		{
			ShowPopUpDiv("fail",g_notice,g_add_comment_empty);
			return;
		}

		if ($.trim(content).length > 150)
		{
			ShowPopUpDiv("fail",g_notice,g_add_comment_words_overflow);
			return;
		}

		var data = {
			'id':id,
			'type':type,
			'content':content
		}

		var jsonarr = {cmd:"comment_add",data:data};
		var jsontxt = JSON.stringify(jsonarr);
		$.ajax({
			type:'get',
			url:url,
			data:{json:jsontxt},
			timeout:90000,
			beforeSend:function(){
				showLoading();
			},
			success:function(str){
				var o = eval("("+str+")");
				if (CheckValidSession(o,null)){
				if (o.data == 'ok')
				{
					var o = [{
						"uid" : GetCookie("uid"),
						"thumbnail_url" : GetCookie("thumbnail_url"),
						"creation_datetime" : '0fenzhofsf',
						"description" : content,
						"display_name" : GetCookie("username").replace('+','&nbsp;')
					}];
					var str = map.replaced(o,g_place_detail_comment);
					$("#content").val('');
					app.comment(id,1,type);
					if(divid!=undefined){
						document.getElementById(divid).innerHTML=parseInt(document.getElementById(divid).innerHTML)+1;
					}
				}
				}
			},
			complete:function(){
				showLoading();
			},
			error:function(){
			}
		});
	},

	commentDel: function(id){
		if (id)
		{

		}
	},

	searchMap: function(size,id){
		var o = $("#" + id);
		
		if (!o)
		{
			return;
		}
		
		var query = o.val();

		var url = 'request/index.php?time='+Math.random();
	//var url = 'list.php?action=searchMap&query='+ query +'&size='+ size;

		var jsonarr = {cmd:"searchres_map",data:{query:query,size:size}};
		var jsontxt = JSON.stringify(jsonarr);
		$.ajax({
			type:'get',
			url:url,
			data:{json:jsontxt},
			timeout:90000,
			beforeSend:function(){
			},
			success:function(str){
				var o = eval("("+str+")");

				if (CheckValidSession(o,null)){
				if (o.data)
				{
					complete.init(id,o.data);
				}
				else
				{
					alert(g_search_result);
				}
				}
			},
			complete:function(){
			},
			error:function(){
			}
		});
	},

	addPlace: function(){
		var f = $("#frm");
		var placename = $("#placename");
		var foldername = $("#foldername");
		var placedesc = $("#placedesc");
		var placekey = $("#placekey");
		var files = $("input:file");
		
		//判断
		var t = 0;
		for (var i=0;i<files.length ;i++ )
		{
			if (files[i].value != '')
			{
				//上传类型判断
				if (!validUpload(files[i],'all'))
				{
					ShowPopUpDiv('fail','',g_upload_allow_ext_all);
					return;
				}
				t++;
			}
		}
		
		if ($.trim(placename.val()) == '')
		{
			ShowPopUpDiv('succ',g_notice,g_add_place_name);
			return;
		}
		
		if ($.trim(foldername.val()) == '')
		{
			ShowPopUpDiv('succ',g_notice,g_folder_name);
			return;
		}

		if (t == 0)
		{
			ShowPopUpDiv('succ',g_notice,g_upload_file);
			return;
		}
		
		$(".btn_1").addClass('btn1_hover');
		f.submit();
	},

	editplace: function(){
		var f = $("#frm");
		var placename = $("#placename");
		var foldername = $("#foldername");
		var placedesc = $("#placedesc");
		var placekey = $("#placekey");
		var files = $("input:file");
		
		//判断
		var t = 0;
		for (var i=0;i<files.length ;i++ )
		{
			if (files[i].value != '')
			{
				//上传类型判断
				if (!validUpload(files[i],'all'))
				{
					ShowPopUpDiv('fail','',g_upload_allow_ext_all);
					return;
				}
				t++;
			}
		}

		if ($.trim(placename.val()) == '')
		{
			ShowPopUpDiv('succ',g_notice,g_add_place_name);
			return;
		}
		
		if ($.trim(foldername.val()) == '')
		{
			ShowPopUpDiv('succ',g_notice,g_folder_name);
			return;
		}
		
		$(".btn_1").addClass('btn1_hover');
		f.submit();
	},

	addGroup: function(){
		var f = $("#frm");
		var group_name = $("#group_name");
		var group_desc = $("#group_desc");
		var publicstate = $("#publicstate");
		var joinstate = $("#joinstate");
		var files = $("input:file");
		
		//判断
		var t = 0;
		for (var i=0;i<files.length ;i++ )
		{
			if (files.val() != '')
			{
				t++;
			}
		}

		if ($.trim(group_name.val()) == '')
		{
			ShowPopUpDiv('fail','',g_add_group_name);
			return;
		}

		if ($.trim(group_name.val()).length > 30)
		{
			ShowPopUpDiv('fail',g_notice,g_add_group_name2long);
			return;
		}

		if ($.trim(group_desc.val()).length > 300 || group_desc.val() == '')
		{
			ShowPopUpDiv('fail',g_notice,g_add_group_desc2long);
			return;
		}
		
		if ($.trim(publicstate.val()) == '')
		{
			ShowPopUpDiv('fail','',g_add_group_publicstate);
			return;
		}

		if ($.trim(joinstate.val()) == '')
		{
			ShowPopUpDiv('fail','',g_add_group_joinstate);
			return;
		}

		if (t == 0)
		{
			ShowPopUpDiv('fail','',g_upload_group_icon_empty);
			return;
		}
		else
		{
			//上传类型判断
			if (!validUpload(files[0],''))
			{
				ShowPopUpDiv('fail','',g_upload_allow_ext);
				return;
			}
		}

		f.submit();
	},

	editGroup: function(){
		var f = $("#frm");
		var group_name = $("#group_name");
		var group_desc = $("#group_desc");
		var publicstate = $("#publicstate");
		var joinstate = $("#joinstate");
		var files = $("input:file");
		
		//判断
		var t = 0;
		for (var i=0;i<files.length ;i++ )
		{
			if (files.val() != '')
			{
				t++;
			}
		}

		if ($.trim(group_name.val()) == '')
		{
			ShowPopUpDiv('fail',g_notice,g_add_group_name);
			return;
		}

		if ($.trim(group_name.val()).length > 30)
		{
			ShowPopUpDiv('fail',g_notice,g_add_group_name2long);
			return;
		}

		if ($.trim(group_desc.val()).length > 300 || group_desc.val() == '')
		{
			ShowPopUpDiv('fail',g_notice,g_add_group_desc2long);
			return;
		}

		if ($.trim(publicstate.val()) == '')
		{
			ShowPopUpDiv('fail',g_notice,g_add_group_publicstate);
			return;
		}

		if ($.trim(joinstate.val()) == '')
		{
			ShowPopUpDiv('fail',g_notice,g_add_group_joinstate);
			return;
		}

		//上传类型判断
		if (t > 0)
		{
			if (!validUpload(files[0],''))
			{
				ShowPopUpDiv('fail','',g_upload_allow_ext);
				return;
			}
		}

		f.submit();
	},

	addTitle: function(){
		var f = $("#frm");
		var title = $("#title");
		var content = $("#content");
		
		//判断
		if ($.trim(title.val()) == '' || $.trim(title.val()) == '发布帖子主题')
		{
			ShowPopUpDiv('fail',g_notice,g_add_title_name);
			return;
		}
		
		if ($.trim(content.val()) == '' || $.trim(content.val()) == '发布帖子内容')
		{
			ShowPopUpDiv('fail',g_notice,g_add_title_content);
			return;
		}

		f.submit();
	},

	delGroup: function(){
		var f = $("#frm");
		var title = $("#title");
		var content = $("#content");
		
		//判断
		if ($.trim(title.val()) == '')
		{
			ShowPopUpDiv('succ',g_notice,g_add_title_name);
			return;
		}
		
		if ($.trim(content.val()) == '')
		{
			ShowPopUpDiv('succ',g_notice,g_add_title_content);
			return;
		}

		f.submit();
	},

	addReply: function(){
		var f = $("#frm");
		var content = $("#content");
		
		//判断
		if ($.trim(content.val()) == '')
		{
			ShowPopUpDiv('succ',g_notice,g_add_reply_content);
			return;
		}

		f.submit();
	},
	
	setMyLocation: function(){ 
		$("#frm").submit();
	}
};
//end of app.js

//rating.js import
function ShowRating(){
	var obj = document.getElementById("ratingdiv");
	if (obj)
	{
		obj.style.left = ((document.body.scrollWidth-350)/2) + "px";
		var yScroll = document.documentElement.scrollTop;
		var screenheight = document.documentElement.clientHeight;
		obj.style.top = (yScroll + (screenheight-250)/2)+"px";
		obj.style.display="block";
	}
}

function HideRating(){
	var obj = document.getElementById("ratingdiv");
	if (obj)
	{
		obj.style.display="none";
	}
}

function DoRating(){
		if (document.getElementById("rating")=="0")
		{
			return;
		}

		var url = 'request/index.php?time='+Math.random();

		var data = {
			'id':document.getElementById("ratingid").value,
			'ntype':document.getElementById("ratingtype").value,
			'rat':document.getElementById("rating").value
		}

		var jsonarr = {cmd:"public_rating",data:data};
		var jsontxt = JSON.stringify(jsonarr);
		$.ajax({
			type:'get',
			url:url,
			data:{json:jsontxt},
			timeout:90000,
			beforeSend:function(){
			},
			success:function(str){
				var o = eval("("+str+")");
			if (CheckValidSession(o,null)){
				if (o.data == 'ok')
				{
					var star = $("#rating").val();

					if ($("#place_rate").html() == '0')
					{
						$("#place_rate").html(star);
						$("#place_rate_img img").attr('src','images/public/star/star_'+ star +'.gif');
					}
					else if ($("#place_rate").val() == '0')
					{
						$("#place_rate").val(star);
						$(".my_level p img").attr('src','images/public/star/star_'+ star +'.gif');
					}

					ShowPopUpDiv("succ",g_notice,g_addratsucc);
					HideRating();
				}
				else if (o.data == 'ALREADY_VOTED')
				{
					HideRating();
					ShowPopUpDiv("fail",g_notice,g_rate_has_voted);
					return;
				}
			}
			},
			complete:function(){
			},
			error:function(){
			}
		});
}

function SetRat(rat){
	for (var i=1;i<=5 ;i++ )
	{
		eval("obj=document.getElementById('ratingimg" + i + "')");
		obj.src = "images//public//star//star_out.gif";
	}
	eval("str= g_rat_" + rat);
	document.getElementById("ratingdesc").innerHTML = str;
	document.getElementById("rating").value = rat;
	document.getElementById("ratingbuf").innerHTML=rat;
	for (var i=1;i<=rat ;i++ )
	{
		eval("obj=document.getElementById('ratingimg" + i + "')");
		obj.src = "images//public//star//star_in.gif";
	}
}
//end of rating.js

//come from register.js
function changeYZM(){
	document.getElementById("imgyzm").src= g_hosturl + "/interface/genauthcode.php?rnd="+Math.random();
}

//end of register.js

//import complete.js
var complete = {};
var complete_var = {
	"selected":"#E9E9E9",
	'unselected':'#fff'
};

complete = {
	init: function(o,json){
		
		$(".down_list").html('');

		if (json != '')
		{
			var obj = json;
			var div = '<ul>';
			
			$(".down_list").show();

			if (obj.length < 1)
			{
				$(".down_list").append(g_search_result);
				$(".down_list").fadeOut('slow');
			}
			else
			{
				for (var i=0;i<obj.length ;i++ )
				{
					var lat = obj[i].latitude;
					var lng = obj[i].longitude;

					if (obj[i].address)
					{
						div += "<li onmouseout=\"complete.out(this)\" onmouseover=\"complete.over(this);\"  onclick=\"complete.clicked('"+ o +"',this,'"+ lat +"','"+ lng +"');\">" + obj[i].address + "</li>";
					}
				}
				
				div += '</ul>';
				
				$(".down_list").append(div);
			}
		}
	},

	over: function(o){
		if (o)
		{
			o.style.background = complete_var.selected;
		}
	},
	
	out: function(o){
		if (o)
		{
			o.style.background = complete_var.unselected;
		}
	},
	
	clicked: function(o,obj,lat,lng){
		$(".down_list").html('');
		$(".down_list").hide();
		$("#" + o).val(obj.textContent);

		if (lat && lng)
		{
			$("#lat").val(lat);
			$("#lng").val(lng);

			map.move(lat,lng);
		}
	}
}
//end of complete.js

//come from home.js
function AddFriend(friendid){
	var url = 'request/index.php?time='+Math.random();
	//var url = "addfriend.php";
		var jsonarr = {cmd:"friend_add",data:{action:"add",friendid:friendid}};
		var jsontxt = JSON.stringify(jsonarr);
	$.ajax({
		type:'get',
		url:url,
		data:{json:jsontxt},
		//data:{action:"add",friendid:friendid},
		timeout:90000,
		beforeSend:function(){
			showLoading();
		},
		success:function(text){
			var o = eval("("+text+")");
			if (CheckValidSession(o,null)){
			if (o.data=="ok")
			{
				ShowPopUpDiv("succ",g_notice,g_addfriendok);
			}
			else
				ShowPopUpDiv("fail",g_notice,o.data);
			}
		},
		complete:function(){
			showLoading();
		},
		error:function(){
		}
	});
}

function SetInappropriateUser(uid){
	SetInappropriate(uid,"people")
}

function SetInappropriate(id,ntype){
	if (window.confirm(g_confirmsetinappropriate))
	{

		var url = 'request/index.php?time='+Math.random();
	//var url = "setinappropriate.php";
		var jsonarr = {cmd:"inappropriate_set",data:{action:"set",id:id,ntype:ntype}};
		var jsontxt = JSON.stringify(jsonarr);
		$.ajax({
			type:'get',
			url:url,
			data:{json:jsontxt},
			//data:{action:"set",id:id,ntype:ntype},
			timeout:90000,
			beforeSend:function(){
			},
			success:function(text){
				var o = eval("("+text+")");
				if (CheckValidSession(o,null)){
					if (o.data=="ok")
					{
						ShowPopUpDiv("succ",g_notice,g_setinappropriatesucc);
					}
					else
						ShowPopUpDiv("fail",g_notice,o.data);
				}
			},
			complete:function(){
			},
			error:function(){
			}
		});
	}
}

function setstatus(refreshid){
	if (document.getElementById("newstatus").value=="" || document.getElementById("newstatus").value==g_addnewstatus)
	{
		ShowPopUpDiv('fail',g_notice,g_add_new_status);
		return;
	}
	
	var str = cTrim($("#newstatus").val());

	if (str == '')
	{
		ShowPopUpDiv('fail',g_notice,g_add_new_status);
		return;
	}

	if (str.length > 150)
	{
		ShowPopUpDiv("fail",g_notice,g_add_comment_words_overflow);
		return;
	}

	var url = 'request/index.php?time='+Math.random();
	var jsonarr = {cmd:"user_setstatus",data:{action:"set",status:document.getElementById("newstatus").value}};
	var jsontxt = JSON.stringify(jsonarr);

	$.ajax({
		type:'get',
		url:url,
		data:{json:jsontxt},
		timeout:90000,
		beforeSend:function(){
			showLoading();
		},
		success:function(text){
			var o = eval("("+text+")");
			if (CheckValidSession(o,null)){
			if (o.data=="ok")
			{
				document.getElementById("blogstatus").innerHTML = document.getElementById("newstatus").value;
				document.getElementById("newstatus").value="";
				if(refreshid!=undefined)LoadMiniBlogList(refreshid,1,'my');
			}
			else
			{
				ShowPopUpDiv("fail",g_notice,o.data);
			}
			}
		},
		complete:function(){
			showLoading();
		},
		error:function(){
			ShowPopUpDiv("fail",g_notice,g_load_failure);
		}
	});
}

function replyBlog(uid_creater,blogstatus){
	if (document.getElementById("replyblogcont").value=="" || document.getElementById("replyblogcont").value==g_replystatus)
	{
		ShowPopUpDiv('fail',g_notice,g_msg_subject);
		return;
	}
	var str = $("#replyblogcont").val().replace(/\s|　/gi,"");
	if (str == '')
	{
		ShowPopUpDiv('fail',g_notice,g_input_comment);
		return;
	}

	var url = 'request/index.php?time='+Math.random();
	//var url = "replyblog.php";
		var jsonarr = {cmd:"miniblog_reply",data:{action:"reply",uid_creater:uid_creater,blogid:"",oldstatus:blogstatus,replycont:document.getElementById("replyblogcont").value}};
		var jsontxt = JSON.stringify(jsonarr);
	$.ajax({
		type:'get',
		url:url,
		data:{json:jsontxt},
			//data:{action:"reply",uid_creater:uid_creater,blogid:"",oldstatus:blogstatus,replycont:document.getElementById("replyblogcont").value},
		timeout:90000,
		beforeSend:function(){
			showLoading();
		},
		success:function(text){
			var o = eval("("+text+")");
			if (CheckValidSession(o,null)){
			if (o.data=="ok")
			{
				$("#replyblogcont").val('');
				ShowPopUpDiv("succ",g_notice,g_replyblogok);
			}
			else
				ShowPopUpDiv("fail",g_notice,g_message_sent_failure);
			}
		},
		complete:function(){
			showLoading();
		},
		error:function(){
		}
	});
}
//end of home.js

//import countrycity.js
var countryArr = new Array('中国');
var provinceArr = new Array(1);
provinceArr[0] = new Array('北京市','重庆市','上海市','天津市','安徽省','福建省','甘肃省','广东省','广西自治区','贵州省','海南省','河北省','黑龙江省','河南省','湖北省','湖南省','江苏省','江西省','吉林省','辽宁省','内蒙古自治区','宁夏自治区','青海省','陕西省','山东省','山西省','四川省','新疆自治区','西藏自治区','云南省','浙江省');
var cityArr = new Array(1);
cityArr[0] = new Array(1);
cityArr[0][0] = new Array(' 东城区',' 西城区',' 崇文区',' 宣武区',' 朝阳区',' 丰台区',' 石景山区',' 海淀区',' 门头沟区',' 房山区',' 通州区',' 顺义区',' 昌平区',' 大兴区',' 怀柔区',' 平谷区',' 密云县',' 延庆县');
cityArr[0][1] = new Array(' 万州区',' 涪陵区',' 渝中区',' 大渡口区',' 江北区',' 沙坪坝区',' 九龙坡区',' 南岸区',' 北碚区',' 万盛区',' 双桥区',' 渝北区',' 巴南区',' 黔江区',' 长寿区',' 綦江县',' 潼南县',' 铜梁县',' 大足县',' 荣昌县',' 璧山县',' 梁平县',' 城口县',' 丰都县',' 垫江县',' 武隆县',' 忠县',' 开县',' 云阳县',' 奉节县',' 巫山县',' 巫溪县',' 石柱土家族自治县',' 秀山土家族苗族自治县',' 酉阳土家族苗族自治县',' 彭水苗族土家族自治县',' 江津市',' 合川市',' 永川市',' 南川市');
cityArr[0][2] = new Array(' 黄浦区',' 卢湾区',' 徐汇区',' 长宁区',' 静安区',' 普陀区',' 闸北区',' 虹口区',' 杨浦区',' 闵行区',' 宝山区',' 嘉定区',' 浦东新区',' 金山区',' 松江区',' 青浦区',' 南汇区',' 奉贤区',' 崇明县');
cityArr[0][3] = new Array(' 和平区',' 河东区',' 河西区',' 南开区',' 河北区',' 红桥区',' 塘沽区',' 汉沽区',' 大港区',' 东丽区',' 西青区',' 津南区',' 北辰区',' 武清区',' 宝坻区',' 宁河县',' 静海县',' 蓟县');
cityArr[0][4] = new Array(' 合肥市',' 芜湖市',' 蚌埠市',' 淮南市',' 马鞍山市',' 淮北市',' 铜陵市',' 安庆市',' 黄山市',' 滁州市',' 阜阳市',' 宿州市',' 巢湖市',' 六安市',' 亳州市',' 池州市',' 宣城市');
cityArr[0][5] = new Array(' 福州市',' 厦门市',' 莆田市',' 三明市',' 泉州市',' 漳州市',' 南平市',' 龙岩市',' 宁德市');
cityArr[0][6] = new Array(' 兰州市',' 嘉峪关市',' 金昌市',' 白银市',' 天水市',' 武威市',' 张掖市',' 平凉市',' 酒泉市',' 庆阳市',' 定西市',' 陇南市',' 临夏回族自治州',' 甘南藏族自治州');
cityArr[0][7] = new Array(' 韶关市',' 深圳市',' 珠海市',' 汕头市',' 佛山市',' 江门市',' 湛江市',' 茂名市',' 肇庆市',' 惠州市',' 梅州市',' 汕尾市',' 河源市',' 阳江市',' 清远市',' 东莞市',' 中山市',' 潮州市',' 揭阳市',' 云浮市',' 东沙群岛',' 广州市');
cityArr[0][8] = new Array(' 南宁市',' 柳州市',' 桂林市',' 梧州市',' 北海市',' 防城港市',' 钦州市',' 贵港市',' 玉林市',' 百色市',' 贺州市',' 河池市',' 来宾市',' 崇左市');
cityArr[0][9] = new Array(' 贵阳市',' 六盘水市',' 遵义市',' 安顺市',' 铜仁地区',' 黔西南布依族苗族自治州',' 毕节地区',' 黔东南苗族侗族自治州',' 黔南布依族苗族自治州');
cityArr[0][10] = new Array(' 海口市',' 三亚市');
cityArr[0][11] = new Array(' 石家庄市',' 唐山市',' 秦皇岛市',' 邯郸市',' 邢台市',' 保定市',' 张家口市',' 承德市',' 沧州市',' 廊坊市',' 衡水市');
cityArr[0][12] = new Array(' 哈尔滨市',' 齐齐哈尔市',' 鸡西市',' 鹤岗市',' 双鸭山市',' 大庆市',' 伊春市',' 佳木斯市',' 七台河市',' 牡丹江市',' 黑河市',' 绥化市',' 大兴安岭地区');
cityArr[0][13] = new Array(' 郑州市',' 开封市',' 洛阳市',' 平顶山市',' 安阳市',' 鹤壁市',' 新乡市',' 焦作市',' 濮阳市',' 许昌市',' 漯河市',' 三门峡市',' 南阳市',' 商丘市',' 信阳市',' 周口市',' 驻马店市');
cityArr[0][14] = new Array(' 武汉市',' 黄石市',' 十堰市',' 宜昌市',' 襄樊市',' 鄂州市',' 荆门市',' 孝感市',' 荆州市',' 黄冈市',' 咸宁市',' 随州市',' 恩施土家族苗族自治州');
cityArr[0][15] = new Array(' 长沙市',' 株洲市',' 湘潭市',' 衡阳市',' 邵阳市',' 岳阳市',' 常德市',' 张家界市',' 益阳市',' 郴州市',' 永州市',' 怀化市',' 娄底市',' 湘西土家族苗族自治州');
cityArr[0][16] = new Array(' 南京市',' 无锡市',' 徐州市',' 常州市',' 苏州市',' 南通市',' 连云港市',' 淮安市',' 盐城市',' 扬州市',' 镇江市',' 泰州市',' 宿迁市');
cityArr[0][17] = new Array(' 南昌市',' 景德镇市',' 萍乡市',' 九江市',' 新余市',' 鹰潭市',' 赣州市',' 吉安市',' 宜春市',' 抚州市',' 上饶市');
cityArr[0][18] = new Array(' 长春市',' 吉林市',' 四平市',' 辽源市',' 通化市',' 白山市',' 松原市',' 白城市',' 延边朝鲜族自治州');
cityArr[0][19] = new Array(' 沈阳市',' 大连市',' 鞍山市',' 抚顺市',' 本溪市',' 丹东市',' 锦州市',' 营口市',' 阜新市',' 辽阳市',' 盘锦市',' 铁岭市',' 朝阳市',' 葫芦岛市');
cityArr[0][20] = new Array(' 呼和浩特市',' 包头市',' 乌海市',' 赤峰市',' 通辽市',' 鄂尔多斯市',' 呼伦贝尔市',' 巴彦淖尔市',' 乌兰察布市',' 兴安盟',' 锡林郭勒盟',' 阿拉善盟');
cityArr[0][21] = new Array(' 银川市',' 石嘴山市',' 吴忠市',' 固原市',' 中卫市');
cityArr[0][22] = new Array(' 西宁市',' 海东地区',' 海北藏族自治州',' 黄南藏族自治州',' 海南藏族自治州',' 果洛藏族自治州',' 玉树藏族自治州',' 海西蒙古族藏族自治州');
cityArr[0][23] = new Array(' 西安市',' 铜川市',' 宝鸡市',' 咸阳市',' 渭南市',' 延安市',' 汉中市',' 榆林市',' 安康市',' 商洛市');
cityArr[0][24] = new Array(' 济南市',' 青岛市',' 淄博市',' 枣庄市',' 东营市',' 烟台市',' 潍坊市',' 济宁市',' 泰安市',' 威海市',' 日照市',' 莱芜市',' 临沂市',' 德州市',' 聊城市',' 滨州市',' 菏泽市');
cityArr[0][25] = new Array(' 太原市',' 大同市',' 阳泉市',' 长治市',' 晋城市',' 朔州市',' 晋中市',' 运城市',' 忻州市',' 临汾市',' 吕梁市');
cityArr[0][26] = new Array(' 成都市',' 自贡市',' 攀枝花市',' 泸州市',' 德阳市',' 绵阳市',' 广元市',' 遂宁市',' 内江市',' 乐山市',' 南充市',' 眉山市',' 宜宾市',' 广安市',' 达州市',' 雅安市',' 巴中市',' 资阳市',' 阿坝藏族羌族自治州',' 甘孜藏族自治州',' 凉山彝族自治州');
cityArr[0][27] = new Array(' 乌鲁木齐市',' 克拉玛依市',' 吐鲁番地区',' 哈密地区',' 昌吉回族自治州',' 博尔塔拉蒙古自治州',' 巴音郭楞蒙古自治州',' 阿克苏地区',' 克孜勒苏柯尔克孜自治州',' 喀什地区',' 和田地区',' 伊犁哈萨克自治州',' 塔城地区',' 阿勒泰地区');
cityArr[0][28] = new Array(' 拉萨市',' 昌都地区',' 山南地区',' 日喀则地区',' 那曲地区',' 阿里地区',' 林芝地区');
cityArr[0][29] = new Array(' 昆明市',' 曲靖市',' 玉溪市',' 保山市',' 昭通市',' 丽江市',' 思茅市',' 临沧市',' 楚雄彝族自治州',' 红河哈尼族彝族自治州',' 文山壮族苗族自治州',' 西双版纳傣族自治州',' 大理白族自治州',' 德宏傣族景颇族自治州',' 怒江傈僳族自治州',' 迪庆藏族自治州');
cityArr[0][30] = new Array(' 杭州市',' 宁波市',' 温州市',' 嘉兴市',' 湖州市',' 绍兴市',' 金华市',' 衢州市',' 舟山市',' 台州市',' 丽水市');

function BindCountry(){
	if (document.getElementById("country"))
	{
		var value="";
		for(var i=0;i < countryArr.length ;i++)
		{
			value=countryArr[i];
			document.getElementById("country").options.add(new Option(" "+ value +" ", value));
		}
	}
}

function SelecteProvince(){
	var objprovince = document.getElementById("province");
	var option_province = objprovince.options[0];
	objprovince.options.length=0;
	objprovince.options.add(option_province); 
	
	var objcity = document.getElementById("city");
	var option_city = objcity.options[0];
	objcity.options.length=0;
	objcity.options.add(option_city);

	var value="";
	var selindex =  document.getElementById("country").selectedIndex;
	if (selindex==0)
	{
		return;
	}
	selindex = selindex - 1;
	for(var i=0;i < provinceArr[selindex].length ;i++)
	{
		value=provinceArr[selindex][i];
		document.getElementById("province").options.add(new Option(" "+ value +" ", value));
	}
	

}

function SelecteCity(){
	var objcity = document.getElementById("city");
	var option_city = objcity.options[0];
	objcity.options.length=0;
	objcity.options.add(option_city);

	var value="";
	var selindex1 =  document.getElementById("country").selectedIndex;
	if (selindex1 == 0)
	{
		return;
	}
	selindex1 = selindex1 - 1;
	var selindex2 =  document.getElementById("province").selectedIndex;
	if (selindex2 == 0)
	{
		return;
	}
	selindex2 = selindex2 - 1;
	for(var i=0;i < cityArr[selindex1][selindex2].length ;i++)
	{
		value=cityArr[selindex1][selindex2][i];
		document.getElementById("city").options.add(new Option(" "+ value +" ", value));
	}
}
//end of countrycity.js

//关闭消息提示框
function msgClose()
{
	$("#scroll").hide();
}

function getMsg()
{
	var type = GetCookie("msg_type");
	var url = '';

	if (type == 1)
	{
		url = 'inbox.php';
	}
	else if(type == 2)
	{
		url = 'invite.php?act=inbox';
	}

	window.location.href = url;
}

function CheckValidSession(jsonobj,elemtobj){
	if (jsonobj)
	{
		if (jsonobj.rsp=="0")
		{
			if (jsonobj.msg=="1001")
			{
				if (elemtobj)
				{
					elemtobj.innerHTML='';
				}
				ShowPopUpDiv("fail",g_notice,g_sessioninvalid);
				return false;
			}
		}
	}
	return true;
}

//替换全角和英文的空格
function cTrim(str)
{
	str = $.trim(str);
	str = str.replace(/\s|　/gi,"");
	str = str.replace("<","");
	str = str.replace(">","");
	str = str.replace("&","");

	return str;
}

function string_replace(str){
	return str.replace(/(^\s*)|(\s*$)/g, "");
}