/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

function showHide (p_tabID, p_tabDivs, p_overTabs){

    var tabId = p_tabID;
    var tabDiv = p_tabDivs;


  
    if(p_overTabs == null){
        var theTabs = tabId;
    }else{
       var theTabs = p_overTabs;
    }

    for(var i=0; i < tabDiv.length; i++){
        $(tabDiv[i]).hide(); // Hide all divs
    }
    $(tabId+' div:first').show(); // Show the first div
    $(theTabs +' ul li:first').addClass('active'); // Set the class of the first link to active
        $(theTabs +' ul li a').click(function(){ //When any link is clicked
            $(theTabs +' ul li').removeClass('active'); // Remove active class from all links
            $(this).parent().addClass('active'); //Set clicked link class to active
            var currentTab = $(this).attr('href'); // Set variable currentTab to value of href attribute of clicked link
             for(var j=0; j < tabDiv.length; j++){
                $(tabDiv[j]).hide(); // Hide all divs
            }
            $(currentTab).show(); // Show div with id equal to variable currentTab
            return false;
        }
        
)};

function Banners(p_urlBanners, p_aHrefs, p_alts, p_imageRef)
{
    this.bannerImg = p_urlBanners;
    this.anchors = p_aHrefs;
    this.alts = p_alts;
    this.newBanner = 0;
    this.totalBan = this.bannerImg.length;
    this.imageRefs =  p_imageRef;
    this.callRotate();
    
}
function writeString(){
    //alert("the new banner is here " +newBanner);
    document.getElementById('promorotate').innerHTML ='<a href="'+this.anchors[newBanner]+'" title="MMOHub Promotions" ><img src="'+this.imageRefs+this.bannerImg[newBanner]+'" alt="MMO Promotions" /></a>';
}
function cycle(){
  if (this.newBanner == this.totalBan) {
      this.newBanner = 0;
  }
  document.getElementById('promorotate').innerHTML ='<a href="'+this.anchors[this.newBanner]+'" title="'+this.alts[this.newBanner]+'" target="_blank" onrel="nofollow"><img src="'+this.imageRefs+this.bannerImg[this.newBanner]+'" alt="'+this.alts[this.newBanner]+'" /></a>';
  this.newBanner++;
}

function callRotate(){
    this.theinterval = setInterval("this.cycle()", 3000);
}

Banners.prototype.cycle = cycle;
Banners.prototype.writeString = writeString;
Banners.prototype.callRotate = callRotate;


