Ext.BLANK_IMAGE_URL = 'http://cloud.onlineweg.de/extjs/resources/images/default/s.gif';

function checkLoginStatus(){
    var conn = new Ext.data.Connection();
    var returnText = 'false';
    conn.request({
        url: 'http://www.wowarstdu.de/auth/ajax-check-login-status',
        method: 'GET',
        success: function(responseObject) {
            returnText = responseObject.responseText;
        },
        failure: function() {}
    });
    
    return returnText;
}
// Funktionen für die Registrierung
function checkUsername(){
    usernameLocal = Ext.get('usernameCheck').dom.value;
    var conn = new Ext.data.Connection();
    conn.request({
        url: 'http://www.wowarstdu.de/auth/ajax-registrierung-username',
        method: 'GET',
        params: {"username": usernameLocal},
        success: function(responseObject) {
            if(responseObject.responseText == 'false'){
                Ext.get('usernameCheck').dom.value = '';
                Ext.Msg.show({
                    titel: 'Status',
                    msg: 'Der Username <b>'+usernameLocal+'</b> ist bereits vorhanden.<br />Bitte wählen Sie einen anderen aus.',
                    modal: true,
                    icon: Ext.Msg.WARNING,
                    buttons: Ext.Msg.OK
                });
                Ext.getCmp('usernameCheck').focus();
            }
        },
        failure: function() {}
    });
}
function checkEmail(){
    email = Ext.get('email1').dom.value;
    var conn = new Ext.data.Connection();
    conn.request({
        url: 'http://www.wowarstdu.de/auth/ajax-registrierung-email',
        method: 'GET',
        params: {"email": email},
        success: function(responseObject) {
            if(responseObject.responseText == 'false'){
                Ext.get('email1').dom.value = '';
                Ext.Msg.show({
                    titel: 'Status',
                    msg: 'Die E-Mail-Adresse <b>'+email+'</b> ist bereits vorhanden.<br />Bitte wählen Sie eine andere aus.',
                    modal: true,
                    icon: Ext.Msg.WARNING,
                    buttons: Ext.Msg.OK
                });
            }
        },
        failure: function() {}
    });
}
function compareEmail(){
    email1 = Ext.get('email1').dom.value;
    email2 = Ext.get('email2').dom.value;
    
    if(email1 != email2){
        Ext.Msg.show({
            titel: 'Status',
            msg: 'Die E-Mail-Adressen stimmen nicht überein.<br />Bitte prüfen!',
            modal: true,
            icon: Ext.Msg.WARNING,
            buttons: Ext.Msg.OK
        });
    }
}

