function tab() {
  this.currentlyActive = '';
  this.previouslyActive = '';
}

//This function kills the display on the previous hover and displays the subcategories for the new hover
tab.prototype.activateTab = function (id, prefixoff, prefixover, content) {
  this.currentlyActive = id; 
  
  if (this.previouslyActive != '') {   //Kill the previous display
	document.getElementById(prefixover + this.previouslyActive).style.display = "none";
	document.getElementById(prefixoff + this.previouslyActive).style.display = "inline";
	document.getElementById(content + this.previouslyActive).style.display = "none";
  }
  
  document.getElementById(prefixover + id).style.display = "inline";
  document.getElementById(prefixoff + id).style.display = "none";
  document.getElementById(content + id).style.display = "inline";
  
  this.previouslyActive = id;
}

/*********The functions below are the same as above except that they allow content retrieval through AJAX***/
var xmlHandler;  //AJAX object
var divprefix = '';

function tabAJAX() {
  this.currentlyActiveAJAX = '';
  this.previouslyActiveAJAX = '';
  this.url = '';
  this.destinationdiv = '';
}

//This function kills the display on the previous hover and displays the subcategories for the new hover
tabAJAX.prototype.activateTabAJAX = function (idAJAX, prefixoffAJAX, prefixoverAJAX) {
  this.currentlyActiveAJAX = idAJAX; 
  divprefix = idAJAX;
 
  
  if (this.previouslyActiveAJAX != '') {   //Kill the previous display
    document.getElementById('centertabbercontentbox').innerHTML = '';
	document.getElementById(prefixoverAJAX + this.previouslyActiveAJAX).style.display = "none";
	document.getElementById(prefixoffAJAX + this.previouslyActiveAJAX).style.display = "inline";
  }
  
  document.getElementById(prefixoverAJAX + idAJAX).style.display = "inline";
  document.getElementById(prefixoffAJAX + idAJAX).style.display = "none";
  document.getElementById('centertabbercontentbox').style.display = "inline";
  
  this.destinationdiv = 'centertabbercontentbox';
  document.getElementById(this.destinationdiv).innerHTML = '<div class="ajaxintermediary">Loading...</div>';
  this.previouslyActiveAJAX = idAJAX;
  getContent(this.url, this.destinationdiv);
}


function getContent(url, destinationdiv) {
  xmlHandler = GetXmlHttpObject();
  
  if (xmlHandler == null)  {
    alert ("Browser does not support HTTP Request")
    return;
  } 
  
  destination = destinationdiv;
  xmlHandler.onreadystatechange = byContentChanged;
  
  xmlHandler.open("GET", url, true);
  xmlHandler.send(null);
}


function byContentChanged() { 
  if (xmlHandler.readyState == 4 || xmlHandler.readyState == "complete") { 
	document.getElementById('centertabbercontentbox').innerHTML = xmlHandler.responseText;
	document.getElementById('centertabbercontent' + divprefix).style.display = "inline";
	if (divprefix == 'promotions')  {
	  updatePromotions('promotions1', 1, 2);
	}
  }
}

