/*
geminiCMS4_3 - The natura Projekt: Natura Shop
(c)2007 by Frank Reimering Software Systems
*/

/*
onLoad
*/

var contentMenuCount;
var lastSection = 0;   // 0 = TELL-Home, 1 = Shop, 2 = Portal
var lastMenuIndex;
var lastSubMenuIndex;
var isDynamic = false;

window.onload = function() {
    $("debug").style.display  = "none";
    
    initHintBox();
    initjsDOMenu(); // Wichtig !
    startLoading();

    //getContentMenuCount();
    $("member").style.display     = "block";
    $("searchtext").style.display = "none";
    $("shop").style.display       = "none";
    $("mlogoff").style.display    = "block";
    
    updateBasket();
    
    Effect.Appear("content");
    showRighblocks();

    enterShop();
    showHome();

    stopLoading();
}


/*
function initTell() {
  enterTell();
  showHome();
}
*/

function startLoading()
{
    writetxt(0);
    $('rinfo').style.display = 'block';
    /*
    new Effect.Opacity('nav-main',{duration:0, from:1.0, to:0.25} );
    new Effect.Opacity($('DOMenu1').id,{duration:2, from:1.0, to:0.25} );
    */
}

function stopLoading()
{
    $('rinfo').style.display = 'none';
    writetxt(0);
    /*
    new Effect.Opacity('nav-main',{duration:0, from:0.25, to:1} );
    new Effect.Opacity($('DOMenu1').id,{duration:2, from:0.25, to:1} );
    */
}

function getContentMenuCount() // Anzahl der Menues in Content
{
    new Ajax.Request(
        "Core/backend/tell.php",
        {
           parameters: 'asynchronous=false',
           method: 'post',
           postBody: 'cmd=info&what=content',
           onComplete: function(req) {

                contentMenuCount = Number( req.responseText );

           },
           onError: function() {
                showMessage("Es trat ein Fehler bei der Daten&uuml;bertragung auf.");
           }
        }
    )
}

/////////////////////////////////////////////////////////////////////////////
// Home Bereich
/*
function enterTell() {
    lastSection  = 0;
    lastMenuItem = 0;
    lastSubMenuItem = 0;
    
    $("member").style.display  = "none";
    $("mlogoff").style.display = "none";
    $("shop").style.display    = "none";

    // Menue anpassen
    if(isDynamic) {
        Effect.Fade(docs.id);
        Effect.Fade(warengruppen.id);

        for(n=0;n<contentMenuCount;n++) {
            line = 'menuItem'+(n+4);
            Effect.Appear( $(line).id );
        }
    }
    else {
        $(docs.id).style.display         = "none";
        $(warengruppen.id).style.display = "none";
        
        for(n=0;n<contentMenuCount;n++) {
            line = 'menuItem'+(n+4);
            $(line).style.display = "block";
        }
    }
    //$("content").innerHTML = "Shop";
    //$("rb").innerHTML = "";
}
*/

function enterShop() {
    $("member").style.display  = "none";
    $("mlogoff").style.display = "none";
    $("shop").style.display    = "block";
}

/*
function enterPortal() {
    // ueberpruefen, ob member schon angemeldet ist
    var flag = false;
    
    new Ajax.Request(
        "Core/backend/Member/member.php",
        {
           //parameters: 'asynchronous=false',
           method: 'post',
           postBody: 'cmd=member&what=test',
           onComplete: function(req) {


                //$("debug").innerHTML = req.responseText;
                data = req.responseText.parseJSON();
                flag = (data.elem.reqtext );
                if( flag ) { // schon angemeldet
                    $("member").style.display     = "none";
                    $("mlogoff").style.display    = "block";
                    $("member_msg").style.display = "none";
                    $("member_id").innerHTML      = data.elem.user;
                }
                else {
                    $("member").style.display     = "block";
                    $("mlogoff").style.display    = "none";
                    $("member_msg").style.display = "none";
                }
                $("shop").style.display       = "none";

                // Menue anpassen
                if(isDynamic) {
                    Effect.Appear(docs.id);
                    Effect.Fade(warengruppen.id);

                    for(n=0;n<contentMenuCount;n++) {
                        line = 'menuItem'+(n+4);
                        Effect.Fade( $(line).id );
                    }
                }
                else {
                    $(docs.id).style.display         = "block";
                    $(warengruppen.id).style.display = "none";

                    for(n=0;n<contentMenuCount;n++) {
                        line = 'menuItem'+(n+4);
                        $(line).style.display = "none";
                    }
                }

                /////////////////////////////////////////////////////////////
                // Dokumenten-Menu je nach Berechtigung anpassen
                checkMemberRights();


           },
           onError: function() {
                showMessage("Es trat ein Fehler bei der Daten&uuml;bertragung auf.");
           }
        }
    )
}

function checkMemberRights() {


    new Ajax.Request(
        "Core/backend/tell.php",
        {
           parameters: 'asynchronous=false',
           method: 'post',
           postBody: 'cmd=info&what=memberrights',
           onComplete: function(req) {
                //$("debug").innerHTML = req.responseText;
                data = req.responseText.parseJSON();

                doc_count = Number( data.elem.count );
                mrights   = Number( data.elem.mrights );
                rights    = data.elem.rights;
                
                for(n=0;n<doc_count;n++) {
                    flag = (mrights >= rights[n]) ? 'block' : 'none';
                    line = 'menuItem'+(n+8+contentMenuCount);
                    $(line).style.display = flag;
                }

           },
           onError: function() {
                showMessage("Es trat ein Fehler bei der Daten&uuml;bertragung auf.");
           }
        }
    );
}
*/

function initShop() {
    enterShop();
    $("content").innerHTML = "Shop";
    //document.location.href = "http://www.waagenstore.de"; // bis fertig ist !
}
/*
function initPortal() {
    enterPortal();
    showDocsStart();
}
*/
function showItem(itemid) {
    //alert('ItemId:'+itemid);
}



