


/*-----------------------------------------------------------------*/
var chinaGif= '<img src=/files/china.gif>';

var scroller=Fx.Base.extend    (
//Fx.HS.prototype=Object.extend(new Fx.Base(),
                                                {
                                                        initialize:function(el,_5,_6,_7,_8)
                                                        {
                                                        this.el=$(el); alert
                                                        this.bg=$(_5);

                                                        if(this.el==null)         {        return;                }

                                                        this.setOptions(_8);

                                                        this.dr_step=this.options.dr_step||100;
                                                        this.axis=this.options.axis||"horizontal";
                                                        if(this.axis=="horizontal")
                                                                {
                                                                this.buttons={left:$(_6),right:$(_7)};
                                                                this.now=this.el.offsetLeft;
                                                                }else{
                                                                this.buttons={up:$(_6),down:$(_7)};
                                                                this.now=this.el.offsetTop;
                                                                }
var _9=this;
this.eventMouseAction=this.buttonAction.bindWithEvent(this);
//$('myElement').addEvent('click', function(){alert('clicked!')});
$(_6).addEvent("mousedown",_9.eventMouseAction)
$(_7).addEvent("mousedown",_9.eventMouseAction)
//addEvent($(_6),"click",_9.eventMouseAction);
//addEvent($(_7),"mousedown",_9.eventMouseAction);

},

                scroll:function(){
                        switch(this.axis){
                                case "horizontal":
                                        this.clearTimer();
                                        Xright=this.el.offsetLeft+this.el.offsetWidth;
                                        Xleft=(this.bg.offsetLeft+this.bg.offsetWidth)/2;
                                        if(Xright+this.dr_step*this.multi<Xleft&&this.multi<0){ return; }
                                        if(this.el.offsetLeft+this.dr_step*this.multi>=this.bg.offsetLeft&&this.multi>0){return;}
                                        this.start(this.now,this.now+this.dr_step*this.multi);
                                        break;
                                case "vertical":
                                        this.clearTimer();
                                        Xbottom=this.el.offsetHeight+this.el.offsetTop;
                                        if(Xbottom<=0&&this.multi<0){return;}
                                        if(this.el.offsetTop>=0&&this.multi>0){return;}
                                        this.start(this.now,this.now+this.dr_step*this.multi);
                                default:
                                        return;
                                        break;
                                }

                },

                buttonAction:function(e){
                                if(typeof e.target!="undefined"){bt=e.target;}
                                        else{
                                        if(typeof e.srcElement!="undefined") { bt=e.srcElement;} else {return;}
                                        }
                                this.multi=bt==(this.buttons.left||this.buttons.down)?-1:1;
                                switch(e.type){
                                        case "mousedown":
                                        this.scroll();
                                        break;
                                        case "mouseup":
                                        break;
                                        }
                },
                increase:function(){
                        this.axis=="horizontal"?this.el.style.left=this.now+"px":this.el.style.top=this.now+"px";
}});

var fader=Fx.Base.extend    (
                        {
                        initialize:function(h,_c){
this.hover= $$("div").filterByClass("image"); //document.getElementsByClassName(h);

if(this.hover==""){
return;
}
var _d=this;
this.eventMouseAction=this.action.bindWithEvent(this);
for(i=0;i<this.hover.length;i++){
$(this.hover[i]).addEvent("mouseover",_d.eventMouseAction)
this.hover[i].active=false;
}
this.hover[0].active=true;
for(i=0;i<this.hover.length;i++){
el=this.hover[i].id.replace(/h/,"f");
this.doFade(el,false);
}
},action:function(e){
if(typeof e.target!="undefined"){
source=e.target.parentNode.parentNode;
}else{
if(typeof e.srcElement!="undefined"){
source=e.srcElement.parentNode.parentNode;
}else{
return;
}
}
for(i=0;i<this.hover.length;i++){
if(this.hover[i].active){
this.hover[i].active=false;
off=this.hover[i].id;
off=off.replace(/h/,"f");
break;
}
}
this.doFade(off,false);
source.active=true;
on=source.id.replace(/h/,"f");
if(!source.id){return;}
if(e.type=="mouseover"){
this.doFade(on,true);
}
},doFade:function(_f,_10){

z=new Fx.Style($(_f), 'opacity', {duration:500})
//z=new Fx.Opacity(_f,{duration:1000});
//z.start(0);
//this.now=0;
if(_10===true){
z.start(0,1);
}else{
z.start(1,0);
}
}});









 function scrol () {
         scr = new scroller ('scrContent', 'scrBg', 'dr_right', 'dr_left',
                         {duration: 500, axis: 'horizontal', dr_step: 300});
                         }
function verticalScroll () {
                  scr1 = new scroller ('verticalCont', 'verticalBg', 'verticalUp', 'verticalDown',
                                 {duration: 500, axis: 'vertical', dr_step: 100});
                                 }
function teamScroll () {
                  scr2 = new scroller ('teamCont', 'teamBg', 'teamUp', 'teamDown',
                                 {duration: 500, axis: 'vertical', dr_step: 100});

                                 }
function singlePr () {scr3 = new scroller ('singleContent', 'singleBg', 'dr_single_up', 'dr_single_down',
                                {duration: 500, axis: 'vertical', dr_step: 100});
                                 }



// helper fpr accordion to switch class of togglers ans allow active/not active states.
  function accordeon (tog, stretch) {
  var togs    = $$("div").filterByClass(tog);
  var stretcher = $$("div").filterByClass(stretch);
 if (stretcher.length==0 || togs.length==0) return;
  // must be before Accordion
  //togs.each(function(tog, i) {
    //tog.onclick = function() {


      // reset them all then set clicked
    //  togs.each(function(rtog, ri) {togs[ri].className = 'stretchtoggle';});
    //  tog.className='stretch_active';
    //};

  //}
 // );

  var acc = new Accordion(togs, stretcher, {opacity:false, width:false, height:true});

}

function swapChina () {
if (china=$('menu-139') ) $('menu-139').innerHTML= '<a href="/taxonomy_menu/2/11/113" title="">'+ chinaGif + '</a>';
else if (china=$('menu-144') ) $('menu-144').innerHTML= '<a href="/taxonomy_menu/2/11/113" title="">'+ chinaGif + '</a>';
else 
return;
}


function dr_preloader () {

       if (loader=$('preloader')) loader.style.display='none';
      // $('scrBg').style.visibility='visible';


}


function init () {
 swapChina();
// initLightbox();
//myLightbox = new Lightbox();
//  lightbox2_image_nodes();

 if ($('dr_left'))  {
        scrol();
        fade=new fader ('img1', {duration: 300});
        dr_preloader ();
        $('scrBg').style.visibility='visible';
        };

  if ($('verticalUp')) verticalScroll();
   if ($('teamUp')) teamScroll();
   if ($('dr_single_up')) singlePr();

   if (acc = $('accordeon'))  {
        accordeon('stretchtoggle', 'stretcher');
          acc.style.visibility='visible';
        }


  dr_preloader();


 // Lightbox.init.bind(Lightbox)


}





if (isJsEnabled()) {
addLoadEvent (dr_preloader);
addLoadEvent (init);

}