
	var SITE = {
		start: function() {
			SITE.liOver($$('#navi li'), 'over');

			SITE.imageAutoMover($$('img.auto-mover'), '_on', '_off');

			SITE.setTooltip($$('.tooltip_a'), 'tt_auktionen');
			SITE.setTooltip($$('.tooltip_m'), 'tt_makler');
			
			new CL_Zebra([$$('table.table_zebra tbody tr')], {
				zebraClasses: ['bg_zebra_1','bg_zebra_2'],
				addOverState: 'element-list_over'
			});
			
			SITE.appendCountdown();

		},

		liOver: function(e, c) {
			e.addEvents({
				'mouseenter': function(ev) {
					if(!this.hasClass(c))
						this.addClass(c);
				},
				'mouseleave': function(ev) {
					this.removeClass(c);
				}
			});
		},

		imageAutoMover: function(e, over, out) {
			if(e.length>0) {
				e.each(function(img) {
					var img = $(img);

					if($chk(img.src)) {
						if(img.src.indexOf(out)>0) {
							img.addEvent('mouseenter', function() {
								img.src = img.src.replace(out, over);
							}).addEvent('mouseleave', function() {
								img.src = img.src.replace(over, out);
							});
						}
					}
				});
			}
		},

		setTooltip: function(e, c) {
			var siteTips = new Tips(e, {
				'className': c,
				'offsets': {
					'x': 14,
					'y': 6
				},
				'onShow': function(tip) {
					tip.setStyle('opacity', .7);
					//tip.fade('in');
				},
				'onHide': function(tip) {
					tip.setStyle('opacity', .0);
					//tip.fade('out');
				}
			});
		},
		
   toSt2:   function (n) {
        s = "";
        if (n < 10) s += "0";
        return (s + n).toString();
      },
      
   toSt3:  function (n) {
        s = "";
        if (n < 10) s += "00";
        else if (n < 100) s += "0";
        return (s + n).toString();
      },
		
		
    countdown : function (end) {
        d = new Date();
        count = Math.floor(end.getTime() - d.getTime());
				//alert(end);
        if(count > 0) {
          miliseconds = SITE.toSt3(count%1000); count = Math.floor(count/1000);
          seconds = SITE.toSt2(count%60); count = Math.floor(count/60);
          minutes = SITE.toSt2(count%60); count = Math.floor(count/60);
          hours = SITE.toSt2(count%24); count = Math.floor(count/24);
          days = count;
          document.getElementById('cd-days').innerHTML = days;
          document.getElementById('cd-hours').innerHTML = hours;
          document.getElementById('cd-minutes').innerHTML = minutes;
          document.getElementById('cd-seconds').innerHTML = seconds;
          setTimeout(SITE.countdown, 50, end);
        }
     }, 
		
  appendCountdown: function() {

    if($chk($('countdown'))) {

      var now = new Date();
      var end = 0;

      var dates = new Array(
        new Date(2010, 3-1, 2, 11, 0, 0), 
        new Date(2010, 3-1, 4, 11, 0, 0), 
        new Date(2010, 3-1, 6, 11, 0, 0)
        );

      if(dates.length > 0) {
        
        for (i=0;i<dates.length;++i) {

        diff = dates[i].getTime()-now.getTime();
        
        if (diff > 0 && (end == 0 || diff<end.getTime()-now.getTime())) {
          end = dates[i];
        }
        }
      }

      if(end == 0) {
        $('countdown').dispose();
        }


      var year = now.getYear();
      if (year < 1900) {
        year += 1900;
      }


      SITE.countdown(end);

    }

  }		
	};

	window.addEvent('domready', SITE.start);