var utils = {
  theDropDownButton : null,
  slide : null, 
  t : null,
  flashContainer : null,
  flashContainerImgs : null,
  
  init : function(e){
    utils.theDropDownButton = document.getElementById('dropdown');
    if( utils.theDropDownButton){
		utils.addEvent(utils.theDropDownButton, 'mouseover', utils.dropdown);
		utils.addEvent(utils.theDropDownButton, 'mouseout', utils.closeDropdown);
    }
    utils.slide = 1;
    var theHomepage = document.getElementById('home');
    if (theHomepage){utils.slidesInit();}
    var theContactPage = document.getElementById('contact');
    if (theContactPage){utils.fixContactElements();}
    var theBody = document.getElementsByTagName('body')[0];
    if (theBody.className == "signup"){utils.fixSignUpElements();}
    if (theBody.className == "career_contacts"){utils.fixCareerContactElements();}
   
  },
  
  fixContactElements : function(){
	var theSecondTable = document.getElementsByTagName('table')[1];
	var theTableRows = theSecondTable.getElementsByTagName('tr');
	var the1Cell = theTableRows[0].getElementsByTagName('td')[0];
	var contactHeader = the1Cell.getElementsByTagName('b')[0];
	if(theTableRows[17]){
		var the17Cell = theTableRows[17].getElementsByTagName('td')[0];
		the17Cell.className = "input_margin";
	}
	if(theTableRows[16]){
		var the16Cell = theTableRows[16].getElementsByTagName('td')[0];
		the16Cell.className = "input_margin";
	}
	if(theTableRows[23]){
		var the24Cell = theTableRows[23].getElementsByTagName('td')[0];
		the24Cell.childNodes[1].id = "submit";
		the24Cell.childNodes[1].onmouseover = function(){this.className = "over";}
		the24Cell.childNodes[1].onmouseout = function(){this.className = "";}
	}	
	
	contactHeader.id = "contact_us_h";
	the1Cell.removeChild(the1Cell.childNodes[1]);
	the1Cell.className = "gray"
	for (var i=16; i<theTableRows.length; i++){
		var theTableCells = theTableRows[i].getElementsByTagName('td');
		for (var j=0; j<theTableCells.length; j++){
			theTableCells[j].className += " less_width";
		}
	}
  },
  
  fixSignUpElements : function(){
	var theSecondTable = document.getElementsByTagName('table')[1];
	var theTableRows = theSecondTable.getElementsByTagName('tr');
	for (var i=8; i<theTableRows.length; i++){
		var theTableCells = theTableRows[i].getElementsByTagName('td');
		for (var j=0; j<theTableCells.length; j++){
			theTableCells[j].className += " less_width";
		}
	}
	if(theTableRows[16]){
		var the24Cell = theTableRows[16].getElementsByTagName('td')[0];
		the24Cell.childNodes[1].id = "submit";
		the24Cell.childNodes[1].onmouseover = function(){this.className = "over";}
		the24Cell.childNodes[1].onmouseout = function(){this.className = "";}
	}	
	
  },
  
  fixCareerContactElements : function(){
	var theThirdTable = document.getElementsByTagName('table')[2];
	if (theThirdTable) {
	    var theTableRows = theThirdTable.getElementsByTagName('tr');
	    for (var i=0; i<3; i++){
		    var theTableCells = theTableRows[i].getElementsByTagName('td');
		    theTableCells[0].className = "less_width";
	    }
	    var theSubmitCell = theTableRows[6].getElementsByTagName('td')[0];
	    theSubmitCell.childNodes[1].id = "submit";
	    theSubmitCell.childNodes[1].onmouseover = function(){this.className = "over";}
	    theSubmitCell.childNodes[1].onmouseout = function(){this.className = "";}
	}
  },
  
  dropdown : function(e){
      utils.theDropDownButton.className =  "display";
      document.getElementById("visit_top").style.cursor = "default";	
  },
  
  closeDropdown : function(){
	  utils.theDropDownButton.className =  "";
  },  
  
 slidesInit : function() {
	var flashContainer = document.getElementById("flashContainer");
	if(flashContainer.childNodes[0].id != "homepage_flash"){
		utils.flashContainer = document.getElementById('flashContainer');
		utils.flashContainer.className = "brandLink" + utils.slide;
		
		if(utils.slide == "6"){
			utils.slide = 0;
		}
		
		utils.slide++;
		utils.t = setTimeout("utils.slidesInit()", 3000);	
	}
},


  addEvent : function(obj, type, func) {
    if (obj.addEventListener) {obj.addEventListener(type, func, false);}
    else if (obj.attachEvent) {
      obj["e" + type + func] = func;
      obj[type + func] = function() {obj["e" + type + func] (window.event);}
      obj.attachEvent("on" + type, obj[type + func]);
    }
    else {obj["on" + type] = func;}
	},
	
	stopDefault : function(e) {
     if (!e) {e = window.event;}
     if (!e.preventDefault) {
         e.preventDefault = function() { this.returnValue = false; }
     }
     e.preventDefault();
     return false;
  }
}

utils.addEvent(window, 'load', utils.init);

function getCopyrightYear(){
    var today = new Date();
    var year = today.getYear();
    if(year<1000) 
        year+=1900;
    return year;
}