/*
 * Ext JS Library 2.1
 * Copyright(c) 2006-2008, Ext JS, LLC.
 * licensing@extjs.com
 * 
 * http://extjs.com/license
 */
 
Ext.onReady(function(){
    var themenblock_1 = Ext.get('themenblock_1');
    var themenblock_2 = Ext.get('themenblock_2');
    var themenblock_3 = Ext.get('themenblock_3');
    var themenblock_4 = Ext.get('themenblock_4');
    var themenblock_5 = Ext.get('themenblock_5');
    var themenblock_6 = Ext.get('themenblock_6');
    var themenblock_7 = Ext.get('themenblock_7');
        
    themenblock_1.on('click', function(){
        // create the window on the first click and reuse on subsequent clicks
        win1 = CreateWin_Themeblock(win1,'Themenblock 1: Consolidated & Optimized IT',tabpanel_themeblock_1);
        win1.show(this);
    });
    themenblock_2.on('click', function(){
        // create the window on the first click and reuse on subsequent clicks
        win2 = CreateWin_Themeblock(win2,'Themenblock 2: SAP Enterprise Services Oriented Architecture',tabpanel_themeblock_2);
        win2.show(this);
    });
    themenblock_3.on('click', function(){
        // create the window on the first click and reuse on subsequent clicks
        win3 = CreateWin_Themeblock(win3,'Themenblock 3: Information Discovery & Delivery',tabpanel_themeblock_3);
        win3.show(this);
    });
    themenblock_4.on('click', function(){
        // create the window on the first click and reuse on subsequent clicks
        win4 = CreateWin_Themeblock(win4,'Themenblock 4: Empowered & Connected Users',tabpanel_themeblock_4);
        win4.show(this);
    });    
    themenblock_5.on('click', function(){
        // create the window on the first click and reuse on subsequent clicks
        win5 = CreateWin_Themeblock(win5,'Themenblock 5: Trusted Information',tabpanel_themeblock_5);
        win5.show(this);
    });
    themenblock_6.on('click', function(){
        // create the window on the first click and reuse on subsequent clicks
        win6 = CreateWin_Themeblock(win6,'Themenblock 6: Adaptable Business Processes',tabpanel_themeblock_6);
        win6.show(this);
    });
    themenblock_7.on('click', function(){
        // create the window on the first click and reuse on subsequent clicks
        win7 = CreateWin_Themeblock(win7,'Themenblock 7: innovation@work',tabpanel_themeblock_7);
        win7.show(this);
    });
});

var win1,win2, win3, win4, win5, win6, win7, win8;
var regEx = /(<!--)(\d+.\d+)(-->)/;
var res = '';

function ProcessRegistration(reg,tp,t){
    //get id from html comment '<!--x.y-->'
    res = regEx.exec(tp.getActiveTab().title);
    if(res!=null)
    {
        //check function
        if(reg)
        {
            ref = CheckBasketCompatibility(res[2]);
            if(ref.length==0)
            {
                Ext.MessageBox.confirm('Anmeldung vorgemerkt', 'Ihre Registrierung f&uuml;r:<br />'+t+'<br />'+tp.getActiveTab().title.replace('<br />',' (')+') wurde vorgemerkt.<br />&nbsp;<br />M&ouml;chten Sie an weiteren Referaten teilnehmen?', ProcessSubscribe);
            }
            else
            {
                Ext.Msg.alert('Terminkollision', 'Sie haben zur selben Zeit bereits Referat '+ref+' ausgew&auml;hlt.');
            }
        }
        else
        {
            Ext.MessageBox.confirm('Abmeldung', 'Ihre Registrierung f&uuml;r:<br />'+t+'<br />'+tp.getActiveTab().title.replace('<br />',' (')+') wird annuliert.<br />&nbsp;<br />Sind Sie sicher?', ProcessUnsubscribe);
        }               
    }
}

function ProcessSubscribe(btn){
    //ok, found search string - get interesting middle part with index=2
    //res cannot be 'null' because the caller function have a check
    document.location.href='/saptour/technology/basket.asp?op=add&agenda='+btn+'&ref='+res[2];
}
function ProcessUnsubscribe(btn){
    //ok, found search string - get interesting middle part with index=2
    //res cannot be 'null' because the caller function have a check
    if(btn=='yes')
    {    
        document.location.href='/saptour/technology/basket.asp?op=del&agenda=yes&ref='+res[2];
    }
}

function CreateWin_Themeblock(win,winTitle,tabThemeblock,tabActive)
{
    var winWidth = 640;
    var winHeight = 320;
    if(tabActive!=null)
    {
        tabThemeblock.setActiveTab(tabActive);
    }
    if(!win)
    {
        win = new Ext.Window({
            title: winTitle,
            layout:'fit',
            width:winWidth,
            height:winHeight,
            closeAction:'hide',
            plain: true,
            items: [tabThemeblock],
            buttons: [{
                text: 'Schliessen',
                handler: function(){
                    win.hide();
                }
            }]
        });
    }
    return win;
}

