/* NEWSSHOW */
function Tabber(){
   this.curr = 0;
   this.playing = true;
}
Tabber.prototype.Switch = function(id){
   if(id>=0 && id<=4){
      var pos = "-"+(id * 230)+"px";
      jQuery("div[id*='tb_sw']").removeClass("tb_switch_on").addClass("tb_switch_off");
      jQuery("#tb_sw"+id).removeClass("tb_switch_off").addClass("tb_switch_on")
      jQuery("#tb_strip").animate({top: pos},1000,function(){});
   }
}
Tabber.prototype.Play = function(){
   if(this.playing){
      if(this.curr > 3 || this.curr < 0) { nxt = 0; }
      else { nxt=this.curr+1; }
      this.Switch(nxt);
      this.curr = nxt;
   }
   setTimeout(function(){tabber.Play();},5000);
}
Tabber.prototype.Pause = function(){
   if(this.playing){
      jQuery("#tb_button").removeClass("tb_play").addClass("tb_pause");
      this.playing = false;
   }
   else{
      jQuery("#tb_button").removeClass("tb_pause").addClass("tb_play");
      this.playing = true;
   }
}
var tabber =new Tabber;
jQuery(document).ready(function(){
   setTimeout(function(){ tabber.Play(); },5000);
});


function openFlipbook(crmq){
   var pos_x = Math.round(screen.width * 0.25);
   var pos_y = Math.round(screen.height * 0.25);
   var options = "width=420,height=281,resizable=no,scrollbars=no,toolbar=no,location=no,directories=no,status=no,";
   options+= "menubar=no,copyhistory=no,";
   options+= "screenX="+pos_x+",left="+pos_x+",";
   options+= "screenY="+pos_y+",top="+pos_y;
   if(crmq == 1)
      window.open('http://collisionrepairmag.com/index.php?option=com_magconnect&task=crmq&format=raw','flipbook_window',options);      
   else if(crmq == 2)
      window.open('http://collisionrepairmag.com/index.php?option=com_magconnect&task=water&format=raw','flipbook_window',options);      
   else
      window.open('http://collisionrepairmag.com/index.php?option=com_magconnect&format=raw','flipbook_window',options);
}




/*
function tb_switch(id){
   if(id>=0 && id<=5){
      var pos = "-"+(id * 110)+"px";
      jQuery("div[id*='tb_sw']").removeClass("tb_switch_on").addClass("tb_switch_off");
      jQuery("#tb_sw"+id).removeClass("tb_switch_off").addClass("tb_switch_on")
      jQuery("#tb_strip").animate({top: pos},1000,function(){});
   }
}*/