// Funktionen Userprofil
var expId;
    var hotelGrid;
    var tippGrid;
    var bilderGrid;
    var videoGrid;
    var forumGrid;
    var blogGrid;
    
    // Renderfunktionen der GridPanels
    function renderHotelname(value, p, record){
        var kategorie = ' ';
        var returnStr = '';
        var video = '';
        var hotelId = record.data.hotelId;
        var startValue = record.data.start;

        for (i=1;i<=record.data.kategorie;i++){
            kategorie = kategorie + '<img src="http://www.wowarstdu.de/pics/stern.gif" align="top" width="9" height="11" border="0" alt="stern"/>';
            if (record.data.kategorie == (i + 0.5)){
                kategorie = kategorie + '<img src="http://www.wowarstdu.de/pics/stern_halb.gif" align="top" width="5" height="11" border="0" alt="halber Stern"/>';
            }
        }
                                                            /*<?php print $this->url(array('controller' => 'bewertungen', 'action' => 'bewertungen-anzeigen'), null, true, true) ?>*/
        returnStr = '<div class="spaceH5"></div><b><a href="http://www.wowarstdu.de/bewertungen/bewertungen-anzeigen/start/'+startValue+'/hotelId/'+hotelId+'">'+value+'</a></b>'+kategorie;
        record.data.bewertungenCounter > 1 ? bewertung = 'Bewertungen' : bewertung = 'Bewertung';
        //record.data.video == 1 ? video = '<img src="<?php print $this->baseUrl() ?>/pics/icon_video.gif" height="20">' : video = '';
        /*<?php print $this->url(array('controller' => 'bewertungen', 'action' => 'bewertungen-anzeigen'), null, true, true) ?>*/
        returnStr += '<table width="100%" cellpadding="2" cellspacing="0" border="0" style="padding:2px"><tr><td rowspan="4" valign="top" width="110" align="center"><div class="spaceH5"></div><a href="http://www.wowarstdu.de/bewertungen/bewertungen-anzeigen/start/'+startValue+'/hotelId/'+hotelId+'"><img src="'+record.data.imageCut+'"></a></td><td width="150">Reiseland / Destination:</td><td><span onclick="doSearch(0,\''+record.data.country+'\')" class="info px11" style="cursor:pointer;"><u>'+record.data.country+'</u></span> / <span onclick="doSearch(0,\''+record.data.destination+'\')" class="info px11" style="cursor:pointer;"><u>'+record.data.destination+'</u></span></td><td align="center"></td></tr><tr><td>Urlaubsort:</td><td><span onclick="doSearch(0,\''+record.data.city+'\')" class="info px11" style="cursor:pointer;"><u>'+record.data.city+'</u></span></td><td rowspan="4" valign="top" align="center" class="weiterempfehlung100"></td></tr><tr><td>Bewertungen:</td><td>'+record.data.bewertungenCounter+' '+bewertung+'</td></tr><tr><td valign="top">Hotelzeugnis:</td><td>Gesamtnoten: <img src="http://www.wowarstdu.de/pics/icon_urlauber.gif" align="absmiddle"/> = <b>'+record.data.gesamtnoteUrlauber+'</b>&nbsp;&nbsp;<img src="http://www.wowarstdu.de/pics/icon_experte.gif" align="absmiddle"/> = <b>'+record.data.gesamtnoteExperten+'</b>&nbsp;&nbsp;<img src="http://www.wowarstdu.de/pics/icon_kinderreporter.gif" align="absmiddle"/> = <b>'+record.data.gesamtnoteKinderreporter+'</b></td></tr><tr><td colspan="3"><span class="px10 afafaf">0=nicht bewertet, 1=sehr gut, 2=gut, 3=befriedigend, 4=ausreichend, 5=mangelhaft, 6=ungen&uuml;gend</span></td></tr><tr><td colspan="3"><a href="http://www.wowarstdu.de/bewertungen/bewertungen-anzeigen/start/'+startValue+'/hotelId/'+hotelId+'">Bewertungen anzeigen</a> | <a href="http://www.wowarstdu.de/bewertungen/bewertung-abgeben-schritt-eins/hotelId/'+hotelId+'">dieses Hotel jetzt bewerten</a></td><td>'+video+'</td></tr></table><div class="spaceH5"></div>';

        return String.format(returnStr);
    }
    function renderEmpfehlung(value, p, record){
        record.data.weiterempfehlung == 'J' ? weiterempfehlung = 'JA' : weiterempfehlung = 'NEIN';
        return String.format(
            '<div class="spaceH5"></div><div class="weiterempfehlung100">'+weiterempfehlung+'</div>',
            value);
    }
    function renderReisetipp(value, p, record){
        var returnStr = '';
        var tippId = record.data.tippId;
        var startValue = record.data.start;
        var filter = record.data.filter;
        var filterKategorie = record.data.filterKategorie;
        var titel = record.data.titel;
        var country = record.data.country;
        var destination = record.data.destination;
        var city = record.data.city;
        var rubrik = record.data.rubrik;
        var createDate = record.data.createDate;
        var description = record.data.description;
        var userTyp = record.data.userTyp;
        var username = record.data.username;

        returnStr = '<div class="spaceH5"></div><b><a href="http://www.wowarstdu.de/tipps/tipp-lesen/start/'+startValue+'/filter/'+filter+'/filterKategorie/'+filterKategorie+'/tippId/'+tippId+'">'+titel+'</a></b><div class="spaceH3"></div><table width="100%" cellpadding="2" cellspacing="0" border="0"><tr><td width="120">Reiseland / Region:</td><td><span onclick="doSearch(0,\''+country+'\')" class="info px11" style="cursor:pointer;"><u>'+country+'</u></span> / <span onclick="doSearch(0,\''+destination+'\')" class="info px11" style="cursor:pointer;"><u>'+destination+'</u></span></td></tr><tr><td width="120">Ort:</td><td><span onclick="doSearch(0,\''+city+'\')" class="info px11" style="cursor:pointer;"><u>'+city+'</u></span></td></tr><tr><td width="120">Rubrik:</td><td><span onclick="doSearch(0,\''+rubrik+'\')" class="info px11" style="cursor:pointer;"><u>'+rubrik+'</u></span></td></tr><tr><td>erstellt:</td><td>'+createDate+' von <img src="http://www.wowarstdu.de/pics/icon_'+userTyp+'.gif" align="absmiddle"/> '+username+'</td></tr><tr><td>Beschreibung:</td><td>'+description+'</td></tr></table>';

        return String.format(returnStr);
    }
    function renderImage(value, p, record){
        var ort = '';
        if(record.data.city != ''){
            ort = '<tr><td>Ort:</td><td>'+record.data.city+'</td></tr>';
        }
        var hotel = '';
        if(record.data.hotelname != ''){
            hotel = '<tr><td>Hotel:</td><td>'+record.data.hotelname+'</td></tr>';
        }
        var imgStr = '<b>'+record.data.imgTyp+': '+record.data.title+'</b><table width="100%" cellpadding="2" cellspacing="0" border="0"><tr><td valign="top" width="120" align="left"><a href="http://www.wowarstdu.de/bilder/bilder-anzeigen/bildId/'+record.data.id+'" border="0"><img src="http://files.wowarstdu.de/thumbnails/'+record.data.filename+'" border="0" width="100"></a></td><td valign="top" width="300"><table width="100%"><tr><td width="100">Land:</td><td>'+record.data.country+'</td></tr><tr><td>Region:</td><td>'+record.data.destination+'</td></tr>'+ort+hotel+'<tr><td><b>Gesamtnote:</b></td><td><b>'+record.data.note+'</b></td></tr><tr><td>Bewertungen:</td><td>'+record.data.countBewertungen+'</td></tr><tr><td>Hotelbewertungen:</td><td>'+record.data.countHotelbewertungen+'</td></tr></table></td><td valign="top"><table width="100%"><tr><td>Erstellt am '+record.data.createDate+'</td></tr><tr><td>von <img src="http://www.wowarstdu.de/pics/icon_'+record.data.userTyp+'.gif" align="absmiddle"/> <a href="http://www.wowarstdu.de/bilder/index/search/'+record.data.username+'" title="alle Bilder von '+record.data.username+' anzeigen">'+record.data.username+'</a></td></tr><tr><td>'+record.data.counter+' mal angeklickt</td></tr></table></td></tr></table><div class="spaceH10"></div>';

        return String.format(imgStr);
    }
    function renderExperten(value, p, record){
        startValueExperten = record.data.start;
        var imgStr = '';
        var userFoto = 'noFoto.jpg';
        if(record.data.userFoto != ''){
            userFoto = record.data.userFoto;
        }
        //if(record.data.username != ''){
            var username = '<tr><td width="80">Username</td><td>'+record.data.username+'</td></tr>';
        //}else{
            username = username+'<tr><td width="80">Name</td><td>'+record.data.vorname+'</td></tr>';
        //}
        
        userTyp = record.data.userTyp.charAt(0).toUpperCase()+record.data.userTyp.substr(1);
        imgStr = '<b><u><span onclick="showProfil('+record.data.userId+')">'+record.data.firma+'</span></u></b><br><table width="100%"><tr><td width="89" align="center"><img src="http://www.wowarstdu.de/pics/profilfotos/'+userFoto+'" border="1"></td><td valign="top"><table width="100%">'+username+'<tr><td>Status</td><td><img src="http://www.wowarstdu.de/pics/icon_'+record.data.userTyp+'.gif" border="0" align="absmiddle"/> '+userTyp+'</td></tr><tr><td>Mitglied seit</td><td>'+record.data.createDate+'</td></tr><tr><td>Bewertungen</td><td>'+record.data.bewertungenCount+'</td></tr><tr><td>Tipps</td><td>'+record.data.tippsCount+'</td></tr></table></td><td width="50%" valign="top" align="left"><table width="100%"><tr><td valign="top" width="80">Anschrift</td><td>'+record.data.str+'<br />'+record.data.land+' - '+record.data.plz+', '+record.data.ort+'</td></tr><tr><td>Tel.</td><td>'+record.data.tel+'</td></tr><tr><td>Fax</td><td>'+record.data.fax+'</td></tr><tr><td>Domain</td><td><a href="http://www.onlineweg.de/'+record.data.verzeichnis+'" title="http://www.onlineweg.de/'+record.data.verzeichnis+'" target="_blank">http://www.onlineweg.de/'+record.data.verzeichnis+'</a></td></tr><tr><td></td><td><span onclick="sendMsgToExpert(\''+record.data.username+'\','+record.data.userId+');"><u>Nachricht an Experten senden</u></span></td></tr></table></td></tr></table>';
        
        return String.format(imgStr);        
    }
    function renderVideo(value, p, record){
        var ort = '';
        if(record.data.city != ''){
            ort = '<tr><td>Ort:</td><td>'+record.data.city+'</td></tr>';
        }
        var hotel = '';
        if(record.data.hotelname != ''){
            hotel = '<tr><td>Hotel:</td><td>'+record.data.hotelname+'</td></tr>';
        }
        
        var videobeschreibung = record.data.videobeschreibung.length > 100 ? record.data.videobeschreibung.substr(0,100)+'...' : record.data.videobeschreibung.substr(0,120);
        videobeschreibung = videobeschreibung.replace(/<br \/>/g," ");
        
        var imgStr = '<b>'+record.data.title+'</b><table width="100%" colpadding="0" cellpadding="0"><tr><td valign="top" width="140"><a href="http://www.wowarstdu.de/videos/video-anschauen/videoId/'+record.data.filename+'" border="0"><img src="http://img.youtube.com/vi/'+record.data.filename+'/default.jpg" border="0" /></a></td><td valign="top" width="300"><table width="100%"><tr><td width="100">Land:</td><td><a href="http://www.wowarstdu.de/videos/index/search/'+record.data.country+'" title="alle '+record.data.country+' Videos anzeigen">'+record.data.country+'</a></td></tr><tr><td>Region:</td><td><a href="http://www.wowarstdu.de/videos/index/search/'+record.data.destination+'" title="alle Videos von '+record.data.destination+' anzeigen">'+record.data.destination+'</a></td></tr>'+ort+hotel+'<tr><td><b>Gesamtnote:</b></td><td><b>'+record.data.gesamtnote+'</b></td></tr><tr><td>Bewertungen:</td><td>'+record.data.countBewertungen+'</td></tr></table></td><td valign="top"><table width="100%"><tr><td>Erstellt am '+record.data.datum+'</td></tr><tr><td>von <img src="http://www.wowarstdu.de/pics/icon_'+record.data.userTyp+'.gif" align="absmiddle"/> <a href="http://www.wowarstdu.de/videos/index/search/'+record.data.username+'" title="alle Videos von '+record.data.username+' anzeigen">'+record.data.username+'</a></td></tr><tr><td>'+record.data.counter+' mal angeklickt</td></tr></table></td></tr><tr><td colspan="3"><b>Videobeschreibung</b><br />'+videobeschreibung+'</td></tr></table><div class="spaceH10"></div>';

        return String.format(imgStr);
    }
    function renderForumThema(value, p, record){
        var thema = '<b><u><span onclick="location.href=\'http://www.wowarstdu.de/community/forum/forumId/'+record.data.forumId+'/topicId/'+record.data.topicId+'\'" title="'+record.data.title+'" style="cursor:pointer">'+record.data.title+'</span></u></b>';
        return String.format(thema);
    }
    function renderForumTopic(value, p, record){
        var topic = '<span onclick="location.href=\'http://www.wowarstdu.de/community/forum/forumId/'+record.data.forumId+'/topicId/'+record.data.topicId+'\'" title="'+record.data.topic+'" style="cursor:pointer">'+record.data.topic+'</span>';
        return String.format(topic);
    }
    function renderForumForum(value, p, record){
        var forum = '<span onclick="location.href=\'http://www.wowarstdu.de/community/forum/forumId/'+record.data.forumId+'/topicId/'+record.data.topicId+'\'" title="'+record.data.forum+'" style="cursor:pointer">'+record.data.forum+'</span>';
        return String.format(forum);
    }
    function renderBlog(value, p, record){
        var blog = '<b><u><span onclick="location.href=\'http://www.wowarstdu.de/community/reiseblog/blogId/'+record.data.blogId+'/postId/'+record.data.postId+'\'" title="'+record.data.title+'" style="cursor:pointer">'+record.data.title+'</span></u></b><br /><div class="info">'+record.data.country+' - '+record.data.destination+'</div>';
        return String.format(blog);
    }
