var waitingFriendRequests=0;var waitingFriendIntroductions=0;var unreadMessagesNum=0;var totalEventInvitations=0;var totalGroupInvitations=0;var totalGroupRequests=0;var totalNotificationNews=0;var totalLocationInvitations=0;var totalPollInvitations=0;var totalUblogMessages=0;var NOTIFICATION_REQUEST=1;var NOTIFICATION_INTRODUCTION=1;var NOTIFICATION_UNREADMSG=1;var NOTIFICATION_TRIGMSG=0;var NOTIFICATION_GRPREQUEST=1;var weather_forecast=null;var myCurrentlyLocationRow=-1;var pollInviteWin=null;var now_online_friends=null;var myLocationsData=[];var unknowLocationData=null;var locationData=null;var myFriendsData=[];var myGroupsData=[];var friendsLabelData=[];var myUrbianData=[];var friendsAndlabelsData=[];function _C(A){return document.createElement(A)}function _GT(A){return document.getElementsByTagName(A)}function _CT(E,A,C,D){var B=_C("table");B.id=E;B.cellPadding=C!=""?C:0;B.cellSpacing=D!=""?D:0;B.width=A!=""?A:"100%";B.className="smallText";return B}function _CD(F,D,A,C,B){var E=_C("div");E.id=F!=""?F:"";if(D!=""){E.style.width=D}if(A!=""){E.style.height=A}E.style.border=C;E.className=B!=""?B:"";return E}function checkImage(A,D,C){var B=new Image();B.src=D;var E;if(C==null||C==""||C=="_s"){E=50}else{if(C=="medium"||C=="_m"){E=80}}var F=setInterval(function(){if(B.width>0){clearInterval(F);if(B.width<E&&B.height<E){A.style.marginTop=Math.round((E-B.height)/2)+"px";A.style.marginLeft=Math.round((E-B.width)/2)+"px"}else{if(B.width>B.height){A.style.width=E+"px";A.style.height=Math.round((B.height*E)/B.width)+"px";A.style.marginTop=Math.round((E-parseInt(A.style.height))/2)+"px"}else{if(B.width<=B.height){A.style.height=E+"px";A.style.width=Math.round((B.width*E)/B.height)+"px";A.style.marginLeft=Math.round((E-parseInt(A.style.width))/2)+"px"}}}A.style.display="";B=null}},5)}function addThumbImage(C,G,F,D,E,B){var A=_C("img");A.style.cursor="pointer";A.style.display="none";A.alt=F;if(G==undefined||G.length<4){if(C=="user"){if(E==null||E==""){G=STATIC_IMAGE_PATH+"user_defaultsmall"}else{G=STATIC_IMAGE_PATH+"user_defaultmedium"}}else{if(C=="group"){if(E==null||E==""){G=STATIC_IMAGE_PATH+"group_defaultsmall"}else{G=STATIC_IMAGE_PATH+"group_defaultmedium"}}else{if(C=="location"){if(E==null||E==""){G=STATIC_IMAGE_PATH+"loc_defaultsmall"}else{G=STATIC_IMAGE_PATH+"loc_defaultmedium"}}}}}else{A.style.border="1px solid #ccc";if(E==null||E==""){G=USERS_IMAGE_PATH+"/"+G+"small"}else{G=USERS_IMAGE_PATH+"/"+G+E}}A.onload=function(){checkImage(this,G,E)};A.src=G;if(D!=""){A.onclick=function(){document.location.href=D}}return A}function createNormalBox(E,G,B,A,F,C){var D=new Ext.Window({title:E,width:B,height:A,shadow:false,id:G,layout:"fit",modal:true,resizable:false,plain:true,html:"<div id='boxDiv' style='width:100%;height:100%;padding:5px;text-align:left;'></div>",buttons:[{text:sendText,handler:function(){F(D,G)}},{text:cancelText,handler:function(){D.close()}}]});D.show();C(D)}function showAlert(C){$("urbianErrStr").innerHTML="";var B=_C("table");B.className="urbianErrCon";tr=B.insertRow(0);con=tr.insertCell(0);con.align="center";con.style.padding="10px 20px 10px 20px";con.innerHTML=C;$("urbianErrStr").appendChild(B);var A=setTimeout(function(){Effect.BlindUp("urbianErr",11)},4500);Effect.BlindDown("urbianErr",11)}Ext.onReady(function(){if(typeof errorMessage!="undefined"&&errorMessage.length>0){showAlert(errorMessage)}});function addChangeBox(F,C,A){var E;if(!$(F)){var D=_C("div");D.id=F;D.className="my_status_div";D.style.width="0px";D.style.height="0px";D.style.zIndex=999999;$("p_set_div").innerHTML="";$("p_set_div").style.top=C+"px";$("p_set_div").appendChild(D);var B=_C("div");B.className="arrow_div";D.appendChild(B);E=setInterval(function(){if(parseInt(D.style.width)<180){D.style.width=parseInt(D.style.width)+18+"px";D.style.height=parseInt(D.style.height)+3+"px"}else{clearInterval(E);var G=_C("input");G.id=A;G.name=A;G.className="inputText";G.style.border="0px";G.style.width="175px";G.style.height="26px";G.maxLength=100;G.onkeyup=function(H){H=H||event;if(A=="meLocation"){if(Ext.isIE6||Ext.isIE7){var I="-114px"}else{var I="20px"}showMyLocationSuggestionBox(H,"meLocation","myLocationSuggestFrame","myLocationSuggestDiv",I,"")}else{if(A=="meStatus"){enterStatus(H)}}};G.onblur=function(){if(myCurrentlyLocationRow==-1){hideStatusBox(F)}};D.appendChild(G);G.focus()}},10)}}function noLocation(){var C;if(!$("nolocationDiv")){var B=_C("div");B.id="nolocationDiv";B.className="my_status_div";B.style.width="0px";B.style.height="0px";B.style.zIndex=999999;$("p_set_div").innerHTML="";$("p_set_div").style.top="10px";$("p_set_div").appendChild(B);var A=_C("div");A.className="arrow_div";B.appendChild(A);C=setInterval(function(){if(parseInt(B.style.width)<180){B.style.width=parseInt(B.style.width)+18+"px";B.style.height=parseInt(B.style.height)+3+"px"}else{clearInterval(C);var D=_C("div");D.className="smallText";D.style.padding="2px";D.innerHTML=whereAreYouHelp;B.appendChild(D)}},10)}else{hideStatusBox("nolocationDiv")}}function checkAndGetAllMyLocations(type){if($("nolocationDiv")){hideStatusBox("nolocationDiv")}else{Ext.Ajax.request({url:"ajax/get_all_my_locations.php",success:function(callBackStr,action){var obj=eval("["+callBackStr.responseText+"]");myLocationsData=obj[0];if(type=="change"){$("myLocationSuggestDiv").innerHTML="";$("myLocationSuggestFrame").style.display="none"}else{if(type=="new"){if(myLocationsData!=null&&myLocationsData.length>0){if(!$("myLocation_div")){addChangeBox("myLocation_div",10,"meLocation");if(Ext.isIE6||Ext.isIE7){$("myLocationSuggestFrame").style.left="-114px"}else{$("myLocationSuggestFrame").style.left="20px"}$("myLocationSuggestDiv").innerHTML="";$("myLocationSuggestFrame").style.display="none"}}else{noLocation()}}}},failure:function(obj,action){Ext.MessageBox.alert("Connection error","A network error occured during connection, please try again shortly.")}})}}function changeMyLocation(){if(!$("myLocation_div")){addChangeBox("myLocation_div",10,"meLocation");$("myLocationSuggestDiv").innerHTML=loadingText;if(Ext.isIE6||Ext.isIE7){$("myLocationSuggestFrame").style.left="-114px"}else{$("myLocationSuggestFrame").style.left="20px"}$("myLocationSuggestFrame").style.display="";if(myLocationsData==null){checkAndGetAllMyLocations("change")}else{$("myLocationSuggestDiv").innerHTML="";$("myLocationSuggestFrame").style.display="none"}}else{$("myLocationSuggestDiv").innerHTML="";$("myLocationSuggestFrame").style.display="none";hideStatusBox("myLocation_div")}}function chkMyLocationKeyword(N,C){if(C=="my"){locationData=myLocationsData}else{if(C=="unknow"){locationData=unknowLocationData}}myCurrentlyLocationRow=-1;var F=[];var P=N.toLowerCase().split(" ");var G,D,L,M,R,H,Q;var E=0;var B=0;var O="";var A=0;for(var I=0;I<P.length;I++){Q=P[I].trim();if(Q!=""){A++}}for(var K=0;K<locationData.length;K++){G=locationData[K]["name"];D=locationData[K]["name"].toLowerCase();L=G.split(" ");M=D.split(" ");O="";B=0;for(var J=0;J<M.length;J++){R=M[J].trim();if(R!=""){for(var I=0;I<P.length;I++){Q=P[I].trim();if(Q!=""&&O.indexOf(I)<0){H=Q.length;if(R.substring(0,H)==Q){O+=I+",";B++;L[J]='<span style="background-color:#ddd;"><b>'+L[J].substring(0,H)+"</b></span>"+L[J].substring(H,L[J].length);break}}}}}if(B==A){if(typeof (F[E])=="undefined"){F[E]=[]}F[E]["index"]=K;if(typeof (F[E]["username"])=="undefined"){F[E]["username"]=[]}F[E]["username"]=L.join(" ");E++}if(E>10){break}}return F}var searchTimer=null;function showMyLocationSuggestionBox(M,D,G,I,R,O){clearTimeout(searchTimer);if(M.keyCode==40){if($("resultTable")){myCurrentlyLocationRow++;$(I).style.display="";$("resultTable").onmouseover()}}else{if(M.keyCode==38){if($("resultTable")){myCurrentlyLocationRow--;$(I).style.display="";$("resultTable").onmouseover()}}else{if(M.keyCode==13){if(myCurrentlyLocationRow>=0&&$("resultTable")){$("resultTable").onclick()}}else{var N=$(D).value.trim();$(G).style.display="none";if(N!=""){$(G).style.left=R;$(I).innerHTML="";var P=new Array();var H,B,K,Q,J,F,L,A,E,C;P=chkMyLocationKeyword(N,"my");if(P.length>0){createMatchLocationsList(P,I,G,O)}else{if(N.length>2){searchInAllLocations(N,I,G,O)}}}}}}}function createMatchLocationsList(H,A,C,I){$(C).style.display="";var G,K,E,L,J,D,B;L=_CT("resultTable","184px",0,0);$(A).appendChild(L);for(var F=0;F<H.length;F++){J=L.insertRow(F);J.id="tr_"+H[F]["index"]+"_"+F;J.onmouseover=function(){var M=this.id.split("_");myCurrentlyLocationRow=M[2]};D=J.insertCell(0);D.width="10%";D.style.borderBottom="1px solid #ddd";D.align="right";D.style.paddingTop="4px";D.style.paddingRight="2px";G=_C("img");if(locationData[H[F]["index"]]["image"]==""){if(typeof (locationData[H[F]["index"]]["location_id"])=="undefined"){image=STATIC_IMAGE_PATH+"user_defaultsmall"}else{image=STATIC_IMAGE_PATH+"loc_defaulticon.png"}}else{image=USERS_IMAGE_PATH+"/"+locationData[H[F]["index"]]["image"]+"small"}G.src=image;G.className="nowOnline_img";D.appendChild(G);D=J.insertCell(1);D.width="90%";D.style.borderBottom="1px solid #ddd";B=locationData[H[F]["index"]]["address"]+"&nbsp;";D.innerHTML="<div class='smallText' style='width:152px;height:13px;overflow:hidden;'>"+H[F]["username"]+"</div><div class='smallTextLight' style='width:152px;height:13px;overflow:hidden;'>"+B+"</div>"}if($("resultTable")){$("resultTable").onmouseover=function(){disappear=false;if(myCurrentlyLocationRow>this.rows.length-1){myCurrentlyLocationRow=0}else{if(myCurrentlyLocationRow<0){myCurrentlyLocationRow=-1}}for(var M=0;M<this.rows.length;M++){if(M==myCurrentlyLocationRow){this.rows[M].style.backgroundColor="#ddd"}else{this.rows[M].style.backgroundColor=""}}disappear=true};$("resultTable").onclick=function(){if(myCurrentlyLocationRow>-1){var M=this.rows[myCurrentlyLocationRow].id.split("_");$(A).innerHTML="";$(C).style.display="none";showPrivacyOptions(M[1],C,A,I)}};$("resultTable").onmouseout=function(){disappear=true}}}function searchInAllLocations(keyword,id,frame,closeDiv,myres){searchTimer=setTimeout(function(){$(frame).style.display="";$(id).innerHTML=loadingText;Ext.Ajax.request({url:"ajax/currently_at.php",method:"POST",params:{keyword:keyword},success:function(callBackStr,action){var obj=eval("["+callBackStr.responseText+"]");unknowLocationData=obj[0];$(id).innerHTML="";var res=chkMyLocationKeyword(keyword,"unknow");if(res.length>0){createMatchLocationsList(res,id,frame,closeDiv)}},failure:function(obj,action){Ext.MessageBox.alert("Connection error","A network error occured during connection, please try again shortly.")}})},1000)}function showPrivacyOptions(B,D,E,A){var C=_CT("resultTable","100%",0,0);$(E).appendChild(C);$(D).style.display="";tr=C.insertRow(0);td=tr.insertCell(0);td.width="10%";td.style.borderWidth="1px";td.style.borderBottomStyle="solid";td.style.borderColor="#ddd";td.align="right";td.style.paddingTop="4px";td.style.paddingRight="2px";img=_C("img");if(locationData[B]["image"]==""){if(typeof (locationData[B]["location_id"])=="undefined"){image=STATIC_IMAGE_PATH+"user_defaultsmall"}else{image=STATIC_IMAGE_PATH+"loc_defaulticon.png"}}else{image=USERS_IMAGE_PATH+"/"+locationData[B]["image"]+"small"}img.src=image;img.className="nowOnline_img";td.appendChild(img);td=tr.insertCell(1);td.width="90%";td.style.borderWidth="1px";td.style.borderBottomStyle="solid";td.style.borderColor="#ddd";job=locationData[B]["address"]+"&nbsp;";td.innerHTML="<div class='smallText' style='width:152px;height:13px;overflow:hidden;'>"+locationData[B]["name"]+"</div><div class='smallTextLight'>"+job+"</div>";tr=C.insertRow(1);td=tr.insertCell(0);td.colSpan=2;td.style.padding="4px";td.className="smallText";td.innerHTML="<b>"+locationPrivacy+": "+plsChooseOne+"</b><br /><a href='javascript:void(0);' onclick='javascript:saveMyCurrentlyLocation("+B+', 1, "'+A+"\");'>"+locationPrivacy_0+"</a><br /><a href='javascript:void(0);' onclick='javascript:saveMyCurrentlyLocation("+B+', 2, "'+A+"\");'>"+locationPrivacy_1+"</a><br /><a href='javascript:void(0);' onclick='javascript:saveMyCurrentlyLocation("+B+', 3, "'+A+"\");'>"+locationPrivacy_2+"</a>"}function saveMyCurrentlyLocation(C,B,A){if($("myLocationLink")){hideStatusBox("myLocation_div")}Ext.Ajax.request({url:"ajax/set_current_location.php",method:"POST",params:{location_id:locationData[C]["location_id"],longitude:locationData[C]["longitude"],latitude:locationData[C]["latitude"],privacy:B},success:function(D,E){if($("myLocationLink")){$("myLocationLink").innerHTML=locationData[C]["name"]}else{$("atSpan").style.display="";$("noLocationLink").innerHTML=locationData[C]["name"];$("noLocationLink").id="myLocationLink";$("noLocationLink").onclick=function(){changeMyLocation()}}if($("currentLocationDiv")&&$("displayLocationDiv")){my_current_location_ID=locationData[C]["location_id"];map.closeInfoWindow();map.clearOverlays();current_markers=[];current_locations=[];$("currentLocationDiv").style.display="none";showWinLocationID=locationData[C]["location_id"];map.panTo(new GLatLng(locationData[C]["latitude"],locationData[C]["longitude"]));$("displayLocationDiv").innerHTML="<a href='javascript:void(0);' onclick='javascript:showSelectCurrentLocation();'>"+imCurrentAt+"&nbsp;</a><a href='javascript:void(0);' onclick='javascript:goToLocation(\""+locationData[C]["longitude"]+'", "'+locationData[C]["latitude"]+'", "'+locationData[C]["location_id"]+"\")'><b>"+locationData[C]["name"]+"</b></a>"}if($(A)){$(A).onclick()}},failure:function(){Ext.MessageBox.alert("Connection error","A network error occured during connection, please try again shortly.")}})}function changeStatus(){addChangeBox("myStatus_div",-10,"meStatus")}function hideStatusBox(B){var A=$(B);if(B=="myLocation_div"){myCurrentlyLocationRow=-1;$("myLocationSuggestDiv").innerHTML="";$("myLocationSuggestFrame").style.display="none"}$("p_set_div").innerHTML=""}function saveStatus(){var status=$("meStatus").value.trim();hideStatusBox("myStatus_div");Ext.Ajax.request({url:"ajax/change_user_status.php",method:"POST",params:{status:status},success:function(callBackStr,action){var obj=eval(callBackStr.responseText);showStatus(obj,status)},failure:function(obj,action){Ext.MessageBox.alert("Connection error","A network error occured during connection, please try again shortly.")}})}function showStatus(B,A){if(B[0].trim()==""){$("tr_nowStatus").title=setStatusHere;$("now_status").innerHTML=setStatusHere}else{$("tr_nowStatus").title=B[1];$("now_status").innerHTML=B[1]}if(B[2]>0){syncStatus(A)}}function syncStatus(A){Ext.Ajax.request({url:"ajax/sync_status.php",method:"POST",params:{status:A},success:function(B,C){},failure:function(C,B){Ext.MessageBox.alert("Connection error","A network error occured during connection, please try again shortly.")}})}function enterStatus(A){if(A.keyCode==13){saveStatus()}}function changeImageSrc(B,A){document.getElementById(B).src=A}function changeStyle(B,A){document.getElementById(B).className=A}function createDraggable(A){new Draggable(A,{revert:true,scroll:window})}function createDraggableNoRevert(A){new Draggable(A,{revert:false,scroll:window})}function HTMLEncode(A){var C=_C("div");var B=document.createTextNode(A);C.appendChild(B);return C.innerHTML}function playAnimation(A){var B=new Ext.Window({title:watcheAnimation,width:500,height:450,modal:true,plain:true,buttonAlign:"center",autoLoad:{url:"animation.php?type="+A},buttons:[{text:offText,handler:function(){B.close()}}]});B.show()}var imageSwitch="off";if(imageSwitch=="off"){var STATIC_IMAGE_PATH=amazon_static_image;var USERS_IMAGE_PATH=partner_user_files}else{var STATIC_IMAGE_PATH="../images";var USERS_IMAGE_PATH="http://userfiles.urbian.org";if(Ext.isIE6){STATIC_IMAGE_PATH="../ie6/images"}}function showToolTip(D,B,C,A){div=_C("div");div.className="toolbar_pop";div.innerHTML=B;$(D).appendChild(div)}function hideToolTip(A){$(A).innerHTML=""}function checkstr(D,A){var E=D;var C="+/=<>%&'\\\"-,*";var F="";for(var B=0;B<E.length;B++){if(C.indexOf(E.charAt(B))>-1){F=E.charAt(B);return"("+F+")"+A}}return""}function checklen(F,E,B,C,D){var A=getLength(F.trim());if(A<E){if(C.indexOf("[0]")>-1){C=C.replace("[0]",E)}return C}else{if(A>B){if(D.indexOf("[0]")>-1){D=D.replace("[0]",B)}return D}else{return""}}}function getLength(C){var A=0;for(var B=0;B<C.length;B++){if(C.charCodeAt(B)>127){A+=3}else{A++}}return A}function cutdownstr(B,A){if(A<B.length){B=B.slice(0,A)}return B}function getFormatDate(H){var F=new Date();var D=Date.parseDate(F.format("Y-m-d H:i:s"),"Y-m-d H:i:s").valueOf();var B=new Date(H.substring(0,4),parseInt(H.substring(5,7))-1,H.substring(8,10),H.substring(11,13),H.substring(14,16),H.substring(17,19));if(D>=B){var A=Math.floor((D-B)/(60*60*1000));if(A==0){var E=Math.floor((D-B)/(60*1000));return E+minutesAgo}else{if(A<24){return A+hoursAgo}else{var G=Math.floor(A/24);if(G<=6){if(G==1){return G+dayAgo}else{return G+daysAgo}}else{var C=Date.parseDate(H,"Y-m-d h:i:s");if(currentLanguage=="ZH"){return C.format("n"+monthText+"j"+dayText)}else{return C.format("F j")}}}}}else{var C=Date.parseDate(H,"Y-m-d h:i:s");if(currentLanguage=="ZH"){return C.format("n"+monthText+"j"+dayText)}else{return C.format("F j")}}}function getLanguageDate(B){var A=Date.parseDate(B,"Y-m-d h:i:s");if(currentLanguage=="ZH"){return A.format("n"+monthText+"j"+dayText)}else{return A.format("F j")}}function cutLongWord(A){if(!Ext.isIE){$(A).innerHTML=$(A).innerHTML.split("").join("&#8203;")}}function htmlspecial_back(A){A=A.replace(/&lt;/g,"<");A=A.replace(/&gt;/g,">");A=A.replace(/&nbsp;/g," ");A=A.replace(/&amp;/g,"&");A=A.replace(/&quot;/g,'"');A=A.replace(/&times;/g,"×");A=A.replace(/&devide;/g,"÷");A=A.replace(/&copy;/g,"©");A=A.replace(/&reg;/g,"®");A=A.replace(/&trade;/g,"™");A=A.replace(/&sect;/g,"§");return A}function feedback(){var C=new Ext.data.SimpleStore({fields:["catname","value"],data:feedbacktype});var B=new Ext.form.ComboBox({store:C,name:"selecttype",fieldLabel:feedbackLabel,displayField:"catname",valueField:"value",typeAhead:true,mode:"local",triggerAction:"all",editable:false,value:"general",listAlign:"tl",selectOnFocus:true});var D=new Ext.form.FormPanel({baseCls:"x-plain",labelWidth:60,defaultType:"textfield",waitMsgTarget:true,items:[{xtype:"hidden",name:"url",id:"url",value:document.location.href},B,{xtype:"textarea",id:"fbcontent",hideLabel:true,height:80,name:"fbcontent",emptyText:feedbackDefault,anchor:"100%"}]});var A=new Ext.Window({title:feedbackTitle,modal:true,width:320,height:222,layout:"fit",plain:true,buttonAlign:"center",items:D,buttons:[{text:feedbackSave,handler:function(){if($("fbcontent").value==""||$("fbcontent").value==feedbackDefault||B.getValue()==""){return }else{Ext.Ajax.request({url:"ajax/feedback.php",method:"POST",params:{type:B.getValue(),content:$("fbcontent").value,url:$("url").value},success:function(E,F){if(E.responseText=="addSucc"){Ext.MessageBox.alert(feedbackTitle,feedbackSucc)}},failure:function(F,E){Ext.MessageBox.alert("Connection error","A network error occured during connection, please try again shortly.")}});A.close()}}},{text:feedbackCancel,handler:function(){A.close()}}]});A.show()}function goSearch(B,A){setTimeout(function(){document.location.href=encodeURI("friends_search.php?type="+B+"&key="+encodeURI(A))},10)}function setTimezone(){d=new Date();Ext.Ajax.request({url:"ajax/set_timezone.php",method:"POST",params:{timezone:d.getTimezoneOffset()},success:function(A,B){},failure:function(B,A){Ext.MessageBox.alert("Connection error","A network error occured during connection, please try again shortly.")}})}function showNotification(){if(waitingFriendRequests>0||waitingFriendIntroductions>0||unreadMessagesNum>0||totalEventInvitations>0||totalGroupInvitations>0||totalGroupRequests>0||totalLocationInvitations>0||totalPollInvitations>0||totalUblogMessages>0){var B=$("notificationDiv");B.style.display="";var A;A=setInterval(function(){if(parseInt(B.style.height)<30){B.style.height=parseInt(B.style.height)+5+"px"}else{clearInterval(A);B=$("notificationItemsDiv");B.innerHTML="";if(waitingFriendRequests>0){addNotificationDiv(B,"al_f_request",waitingFriendRequests,friendRequestsText,"friends_request.php?type=all")}if(waitingFriendIntroductions>0){addNotificationDiv(B,"al_f_introduction",waitingFriendIntroductions,friendIntroductionsText,"friends_introductions.php")}if(unreadMessagesNum>0){addNotificationDiv(B,"al_message",unreadMessagesNum,newMessagesText,"messages.php?unread=1")}if(totalEventInvitations>0){addNotificationDiv(B,"al_calendar",totalEventInvitations,newInvitationsText,"#")}if(totalGroupInvitations>0){addNotificationDiv(B,"al_g_invitation",totalGroupInvitations,groupInvitationsText,"group_invitation.php")}if(totalGroupRequests>0){addNotificationDiv(B,"al_g_request",totalGroupRequests,groupRequestsText,"groups_request.php")}if(totalLocationInvitations>0){addNotificationDiv(B,"al_l_invitation",totalLocationInvitations,locationInvitationsText,"locations.php?act=inv")}if(totalPollInvitations>0){addNotificationDiv(B,"al_p_invitation",totalPollInvitations,pollInvitationText,"javascript:getPollInvitations();")}if(totalUblogMessages>0){addNotificationDiv(B,"al_u_message",totalUblogMessages,uBlogsMessagesText,"board.php")}}},10);if(totalNotificationNews>0){if(document.title.substring(0,1)=="("){document.title="("+totalNotificationNews+") "+document.title.substring(document.title.indexOf(")")+2,document.title.length)}else{document.title="("+totalNotificationNews+") "+document.title}}}else{closeNotification()}}function getPollInvitations(){Ext.Ajax.request({url:"ajax/get_poll_invitations.php",success:function(callBackStr,action){var obj=eval("["+callBackStr.responseText+"]");if(obj!=""&&obj[0].length>0){if($("ballDiv_al_p_invitation")){$("ballDiv_al_p_invitation").innerHTML=obj[0].length}if($("pollInvitationDiv")){showPollInvitationsList(obj[0])}else{showPollInvitations(obj[0])}}else{if(pollInviteWin!=null){pollInviteWin.close()}if($("nDiv_al_p_invitation")){$("notificationItemsDiv").removeChild($("nDiv_al_p_invitation"))}}},failure:function(){Ext.MessageBox.alert("Connection error","A network error occured during connection, please try again shortly.")}})}function showPollInvitations(A){pollInviteWin=new Ext.Window({title:pollInvitationText,width:500,height:350,shadow:false,id:"pollInviteWin",layout:"fit",modal:true,resizable:false,plain:true,html:"<div id='pollInvitationDiv' style='width:97%;height:250px;padding:5px;overflow:auto;'></div>"});pollInviteWin.show();showPollInvitationsList(A)}function showPollInvitationsList(G){$("pollInvitationDiv").innerHTML="";var D=_CT("pollInvitationTable","100%",0,0);$("pollInvitationDiv").appendChild(D);var E,F,B,A;for(var C=0;C<G.length;C++){E=D.insertRow(D.rows.length);F=E.insertCell(0);F.width="100%";F.vAlign="top";F.align="left";B=G[C]["name"]+" "+G[C]["surname"];F.innerHTML="<br />"+String.format(whoInviteVoteFor,'<a href="userinfo.php?uid='+G[C]["user_id"]+'">'+B+"</a>",'<b>"'+G[C]["subject"]+'"</b>')+'<br /><br /><span style="color:#aaa;">"'+G[C]["message"]+'"</span>';F=E.insertCell(1);F.vAlign="top";var A=addThumbImage("user",G[C]["image"],G[C]["name"]+" "+G[C]["surname"],"userinfo.php?uid="+G[C]["user_id"]);A.style.marginTop="3px";A.style.marginLeft="10px";F.appendChild(A);E=D.insertRow(D.rows.length);F=E.insertCell(0);F.colSpan=2;F.vAlign="top";F.style.borderBottom="1px solid #ccc";F.style.paddingBottom="3px";F.align="right";F.innerHTML="<a href='javascript:void(0);' onclick='javascript:acceptPollInvitation("+G[C]["vote_id"]+", "+G[C]["user_id"]+");'>"+acceptText+"</a>&nbsp;|&nbsp;<a href='javascript:void(0);' onclick='javascript:ignorePollInvitation("+G[C]["vote_id"]+", "+G[C]["user_id"]+");'>"+ignoreText+"</a>&nbsp;&nbsp;"+G[C]["invite_time"]}}function acceptPollInvitation(B,A){actPollInvitation(B,A,1)}function ignorePollInvitation(B,A){actPollInvitation(B,A,2)}function actPollInvitation(C,B,A){Ext.Ajax.request({url:"ajax/poll_invitation.php",method:"POST",params:{vote_id:C,inviter:B},success:function(D,E){if(D.responseText.trim()=="succ"){if(A==1){pollInviteWin.close();document.location.href="vote.php?vid="+C}else{if(totalNotificationNews>1){totalNotificationNews-=1;document.title="("+totalNotificationNews+") "+document.title.substring(document.title.indexOf(")")+2,document.title.length);getPollInvitations()}else{pollInviteWin.close();totalNotificationNews=0;document.title=document.title.substring(document.title.indexOf(")")+2,document.title.length);closeNotification()}}}},failure:function(){Ext.MessageBox.alert("Connection error","A network error occured during connection, please try again shortly.")}})}function closeNotification(){var A=$("notificationDiv");timer=setInterval(function(){if(parseInt(A.style.height)>0){A.style.height=parseInt(A.style.height)-5+"px"}else{clearInterval(timer);A.style.display="none"}},10)}function addNotificationDiv(B,G,H,I,C){var F,A,K,J,E,D;F=_C("div");F.id="nDiv_"+G;F.className="f-l smallText notification_div";F.onclick=function(){document.location.href=C};F.onmouseover=function(){D.style.textDecoration="underline"};F.onmouseout=function(){D.style.textDecoration="none"};B.appendChild(F);A=_C("div");A.className="icon_divL";F.appendChild(A);K=_C("div");K.className="icon_divM";F.appendChild(K);J=_C("div");J.className="icon_divR";F.appendChild(J);E=_C("div");E.id="ballDiv_"+G;E.className="ball_div";if(H<10){E.style.background="url("+STATIC_IMAGE_PATH+"red_alert_circle_1.png)"}else{E.style.width="21px";E.style.left="-7px";E.style.background="url("+STATIC_IMAGE_PATH+"red_circle_large_1.png)"}E.innerHTML=H;K.appendChild(E);D=_C("div");D.className="item_div";D.innerHTML=I;K.appendChild(D)}function checkAlerts(){var get_myfriends=0;var get_mylocations=0;var get_mygroups=0;var get_friendslabel=0;if(myFriendsData==""){get_myfriends=1}if(myLocationsData==""){get_mylocations=1}if(myGroupsData==""){get_mygroups=1}if(friendsLabelData==""){get_friendslabel=1}Ext.Ajax.request({url:"ajax/check_alerts.php",method:"POST",params:{chk_request:NOTIFICATION_REQUEST,chk_introduction:NOTIFICATION_INTRODUCTION,chk_unreadMsg:NOTIFICATION_UNREADMSG,chk_trigMsg:NOTIFICATION_TRIGMSG,chk_grprequest:NOTIFICATION_GRPREQUEST,get_myfriends:get_myfriends,get_mylocations:get_mylocations,get_mygroups:get_mygroups,get_friendslabel:get_friendslabel},success:function(callBackStr,action){var obj=eval("["+callBackStr.responseText+"]");waitingFriendRequests=obj[0]["request"];waitingFriendIntroductions=obj[0]["introduction"];unreadMessagesNum=obj[0]["message"];totalEventInvitations=obj[0]["event"];totalGroupInvitations=obj[0]["invitation"];totalGroupRequests=obj[0]["group_request"];totalLocationInvitations=obj[0]["location_invitation"];totalPollInvitations=obj[0]["poll_invitation"];totalUblogMessages=obj[0]["uBlog_messages"];totalNotificationNews=obj[0]["totalNews"];now_online_friends=obj[0]["nowOnline"];if(myFriendsData==""&&obj[0]["allmyfriends"]!=null){myFriendsData=obj[0]["allmyfriends"]}if(myLocationsData==""&&obj[0]["allmylocations"]!=null){myLocationsData=obj[0]["allmylocations"]}if(myGroupsData==""&&obj[0]["allmygroups"]!=null){myGroupsData=obj[0]["allmygroups"]}if(friendsLabelData==""&&obj[0]["friendsLabels"]!=null){friendsLabelData=obj[0]["friendsLabels"]}if(friendsAndlabelsData==""){friendsAndlabelsData=myFriendsData.concat(friendsLabelData)}if(myUrbianData==""){myUrbianData=myFriendsData.concat(myLocationsData,myGroupsData,friendsLabelData)}showNotification();showMyOnlineFriends()},failure:function(obj,action){Ext.MessageBox.alert("Connection error","A network error occured during connection, please try again shortly.")}})}function showMyOnlineFriends(){var B=$("friendsOnlineBox");B.style.display="";if(now_online_friends!=null&&now_online_friends.length>0){var K=_CT("","100%",0,0);if($("friendsOnlineBoxTable")){B.replaceChild(K,$("friendsOnlineBoxTable"))}else{B.innerHTML="";B.appendChild(K)}K.id="friendsOnlineBoxTable";var I,D,G,E,H,A,C,J;for(var F=0;F<now_online_friends.length;F++){I=K.insertRow(K.rows.length);D=I.insertCell(0);D.onmouseover=function(){this.className="rowHighlight"};D.onmouseout=function(){this.className="row"};D.className="row";D.id="td_nowonline_"+now_online_friends[F]["user_id"];D.onclick=function(){document.location.href="friendDetails.php?uid="+this.id.split("_")[2]};G=_C("img");if(now_online_friends[F]["image"]==undefined||now_online_friends[F]["image"].length<4){path=STATIC_IMAGE_PATH+"user_defaultsmall"}else{path=USERS_IMAGE_PATH+"/"+now_online_friends[F]["image"]+"small"}G.src=path;G.className="onlineNowImage0";D.appendChild(G);H=_C("div");H.className="f-l";H.style.width="85px";H.innerHTML="<span class='smallText'>"+now_online_friends[F]["name"]+"<br /></span><span class='mediumText'>"+now_online_friends[F]["surname"]+"</span>";D.appendChild(H);if(now_online_friends[F]["mobile"]==1){A=_CD("","22px","22px","","f-l");A.style.background="url("+STATIC_IMAGE_PATH+"mobile_phone_icon_small.png) 0 0 repeat-x";D.appendChild(A)}I=K.insertRow(K.rows.length);D=I.insertCell(0);if(now_online_friends[F]["status_text"]!=""){C=_C("div");C.className="smallTextLight";C.style.width="140px";C.style.overflow="hidden";C.style.paddingLeft="4px";C.style.marginBottom="3px";C.innerHTML=now_online_friends[F]["status_text"];D.appendChild(C)}if(now_online_friends[F]["location_privacy"]>0&&now_online_friends[F]["location_id"]>0){J=_C("div");J.style.paddintTop="2px";J.style.paddingBottom="2px";J.style.backgroundColor="#ededed";if(now_online_friends[F]["last"]!=1){J.style.marginBottom="5px";J.style.borderBottom="1px solid #ccc"}J.innerHTML="<table cellpadding='0' cellspacing='0'><tr><td><div class='smallTextLight' style='width:130px; float:left;overflow:hidden; padding-left:4px; background-color:#ededed;'>"+atWhere+"<a href='locations.php?lid="+now_online_friends[F]["location_id"]+"'>"+now_online_friends[F]["location_name"]+"</a></div></td><td><div style='width:10px;float:left; background-color:#ededed;'><img src='"+STATIC_IMAGE_PATH+"Icon_now_online_location_1.png' /></div></td></tr></table>";D.appendChild(J)}else{if(F<now_online_friends.length-1){J=_C("div");J.style.borderBottom="1px solid #ccc";D.appendChild(J)}}}}else{B.innerHTML="<table cellspacing='0' cellpadding='0' width='100%' border='0'><tr><td><span class='smallTextLight'>"+noOneOnline+"</span></td></tr></table>"}}if(typeof (suser_id)!="undefined"&&parseInt(suser_id)>0){if(stimezone==""){setTimezone()}checkAlerts();timer=setInterval(checkAlerts,300000);if($("weather_div")){getWeatherForecast()}}function getWeatherForecast(){Ext.Ajax.request({url:"ajax/weather.php",success:function(callBackStr,action){var obj=eval("["+callBackStr.responseText+"]");weather_forecast=obj[0];if(weather_forecast.length>0){showWeatherForecast(0)}},failure:function(obj,action){Ext.MessageBox.alert("Connection error","A network error occured during connection, please try again shortly.")}})}function showWeatherForecast(E){var F,B;var C=$("weather_div");C.style.display="";var H=$("weather_table");var I="";if(weather_forecast[E]["city"].trim()!=""){I=", "+weather_forecast[E]["city"]}if(!H){H=_C("table");H.id="weather_table";C.appendChild(H);F=H.insertRow(0);B=F.insertCell(0);B.innerHTML=weather_forecast[E]["weekday"]+I;B.colSpan=2;F=H.insertRow(1);B=F.insertCell(0);B.width="70%";B.innerHTML=weather_forecast[E]["high"]+"&deg;C～"+weather_forecast[E]["low"]+"&deg;C";B=F.insertCell(1);B.innerHTML="<img title='"+weather_forecast[E]["condition"]+"' alt='"+weather_forecast[E]["condition"]+"' src='http://www.google.com"+weather_forecast[E]["icon"]+"' />";B.rowSpan=2;F=H.insertRow(2);B=F.insertCell(0);B.innerHTML=weather_forecast[E]["humidity"];F=H.insertRow(3);B=F.insertCell(0);B.height="18";B.colSpan=2;if(currentLanguage=="ZH"){var G=weather_forecast[E]["windtoward"]+windPowerText+weather_forecast[E]["windpower"]}else{var G=weather_forecast[E]["wind"]}B.innerHTML=G;F=H.insertRow(4);B=F.insertCell(0);B.align="left";B=F.insertCell(1);B.align="right"}else{H.rows[0].cells[0].innerHTML=weather_forecast[E]["weekday"]+I;H.rows[1].cells[0].innerHTML=weather_forecast[E]["high"]+"&deg;C～"+weather_forecast[E]["low"]+"&deg;C";H.rows[1].cells[1].innerHTML="<img title='"+weather_forecast[E]["condition"]+"' alt='"+weather_forecast[E]["condition"]+"' src='http://www.google.com"+weather_forecast[E]["icon"]+"' />";if(E>0){H.rows[2].cells[0].style.display="none";H.rows[3].cells[0].style.display="none"}else{H.rows[2].cells[0].style.display="";H.rows[3].cells[0].style.display=""}}H.rows[4].cells[0].innerHTML="";H.rows[4].cells[1].innerHTML="";if(E>0){var A=E-1;H.rows[4].cells[0].innerHTML="<img src='"+STATIC_IMAGE_PATH+"feed_pre.png' style='cursor:pointer;' onclick='javascript:showWeatherForecast("+A+");' />"}if(E<weather_forecast.length-1){var D=E+1;H.rows[4].cells[1].innerHTML="<img src='"+STATIC_IMAGE_PATH+"feed_next.png' style='cursor:pointer;' onclick='javascript:showWeatherForecast("+D+");' />"}};