//***************************Browser Stuff***************************************************************
//This function detects the browser, so I can figure out which AJAX handler to use.
function GetXmlHttpObject(handler) { 
  var objXMLHttp=null;
  
  //Mozilla, Netscape, Safari, etc. You know, the browsers that follow the standards.
  if (window.XMLHttpRequest) {
    objXMLHttp=new XMLHttpRequest();
  }
  
  //IE. What more needs to be said.
  else if (window.ActiveXObject) {
    objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
  return objXMLHttp;
}

//*******************************************************************************************************
function updatePromotions(promotiondiv, number, numchoices) {

  beforediv = 'promotions' + (number - 1);
  afterdiv = 'promotions' + (number + 1);
  
  for (var i=0;i<numchoices;i++) {
	  
	otherdiv = 'promotions' + i;
	if ((number - 1) < 0 || (number + 1) > (numchoices - 1)) {
	  if ((number - 1) < 0) {
        document.getElementById('topspace').style.borderRight = '0px solid #FFFFFF';
	    document.getElementById('topspace').style.backgroundImage =     
	    "url(\'http://newsite.lancasteronline.com/blocks/centertabber/promotions/images/navcornertop.gif\')";
		
	    document.getElementById('bottomspace').style.backgroundImage = '';
	    document.getElementById('bottomspace').style.borderRight = "1px solid #DFDFDF";
        document.getElementById('bottomspace').style.backgroundColor = "#F2F2F2"; 	
      }
  
      if ((number + 1) > (numchoices - 1)) {
        document.getElementById('bottomspace').style.borderRight = '0px solid #FFFFFF';
	    document.getElementById('bottomspace').style.backgroundImage =     
	    "url(\'http://newsite.lancasteronline.com/blocks/centertabber/promotions/images/navcornerbottom.gif\')";
		
		//This should be commented when there is only one promotion
		document.getElementById('topspace').style.backgroundImage = '';
	    document.getElementById('topspace').style.borderRight = "1px solid #DFDFDF";
        document.getElementById('topspace').style.backgroundColor = "#F2F2F2"; 	
		
      }
	}
	else {
	  document.getElementById('topspace').style.backgroundImage = '';
	  document.getElementById('topspace').style.borderRight = "1px solid #DFDFDF";
      document.getElementById('topspace').style.backgroundColor = "#F2F2F2"; 	
	  document.getElementById('bottomspace').style.backgroundImage = '';
	  document.getElementById('bottomspace').style.borderRight = "1px solid #DFDFDF";
      document.getElementById('bottomspace').style.backgroundColor = "#F2F2F2"; 	
		
	}
      
	if (i == (number - 1)) {
	  document.getElementById(beforediv).style.backgroundImage = '';
	  document.getElementById(beforediv).style.borderRight = '0px solid #FFFFFF';
	  document.getElementById(beforediv).style.backgroundImage =     
	  "url(\'http://newsite.lancasteronline.com/blocks/centertabber/promotions/images/navcornertop.gif\')";
	} 
	else if (i == (number + 1)) {
	  document.getElementById(afterdiv).style.backgroundImage = '';
      document.getElementById(afterdiv).style.borderRight = '0px solid #FFFFFF';
	  
	  if ((number + 1) != (numchoices - 1)) {
	    document.getElementById(afterdiv).style.backgroundImage =     
	    "url(\'http://newsite.lancasteronline.com/blocks/centertabber/promotions/images/navcornerbottom.gif\')";
	  }
	  else {
	    document.getElementById(afterdiv).style.backgroundImage =     
	    "url(\'http://newsite.lancasteronline.com/blocks/centertabber/promotions/images/navcornerbottom32tall.gif\')";
	  }
	} 
	else if (i == number)  {
	  document.getElementById(promotiondiv).style.borderRight = "1px solid #FFFFFF";
      document.getElementById(promotiondiv).style.backgroundColor = "#FFFFFF";
	  document.getElementById(promotiondiv).style.backgroundImage = "";
	}
	else {
	  document.getElementById(otherdiv).style.backgroundImage = "";
	  document.getElementById(otherdiv).style.borderRight = "1px solid #DFDFDF";
      document.getElementById(otherdiv).style.backgroundColor = "#F2F2F2";  
	}
  }
  
  if (number == 0) {
	thePromo = 'worldseries';
    document.getElementById('promotionsimage').innerHTML = 
   '<a href="http://sections.lancasteronline.com/local/19/2"><img border=0 style="outline:0;" src="http://newsite.lancasteronline.com/blocks/centertabber/promotions/images/' + number + '.jpg" width="764" height="140"/></a>';
  }
/*
  if (number == 1) {
	thePromo = 'fathersday';
    document.getElementById('promotionsimage').innerHTML = 
   '<a href="http://lancmoms.com/sites/lancmoms.com/files/pdf/fmday09.pdf"><img src="http://newsite.lancasteronline.com/blocks/centertabber/promotions/images/' + number + '.jpg" width="764" height="140"/></a>';
  }
*/
  if (number == 1) {
	thePromo = 'votersguide';
    document.getElementById('promotionsimage').innerHTML = 
   '<a href="http://election.lancasteronline.com/"><img src="http://newsite.lancasteronline.com/blocks/centertabber/promotions/images/' + number + '.jpg" width="764" height="140"/></a>';
  }





if (number == 2) {
	thePromo = 'mothersday';
    document.getElementById('promotionsimage').innerHTML = 
   '<a href="http://lancmoms.com/sites/lancmoms.com/files/pdf/fmday09.pdf"><img src="http://newsite.lancasteronline.com/blocks/centertabber/promotions/images/' + number + '.jpg" width="764" height="140"/></a>';
  }

}

//*************************************************************************************************************
function updateYouTube(youtubediv, number, numchoices) {
  beforediv = 'youtube' + (number - 1);
  afterdiv = 'youtube' + (number + 1);
  
  for (var i=0;i<numchoices;i++) {
	  
	otherdiv = 'youtube' + i;
	
	if ((number - 1) < 0 || (number + 1) > (numchoices-1)) {
	  if ((number - 1) < 0) {
        document.getElementById('topspace').style.borderRight = '0px solid #FFFFFF';
	    document.getElementById('topspace').style.backgroundImage =     
	    "url(\'http://newsite.lancasteronline.com/images/content/prettymenu/navcornertop125.gif\')";
		
	    document.getElementById('bottomspace').style.backgroundImage = '';
	    document.getElementById('bottomspace').style.borderRight = "1px solid #DFDFDF";
        document.getElementById('bottomspace').style.backgroundColor = "#F2F2F2"; 	
      }
  
      if ((number + 1) > (numchoices-1)) {
        document.getElementById('bottomspace').style.borderRight = '0px solid #FFFFFF';
	    document.getElementById('bottomspace').style.backgroundImage =     
	    "url(\'http://newsite.lancasteronline.com/images/content/prettymenu/navcornerbottom125.gif\')";
		
		document.getElementById('topspace').style.backgroundImage = '';
	    document.getElementById('topspace').style.borderRight = "1px solid #DFDFDF";
        document.getElementById('topspace').style.backgroundColor = "#F2F2F2"; 	
      }
	}
	else {
	  document.getElementById('topspace').style.backgroundImage = '';
	  document.getElementById('topspace').style.borderRight = "1px solid #DFDFDF";
      document.getElementById('topspace').style.backgroundColor = "#F2F2F2"; 	
	  document.getElementById('bottomspace').style.backgroundImage = '';
	  document.getElementById('bottomspace').style.borderRight = "1px solid #DFDFDF";
      document.getElementById('bottomspace').style.backgroundColor = "#F2F2F2"; 	
		
	}
      
	if (i == (number - 1)) {
	  document.getElementById(beforediv).style.backgroundImage = '';
	  document.getElementById(beforediv).style.borderRight = '0px solid #FFFFFF';
	  document.getElementById(beforediv).style.backgroundImage =     
	  "url(\'http://newsite.lancasteronline.com/images/content/prettymenu/navcornertop125.gif\')";
	} 
	else if (i == (number + 1)) {
	  document.getElementById(afterdiv).style.backgroundImage = '';
      document.getElementById(afterdiv).style.borderRight = '0px solid #FFFFFF';
	  
	  document.getElementById(afterdiv).style.backgroundImage =     
	  "url(\'http://newsite.lancasteronline.com/images/content/prettymenu/navcornerbottom125.gif\')";
	} 
	else if (i == number)  {
	  document.getElementById(youtubediv).style.borderRight = "1px solid #FFFFFF";
      document.getElementById(youtubediv).style.backgroundColor = "#FFFFFF";
	  document.getElementById(youtubediv).style.backgroundImage = "";
	}
	else {
	  document.getElementById(otherdiv).style.backgroundImage = "";
	  document.getElementById(otherdiv).style.borderRight = "1px solid #DFDFDF";
      document.getElementById(otherdiv).style.backgroundColor = "#F2F2F2";  
	}
  }
  
  for (j=0;j<numchoices;j++) {
	
    if (j != number) {
	  document.getElementById('youtubevideo' + j).style.display = "none";
	}
	else {
      document.getElementById('youtubevideo' + number).style.display = "block";
	}
  }
}