// Experten-TabPanel
function showProfil(userId, username){
        expId = '';
        userPanel = '';
        expId = userId;
        userPanel = new Ext.Window({
            layout:'fit',
            title:'Userprofil von '+username,
            id: 'userWin',
            name: 'userWin',
            width:706,
            height:500,
            closeAction:'destroy',
            autoDestroy: true,
            plain: true,
            border:false,
            bodyStyle:{padding:'5'},
            items:[          
            {    
                xtype:'tabpanel',
                autoScroll: true, 
                activeTab:0,
                frame:false,
                border:true,
                items:[
                {
                    title: 'Userprofil',
                    id:'userprofilTab',
                    closable:false,
                    autoScroll:true,
                    autoLoad:{
                        url:'http://www.wowarstdu.de/experten/ajax-expertenprofil',  /*<?php print $this->url(array('controller' => 'experten', 'action' => 'ajax-expertenprofil'),null, true, true) ?>*/
                        params:{ expertenId: userId, tab:1 }
                    }
                },{
                    title: 'Bewertungen',
                    id:'bewertungenTab',
                    closable:false,
                    autoScroll:true,
                    html:'<div id="bewertungenGrid"></div>',
                    listeners: {activate: showBewertungenGrid},
                },{
                    title: 'Reisetipps',
                    id:'reisetippsTab',
                    closable:false,
                    autoScroll:true,
                    html:'<div id="tippGridDiv"></div>',
                    listeners: {activate: showReisetippGrid}, 
                },{
                    title: 'Bilder',
                    id:'bilderTab',
                    closable:false,
                    autoScroll:true,
                    html:'<div id="bilderGridDiv"></div>',
                    listeners: {activate: showBilderGrid}, 
                },{
                    title: 'Videos',
                    id:'videosTab',
                    closable:false,
                    autoScroll:true,
                    html:'<div id="videosGridDiv"></div>',
                    listeners: {activate: showVideosGrid},
                },{
                    title: 'Forumeinträge',
                    id:'forumTab',
                    closable:false,
                    autoScroll:true,
                    html:'<div id="forumGridDiv"></div>',
                    listeners: {activate: showForumGrid},
                },{
                    title: 'Reiseblog',
                    id:'reiseblogTab',
                    closable:false,
                    autoScroll:true,
                    html:'<div id="blogGridDiv"></div>',
                    listeners: {activate: showBlogGrid},
                }
                ]
            }
            ]
        }).show();
}
    
