(function(){$imm={PageTitle:jQuery("title").text(),Debug:false,Debugger:function(obj,method){},AutoLogin:null,ListType:null,WebCamIsActive:false,ContactListTimeout:300000,UserRefreshTimeout:1000,LoadRefreshTimeout:2000,convAutoTimeoutId:0,ConvAutoRefreshTimeout:15000,convBlockTimeoutId:0,ConvBlockRefreshTimeout:10000,ConversationMsgCount:20,searchTimeoutId:0,SearchRefreshTimeout:5000,listTimeoutId:0,ListRefreshTimeout:10000,WaitingMsgCount:25,WaitingMsgRefresh:15,autoTimeoutId:0,NoneMsgRefreshTimeout:15000,SomeMsgRefreshTimeout:30000,ManyMsgRefreshTimeout:45000,DelayedUserDisplay:0,DoTchatcheInscription:false,DisplayPanel:function(panelName,callBack){callBack=callBack||function(){};
if($c.DisplayedPanel!==undefined){jQuery($c.DisplayedPanel).triggerHandler("hide");
jQuery($c.DisplayedPanel).hide();
}else{jQuery("#default-panel").triggerHandler("hide");
jQuery("#default-panel").hide();
}$c.DisplayedPanel=panelName;
jQuery(panelName).triggerHandler("show");
jQuery(panelName).show();
if(panelName!="#waiting-panel"){$imm.UpdateAdvertisements("DisplayPanel");
}$imm.ResetElements();
callBack();
},AddSmiley:function(smiley){var dom=jQuery($c.DisplayedPanel+" #message").get(0);
dom.focus();
if(dom.setSelectionRange){var start=dom.value.substring(0,dom.selectionStart);
var end=dom.value.substring(dom.selectionStart,dom.value.length);
dom.value=start+unescape(" "+smiley+" ")+end;
console.log("start : "+start);
console.log("end : "+end);
}else{if(document.selection&&document.selection.createRange){var range=document.selection.createRange();
range.text=unescape(" "+smiley+" ")+range.text;
}}jQuery($c.DisplayedPanel+" #smiley-list").hide();
},ShowSmiles:function(){if($c.Smileys===undefined){AjaxManager.GetSmiles(57,$imm.ShowSmilesCallBack);
}else{$imm.ShowSmilesCallBack();
}},ShowSmilesCallBack:function(res){if($imm.HandleError(res,"ShowSmilesCallBack")){return;
}if(res!==undefined){$c.Smileys=jQuery.ObjMerge(res.value);
}$imm.ResetElements();
jQuery($c.DisplayedPanel+" #smiley-list").BindTemplate($c.Smileys).slideToggle("slow");
},ShowAvatars:function(){if($c.Pictos===undefined){AjaxManager.GetPictos("0",$imm.ShowAvatarsCallBack);
}else{$imm.ShowAvatarsCallBack(undefined);
}},ShowAvatarsCallBack:function(res){if($imm.HandleError(res,"ShowAvatarsCallBack")){return;
}if(res!==undefined){$c.Pictos=jQuery.ObjMerge(res.value);
}jQuery("#picto-list").BindTemplate($c.Pictos).slideToggle("slow");
},UpdateAvatar:function(avatarId,fileName){AjaxManager.UpdateAvatar(avatarId);
if(fileName!==undefined){$c.Me.Picto=fileName;
$c.Me.PictoId=avatarId;
}},ShowImageUpload:function(){$imm.ResetElements();
jQuery("#image-upload").attr({src:"/content/elements/image-upload.aspx"}).slideToggle("slow");
},BlockUser:function(contactId){contactId=contactId||0;
if(contactId>0){$imm.ContactsAdd(contactId,$c.Constants.Contact.Type.UnWanted);
}if($c.Me.Correspondant!==undefined){AjaxManager.BlockUser($c.Me.Correspondant.Id);
}$imm.ShowNextMessage();
},ContactsGet:function(contactType){contactType=contactType||$c.Constants.Contact.Type.Buddy;
if($c.Me.Contacts[contactType]==undefined){AjaxManager.ContactsGet($c.Me.Id,contactType,function(res){$imm.ContactsGetCallBack(res,contactType);
});
}else{$imm.ContactsGetCallBack(undefined,contactType);
}},ContactsGetCallBack:function(res,contactType){if($imm.HandleError(res,"ContactsGetCallBack")){return;
}if(res!==undefined){$c.Me.Contacts[contactType]=jQuery.ObjMerge(res.value);
}jQuery("#buddy-list").data("ContactType",contactType).BindTemplate($c.Me.Contacts[contactType]).slideDown("slow");
setTimeout("$c.Me.Contacts = [];",$imm.ContactListTimeout);
},ContactsAdd:function(contactId,contactType){contactType=contactType||$c.Constants.Contact.Type.Buddy;
if($c.Me.TId!=0&&contactId!=0){AjaxManager.ContactsAdd(contactId,contactType,function(res){$imm.ContactsAddCallBack(res,contactType);
});
}else{jQuery("#invit-buddy").BindTemplate(contactId).slideHorizontal("toggle");
jQuery("#voice-mail").slideHorizontal("hide");
}},ContactsAddCallBack:function(res,contactType){if($imm.HandleError(res,"ContactsAddCallBack")){return;
}$c.Users.All=[];
$c.Me.Contacts=[];
jQuery("#buddy-add").hide();
$imm.ContactsGet(contactType);
},ContactsRemove:function(contactId,contactType){contactType=contactType||$c.Constants.Contact.Type.Buddy;
AjaxManager.ContactsRemove(contactId,contactType,function(res){$imm.ContactsRemoveCallBack(res,contactType);
});
},ContactsRemoveCallBack:function(res,contactType){if($imm.HandleError(res,"ContactsRemoveCallBack")){return;
}$c.Users.All=[];
$c.Me.Contacts[contactType]=undefined;
$imm.ContactsGet(contactType);
},ContactIsTypeOf:function(contactId,contactType){AjaxManager.ContactIsTypeOf(contactId,contactType,$imm.ContactIsTypeOfCallBack);
},ContactIsTypeOfCallBack:function(res){if($imm.HandleError(res,"ContactIsTypeOfCallBack")){return;
}return res.value;
},DisplayContactBook:function(){AjaxManager.GetContactBook($imm.DisplayContactBookCallBack);
},DisplayContactBookCallBack:function(res){if($imm.HandleError(res,"DisplayContactBookCallBack")){return;
}jQuery("#contact-list").BindTemplate(res.value).slideDown("slow");
},DisplayInterview:function(){jQuery("#interview").attr("src","/interview.aspx");
$imm.DisplayPanel("#interview-panel");
},ShowDedications:function(){},RefreshDedications:function(){},RefreshDedicationsCallBack:function(res){},GeoCleanUp:function(isLoaded){$c.GeoSearch.Loaded=isLoaded||false;
if($c.GeoSearch.Markers.length>0){for(i in $c.GeoSearch.Markers){$c.GeoSearch.Markers[i].setMap(null);
}$c.GeoSearch.Markers=[];
}if($c.GeoSearch.InfoWindow!=undefined){$c.GeoSearch.InfoWindow.close();
$c.GeoSearch.InfoWindow=undefined;
}},GeoSearch:function(){$imm.DisplayPanel("#waiting-panel");
if(jQuery("#geo-user").hasTemplate()){$imm.GeoMapAddUsers($c.Search.Result.Values);
return;
}jQuery("#geo-user").setTemplateURL("/content/templates/geo-user.aspx");
var latlng=new google.maps.LatLng($c.Me.Lat,$c.Me.Lng);
var options={zoom:12,center:latlng,mapTypeId:google.maps.MapTypeId.ROADMAP,mapTypeControlOptions:{style:google.maps.MapTypeControlStyle.HORIZONTAL_BAR,position:google.maps.ControlPosition.TOP_LEFT},navigationControlOptions:{style:google.maps.NavigationControlStyle.SMALL}};
$c.GeoSearch.Map=new google.maps.Map(jQuery("#geo-map").get(0),options);
google.maps.event.addListener($c.GeoSearch.Map,"zoom_changed",function(){if($c.GeoSearch.Map.getZoom()>12){$c.GeoSearch.Map.setZoom(12);
}});
$imm.GeoMapAddUsers($c.Search.Result.Values);
},GeoMapAddUsers:function(users){if($c.GeoSearch.Loaded){$imm.DisplayPanel("#geo-panel");
return;
}$imm.GeoCleanUp(true);
var points=[];
var minLat;
var maxLat;
var minLng;
var maxLng;
for(var i=0;
i<users.length;
i++){var lat=users[i].Lat;
var lng=users[i].Lng;
if(lat==0&&lng==0){continue;
}if(!minLat||lat<minLat){minLat=lat;
}if(!maxLat||lat>maxLat){maxLat=lat;
}if(!minLng||lng<minLng){minLng=lng;
}if(!maxLng||lng>maxLng){maxLng=lng;
}if(points[lat]==lng){lat+=0.0001;
lng+=0.0001;
}var point=new google.maps.LatLng(lat,lng);
points[lat]=lng;
$imm.GeoMapAddMarker(point,users[i]);
}$imm.DisplayPanel("#geo-panel",function(){$c.GeoSearch.Loaded=true;
google.maps.event.trigger($c.GeoSearch.Map,"resize");
var bounds=new google.maps.LatLngBounds(new google.maps.LatLng(minLat,minLng),new google.maps.LatLng(maxLat,maxLng));
$c.GeoSearch.Map.fitBounds(bounds);
});
},GeoMapAddMarker:function(point,user){var image;
if(user.Photo){image=$c.MediaServer.GetPhotoURL(user.MasterStore,user.Photo,40,40);
}else{if(user.Sex==$c.Constants.User.Gender.Male){image="/content/images/AvatarHomme.gif";
}else{if(user.Sex==$c.Constants.User.Gender.Female){image="/content/images/AvatarFemme.gif";
}else{image="/content/images/AvatarInconnu.gif";
}}}var html=jQuery("#geo-user").processTemplate(user,null).html();
var marker=new google.maps.Marker({position:point,map:$c.GeoSearch.Map,icon:image,title:user.Pseudo});
$c.GeoSearch.Markers.push(marker);
google.maps.event.addListener(marker,"click",function(){if($c.GeoSearch.InfoWindow!=undefined){$c.GeoSearch.InfoWindow.close();
$c.GeoSearch.InfoWindow=undefined;
}$c.GeoSearch.InfoWindow=new google.maps.InfoWindow({content:html,maxWidth:265});
$c.GeoSearch.InfoWindow.open($c.GeoSearch.Map,marker);
});
},FirstPage:function(){if($c.Search.CurrentPage>0){$imm.GeoCleanUp(false);
$imm.LoadList(0);
}$c.Search.CurrentPage=0;
},PreviousPage:function(){if($c.Search.CurrentPage>0){$imm.GeoCleanUp(false);
$imm.LoadList(--$c.Search.CurrentPage);
}},NextPage:function(){if($c.Search.CurrentPage<$c.Search.PageCount-1){$imm.GeoCleanUp(false);
$imm.LoadList(++$c.Search.CurrentPage);
}},LastPage:function(){if($c.Search.CurrentPage<$c.Search.PageCount-1){$imm.GeoCleanUp(false);
$imm.LoadList($c.Search.PageCount-1);
}$c.Search.CurrentPage=$c.Search.PageCount-1;
},RefreshList:function(){if($c.Users.RefreshBlock==true){return;
}$c.Users.RefreshBlock=true;
$imm.GeoCleanUp(false);
clearTimeout($imm.listTimeoutId);
$imm.listTimeoutId=setTimeout("$c.Users.RefreshBlock=false;",$imm.ListRefreshTimeout);
$imm.LoadList(0);
},LoadList:function(pageIndex){$c.Search.CurrentPage=pageIndex;
if($c.GeoSearch.Map!=undefined&&$c.DisplayedPanel=="#geo-panel"){$c.GeoSearch.Active=true;
}else{$c.GeoSearch.Active=false;
}if($c.Search.Active===true){AjaxManager.SearchUsers($c.Search.Criteria,pageIndex,$c.Search.PageSize,$imm.LoadListCallBack);
}else{AjaxManager.GetConnectedUsers(pageIndex,$c.Search.PageSize,$imm.LoadListCallBack);
}},LoadListCallBack:function(res){if($imm.HandleError(res,"LoadListCallBack")){return;
}$c.Search.Result=res.value;
$c.Search.PageCount=$c.Search.Result.pageCount;
if($c.Search.Result.length==0&&$c.Search.Active==false){setTimeout("$imm.LoadList(0);",3000);
}jQuery("#connected-template").BindTemplate($c.Search.Result,function(){jQuery("#loading-panel").hide();
if($imm.DelayedUserDisplay.length>10){$imm.DisplayUser($imm.DelayedUserDisplay);
$imm.DelayedUserDisplay=0;
}}).show();
jQuery("#totalusercount").text($c.Search.Result.totalLength);
jQuery("#totaluserlocalcount").text($c.Search.Result.totalLocalizedLength);
jQuery("#totalusersearchcount").text($c.Search.Result.totalLength);
jQuery("#pagetotal").text($c.Search.PageCount);
var idx=0;
if($c.Search.PageCount>0){idx=$c.Search.CurrentPage+1;
}jQuery("#pageindex").text(idx);
jQuery("#connected-list").scrollTop(0);
if($c.GeoSearch.Active){$imm.GeoMapAddUsers($c.Search.Result.Values);
}else{if($c.GeoSearch.AutoSearch){$imm.GeoSearch();
$c.GeoSearch.AutoSearch=false;
}}},salonAutoTimeoutId:0,SalonAutoRefreshTimeout:10000,SalonMessageBuffer:[],SalonLastMsgTime:0,DisplaySalon:function(){$imm.SalonLastMsgTime=0;
$imm.bindSalonMessagesId=undefined;
$imm.DisplayPanel("#waiting-panel");
jQuery("#salon-panel").BindTemplate(undefined,function(){if($imm.bindSalonMessagesId==undefined){$imm.bindSalonMessagesId=setInterval("$imm.BindSalonMessages();",1);
}jQuery("#salon-panel").one("hide",function(){clearTimeout($imm.salonAutoTimeoutId);
clearTimeout($imm.bindSalonMessagesId);
});
$imm.DisplayPanel("#salon-panel",function(){$imm.ResizeElements();
$imm.GetLatestSalonMessages();
jQuery("#bg-pickerv2").smallColorPicker({defaultColor:$imm.GetCookieValue("bg")||"#FFF",popupColorClassName:"jscp-picker_panel_top_left",buttonBackClassName:"jscp-smallColorPicker_button_back_bg",click:function(e){$imm.SetCookieValue("bg",e);
}});
jQuery("#fg-pickerv2").smallColorPicker({defaultColor:$imm.GetCookieValue("fg")||"#000",popupColorClassName:"jscp-picker_panel_top_right",buttonBackClassName:"jscp-smallColorPicker_button_back_fg",click:function(e){$imm.SetCookieValue("fg",e);
},colorValues:Array("#000000","#002252","#284f8b","#415d7c","#57778a","#648786","#566038","#032c23","#666666","#3d2d1f","#905a33","#8e6f5e","#8f6371","#892034","#cd5806","#ffa243")});
jQuery("#message").focus();
});
});
},BindSalonMessages:function(){if($imm.SalonMessageBuffer.length==0){return;
}var message=$imm.SalonMessageBuffer.shift();
var panel=jQuery("#salon-messages");
panel.BindTemplateResult(message,function(result){if(jQuery("#salon-messages div").length>50){jQuery("#salon-messages div:first").remove();
}panel.append(result);
panel.scrollTop(3000);
});
},GetLatestSalonMessages:function(){AjaxManager.GetLatestSalonMessages(30,$imm.SalonLastMsgTime,$imm.GetLatestSalonMessagesCallBack);
},GetLatestSalonMessagesCallBack:function(res){if($imm.HandleError(res,"GetLatestSalonMessagesCallBack")){return;
}if(res!==undefined&&res.value!==undefined){var messages=jQuery.ObjMerge(res.value).Values;
if(messages.length>0){for(m in messages){$imm.SalonMessageBuffer.push(messages[m]);
}$imm.SalonLastMsgTime=$imm.SalonMessageBuffer[$imm.SalonMessageBuffer.length-1].Time;
}}clearTimeout($imm.salonAutoTimeoutId);
$imm.salonAutoTimeoutId=setTimeout("$imm.GetLatestSalonMessages();",$imm.SalonAutoRefreshTimeout);
},SendSalonMessage:function(msg){var msg=jQuery($c.DisplayedPanel+" #message");
if(msg.val()!=""){var fg=$imm.GetCookieValue("fg")||"#000000";
var bg=$imm.GetCookieValue("bg")||"#FFFFFF";
AjaxManager.SendSalonMessage(msg.val(),fg,bg,$imm.GetSalonMessages);
msg.val("");
msg.get(0).focus();
$imm.UpdateAdvertisements("SendSalonMessage");
$imm.GetLatestSalonMessages();
}},DisplayUser:function(userId){$imm.DisplayPanel("#waiting-panel");
if($c.Messages.Waiting.length>0){$c.Messages.Remove(userId);
$imm.BindWaitingMessagesTemplate();
}if($c.Messages.Waiting.length<=$imm.WaitingMsgRefresh){if($c.Messages.Waiting.total>$c.Messages.Waiting.length){$imm.GetWaitingMessages();
}else{clearTimeout($imm.autoTimeoutId);
$imm.autoTimeoutId=setTimeout("$imm.GetWaitingMessages();",$imm.NoneMsgRefreshTimeout);
}}if($c.Users.GetByUserId(userId)===undefined){AjaxManager.GetUser(userId,$imm.DisplayUserCallBack);
}else{$imm.DisplayUserCallBack(undefined,userId);
}},DisplayUserCallBack:function(res,userId){if($imm.HandleError(res,"DisplayUserCallBack")){return;
}if(res!==undefined&&res.value==undefined){jQuery("#disconnected-panel").BindTemplate(undefined,function(){$imm.DisplayPanel("#disconnected-panel");
});
return;
}if(userId!==undefined){$c.Me.Correspondant=$c.Users.GetByUserId(userId);
}else{if(res.value!==undefined){$c.Users.Add(res.value);
$c.Me.Correspondant=res.value;
}}if($c.Me.Correspondant.IsAd){$imm.GetConversation($c.Me.Correspondant.Id);
}else{jQuery("#conversation-panel").BindTemplate($c.Me.Correspondant,function(){jQuery("#display-profile-template").BindTemplate($c.Me.Correspondant,function(){$imm.ResizeElements();
$imm.DisplayPanel("#conversation-panel",function(){jQuery("#autonextmessage").get(0).checked=$imm.GetCookieValue("AutoNext");
$imm.GetConversation($c.Me.Correspondant.Id);
});
});
});
}},GetCurrentUser:function(){AjaxManager.GetCurrentUser($imm.GetCurrentUserCallBack);
},GetCurrentUserCallBack:function(res){if($imm.HandleError(res,"GetCurrentUserCallBack")){return;
}if(res.value===undefined){return;
}$c.Me=res.value;
$c.Me.Contacts=[];
$c.Me.Correspondant=undefined;
$c.Me.GeoIp=$imm.GetCookieAsObject($c.GeoIpCookie);
if($c.Me.GeoIp==undefined){$c.Me.GeoIp={CountryCode:"XX",IP:"127.0.0.1"};
}else{if($c.Me.GeoIp.CountryCode=="FR"){jQuery("#nav-itw").show();
}}jQuery("#currentuser-nickname").html($c.Me.Pseudo);
if($c.Me.TId!=0){jQuery("#nav-buddies").show();
}else{}$imm.DisplayPanel("#profils-panel");
if($c.Me.TId==0){if(jQuery.JSONCookie("DoTchatcheInscription").value==undefined){jQuery(document).bind("click",$imm.TchatcheInscription);
var minutes=(1000*60)*5;
setTimeout("$imm.DoTchatcheInscription=true;",minutes);
}}setTimeout("$imm.CamTest()",500);
setTimeout("$imm.LoadList(0);",$imm.LoadRefreshTimeout);
$imm.autoTimeoutId=setTimeout("$imm.GetWaitingMessages();",$imm.NoneMsgRefreshTimeout);
$imm.TrackEvent("Users","Age",$c.Me.Age>17?"Major":"Minor",$c.Me.Age);
$imm.TrackEvent("Users","Sex",$c.Me.Sex==0?"Male":"Female",$c.Me.Sex);
},GetSupervisor:function(){AjaxManager.GetSupervisor($imm.GetSupervisorCallBack);
},GetSupervisorCallBack:function(res){if($imm.HandleError(res,"GetSupervisorCallBack")){return;
}if(res.value!==null){jQuery("#supervisor-template").html(res.value);
}},ShowUserOptions:function(){$imm.DisplayPanel("#waiting-panel");
if($c.Me.TId!=0){jQuery("#dashboard-panel").BindTemplate(undefined,function(){$imm.DisplayPanel("#dashboard-panel");
});
}else{$imm.ListType="options";
jQuery("#option-panel").BindTemplate(undefined,function(){$imm.DisplayPanel("#option-panel",$imm.GetCountries());
jQuery("#ProfileTextBox").get(0).focus();
});
}},UpdateUserOptions:function(){if(jQuery("#option-panel #country-list").val()=="0"){jQuery("#errors").show();
return;
}jQuery("#errors").hide();
$c.Me.Comment=jQuery("#ProfileTextBox").val();
$c.Me.CountryId=jQuery("#option-panel #country-list").val();
$c.Me.LocalizationId=jQuery("#option-panel #region-list").val();
if($c.Me.LocalizationId==null){$c.Me.LocalizationId=0;
}AjaxManager.UpdateCurrentUser($c.Me.Comment,$c.Me.PictoId,$c.Me.CountryId,$c.Me.LocalizationId,$imm.UpdateUserOptionsCallBack);
},UpdateUserOptionsCallBack:function(res){if($imm.HandleError(res,"UpdateUserOptionsCallBack")){return;
}$imm.LoadList(0);
$imm.DisplayPanel("#default-panel");
},GetAutoLogin:function(service,alternate){jQuery("#modif-subscription").slideUp("slow");
$imm.AutoLogin=window.open("","AutoLogin");
AjaxManager.GetAutoLogin(service,alternate,$imm.GetAutoLoginCallBack);
},GetAutoLoginCallBack:function(res){if($imm.HandleError(res,"GetAutoLoginCallBack")){return;
}if(res.value!=undefined){if($imm.AutoLogin){$imm.AutoLogin.location.href=res.value;
}}},VoiceMail:function(){jQuery("#voice-mail").BindTemplate($c.Me.Correspondant).slideHorizontal("toggle");
jQuery("#invit-buddy").slideHorizontal("hide");
},DisplayUserPicture:function(photoId,masterStore){var url=$c.MediaServer.GetPhotoURL(masterStore,photoId,-1,250);
jQuery("#picture-panel").BindTemplate({Url:url}).show();
},HideUserPicture:function(){jQuery("#picture-panel").hide();
},AutoRefreshConversation:function(){if($c.DisplayedPanel!="#conversation-panel"){return;
}clearTimeout($imm.convAutoTimeoutId);
$imm.convAutoTimeoutId=setTimeout("$imm.GetConversation();",$imm.ConvAutoRefreshTimeout);
jQuery("#conversation-panel").one("hide",function(){clearTimeout($imm.convAutoTimeoutId);
});
},RefreshConversation:function(userId){if($c.DisplayedPanel!="#conversation-panel"){return;
}if(userId===undefined){userId=$c.Me.Correspondant.Id;
}if($c.Messages.RefreshBlock==true&&$c.Messages.LastUserId===userId){return;
}clearTimeout($imm.convBlockTimeoutId);
$imm.convBlockTimeoutId=setTimeout("$c.Messages.RefreshBlock=false;",$imm.ConvBlockRefreshTimeout);
$c.Messages.RefreshBlock=true;
$imm.GetConversation(userId);
},GetConversation:function(userId){if(userId===undefined){userId=$c.Me.Correspondant.Id;
}$c.Messages.LastUserId=userId;
AjaxManager.GetConversation(userId,$imm.ConversationMsgCount,$imm.GetConversationCallBack);
},GetConversationCallBack:function(res){if($imm.HandleError(res,"GetConversationCallBack")){return;
}var messages=jQuery.ObjMerge(res.value);
for(i=0;
i<messages.Values.length;
i++){if(messages.Values[i].IsAd==true){jQuery("#ad-panel").BindTemplate(messages,function(){$imm.DisplayPanel("#ad-panel");
});
return;
}}if(messages.Values.length>0){jQuery("#user-messages").BindTemplate(messages,function(){jQuery("#user-messages").scrollTop(1000);
$imm.AutoRefreshConversation();
if($imm.GetCookieValue("BuddyReminded")==null){if($c.Me.BuddyReminded==undefined){$c.Me.BuddyReminded={};
$c.Me.BuddyReminded.count=0;
}var meCount=0;
var heCount=0;
var heName="";
for(i=0;
i<messages.Values.length;
i++){if(messages.Values[i].Sender==$c.Me.Pseudo){meCount++;
}else{heCount++;
heName=messages.Values[i].Sender;
}}if(heCount>2&&meCount>2&&$c.Me.BuddyReminded.count<3&&$c.Me.BuddyReminded[heName]==undefined){$c.Me.BuddyReminded[heName]=true;
$c.Me.BuddyReminded.count++;
$imm.ResetElements();
jQuery("#invite-buddy-message").slideDown("slow",function(){jQuery("#buddy-add img").effect("pulsate");
});
}}});
}jQuery($c.DisplayedPanel+" #message").get(0).focus();
},GetWaitingMessages:function(){AjaxManager.GetWaitingMessages($imm.WaitingMsgCount,$imm.GetWaitingMessagesCallBack);
},GetWaitingMessagesCallBack:function(res){if($imm.HandleError(res,"GetWaitingMessagesCallBack")){return;
}if(res.value==0){$c.Messages.Waiting=[];
}else{$c.Messages.Waiting=jQuery.ObjMerge(res.value);
}clearTimeout($imm.autoTimeoutId);
if($c.Messages.Waiting.length==0){$imm.autoTimeoutId=setTimeout("$imm.GetWaitingMessages();",$imm.NoneMsgRefreshTimeout);
}else{if($c.Messages.Waiting.length<=$imm.WaitingMsgRefresh){$imm.autoTimeoutId=setTimeout("$imm.GetWaitingMessages();",$imm.SomeMsgRefreshTimeout);
}else{$imm.autoTimeoutId=setTimeout("$imm.GetWaitingMessages();",$imm.ManyMsgRefreshTimeout);
}}$imm.BindWaitingMessagesTemplate();
},BindWaitingMessagesTemplate:function(){if($c.Messages.Waiting.length>0){jQuery("#message-list").BindTemplate($c.Messages.Waiting,function(){jQuery("#click-msg-stack-none").hide();
jQuery("#click-msg-stack-more").show();
jQuery("#waiting-messages-count").get(0).innerHTML=$c.Messages.Waiting.total;
document.title=$c.Messages.Waiting.total+" "+jQuery("#waiting-messages-label").text();
});
}else{jQuery("#click-msg-stack-none").show();
jQuery("#click-msg-stack-more").hide();
jQuery("#waiting-messages-count").get(0).innerHTML=0;
document.title=$imm.PageTitle;
}},ShowWaitingMessages:function(){if($c.Messages.Waiting.length==0){$imm.DisplayPanel("#default-panel");
return;
}jQuery("#message-list").slideDown("slow");
},ShowNextMessage:function(){if($c.Messages.Waiting.length==0){$imm.DisplayPanel("#default-panel");
return;
}$imm.DisplayUser($c.Messages.Waiting.Values[0].Id);
},oldText:" ",OnMessageKey:function(e,callback){var newText=jQuery($c.DisplayedPanel+" #message").val();
if(newText.length>($imm.oldText.length+6)){jQuery($c.DisplayedPanel+" #message").val($imm.oldText);
}else{$imm.oldText=newText;
}if(e.type==="keydown"&&e.keyCode===13){callback=callback||function(){};
e.cancelBubble=true;
e.returnValue=false;
callback();
return false;
}},SendMessage:function(){var msg=jQuery($c.DisplayedPanel+" #message").val();
var tId=$c.Me.Correspondant.TId||0;
var pId=jQuery("#image-upload-attachment").attr("photoid")||"";
if(msg!=""||pId!=""){AjaxManager.SendMessage($c.Me.Correspondant.Id,tId,msg,pId,$imm.SendMessageCallBack);
jQuery("#image-upload-attachment").attr("photoid","").hide();
}if(pId!=""){$imm.TrackEvent("Images","Age",$c.Me.Age>17?"Major":"Minor",$c.Me.Age);
$imm.TrackEvent("Images","Sex",$c.Me.Sex==0?"Male":"Female",$c.Me.Sex);
}},SendMessageCallBack:function(res){if($imm.HandleError(res,"SendMessageCallBack")){return;
}if(jQuery("#autonextmessage").get(0).checked===true){$imm.ShowNextMessage();
}else{jQuery($c.DisplayedPanel+" #message").val("");
$c.Messages.RefreshBlock=false;
$imm.GetConversation();
$imm.UpdateAdvertisements("SendMessageCallBack");
}},LimitText:function(maxLength,textArea){if(textArea.value.length>maxLength){textArea.value=textArea.value.substring(0,maxLength);
}},DisplaySearch:function(){$imm.DisplayPanel("#waiting-panel");
$imm.ListType="search";
if(jQuery("#search-panel").hasTemplate()){$imm.DisplayPanel("#search-panel");
return;
}jQuery("#search-panel").BindTemplate(undefined,function(){var min=$c.Me.Age>17?18:10;
var max=$c.Me.Age>17?99:17;
var range=jQuery.makeRange(min,max);
jQuery("#age-criteria").BindTemplate(range,function(){jQuery("#searchfield-agemax").val(max);
$imm.DisplayPanel("#search-panel",$imm.GetCountries());
});
});
},DoSearch:function(e){if(e.keyCode===13){$imm.Search();
e.cancelBubble=true;
e.returnValue=false;
return false;
}},Search:function(GeoAutoSearch){$c.Search.Active=true;
if($c.Search.RefreshBlock==true){return;
}$c.Search.RefreshBlock=true;
$c.GeoSearch.AutoSearch=GeoAutoSearch||false;
$c.GeoSearch.Loaded=false;
clearTimeout($imm.searchTimeoutId);
$imm.searchTimeoutId=setTimeout("$c.Search.RefreshBlock=false;",$imm.SearchRefreshTimeout);
$c.Search.Criteria=jQuery("#searchfield-pseudo").val();
$c.Search.Criteria+=";";
$c.Search.Criteria+=jQuery("#searchfield-cv").val();
$c.Search.Criteria+=";";
var userSearchType=0;
if(jQuery("#searchfield-type-photo").get(0).checked===true){userSearchType|=2;
}if(jQuery("#searchfield-type-blog").get(0).checked===true){userSearchType|=4;
}if(jQuery("#searchfield-type-webcam").get(0).checked===true){userSearchType|=8;
}$c.Search.Criteria+=userSearchType;
$c.Search.Criteria+=";";
$c.Search.Criteria+=jQuery("#searchfield-agemin").val();
$c.Search.Criteria+=";";
$c.Search.Criteria+=jQuery("#searchfield-agemax").val();
$c.Search.Criteria+=";";
var countries=jQuery("#search-panel #country-list").val();
if(countries!=null){if(countries[0]=="0"){countries.shift();
}$c.Search.Criteria+=countries.join(",");
}$c.Search.Criteria+=";";
var regions=jQuery("#search-panel #region-list").val();
if(regions!=null){if(regions[0]=="0"){regions.shift();
}$c.Search.Criteria+=regions.join(",");
}$c.Search.Criteria+=";";
if(jQuery("#searchfield-sex-all").get(0).checked===true){$c.Search.Criteria+="";
}if(jQuery("#searchfield-sex-hommes").get(0).checked===true){$c.Search.Criteria+="0";
}if(jQuery("#searchfield-sex-femmes").get(0).checked===true){$c.Search.Criteria+="1";
}$imm.LoadList(0);
jQuery("#connected-list-searchheader").show();
jQuery("#connected-list-header").hide();
},EndSearch:function(){$c.Search.Active=false;
$imm.GeoCleanUp(false);
$imm.LoadList(0);
jQuery("#page-counts").show();
jQuery("#connected-list-searchheader").hide();
jQuery("#connected-list-header").show();
$imm.DisplayPanel("#default-panel");
},CamTest:function(){var flashvars={callMethod:"AjaxManager.SetWebcam"};
var params={allowScriptAccess:"always"};
var attributes={id:"test-cam"};
swfobject.embedSWF("/common/images/camera-detection.swf","webcam-test","1","1","9.0.0","/common/images/expressInstall.swf",flashvars,params,attributes);
},CamIsActive:function(warn){try{if(jQuery("#webcam-live").get(0).isConnected()){if(warn){alert($t.WebCams.Already);
}return true;
}}catch(err){}return false;
},SendCamInvitation:function(otherId){if($c.Me.Id==otherId){return;
}if($c.Me.TId==0){$imm.DisplayUser(otherId);
$imm.ResetElements();
jQuery("#webcam-subscribing").slideToggle("slow");
return;
}if($imm.CamIsActive(true)){return;
}AjaxManager.SendSpecialMessage(otherId,"WebCam.Invite",function(){$imm.DisplayUser(otherId);
});
$imm.TrackEvent("WebCam","Invite",$c.Me.Sex==0?"Male":"Female",$c.Me.Age);
},RefuseCam:function(otherId){if($c.Me.Id==otherId){return;
}AjaxManager.SendSpecialMessage(otherId,"WebCam.Refuse",function(){$imm.DisplayUser(otherId);
});
$imm.TrackEvent("WebCam","Refuse",$c.Me.Sex==0?"Male":"Female",$c.Me.Age);
},CloseCam:function(otherId){var quit=true;
if($imm.CamIsActive()){quit=confirm($t.WebCams.Quit);
}if(quit){jQuery("#webcam-live").get(0).closeConnection();
jQuery("#webcam-container").hide("fast",function(){AjaxManager.SendSpecialMessage(otherId,"WebCam.Quit",function(){$imm.DisplayUser(otherId);
jQuery("#webcam-live").remove();
$imm.WebCamIsActive=false;
});
});
}},AcceptCam:function(otherId){if($c.Me.Id==otherId){return;
}if($imm.CamIsActive(true)){return;
}jQuery.ajax({type:"POST",url:"webcam.aspx/ConnectMpCam",data:"{userId:'"+$c.Me.Id+"',otherId:'"+otherId+"'}",contentType:"application/json; charset=utf-8",dataType:"json",success:function(msg){var result=jQuery.parseJSON(msg.d);
if(result.status==200||result.status==304){AjaxManager.SendSpecialMessage(otherId,"WebCam.Accept",function(){$imm.DisplayUser(otherId);
$imm.DisplayCam(otherId);
});
}else{alert(result.content);
}}});
$imm.TrackEvent("WebCam","Accept",$c.Me.Sex==0?"Male":"Female",$c.Me.Age);
},StartDuo:function(otherId){if($c.Me.Id==otherId){return;
}if($imm.WebCamIsActive==true){return;
}if($imm.CamIsActive(true)){return;
}AjaxManager.SendSpecialMessage(otherId,"WebCam.Start",function(){$imm.DisplayUser(otherId);
$imm.DisplayCam(otherId);
});
},DisplayCam:function(otherId){if($c.Me.Id==otherId){return;
}if($imm.CamIsActive(true)){return;
}jQuery("#webcam-container").DataBind(otherId).css({left:"0px",top:"90px"}).draggable().show();
var flashvars={userId:$c.Me.Id,userName:$c.Me.Pseudo,otherId:otherId};
var params={allowScriptAccess:"always"};
var attributes={id:"webcam-live"};
swfobject.embedSWF("http://rf.indexmultimedia.com/videochat.swf","webcam-placeholder","261","240","9.0.0","/common/images/expressInstall.swf",flashvars,params,attributes);
$imm.WebCamIsActive=true;
},GetCountries:function(){if($c.Countries===undefined){AjaxManager.GetCountries($imm.GetCountriesCallBack);
}else{$imm.GetCountriesCallBack();
}},GetCountriesCallBack:function(res){if($imm.HandleError(res,"GetCountriesCallBack")){return;
}if(res!==undefined){$c.Countries=jQuery.ObjMerge(res.value);
}$imm.countryList;
$imm.regionList;
if($imm.ListType=="search"){$imm.countryList=jQuery("#search-panel #country-list");
$imm.regionList=jQuery("#search-panel #region-list");
}else{$imm.countryList=jQuery("#option-panel #country-list");
$imm.regionList=jQuery("#option-panel #region-list");
}$imm.regionList.hide();
$imm.countryList.BindTemplate($c.Countries,function(){try{$imm.countryList.val($c.Me.CountryId);
}catch(e){}$imm.GetRegions($c.Me.CountryId);
});
},GetRegions:function(countryId){if($imm.ListType=="search"){jQuery("#search-panel #region-list").hide();
if(jQuery("#search-panel #country-list").val().length>1||countryId=="0"){return;
}}else{jQuery("#option-panel #region-list").hide();
if(jQuery("#option-panel #country-list").val()=="0"||countryId=="0"){return;
}}if($c.Regions[countryId]===undefined){AjaxManager.GetRegions(countryId,$imm.GetRegionsCallBack);
}else{$imm.GetRegionsCallBack(undefined,countryId);
}},GetRegionsCallBack:function(res,countryId){if($imm.HandleError(res,"GetRegionsCallBack")){return;
}var CurrentCountry=0;
if(countryId!==undefined){CurrentCountry=countryId;
}else{if(res!==undefined){CurrentCountry=res.value.Values[0][1];
if(res.value.Values[0][2]===undefined){res.value.Values=[];
}$c.Regions[CurrentCountry]=res.value;
}}if($imm.ListType=="search"){jQuery("#search-panel #region-list").BindTemplate($c.Regions[CurrentCountry],function(){try{jQuery("#search-panel #region-list").val("0");
}catch(e){}if($c.Regions[CurrentCountry].Values.length>0){jQuery("#search-panel #region-list").show();
}});
}else{jQuery("#option-panel #region-list").BindTemplate($c.Regions[CurrentCountry],function(){try{jQuery("#option-panel #region-list").val($c.Me.LocalizationId);
}catch(e){}if($c.Regions[CurrentCountry].Values.length>0){jQuery("#option-panel #region-list").show();
}});
}},ResetElements:function(){jQuery("#buddy-list").slideUp("slow");
jQuery("#contact-list").slideUp("slow");
jQuery("#message-list").slideUp("slow");
jQuery(".slider-item").slideUp("slow");
jQuery("#invit-buddy").slideHorizontal("hide");
jQuery("#voice-mail").slideHorizontal("hide");
},ResizeElements:function(){jQuery("#connected-list").css("height",jQuery("#bottom").offset().top-190);
jQuery("#user-messages").css("height",jQuery("#bottom").offset().top-275);
jQuery("#salon-messages").css("height",jQuery("#bottom").offset().top-220);
},AudioNumber:function(cid){switch(cid){case"FRA":return"0892 700 947 (<em>0,34&euro;/min</em>)";
case"CHE":return"0901 901 985 (<em>4.23 CHF/min</em>)";
case"BEL":return"0907 48 008 (<em>1,5&euro;/min</em>)";
default:return"0892 700 947 (<em>0,34&euro;/min</em>)";
}},UpdateAdvertisements:function(caller){jQuery("iframe.pub-text").each(function(i){if(this.offsetHeight!=0){if($c.Me.GeoIp.CountryCode=="FR"){var key=(this.offsetWidth<468)?2:3;
this.src="http://marketing.indexmultimedia.com/yahoo/Tchat/Yahooframe.aspx?grp=2&key="+key;
key=(key==2)?234:468;
}else{var key=(this.offsetWidth<468)?234:468;
this.src="http://marketing.indexmultimedia.com/google/Tchat/googleframe.aspx?h=60&w="+key;
}this.style.width=key.toString().concat("px");
}});
jQuery("iframe#pub-300x250").each(function(i){if(this.offsetHeight!=0){this.src="/content/pub/300x250.aspx";
}});
jQuery("iframe#pub-120x240").each(function(i){if(this.offsetHeight!=0){this.src="/content/pub/120x240.aspx";
}});
jQuery("iframe#pub-125x125").each(function(i){if(this.offsetHeight!=0){this.src="/content/pub/125x125.aspx";
}});
jQuery("iframe#pub-234x60").each(function(i){if(this.offsetHeight!=0){this.src="/content/pub/234x60.aspx";
}});
jQuery("iframe#pub-728x90").each(function(i){if(this.offsetHeight!=0){this.src="/content/pub/728x90.aspx";
}});
},TrackEvent:function(category,action,label,value){if(typeof(pageTracker)!="undefined"){if(typeof(value)!="undefined"){pageTracker._trackEvent(category,action,label,value);
}else{pageTracker._trackEvent(category,action,label);
}}},GetCookieAsObject:function(name){if(jQuery.cookie(name)==null){return undefined;
}var cObj={};
jQuery.each(jQuery.cookie(name).split("&"),function(index,value){var tmp=value.split("=");
cObj[tmp[0]]=tmp[1];
});
return cObj;
},CancelRefresh:function(e){var obj=window.event?window.event:e;
if(obj.keyCode===116){obj.keyCode=0;
obj.cancelBubble=true;
obj.returnValue=false;
return false;
}return true;
},Quit:function(msg,disconnect){clearTimeout($imm.autoTimeoutId);
if(msg!==false){if(confirm(msg)===false){return;
}}if(disconnect===true){AjaxManager.Quit();
}document.location=disconnect?"/content/quit.aspx":"/content/error-gops.aspx";
},HandleError:function(res,method){if(res===undefined||res.error===null){return false;
}if(window.console){console.error("Error:  "+res.error);
console.error("Method: "+method);
for(s in res.request){try{console.error(s.concat(": ").concat(res.request[s]));
}catch(e){}}}if($imm.Debug===true){if(confirm("Error:\n"+res.error+"\nOpen debugger?")===true){$imm.Debugger(res,method);
return;
}if(confirm("Continue execution?")===false){return;
}}var status=res.request.status;
if(status===401||status===302){window.location.reload();
}var description=res.error.description;
if(description!=null&&description.indexOf("NOT_AUTHENTICATED")>-1){$imm.Quit(false,true);
}else{if(description!=null&&description.indexOf("GOPS")>-1){$imm.Quit(false,false);
}}return true;
},SetCookieValue:function(name,value){if($c.Prefs==undefined){$c.Prefs=jQuery.getJSONCookie("Preferences");
}$c.Prefs[name]=value;
jQuery.setJSONCookie("Preferences",$c.Prefs);
},GetCookieValue:function(name){if($c.Prefs==undefined){$c.Prefs=jQuery.getJSONCookie("Preferences");
}return $c.Prefs[name];
},DeleteCookieValue:function(name){if($c.Prefs==undefined){$c.Prefs=jQuery.getJSONCookie("Preferences");
}delete $c.Prefs[name];
jQuery.setJSONCookie("Preferences",$c.Prefs);
},TchatcheInscription:function(){if($imm.DoTchatcheInscription==false||jQuery.JSONCookie("DoTchatcheInscription").value==true){return;
}$imm.DoTchatcheInscription=false;
jQuery(document).unbind("click",$imm.TchatcheInscription);
jQuery.JSONCookie("DoTchatcheInscription",{value:true},{expires:7});
var path={Url:"http://www.tchatche.com/compte/inscriptionTchatche.aspx?".concat("p=",$c.Me.Pseudo,"&c=",$c.Me.CountryId,"&r=",$c.Me.LocalizationId,"&g=",$c.Me.Sex,"&a=",$c.Me.Age),Name:"tchatche",Options:"toolbar=no,location=no,status=yes,directories=no,menubar=no,scrollbars=yes,resizable=yes,height=550,width=710"};
inscription=window.open(path.Url,path.Name,path.Options);
inscription.focus();
},Initialize:function(delayedUserDisplay){jQuery._temlatePath="/content/templates/";
$imm.DelayedUserDisplay=delayedUserDisplay;
window.onerror=function(msg,url,line){if(jQuery.browser.msie===true){return true;
}$imm.HandleError({error:msg,request:{Url:url,Line:line}},"undefined");
};
jQuery(window).resize($imm.ResizeElements);
jQuery(document).bind("keydown",$imm.CancelRefresh);
setTimeout("$imm.GetCurrentUser();",$imm.UserRefreshTimeout);
$imm.ResizeElements();
self.focus();
}};
})(jQuery);
