LocaGuiWindow=Class.create({initialize:function(){map=main.map;c=map.getContainer();size=map.getSize();this.windowOpts={selectedTab:0,maxContent:"",maxTitle:"",onOpenFn:this.onOpenCallback,onCloseFn:this.onCloseCallback};windowOpen=false;},onOpenCallback:function(){windowOpen=true;},onCloseCallback:function(){windowOpen=false;},getWindowStatus:function(){return windowOpen;},createLocationInfoWindow:function(marker,location_ID,tab){this.windowOpts.selectedTab=tab;if(marker){var p=marker.getLatLng();var d=p.distanceFrom(new google.maps.LatLng(main.myUser.lat,main.myUser.lng));}if(main.maxEvent)google.maps.Event.removeListener(main.maxEvent);new Ajax.Request(index,{method:'get',parameters:{f:'createLocationInfo',s:session,id:location_ID,d:d},onSuccess:function(transport){var jd=transport.responseJSON;var locationTabs=new Array();locationTabs[0]=new google.maps.InfoWindowTab(main.l.tabs.location,jd.tabs.location);locationTabs[1]=new google.maps.InfoWindowTab(main.l.tabs.events,jd.tabs.events);locationTabs[2]=new google.maps.InfoWindowTab(main.l.tabs.galleries,jd.tabs.galleries);var p=map.fromLatLngToContainerPixel(new google.maps.LatLng(jd.data.lat,jd.data.lng));if(marker&&marker.getObject().icon_size)var diff=marker.getObject().icon_size-12;else var diff=0;this.windowOpts.maxContent=new Element('DIV',{ID:"maxContent"});this.windowOpts.maxTitle=new Element('DIV',{ID:"maxTitle"});map.openInfoWindowTabsHtml(map.fromContainerPixelToLatLng(new google.maps.Point(p.x,p.y-diff)),locationTabs,this.windowOpts);var window=map.getInfoWindow();main.maxEvent=google.maps.Event.addListener(window,"maximizeclick",function(){this.windowOpts.maxTitle.update(jd.data.name1+" : "+window.getTabs()[window.getSelectedTab()].name);}.bind(this));soundManager.play('switchSlide');}.bind(this)});},createUserInfoWindow:function(marker,user_ID,tab){this.windowOpts.selectedTab=tab;if(marker){var p=marker.getLatLng();var d=p.distanceFrom(new google.maps.LatLng(main.myUser.lat,main.myUser.lng));}if(main.maxEvent)google.maps.Event.removeListener(main.maxEvent);new Ajax.Request(index,{method:'get',parameters:{f:'createUserInfo',s:session,id:user_ID,d:d,tab:tab},onSuccess:function(transport){var jd=transport.responseJSON;var userTabs=new Array();userTabs[0]=new google.maps.InfoWindowTab(main.l.tabs.home,jd.tabs.home);userTabs[1]=new google.maps.InfoWindowTab(main.l.tabs.chat,jd.tabs.chat,function(e,div){map.getInfoWindow().selectTab(1);$('userWindowChat').scrollTop=$('messageBox'+user_ID).getHeight();});userTabs[2]=new google.maps.InfoWindowTab(main.l.tabs.infos,jd.tabs.infos);userTabs[3]=new google.maps.InfoWindowTab(main.l.tabs.fotos,jd.tabs.fotos);userTabs[4]=new google.maps.InfoWindowTab(main.l.tabs.friends,jd.tabs.friends);main.currentUser=jd.user;var p=map.fromLatLngToContainerPixel(new google.maps.LatLng(jd.user.lat,jd.user.lng));if(marker&&marker.getObject().icon_size)var diff=marker.getObject().icon_size-12;else var diff=0;this.windowOpts.maxContent=new Element('DIV',{ID:"maxContent"});this.windowOpts.maxTitle=new Element('DIV',{ID:"maxTitle"});map.openInfoWindowTabsHtml(map.fromContainerPixelToLatLng(new google.maps.Point(p.x,p.y-diff)),userTabs,this.windowOpts);var window=map.getInfoWindow();main.maxEvent=google.maps.Event.addListener(window,"maximizeclick",function(){this.windowOpts.maxTitle.update(jd.user.name1+" : "+window.getTabs()[window.getSelectedTab()].name);}.bind(this));soundManager.play('switchSlide');}.bind(this)});},createMyInfoWindow:function(marker,user_ID,tab){this.windowOpts.selectedTab=tab;if(main.maxEvent)google.maps.Event.removeListener(main.maxEvent);new Ajax.Request(index,{method:'get',parameters:{f:'getMyData',s:session},onSuccess:function(transport){var jd=transport.responseJSON;main.myUser=jd.user;main.friends=jd.friends;var myTabs=new Array();myTabs[0]=new google.maps.InfoWindowTab(main.l.tabs.my_home,jd.tabs.home);myTabs[1]=new google.maps.InfoWindowTab(main.l.tabs.my_infos,jd.tabs.infos);myTabs[2]=new google.maps.InfoWindowTab(main.l.tabs.my_friends,jd.tabs.friends);myTabs[3]=new google.maps.InfoWindowTab(main.l.tabs.my_fotos,jd.tabs.fotos);var p=map.fromLatLngToContainerPixel(new google.maps.LatLng(jd.user.lat,jd.user.lng));if(marker&&marker.getObject().icon_size)var diff=marker.getObject().icon_size-12;else var diff=0;this.windowOpts.maxContent=new Element('DIV',{ID:"maxContent"});this.windowOpts.maxTitle=new Element('DIV',{ID:"maxTitle"});map.openInfoWindowTabsHtml(map.fromContainerPixelToLatLng(new google.maps.Point(p.x,p.y-diff)),myTabs,this.windowOpts);var window=map.getInfoWindow();main.maxEvent=google.maps.Event.addListener(window,"maximizeclick",function(){if(main.debug)console.debug('maximizeclick');var tabs=window.getTabs();if(window.getSelectedTab()==0)var pre="Mein";else var pre="Meine";this.windowOpts.maxTitle.update(pre+" "+tabs[window.getSelectedTab()].name);}.bind(this));soundManager.play('switchRoll');}.bind(this)});},createAddressInfoWindow:function(address,tab){this.windowOpts.selectedTab=tab;new Ajax.Request(index,{method:'get',parameters:{f:'createAddressInfo',s:session,address:address},onSuccess:function(transport){var jd=transport.responseJSON;var p=new google.maps.LatLng(jd.data.lat,jd.data.lng);main.searchMarker=new google.maps.Marker(p);map.addOverlay(main.searchMarker);var addressTabs=new Array();addressTabs[0]=new google.maps.InfoWindowTab('Adresse',jd.tabs.info);map.openInfoWindowTabsHtml(p,addressTabs,this.windowOpts);soundManager.play('switchSlide');}.bind(this)});},updateIcon:function(icon){$('iconlist_'+icon).blur();if($('iconListCheck'))$('iconListCheck').remove();var list=$$('#myIconList a');list.each(function(item){item.removeClassName('active');});$('iconlist_'+icon).toggleClassName('active');$('iconlist_'+icon).appendChild(new Element('div',{'ID':'iconListCheck','CLASS':'iconFlag check'}));main.data.set('icon',icon);},updateAddUserToMapPosition:function(address){var p=UserAddControl.getMarker().getPoint();var bounds=new google.maps.LatLngBounds();bounds.extend(p);var Geocoder=new google.maps.ClientGeocoder();Geocoder.setViewport(bounds);Geocoder.getLocations(address,function(r){UserAddControl.loadAddressWindow(r);});},showUserData:function(element){if($('userNewAccount'))$('userNewAccount').remove();$(element).addClassName('data_over');new Ajax.Request(index,{method:'get',parameters:{f:'showUserData',s:session,e:element},onSuccess:function(transport){$(element).update(transport.responseJSON.code);}});},showTagData:function(element){$('tag_'+element).addClassName('data_over');new Ajax.Request(index,{method:'get',parameters:{f:'showTagData',s:session,t:element},onSuccess:function(transport){$('tag_'+element).update(transport.responseJSON.code);}});},updateTagData:function(element,edit){var data={value:$('tag_input_'+element).value};new Ajax.Request(index,{method:'get',parameters:{f:'showTagData',s:session,t:element,data:Object.toJSON(data),edit:edit},onSuccess:function(transport){$('tag_'+element).update(transport.responseJSON.code);$('tag_'+element).removeClassName('data_over');}});},showUserEditAccount:function(editAccount){new Ajax.Request(index,{method:'get',parameters:{f:'showUserNewAccount',s:session},onSuccess:function(transport){main.gui.base.displayContent(transport.responseJSON.code.page);}});},updateUserAccount:function(){var data=Form.serialize('accountData',true);data.user_birthdate=data.Date_Year+"-"+data.Date_Month+"-"+data.Date_Day;var inputs=new Array('name1','name2','user_gender','email','passwort','passwort2','user_birthdate');new Ajax.Request(index,{method:'get',parameters:{f:'updateUserAccount',s:session,data:Object.toJSON(data)},onSuccess:function(transport){jd=transport.responseJSON;if(main.gui.base.displayErrors(inputs,jd.errors)){main.myUser=jd.user;$('menuStart').update(jd.code.menuStart);main.load.loadMarker();main.gui.base.removeContent();var tabs=map.getInfoWindow().getContentContainers();tabs[0].update(jd.code.tabs);}}});},showUserNewAccount:function(){var content=new Hash();if(google.loader.ClientLocation){var location=google.loader.ClientLocation;content.set('address',location.address.city);main.gui.base.showContent('startNewAccount',content);}else main.gui.base.showContent('startNewAccount',content);},showEditMyData:function(target){var content=new Hash();switch(target){case "editMyData":if(main.myUser.street)content.set('address',main.myUser.street+", "+main.myUser.city);else content.set('address',main.myUser.city);content.set('name1',main.myUser.name1);content.set('name2',main.myUser.name2);if(main.myUser.user_birthdate)content.set('birthdate',main.myUser.user_birthdate);else content.set('birthdate','0000-00-00');content.set('singlestatus',main.myUser.singlestatus);content.set('sexual_orientation',main.myUser.sexual_orientation);content.set('user_is_logged_in',main.myUser.user_is_logged_in);break;case "editMyDataPrivacy":content.set('allow_chat',main.myUser.flags.allow_chat);content.set('allow_infos',main.myUser.flags.allow_infos);content.set('allow_fotos',main.myUser.flags.allow_fotos);content.set('allow_friends',main.myUser.flags.allow_friends);content.set('send_newsletter',main.myUser.send_newsletter);break;case "editMyDataLook":content.set('look',main.myUser.look);content.set('style',main.myUser.style);content.set('weight',main.myUser.weight);content.set('size',main.myUser.size);break;case "editMyDataPrivate":content.set('hobbies',main.myUser.hobbies);content.set('music',main.myUser.music);content.set('likes',main.myUser.likes);content.set('dislikes',main.myUser.dislikes);content.set('singlestatus',main.myUser.singlestatus);content.set('sexual_orientation',main.myUser.sexual_orientation);break;case "editMyDataOccupation":content.set('occupation',main.myUser.occupation);content.set('fortes',main.myUser.fortes);content.set('foibles',main.myUser.foibles);break;}main.gui.base.showContent(target,content);},showEditUserEvent:function(data_ID,author_ID,action){if($('eventEdit'))$('eventEdit').remove();var button1="<INPUT TYPE=\"button\" OnClick=\"main.gui.base.window.delUserEvent('"+action+"', "+author_ID+")\" VALUE=\"\" CLASS=\"button icon\" STYLE=\"background-image: url("+webroot+"/inc/bilder/icons/PNG/trash.png)\">";var div=new Element('div',{ID:'eventEdit',STYLE:'position: absolute; right: 5px; top: 2px;'});div.insert(button1);$('event_'+data_ID).insert({bottom:div});$('event_'+data_ID).addClassName('over');},removeEditUserEvent:function(data_ID){$('event_'+data_ID).removeClassName('over');},delUserEvent:function(action,author_ID){new Ajax.Request(index,{method:'get',parameters:{f:'delUserEvent',s:session,m:action,a:author_ID},onSuccess:function(transport){var jd=transport.responseJSON;var id=action+"_"+author_ID;if(jd.status){main.events.unset(id);Element.hide('event_'+id);main.gui.base.updateRightBoxHeights();}}});},showEditFriend:function(data_ID,friend_ID,user_ID){if($('friendEdit'))$('friendEdit').remove();var button1="<INPUT TYPE=\"submit\" OnClick='main.gui.base.window.removeUserFriendlist("+data_ID+")' VALUE=\"Entfernen\" CLASS=\"button\" STYLE=\"background-image: url("+webroot+"/inc/bilder/icons/PNG/link-delete.png)\">";var button2="<INPUT TYPE=\"submit\" OnClick='main.jumpToUser("+friend_ID+",1)' VALUE=\"Nachricht\" CLASS=\"button\" STYLE=\"background-image: url("+webroot+"/inc/bilder/icons/PNG/email-write.png)\">";var div=new Element('div',{ID:'friendEdit',STYLE:'height:30px; padding: 0px;'});if(user_ID==main.myUser.id)div.insert(button1);div.insert(button2);$('friend'+data_ID).insert({bottom:div});},removeEditFriend:function(data_ID){$('friendEdit').remove();},showViewFriend:function(data_ID){new Ajax.Request(index,{method:'get',parameters:{f:'showViewFriend',s:session,d:data_ID},onSuccess:function(transport){if($('friend'+data_ID))$('friend'+data_ID).update(transport.responseJSON.code.friend);if($('friend'+data_ID))$('friend'+data_ID).removeClassName('data_frame_over');main.gui.base.update('messageBox');}});},showEditFriendRequest:function(data_ID){if($('friendEdit'))$('friendEdit').remove();var button1="<INPUT TYPE=\"submit\" OnClick='main.gui.base.window.showAnswerFriendRequest("+data_ID+")' VALUE=\"Anfrage ansehen\" CLASS=\"button\" STYLE=\"background-image: url("+webroot+"/inc/bilder/icons/PNG/link.png)\">";var button2="<INPUT TYPE=\"submit\" OnClick='main.gui.base.window.editUserFriendRequest("+data_ID+", false)' VALUE=\"Ablehnen\" CLASS=\"button\" STYLE=\"background-image: url("+webroot+"/inc/bilder/icons/PNG/link-delete.png)\">";var div=new Element('div',{ID:'friendEdit',STYLE:'height:30px; padding: 0px;'});div.insert(button1);div.insert(button2);$('friend'+data_ID).insert({bottom:div});},toogleUserFriendOffer:function(data_ID,friend_ID,container){var is_offer=false;var offer=main.data.get(container);if(!offer)offer=new Hash();is_offer=offer.get(friend_ID);if(is_offer){offer.set(friend_ID,false);$('frienditem'+data_ID).removeClassName('highlight');if($('iconCheck'+data_ID))$('iconCheck'+data_ID).remove();}else{offer.set(friend_ID,true);$('frienditem'+data_ID).addClassName('highlight');$('frienditem'+data_ID).appendChild(new Element('div',{'ID':'iconCheck'+data_ID,'CLASS':'iconFlag pin'}));}main.data.set(container,offer);},editUserFriendRequest:function(data_ID,accept){if(accept){new Ajax.Request(index,{method:'get',parameters:{f:'editUserFriendRequest',s:session,d:data_ID,accept:true},onSuccess:function(transport){jd=transport.responseJSON;main.gui.base.removeContent();if($('myFriends')){if($('friend'+data_ID))$('friend'+data_ID).remove();$('myFriends').insert({top:jd.code.item});$('friend'+jd.data_ID).hide();$('friend'+jd.data_ID).appear();}main.groups=new Hash();main.friends=jd.friends;main.loadMarker();}});}else{if(confirm("Willst du die Anfrage wirklich ablehnen?\nDer Vorgang kann nicht rückgängig gemacht werden!")){new Ajax.Request(index,{method:'get',parameters:{f:'editUserFriendRequest',s:session,d:data_ID,accept:false},onSuccess:function(transport){jd=transport.responseJSON;main.gui.base.removeContent();if($('friend'+data_ID))$('friend'+data_ID).remove();}});}}},addUserFriendRequest:function(user_ID){var requestFriend=main.data.get('requestFriend');new Ajax.Request(index,{method:'get',parameters:{f:'addUserFriendRequest',s:session,u:user_ID,friends:Object.toJSON(requestFriend)},onSuccess:function(transport){main.gui.base.removeContent();main.data.unset('requestFriend');}});},addUserFriendAnswerRequest:function(user_ID){if(confirm("Willst du den User zu deinen Freunden hinzufügen?")){new Ajax.Request(index,{method:'get',parameters:{f:'addUserFriendRequest',s:session,u:user_ID},onSuccess:function(transport){if($('myFriends')){if($('friend'+user_ID)){$('friend'+user_ID).addClassName('highlight');$('friend'+user_ID).insert(new Element('div',{'ID':'iconCheck'+user_ID,'CLASS':'iconFlag check'}));}}}});}},showNewFriendRequest:function(u){new Ajax.Request(index,{method:'get',parameters:{f:'showNewFriendRequest',s:session,u:u},onSuccess:function(transport){jd=transport.responseJSON;if(jd.code.page){main.data.unset('requestFriend');main.gui.base.displayContent(jd.code.page);}}});},showAnswerFriendRequest:function(data_ID){new Ajax.Request(index,{method:'get',parameters:{f:'showAnswerFriendRequest',s:session,control:"request",id:data_ID},onSuccess:function(transport){jd=transport.responseJSON;if(jd.code.page){main.gui.base.displayContent(jd.code.page);}}});},showUserInviteAccount:function(){var location=google.loader.ClientLocation;new Ajax.Request(index,{method:'get',parameters:{f:'showUserInviteAccount',s:session,location:Object.toJSON(location)},onSuccess:function(transport){jd=transport.responseJSON;if(jd.code.page){main.gui.base.displayContent(jd.code.page);}}});},addLocationFavoriteList:function(location_ID){new Ajax.Request(index,{method:'get',parameters:{f:'addLocationFavoriteList',s:session,l:location_ID},onSuccess:function(transport){}});},removeUserFriendlist:function(data_ID){if(confirm("Willst du den User aus der Freundesliste entfernen?")){new Ajax.Request(index,{method:'get',parameters:{f:'delUserToFriends',s:session,d:data_ID},onSuccess:function(transport){jd=transport.responseJSON;if($('friend'+data_ID))$('friend'+data_ID).remove();main.groups=new Hash();main.friends=jd.friends;main.loadMarker();}});}},showAlbumListImageDetail:function(data_ID,step){new Ajax.Request(index,{method:'get',parameters:{f:'getUserAlbumPictureDetail',s:session,id:data_ID,step:step},onSuccess:function(transport){jd=transport.responseJSON;$('myAlbum').update(jd.code.content);}});},showAlbumListImages:function(data_ID){new Ajax.Request(index,{method:'get',parameters:{f:'getUserAlbumPictures',s:session,id:data_ID},onSuccess:function(transport){jd=transport.responseJSON;$('myAlbum').update(jd.code.list);}});},showAlbumList:function(user_ID){new Ajax.Request(index,{method:'get',parameters:{f:'getUserAlbum',s:session,id:user_ID},onSuccess:function(transport){jd=transport.responseJSON;$('myAlbum').update(jd.code.content);}});},showEditAlbum:function(id){new Ajax.Request(index,{method:'get',parameters:{f:'showEditAlbum',s:session,id:id},onSuccess:function(transport){jd=transport.responseJSON;if(jd.code.page){main.gui.base.displayContent(jd.code.page);}}});},delAlbum:function(id){if(confirm("Willst du das komplette Album wirklich löschen?")){new Ajax.Request(index,{method:'get',parameters:{f:'delAlbum',s:session,id:id},onSuccess:function(transport){jd=transport.responseJSON;$('myAlbum').update(jd.code.content);}});}},delAlbumDetail:function(id){if(confirm("Willst du das Bild wirklich löschen?")){new Ajax.Request(index,{method:'get',parameters:{f:'delAlbumDetail',s:session,id:id},onSuccess:function(transport){jd=transport.responseJSON;$('myAlbum').update(jd.code.content);}});}},showEditAlbumDetail:function(id){new Ajax.Request(index,{method:'get',parameters:{f:'showEditAlbumDetail',s:session,id:id},onSuccess:function(transport){jd=transport.responseJSON;if(jd.code.page){main.gui.base.displayContent(jd.code.page);}}});},updateUserAlbumPicture:function(id,titel,image_data){new Ajax.Request(index,{method:'get',parameters:{f:'updateUserAlbumPicture',s:session,id:id,titel:titel,image_data:image_data},onSuccess:function(transport){jd=transport.responseJSON;main.gui.base.removeContent();var tabs=main.map.getInfoWindow().getContentContainers();tabs[3].update(jd.code.tabs);}});},showCommentWall:function(id,data_ID,type){if($('action_comment_form_'+id))$('action_comment_form_'+id).remove();else{new Ajax.Request(index,{method:'get',parameters:{f:'showCommentWall',s:session,id:id,data_ID:data_ID,type:type},onSuccess:function(transport){jd=transport.responseJSON;Element.insert('action_comment_'+id,{after:jd.code.element});}});}},showSearch:function(address){new Ajax.Request(index,{method:'get',parameters:{f:'showSearch',s:session,search:Object.toJSON(main.search),address:address},onSuccess:function(transport){jd=transport.responseJSON;if(jd.code.page){main.gui.base.displayContent(jd.code.page);}}});},changeIconBg:function(over,element){if(!element)var element="myIcon";if(over)$(element).addClassName('overIcon');else $(element).removeClassName('overIcon');},changeDataBg:function(element){if(!$(element).hasClassName('data_frame_over')){Element.insert(element,{top:'<SPAN CLASS=\"close_icon\" ID="over_edit"><IMG SRC=\"./inc/bilder/icons_mini/PNG/mini-edit.png\" BORDER=\"0\"></SPAN>'});$(element).addClassName('data_frame_over');}else{if($('over_edit'))$('over_edit').remove();$(element).removeClassName('data_frame_over');}},changeLinkBg:function(element){if(!$(element).hasClassName('data_frame_over')){$(element).addClassName('data_frame_over');}else{$(element).removeClassName('data_frame_over');}},logout:function(){new Ajax.Request(index,{method:'get',parameters:{f:'updateUserLogout',s:session},onSuccess:function(transport){jd=transport.responseJSON;main.map.closeInfoWindow();main.load.clearMyEvents();main.gui.base.showMyEvents();$('menuStart').update(jd.code.menuStart);main.gui.base.showContent('login');}});},login:function(){var data={user:$('user').value,pass:$('pass').value};new Ajax.Request(index,{method:'get',parameters:{f:'updateUserLogin',s:session,data:Object.toJSON(data)},onSuccess:function(transport){jd=transport.responseJSON;if(jd.user){var p=new GLatLng(jd.user.lat,jd.user.lng);main.loadMarker();main.myUser=jd.user;main.load.pollMyEvents(true);main.gui.base.removeContent();$('menuStart').update(jd.code.menuStart);setTimeout('main.switchToWindow()',500);}}});}});