// Funktionen, um die Tabs zu laden
function showBlogGrid(){
        if(blogGrid){ blogGrid.destroy(); }
        blogStore = new Ext.data.JsonStore({
            //url:'<?php print $this->url(array('controller' => 'experten', 'action' => 'ajax-expertenprofil'),null, true, true) ?>', 
            url:'http://www.wowarstdu.de/experten/ajax-expertenprofil',
            baseParams:{ expertenId: expId, tab:7 },
            root: 'rows',
            totalProperty: 'totalCount',
            storeId: 'ajax-blog-store',
            fields: ['start','title','postId','blogId','createDate','country','destination']
        });
        blogGrid = new Ext.grid.GridPanel({
            renderTo: 'blogGridDiv',
            width:670,
            autoHeight:true,
            store: blogStore,
            disableSelection:true,
            bodyStyle:{padding:0},
            border:false,
            loadMask: true,
            columns:[
            { 
                header: "Titel", 
                dataIndex: 'title', 
                width: 570, 
                renderer: renderBlog, 
                sortable: false 
            },{ 
                header: "Verfasst am", 
                dataIndex: 'createDate', 
                width: 100,  
                sortable: false 
            }],
            bbar: new Ext.PagingToolbar({
                pageSize: 10,
                store: blogStore,
                displayInfo: true,
                displayMsg: 'Reiseblog {0} - {1} von {2}',
                emptyMsg: "Keine Blogs vorhanden"
            }),
            tbar: new Ext.PagingToolbar({
                pageSize: 10,
                store: blogStore,
                displayInfo: true,
                displayMsg: 'Reiseblog {0} - {1} von {2}',
                emptyMsg: "Keine Blogs vorhanden"
            })
        });
        blogStore.load();
}
function showForumGrid(){
        if(forumGrid){ forumGrid.destroy(); }
        forumStore = new Ext.data.JsonStore({
            //url:'<?php print $this->url(array('controller' => 'experten', 'action' => 'ajax-expertenprofil'),null, true, true) ?>', 
            url:'http://www.wowarstdu.de/experten/ajax-expertenprofil',
            baseParams:{ expertenId: expId, tab:6 },
            root: 'rows',
            totalProperty: 'totalCount',
            storeId: 'ajax-forum-store',
            fields: ['start','title','forum','topic','createDate','forumId','topicId','countReplies']
        });
        forumGrid = new Ext.grid.GridPanel({
            renderTo: 'forumGridDiv',
            width:670,
            autoHeight:true,
            store: forumStore,
            disableSelection:true,
            bodyStyle:{padding:0},
            border:false,
            loadMask: true,
            columns:[
            { 
                header: "Thema", 
                dataIndex: 'title', 
                width: 270, 
                renderer: renderForumThema, 
                sortable: false 
            },{ 
                header: "Topic", 
                dataIndex: 'topic', 
                width: 110, 
                renderer: renderForumTopic, 
                sortable: false 
            },{ 
                header: "Forum", 
                dataIndex: 'forum', 
                width: 110, 
                renderer: renderForumForum, 
                sortable: false 
            },{ 
                header: "Verfasst am", 
                dataIndex: 'createDate', 
                width: 100,  
                sortable: false 
            },{ 
                header: "Antworten", 
                dataIndex: 'countReplies', 
                width: 80,
                align:'center', 
                sortable: false 
            }],
            bbar: new Ext.PagingToolbar({
                pageSize: 10,
                store: forumStore,
                displayInfo: true,
                displayMsg: 'Beitrag {0} - {1} von {2}',
                emptyMsg: "Keine Forenbeiträge vorhanden"
            }),
            tbar: new Ext.PagingToolbar({
                pageSize: 10,
                store: forumStore,
                displayInfo: true,
                displayMsg: 'Beitrag {0} - {1} von {2}',
                emptyMsg: "Keine Forenbeiträge vorhanden"
            })
        });
        forumStore.load();
}
function showVideosGrid(){
        if(videoGrid){ videoGrid.destroy(); }
        videoStore = new Ext.data.JsonStore({
            //url:'<?php print $this->url(array('controller' => 'experten', 'action' => 'ajax-expertenprofil'),null, true, true) ?>', 
            url:'http://www.wowarstdu.de/experten/ajax-expertenprofil',
            baseParams:{ expertenId: expId, tab:5 },
            root: 'rows',
            totalProperty: 'totalCount',
            storeId: 'ajax-video-store',
            fields: ['start','filter','country','destination','city','hotelname','gesamtnote','datum','filename','countBewertungen','counter','username','videobeschreibung','title','userTyp']
        });
        videoGrid = new Ext.grid.GridPanel({
            renderTo: 'videosGridDiv',
            width:670,
            autoHeight:true,
            store: videoStore,
            disableSelection:true,
            bodyStyle:{padding:0},
            border:false,
            loadMask: true,
            columns:[{ header: "Videos", dataIndex: 'title', width: 670, renderer: renderVideo, sortable: false }],
            bbar: new Ext.PagingToolbar({
                pageSize: 10,
                store: videoStore,
                displayInfo: true,
                displayMsg: 'Video {0} - {1} von {2}',
                emptyMsg: "Keine Videos vorhanden"
            }),
            tbar: new Ext.PagingToolbar({
                pageSize: 10,
                store: videoStore,
                displayInfo: true,
                displayMsg: 'Video {0} - {1} von {2}',
                emptyMsg: "Keine Videos vorhanden"
            })
        });
        videoStore.load();
}
function showBilderGrid(){
        if(bilderGrid){ bilderGrid.destroy(); }
        bilderStore = new Ext.data.JsonStore({
            //url:'<?php print $this->url(array('controller' => 'experten', 'action' => 'ajax-expertenprofil'),null, true, true) ?>', 
            url:'http://www.wowarstdu.de/experten/ajax-expertenprofil',
            baseParams:{ expertenId: expId, tab:4 },
            root: 'rows',
            totalProperty: 'totalCount',
            storeId: 'ajax-bilder-store',
            fields: ['start', 'filter', 'id', 'filename', 'title', 'imgTyp', 'country', 'destination', 'city', 'hotelname', 'createDate', 'userTyp', 'username', 'note', 'countBewertungen', 'countHotelbewertungen', 'counter']
        });
        bilderGrid = new Ext.grid.GridPanel({
            renderTo: 'bilderGridDiv',
            width:670,
            autoHeight:true,
            store: bilderStore,
            disableSelection:true,
            bodyStyle:{padding:0},
            border:false,
            loadMask: true,
            columns:[{ header: "Bilder", dataIndex: 'title', width: 670, renderer: renderImage, sortable: false }],
            bbar: new Ext.PagingToolbar({
                pageSize: 10,
                store: bilderStore,
                displayInfo: true,
                displayMsg: 'Bilder {0} - {1} von {2}',
                emptyMsg: "Keine Bilder vorhanden"
            }),
            tbar: new Ext.PagingToolbar({
                pageSize: 10,
                store: bilderStore,
                displayInfo: true,
                displayMsg: 'Bilder {0} - {1} von {2}',
                emptyMsg: "Keine Bilder vorhanden"
            })
        });
        bilderStore.load();
}
function showReisetippGrid(){
        if(tippGrid){ tippGrid.destroy(); }
        tippStore = new Ext.data.JsonStore({
            //url:'<?php print $this->url(array('controller' => 'experten', 'action' => 'ajax-expertenprofil'),null, true, true) ?>', 
            url:'http://www.wowarstdu.de/experten/ajax-expertenprofil',
            baseParams:{ expertenId: expId, tab:3 },
            root: 'rows',
            totalProperty: 'totalCount',
            storeId: 'ajax-tipp-store',
            fields: ['start', 'filter', 'filterKategorie', 'gelesenCounter', 'weiterempfehlung', 'tippId', 'titel', 'country', 'destination', 'city', 'rubrik', 'createDate', 'description', 'userTyp', 'username']
        });
        tippGrid = new Ext.grid.GridPanel({
            renderTo: 'tippGridDiv',
            width:670,
            autoHeight:true,
            store: tippStore,
            disableSelection:true,
            bodyStyle:{padding:0},
            border:false,
            loadMask: true,
            columns:[{
                    header: "Reisetipp",
                    dataIndex: 'titel',
                    width: 670,
                    renderer: renderReisetipp,
                    sortable: false
                }],
            bbar: new Ext.PagingToolbar({
                pageSize: 10,
                store: tippStore,
                displayInfo: true,
                displayMsg: 'Reisetipps {0} - {1} von {2}',
                emptyMsg: "Keine Reisetipps vorhanden"
            }),
            tbar: new Ext.PagingToolbar({
                pageSize: 10,
                store: tippStore,
                displayInfo: true,
                displayMsg: 'Reisetipps {0} - {1} von {2}',
                emptyMsg: "Keine Reisetipps vorhanden"
            })
        });
        tippStore.load();
}
function showBewertungenGrid(){
        if(hotelGrid){ hotelGrid.destroy(); }
        hotelStore = new Ext.data.JsonStore({
            //url:'<?php print $this->url(array('controller' => 'experten', 'action' => 'ajax-expertenprofil'),null, true, true) ?>', 
            url:'http://www.wowarstdu.de/experten/ajax-expertenprofil',
            baseParams:{ expertenId: expId, tab:2 },
            root: 'rows',
            totalProperty: 'totalCount',
            storeId: 'ajax-hotel-store',
            fields: ['start', 'hotelId', 'hotelname', 'weiterempfehlung', 'kategorie', 'imageCut', 'country', 'destination', 'city', 'gesamtnoteUrlauber', 'gesamtnoteExperten', 'gesamtnoteKinderreporter']
        });
        
        hotelGrid = new Ext.grid.GridPanel({
                renderTo: 'bewertungenGrid',
                width:670,
                autoHeight:true,
                store: hotelStore,
                disableSelection:true,
                bodyStyle:{padding:0},
                border:false,
                loadMask: true,
                columns:[{
                    header: "Hotelname",
                    dataIndex: 'hotelname',
                    width: 530,
                    renderer: renderHotelname,
                    sortable: false
                },{
                    header: "Weiterempfehlung",
                    dataIndex: 'weiterempfehlung',
                    width: 140,
                    renderer: renderEmpfehlung,
                    align: 'center',
                    sortable: false
                }],
                bbar: new Ext.PagingToolbar({
                    pageSize: 10,
                    store: hotelStore,
                    displayInfo: true,
                    displayMsg: 'Bewertung {0} - {1} von {2}',
                    emptyMsg: "Keine Bewertungen vorhanden"
                }),
                tbar: new Ext.PagingToolbar({
                    pageSize: 10,
                    store: hotelStore,
                    displayInfo: true,
                    displayMsg: 'Bewertung {0} - {1} von {2}',
                    emptyMsg: "Keine Bewertungen vorhanden"
                })
            });
        hotelStore.load(); 
}

