/* Solid-Sys-GA Google analytics tracking code */

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-26718728-1']);
_gaq.push(['_trackPageview']);
(function() {
  var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
  ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
  var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();


/* Solid-Systems-IT JS supplementary methods for Leder-As Online-Shop system*/

// SOLID SYSTEM IT NAME-SPACE:
SSIT = {
    images : new Array(),
    imageinit : false,
    actualimg : 0,
    logcartinfo : null,
    cart : null,
    login : null,
    // product page data :
    org_image_src : '',


    // switch content of logcartinfo background fild on mouseover
    // content switching is done by css, here
    // problem is, that background banner has to be disabled by js
    // because it is not an css ancsestor and so cannot be reached by css
    // Because gradient page bg, a simple color in ilogin or icart bg wont
    // hide bg banner in a nice way.
    switchLogCartBackground : function (event)
    {
       var e=window.event || event;       
       Event.extend(e);
       var switchon=(e.type=='mouseover')?true:false;
       if(e.element().hasClassName('icart') || e.element().hasClassName('ilogin'))
          var obj=e.element();
       else if(o=e.element().up('.icart'))
          var obj=o;
       else
          var obj=e.element().up('.ilogin');
  
       if(!SSIT.logcartinfo)
       {
          SSIT.logcartinfo = obj.up(2);
          SSIT.cart=SSIT.logcartinfo.adjacent('.block-cart')[0];
          SSIT.login=SSIT.logcartinfo.adjacent('.block-login')[0];
       }      

       if(!switchon)
       {
          var toElement=e.toElement || e.relatedTarget;
           if(toElement && ($(toElement).up('.logcartinfo .block-content')==undefined || $(toElement).hasClassName('title')))
             SSIT.logcartinfo.down('.bottompart').style.visibility='visible';
       }
       else
          SSIT.logcartinfo.down('.bottompart').style.visibility='hidden';
    },

    
    // ACTUALLY NOT IN USE !
    // switch content of logcartinfo fild on mouseover
    // full javascript solution: content switching and bg switching by js
    // works even without css :hover property for .icart and .ilogin
    switchContent : function (event)
    {
       var e=window.event || event;       
       Event.extend(e);
       var switchon=(e.type=='mouseover')?true:false;
       
       if(e.element().hasClassName('icart') || e.element().hasClassName('ilogin'))
          var obj=e.element();
       else if(o=e.element().up('.icart'))
          var obj=o;
       else
          var obj=e.element().up('.ilogin');
       
       var classname=(obj.hasClassName('icart'))?'block-cart':'block-login';       
         
       if(!SSIT.logcartinfo)
       {
          SSIT.logcartinfo = $(obj).up(2);
          SSIT.cart=SSIT.logcartinfo.adjacent('.block-cart')[0];
          SSIT.login=SSIT.logcartinfo.adjacent('.block-login')[0];
       }
       
       var dmode = (switchon)?'block':'none';
       var vmode = (switchon)?'hidden':'visible';

       if(!switchon)
       {
          var toElement=e.toElement || e.relatedTarget;
          if($(toElement).up('.logcartinfo .block-content')==undefined || $(toElement).hasClassName('title'))
          {  // disable active of icart or ilogin content and show bg banner
             SSIT.logcartinfo.down('.bottompart').style.visibility= vmode;
             SSIT.logcartinfo.adjacent('.'+classname)[0].style.display=dmode;
          }
       }
       else
       {  
          var fromElement=e.fromElement || e.relatedTarget;
          if($(fromElement).up('.ilogin')==undefined || $(fromElement).up('.icart')==undefined)
          {  // enable one of icart or ilogin content and hide bg banner
             SSIT.logcartinfo.down('.bottompart').style.visibility=vmode;
             SSIT.logcartinfo.adjacent('.'+classname)[0].style.display=dmode;
          }
       }
    },

    /* INERESSANT WÄRE zu WISSEN WARUM sooo oft mousover und mouseout kommt.
       Vielleicht eventhandler nachträglich inst. Dann event obj untersuchen..
    */

    // switch background image every 10 sec on homepage
    switchBackground : function ()
    {
       //reset image on last image:
       var nowimg=SSIT.actualimg;
       if(SSIT.actualimg>=(SSIT.images.length-1))
       {
          var nextimg=0;
          SSIT.actualimg=0;
       }
       else
       {
          var nextimg=SSIT.actualimg+1;				
          ++SSIT.actualimg;
       }
       
       var top =$('bgimagetop');
       var bottom =$('bgimagebottom');		 
		  
       if(!SSIT.imageinit)
          SSIT.imageinit=true;
       else
       {
          top.style.backgroundImage='url("'+SSIT.images[nowimg]+'")';
          new Effect.Appear(top,{duration:0, from:1.0, to:1.0});
       }
       
       bottom.style.backgroundImage='url("'+SSIT.images[nextimg]+'")';
       new Effect.Fade(top,{duration:1});
       SSIT.switchBackground.delay(10)
       
    },

    // switch background image every 10 sec on homepage
    switchBackground_test : function ()
    {
       var top =$('bgimagetop');
       var bottom =$('bgimagebottom');		 

       //reset image on last image:
       var nowimg=SSIT.actualimg;
       if(SSIT.actualimg>=(SSIT.images.length-1))
       {
          var nextimg=0;
          SSIT.actualimg=0;
       }
       else
       {
          var nextimg=SSIT.actualimg+1;				
          ++SSIT.actualimg;
          new Effect.Appear(top,{duration:0, from:1.0, to:1.0});
       }		

       bottom.style.backgroundImage='url("'+SSIT.images[nextimg]+'")';
       new Effect.Fade(top,{duration:1});		  
       top.style.backgroundImage='url("'+SSIT.images[nextimg]+'")';
		  

       window.setTimeout("SSIT.switchBackground()", 10000);

    },

    // switch product detail page image on thumb click
    setProductImage : function ( nr )
    {
       var pimage = $('image');
       SSIT.org_image_src=SSIT.prodImgArray[nr].src;
       pimage.src=SSIT.prodImgArray[nr].src;
    },


    // rollover product detail page image on thumb roll over
    rolloverProductImage : function ( nr )
    {
       var pimage = $('image');
       SSIT.org_image_src=pimage.src;
       pimage.src=SSIT.prodImgArray[nr].src;
    },

    // rollout product detail page image on thumb roll out
    rolloutProductImage : function ()
    {
       var pimage = $('image');
       pimage.src=SSIT.org_image_src;
    }
};

/*
window.addEventListener('load',function(){
				//SSIT.logcartinfo = $(obj).up(2);
	 
	 SSIT.logcartinfo=$$('.logcartinfo');
	 window.alert(SSIT.logcartinfo);
	 SSIT.cart=SSIT.logcartinfo.adjacent('.block-cart')[0];
	 SSIT.login=SSIT.logcartinfo.adjacent('.block-login')[0];
	 SSIT.cart.addEventListener('mouseover',SSIT.activeDisplayState,false);
	 SSIT.cart.addEventListener('mouseout',SSIT.inactiveDisplayState,false);
	 SSIT.login.addEventListener('mouseover',SSIT.activeDisplayState,false);
	 SSIT.login.addEventListener('mouseout',SSIT.inactiveDisplayState,false);
},false);
*/

