function swapTab(tabId, current)
{  
    this.tabId = tabId;
    this.swap(current);
}

swapTab.prototype.tabId = '';
swapTab.prototype.timer = '';
swapTab.prototype.menuClass = 'menu';
swapTab.prototype.menuItemOnClass = 'on';
swapTab.prototype.menuItemOffClass = 'off';
swapTab.prototype.contentClass = 'content';
swapTab.prototype.current = 0;
swapTab.prototype.swapMethod = 'show'
swapTab.prototype.swapSpeed = '';


swapTab.prototype.swap = function(current)
{    
    if(current == undefined){
        current = 0;
    }
    else{
        current--;
    }
    this.current = current+1;

    var itemCol = $("#"+this.tabId+" ."+this.menuClass+" a");
    var contentCol = $("#"+this.tabId+" ."+this.contentClass+" > div");

    for(var i=0 ; i < itemCol.length ; i++){
        if(current == i){            
            $("#"+this.tabId+" ."+this.menuClass+" a:eq("+i+")").attr("className", this.menuItemOnClass);
        }
        else{
            $("#"+this.tabId+" ."+this.menuClass+" a:eq("+i+")").attr("className", this.menuItemOffClass);
        }        
    }

    for(var i=0 ; i < contentCol.length ; i++){
        if(current == i){
            if(this.swapMethod == 'show'){
                $("#"+this.tabId+" ."+this.contentClass+" > div:eq("+i+")").show(this.swapSpeed);
            }
            else if(this.swapMethod == 'fade'){
                $("#"+this.tabId+" ."+this.contentClass+" > div:eq("+i+")").fadeIn(this.swapSpeed);
            }
        }
        else{
            $("#"+this.tabId+" ."+this.contentClass+" > div:eq("+i+")").hide();
        }        
    }
}


swapTab.prototype.auto = function(varable, iMilliSeconds) {

    if($("#"+this.tabId+" ."+this.contentClass+" > div").length > varable.current) {
		    varable.current++; 
	  }
	  else {
		    varable.current=1;
    }
    
 	  varable.timer = setTimeout(function (){
       varable.swap(varable.current);
       varable.auto(varable, iMilliSeconds);
    }, iMilliSeconds);
}

swapTab.prototype.stop = function() {
    clearTimeout(this.timer);
}