Ext.namespace('Ext.reg');
Ext.reg.country = [['EG','Ägypten'],['GQ','Äquatorialguinea'],['ET','Äthiopien'],['AF','Afghanistan'],['AL','Albanien'],['DZ','Algerien'],['VI','Amerikanische Jungferninseln'],['AD','Andorra'],['AO','Angola'],['AI','Anguilla'],['AG','Antigua und Barbuda'],['AR','Argentinien'],['AM','Armenien'],['AW','Aruba'],['AZ','Aserbaidschan'],['AU','Australien'],['BS','Bahamas'],['BH','Bahrain'],['BD','Bangladesch'],['BB','Barbados'],['BE','Belgien'],['BZ','Belize'],['BJ','Benin'],['BM','Bermuda'],['BT','Bhutan'],['BO','Bolivien'],['BA','Bosnien und Herzegowina'],['BW','Botswana'],['BR','Brasilien'],['VG','Britische Jungferninseln'],['BN','Brunei'],['BG','Bulgarien'],['BF','Burkina Faso'],['BI','Burundi'],['KY','Cayman Inseln'],['CL','Chile'],['CN','China'],['CK','Cook-Inseln'],['CR','Costa Rica'],['DK','Dänemark'],['DE','Deutschland'],['DM','Dominica'],['DO','Dominikanische Republik'],['DJ','Dschibuti'],['EC','Ecuador'],['SV','El Salvador'],['CI','Elfenbeinküste'],['ER','Eritrea'],['EE','Estland'],['FJ','Fiji'],['FI','Finnland'],['FR','Frankreich'],['GF','Französisch Guayana'],['PF','Französisch-Polynesien'],['GA','Gabun'],['GM','Gambia'],['GE','Georgien'],['GH','Ghana'],['GI','Gibraltar'],['GD','Grenada'],['GR','Griechenland'],['GL','Grönland'],['GB','Großbritannien'],['GP','Guadeloupe'],['GU','Guam'],['GT','Guatemala'],['GN','Guinea'],['GY','Guyana'],['HT','Haiti'],['HN','Honduras'],['IN','Indien'],['ID','Indonesien'],['IR','Iran'],['IE','Irland'],['IS','Island'],['IL','Israel'],['IT','Italien'],['JM','Jamaika'],['JP','Japan'],['YE','Jemen'],['JO','Jordanien'],['KH','Kambodscha'],['CM','Kamerun'],['CA','Kanada'],['CV','Kap Verde'],['KZ','Kasachstan'],['QA','Katar'],['KE','Kenia'],['KG','Kirgisien / Kirgistan'],['CO','Kolumbien'],['KM','Komoren'],['CG','Kongo'],['CD','Kongo, Demokratische Republik (ex. Zaire)'],['HR','Kroatien'],['CU','Kuba'],['KW','Kuwait'],['LA','Laos'],['LS','Lesotho'],['LV','Lettland'],['LB','Libanon'],['LR','Liberia'],['LY','Libyen'],['LI','Liechtenstein'],['LT','Litauen'],['LU','Luxemburg'],['MG','Madagaskar'],['MW','Malawi'],['MY','Malaysia'],['MV','Malediven'],['ML','Mali'],['MT','Malta'],['MP','Marianen-Inseln'],['MA','Marokko'],['MQ','Martinique'],['MR','Mauretanien'],['MU','Mauritius'],['MK','Mazedonien'],['MX','Mexiko'],['FM','Mikronesien'],['MD','Moldavien'],['MC','Monaco'],['MN','Mongolei'],['ME','Montenegro'],['MS','Montserrat'],['MZ','Mosambique'],['MM','Myanmar'],['NA','Namibia'],['NP','Nepal'],['NC','Neukaledonien'],['NZ','Neuseeland'],['NI','Nicaragua'],['AN','Niederländische Antillen'],['NL','Niederlande'],['NE','Niger'],['NG','Nigeria'],['NF','Norfolk Island'],['NO','Norwegen'],['AT','Österreich'],['OM','Oman'],['PK','Pakistan'],['PW','Palauinseln'],['PA','Panama'],['PG','Papua-Neuguinea'],['PY','Paraguay'],['PE','Peru'],['PH','Philippinen'],['PL','Polen'],['PT','Portugal'],['PR','Puerto Rico'],['RE','Reunion'],['RW','Ruanda'],['RO','Rumänien'],['RU','Russische Föderation'],['VC','Saint Vincent und die Grenadinen'],['ZM','Sambia'],['WS','Samoa'],['SM','San Marino'],['ST','Sao Tome und Principe'],['SA','Saudi-Arabien'],['SE','Schweden'],['CH','Schweiz'],['SN','Senegal'],['RS','Serbien'],['SC','Seychellen'],['SL','Sierra Leone'],['ZW','Simbabwe'],['SG','Singapur'],['SK','Slowakei'],['SI','Slowenien'],['ES','Spanien'],['LK','Sri Lanka'],['KN','St. Kitts und Nevis'],['LC','St. Lucia'],['SD','Sudan'],['ZA','Südafrika'],['KR','Südkorea, Republik'],['SR','Surinam'],['SZ','Swasiland'],['SY','Syrien'],['TW','Taiwan R.O.C.'],['TZ','Tansania'],['TH','Thailand'],['TG','Togo'],['TO','Tonga'],['TT','Trinidad und Tobago'],['TD','Tschad'],['CZ','Tschechische Republik'],['TR','Türkei'],['TN','Tunesien'],['TM','Turkmenistan'],['TC','Turks- und Caicos-Inseln'],['UG','Uganda'],['UA','Ukraine'],['UU','Unbekanntes Land'],['HU','Ungarn'],['UY','Uruguay'],['US','USA'],['UZ','Usbekistan'],['VU','Vanuatu'],['VE','Venezuela'],['AE','Vereinigte Arabische Emirate'],['VN','Vietnam'],['BY','Weißrußland'],['EH','Westsahara'],['CY','Zypern']];
var regFormGlobal = new Ext.FormPanel({
    border:true,
    bodyStyle:'padding-top:5px;padding-left:5px;padding-bottom:5px;margin-bottom:10px',
    layout:'form',
    frame:false,
    width:600,
    autoHeight:true,
    defaults:{labelWidth: 200},
    items: [{
        xtype: 'textfield',
        fieldLabel: 'Username *',
        allowBlank:false,
        name: 'reg[username]',
        width:395,
        id:'usernameCheck',
        listeners: {
            'change': function(){
              checkUsername();
            }
        }
    },{
        xtype: 'textfield',
        fieldLabel: 'Passwort *',
        inputType: 'password',
        allowBlank:false,
        name: 'reg[password]',
        id:'pwrd1',
        width:395
    },{
        xtype: 'textfield',
        fieldLabel: 'Passwort wiederholen *',
        inputType: 'password',
        allowBlank:false,
        name: 'reg[password2]',
        id:'pwrd2',
        width:395
    },{
        xtype: 'textfield',
        fieldLabel: 'Vorname *',
        allowBlank:false,
        name: 'reg[vorname]',
        width:395
    },{
        xtype: 'radiogroup',
        fieldLabel: 'Geschlecht',
        width:200,
        items: [
            {boxLabel: 'männlich', name: 'reg[gender]', inputValue: 'm', checked: true},
            {boxLabel: 'weiblich', name: 'reg[gender]', inputValue: 'w'}
        ]
    },{
        xtype: 'textfield',
        fieldLabel: 'E-Mail-Adresse *',
        allowBlank:false,
        name: 'reg[email]',
        id:'email1',
        width:395,
        listeners: {
            'change': function(){
              checkEmail();
            }
        }
        
    },{
        xtype: 'textfield',
        fieldLabel: 'E-Mail-Adresse bestätigen *',
        allowBlank:false,
        name: 'reg[email2]',
        id:'email2',
        width:395,
        listeners: {
            'change': function(){
              compareEmail();
            }
        }
    },{
        xtype:'box',
        autoEl:{ tag:'span', cls:'px12 808080', html: '<div class="spaceH5"></div><div class="headlineEmpty"></div><div class="spaceH5"></div>Zur Registrierung als Reiseexperte sind die nachfolgenden Angaben erforderlich:<div class="spaceH5"></div>'}
    },{
        xtype:'textfield',
        fieldLabel:'Reisebüroname',
        name:'reg[firmenname]',
        width:395
    },{
        xtype:'textfield',
        fieldLabel:'Strasse, Hausnr.',
        name:'reg[strasse]',
        width:395
    },{
        xtype:'textfield',
        fieldLabel:'PLZ',
        name:'reg[plz]',
        width:395
    },{
        xtype:'textfield',
        fieldLabel:'Ort',
        name:'reg[ort]',
        width:395
    },{
        xtype:'combo',
        fieldLabel: 'Land',
        store: new Ext.data.ArrayStore({
            fields: ['countryCode', 'countryName'],
            data : Ext.reg.country
        }),
        valueField:'countryCode',
        displayField: 'countryName',
        hiddenName:'reg[land]',
        triggerAction: 'all',
        mode: 'local',
        name:'regLand',
        hideTrigger:true,
        listeners:{
            beforequery:function(e) {
                var len=e.query.length;
                e.query=new RegExp(Ext.escapeRe(e.query),"i");
                e.query.length=len;
                return 1;
            }
        },
        width:395
    },{
        xtype:'textfield',
        fieldLabel:'Tel.',
        name:'reg[telefon]',
        width:395
    },{
        xtype:'textfield',
        fieldLabel:'Fax',
        name:'reg[fax]',
        width:395
    },{
        xtype:'box',
        autoEl:{ tag:'span', cls:'px12 808080', html: '<div class="spaceH5"></div><div class="headlineEmpty"></div><div class="spaceH5"></div>Reisebüropartner der onlineweg.de Touristik GmbH tragen bitte die Partner-ID (onlineweg.de-ID) ein:<div class="spaceH5"></div>'}
    },{
        xtype:'textfield',
        fieldLabel:'Partner-ID',
        name:'reg[owegId]',
        width:395
    },{
        xtype: 'checkbox',
        id:'nutzungsbedingungenReg',
        name:'reg[nutzungsbedingungen]',
        boxLabel: 'Die Nutzungsbedingungen von wowarstdu.de akzeptiere ich in der jeweils aktuellen Fassung. *',
        allowBlank:false,
        hideLabel:true
    },{
        xtype: 'checkbox',
        id:'kontaktieren',
        name:'reg[kontakt]',
        boxLabel: 'Andere wowarstdu.de-Nutzer können mich bei Fragen zu meiner Bewertung kontaktieren.',
        checked:true,
        hideLabel:true
    },{
        xtype: 'checkbox',
        id:'newsletter',
        name:'reg[newsletter]',
        boxLabel: 'Ja, ich möchte den Newsletter von wowarstdu.de erhalten und regelmäßig über Neuigkeiten informiert werden.',
        checked:true,
        height:40,
        hideLabel:true
    }
    ],
    buttons: [
    {
        text:'Registrierung absenden',
        handler: function(){
            if(Ext.getCmp('nutzungsbedingungenReg').checked){
                regForm.getForm().submit({
                    url: 'http://www.wowarstdu.de/auth/ajax-registrierung',
                    waitMsg: 'Registrierung wird durchgeführt...',
                    success: function(fp, o){
                        registrierungPanelGlobal.hide();
                        location.reload();
                    }
                });
            }else{
                Ext.Msg.alert('ACHTUNG', 'Sie müssen die Nutzungsbedingungen akzeptieren, damit Sie die Registrierung abschließen können!<br><br>Vielen Dank<br />Ihr wowarstdu.de Team');
            }
        }
    },{
        text: 'Abbrechen',
        handler: function(){
            registrierungPanelGlobal.hide();
        }
    }
    ]
});
var registrierungPanelGlobal = new Ext.Window({
    title:'Registrierung bei wowarstdu.de',
    layout:'fit',
    id:'registrierungWindowGlobal',
    width:600,
    height:700,
    closeAction:'hide',
    items:[regFormGlobal]
});

