//tab functions for StoreLocator
function findclass()
{
	
 var divs,i,j;
// Loop through all h2, check if they contain the class
 divs=document.getElementById('locatorNav').getElementsByTagName('h2');

 for(i=0;i<divs.length;i++)
 {
	 divs[i].onmousedown = function()
 		{

		for(j=0;j<divs.length; j++){
		divs[j].className='normaltab';	
		}
	 if(/normaltab/.test(this.className))
  		{
	  
		
		showHide(this);
  		}
  
 	}
}
}

//show/hide function for tab contents
function showHide(showTab)
{
	showTab.className='livetab';	
	var src,showme,j,hideme;
	hides=document.getElementById('storeLocatorContent').getElementsByTagName('div');
//takes the clicked tab id, subtrings it to get the identifier, then adds 'pane' to it to access the div pane that will show
src=showTab.getAttribute('id');


	showme=src.substring(0,(src.length-3))+"Container";
//hides all tab contents, then set the selected tab contents to 'block'
	for(j=0;j<hides.length;j++)
	{
		if(/block/.test(hides[j].style.display))
		{
			hides[j].style.display='none';
			document.getElementById(showme).style.display='block';
		}
	}
}
//On page load, sets the first tab, as designated, to 'block'
function exposeFirst(defaultDiv, defaultTab){
	findclass();
 document.getElementById(defaultDiv).style.display = 'block';
 document.getElementById(defaultTab).className = "livetab";
 document.getElementById(defaultDiv).onload = ffFocus();
}	

//Autofocus cursor
function ffFocus(container){
//check for container value. if null, set to "shell"
var myContainer = container;
if(myContainer == null){
myContainer = 'shell';
}
//array of all input elements within the "shell" div
var ff = document.getElementById(myContainer).getElementsByTagName('input');
//put focus on first field in array
ff[0].focus();
}