var communityLoginPanelGlobal = new Ext.FormPanel({
            //width:400,
            //autoHeight:true,
            frame:false,
            border:false,
            bodyStyle:'padding:5px',
            items: [{
                xtype: 'textfield',
                fieldLabel: 'Username',
                name: 'username',
                id: 'username',
                allowBlank:false,
                width:245
            },{
                xtype: 'textfield',
                fieldLabel: 'Passwort',
                inputType: 'password',
                name: 'password',
                id: 'password',
                allowBlank:false,   
                width:245
            }],
            buttonAlign:'left',
            buttons: [{
                text:'Login',
                handler: function(){
                    communityLoginPanelGlobal.getForm().submit({
                        url: 'http://www.wowarstdu.de/auth/ajax-login',
                        waitMsg: 'Sie werden eingeloggt...',
                        success: function(fp, o){
                            if(o.result.text == 'false'){
                                Ext.Msg.alert('ACHTUNG','Ihr Login konnte nicht erfolgreich durchgeführt werden. Evtl haben Sie einen falschen Benutzernamen und/oder ein falschen Passwort eingegeben.<br />Bitte versuchen Sie es erneut.<br /><br />Ihr wowarstdu.de Team');
                            }else{
                                if(o.result.text == 'true'){
                                    location.reload();
                                }else{
                                    Ext.Msg.alert('ACHTUNG',o.result.text);
                                    window.setTimeout("location.reload()",5000);
                                }
                            }
                        }
                    });
                }
            },{
                text:'Abbrechen',
                handler: function(){
                    loginWindowGlobal.hide();
                }
            }]
});
var loginWindowGlobal = new Ext.Window({
    title:'Login bei wowarstdu.de',
    layout:'fit',
    id:'loginWindowGlobalId',
    width:400,
    height:150,
    closeAction:'hide',
    items:[communityLoginPanelGlobal]
});
function userLogin(){
    loginWindowGlobal.show();
    loginWindowGlobal.alignTo('loginLink');
}
function userLogout(){
    var conn = new Ext.data.Connection();
    conn.request({
        url: '/auth/ajax-logout',
        method: 'GET',
        success: function(responseObject) {
           window.location = '/';
        },
        failure: function() {
            Ext.Msg.alert('Status', 'Ihr Logout konnte nicht durchgeführt werden. Bitte versuchen Sie es nochmal.');
        }
    });
}

var nutzungsbedingungenWindow = new Ext.Window({
    width:600,
    height:500,
    autoScroll:true,
    plain:true,
    bodyStyle:{padding:'5px'},
    title:'Nutzungsbedingungen von wowarstdu.de',
    closeAction:'hide',
    autoLoad:{ url:'/nutzungsbedingungen/ajax-nutzungsbedingungen'}
});
function showNutzungsbedingungen(){
    nutzungsbedingungenWindow.show();
}