// MNB
// 12/16/08
// loads the tab structure for the product page

function load_product_tab(totalTabsAvailable, tabLabel1, tabLabel2, tabLabel3, tabLabel4)
{
    var tab1Label = document.getElementById('Tab1Label');
    var tab1 = document.getElementById('Tab1');
    
    var tab2Label = document.getElementById('Tab2Label');
    var tab2 = document.getElementById('Tab2');
    
    var tab3Label = document.getElementById('Tab3Label');
    var tab3 = document.getElementById('Tab3');
    
    var tab4Label = document.getElementById('Tab4Label');
    var tab4 = document.getElementById('Tab4');
    
    var tab1content = document.getElementById('Tab1Content');
    
    var tabHeaderTable = document.getElementById('TabHeaderTable');
    
    tab1content.style.display = 'block';
    
    if (totalTabsAvailable == 1)
    {          
        tab1Label.innerHTML = tabLabel1;
        
        tab2.style.backgroundImage = "url('/business/images/local-images/commercial-food-services/products/tab-2-none.gif')";
        tab2.style.cursor = 'default';
        tab2.onclick = '';
        tab2Label.innerHTML = '';
        
        tab3.style.backgroundImage = "url('/business/images/local-images/commercial-food-services/products/tab-3-none.gif')";
        tab3.style.cursor = 'default';
        tab3.onclick = '';
        tab3Label.innerHTML = '';
        
        tab4.style.backgroundImage = "url('/business/images/local-images/commercial-food-services/products/tab-4-none.gif')";
        tab4.style.cursor = 'default';
        tab4.onclick = '';
        tab4Label.innerHTML = '';    
    }
    else if (totalTabsAvailable == 2)
    {          
        tab1Label.innerHTML = tabLabel1;
        
        tab2Label.innerHTML = tabLabel2;
        
        tab3.style.backgroundImage = "url('/business/images/local-images/commercial-food-services/products/tab-3-none.gif')";
        tab3.style.cursor = 'default';
        tab3.onclick = '';
        tab3Label.innerHTML = '';
        
        tab4.style.backgroundImage = "url('/business/images/local-images/commercial-food-services/products/tab-4-none.gif')";
        tab4.style.cursor = 'default';
        tab4.onclick = '';
        tab4Label.innerHTML = ''; 
    }
    else if (totalTabsAvailable == 3)
    {          
        tab1Label.innerHTML = tabLabel1;
        
        tab2Label.innerHTML = tabLabel2;
        
        tab3Label.innerHTML = tabLabel3;
        
        tab4.style.backgroundImage = "url('/business/images/local-images/commercial-food-services/products/tab-4-none.gif')";
        tab4.style.cursor = 'default';
        tab4.onclick = '';
        tab4Label.innerHTML = '';
    }
    else if (totalTabsAvailable == 4)
    {          
        tab1Label.innerHTML = tabLabel1;
        
        tab2Label.innerHTML = tabLabel2;
        
        tab3Label.innerHTML = tabLabel3;
        
        tab4Label.innerHTML = tabLabel4;  
    }
    else
    {
        tab1Label.innerHTML = tabLabel1;
        
        tab2.style.backgroundImage = "url('/business/images/local-images/commercial-food-services/products/tab-2-none.gif')";
        tab2.style.cursor = 'default';
        tab2.onclick = '';
        tab2Label.innerHTML = '';
        
        tab3.style.backgroundImage = "url('/business/images/local-images/commercial-food-services/products/tab-3-none.gif')";
        tab3.style.cursor = 'default';
        tab3.onclick = '';
        tab3Label.innerHTML = '';
        
        tab4.style.backgroundImage = "url('/business/images/local-images/commercial-food-services/products/tab-4-none.gif')";
        tab4.style.cursor = 'default';
        tab4.onclick = '';
        tab4Label.innerHTML = '';
    }
    
    tabHeaderTable.style.display = 'block';
}

function selectTab1()
{
    var tab1 = document.getElementById('Tab1');     
    var tab2 = document.getElementById('Tab2');
    var tab3 = document.getElementById('Tab3'); 
    var tab4 = document.getElementById('Tab4');
    
    var tab1content = document.getElementById('Tab1Content');
    var tab2content = document.getElementById('Tab2Content');
    var tab3content = document.getElementById('Tab3Content');
    var tab4content = document.getElementById('Tab4Content');
       
    tab1content.style.display = 'block';
   
    if (tab2content != undefined)
    {
        tab2content.style.display = 'none';
    }
    if (tab3content != undefined)
    {
        tab3content.style.display = 'none';
    }
    if (tab4content != undefined)
    {
        tab4content.style.display = 'none';
    }

    tab1.style.backgroundImage = "url('/business/images/local-images/commercial-food-services/products/tab-1-selected.gif')";
    
    if (tab2.onclick == '')
    {
        tab2.style.backgroundImage = "url('/business/images/local-images/commercial-food-services/products/tab-2-none.gif')";
    }
    else
    {
        tab2.style.backgroundImage = "url('/business/images/local-images/commercial-food-services/products/tab-2.gif')";
    }
    
    if (tab3.onclick == '')
    {
        tab3.style.backgroundImage = "url('/business/images/local-images/commercial-food-services/products/tab-3-none.gif')"; 
    }
    else
    {
        tab3.style.backgroundImage = "url('/business/images/local-images/commercial-food-services/products/tab-3.gif')"; 
    }
    
    if (tab4.onclick == '')
    {
        tab4.style.backgroundImage = "url('/business/images/local-images/commercial-food-services/products/tab-4-none.gif')";    
    }
    else
    {
        tab4.style.backgroundImage = "url('/business/images/local-images/commercial-food-services/products/tab-4.gif')";    
    }
}

function selectTab2()
{
    var tab1 = document.getElementById('Tab1');     
    var tab2 = document.getElementById('Tab2');
    var tab3 = document.getElementById('Tab3'); 
    var tab4 = document.getElementById('Tab4');
    
    var tab1content = document.getElementById('Tab1Content');
    var tab2content = document.getElementById('Tab2Content');
    var tab3content = document.getElementById('Tab3Content');
    var tab4content = document.getElementById('Tab4Content');
 
    tab1content.style.display = 'none';
    
    tab2content.style.display = 'block';
    
    if (tab3content != undefined)
    {
        tab3content.style.display = 'none';
    }
    if (tab4content != undefined)
    {
        tab4content.style.display = 'none';
    }
 
    if (tab1.onclick == '')
    {
        tab1.style.backgroundImage = "url('/business/images/local-images/commercial-food-services/products/tab-1-none.gif')";
    }
    else
    {
        tab1.style.backgroundImage = "url('/business/images/local-images/commercial-food-services/products/tab-1.gif')";
    }
    
    tab2.style.backgroundImage = "url('/business/images/local-images/commercial-food-services/products/tab-2-selected.gif')";
    
    if (tab3.onclick == '')
    {
        tab3.style.backgroundImage = "url('/business/images/local-images/commercial-food-services/products/tab-3-none.gif')"; 
    }
    else
    {
        tab3.style.backgroundImage = "url('/business/images/local-images/commercial-food-services/products/tab-3.gif')"; 
    }
    
    if (tab4.onclick == '')
    {
        tab4.style.backgroundImage = "url('/business/images/local-images/commercial-food-services/products/tab-4-none.gif')";    
    }
    else
    {
        tab4.style.backgroundImage = "url('/business/images/local-images/commercial-food-services/products/tab-4.gif')";    
    }
}

function selectTab3()
{
    var tab1 = document.getElementById('Tab1');     
    var tab2 = document.getElementById('Tab2');
    var tab3 = document.getElementById('Tab3'); 
    var tab4 = document.getElementById('Tab4');
    
    var tab1content = document.getElementById('Tab1Content');
    var tab2content = document.getElementById('Tab2Content');
    var tab3content = document.getElementById('Tab3Content');
    var tab4content = document.getElementById('Tab4Content');
    
    tab1content.style.display = 'none';

    tab2content.style.display = 'none';

    tab3content.style.display = 'block';
    
    if (tab4content != undefined)
    {
        tab4content.style.display = 'none';
    }

    if (tab1.onclick == '')
    {
        tab1.style.backgroundImage = "url('/business/images/local-images/commercial-food-services/products/tab-1-none.gif')";
    }
    else
    {
        tab1.style.backgroundImage = "url('/business/images/local-images/commercial-food-services/products/tab-1.gif')";
    }
    
    if (tab2.onclick == '')
    {
        tab2.style.backgroundImage = "url('/business/images/local-images/commercial-food-services/products/tab-2-none.gif')";
    }
    else
    {
        tab2.style.backgroundImage = "url('/business/images/local-images/commercial-food-services/products/tab-2.gif')";
    }
    
    tab3.style.backgroundImage = "url('/business/images/local-images/commercial-food-services/products/tab-3-selected.gif')";
    
    if (tab4.onclick == '')
    {
        tab4.style.backgroundImage = "url('/business/images/local-images/commercial-food-services/products/tab-4-none.gif')";    
    }
    else
    {
        tab4.style.backgroundImage = "url('/business/images/local-images/commercial-food-services/products/tab-4.gif')";    
    }
}

function selectTab4()
{
    var tab1 = document.getElementById('Tab1');     
    var tab2 = document.getElementById('Tab2');
    var tab3 = document.getElementById('Tab3'); 
    var tab4 = document.getElementById('Tab4');
    
    var tab1content = document.getElementById('Tab1Content');
    var tab2content = document.getElementById('Tab2Content');
    var tab3content = document.getElementById('Tab3Content');
    var tab4content = document.getElementById('Tab4Content');
    
    tab1content.style.display = 'none';
    tab2content.style.display = 'none';
    tab3content.style.display = 'block';
    tab4content.style.display = 'none';
    
    if (tab1.onclick == '')
    {
        tab1.style.backgroundImage = "url('/business/images/local-images/commercial-food-services/products/tab-1-none.gif')";
    }
    else
    {
        tab1.style.backgroundImage = "url('/business/images/local-images/commercial-food-services/products/tab-1.gif')";
    }
    
    if (tab2.onclick == '')
    {
        tab2.style.backgroundImage = "url('/business/images/local-images/commercial-food-services/products/tab-2-none.gif')";
    }
    else
    {
        tab2.style.backgroundImage = "url('/business/images/local-images/commercial-food-services/products/tab-2.gif')";
    }
    
    if (tab3.onclick == '')
    {
        tab3.style.backgroundImage = "url('/business/images/local-images/commercial-food-services/products/tab-3-none.gif')"; 
    }
    else
    {
        tab3.style.backgroundImage = "url('/business/images/local-images/commercial-food-services/products/tab-3.gif')"; 
    }
    
    tab4.style.backgroundImage = "url('/business/images/local-images/commercial-food-services/products/tab-4-selected.gif')";
}

function loadTab()
{
    var fullQueryString = window.location.search.substring(1);
    
    var tabValue = getSpecificQueryValue(fullQueryString, 'tab');
    
    if (tabValue == 1)
    {
        showTab('operating-manuals');
    }
    else if (tabValue == 2)
    {
        showTab('faqs');
    }
    else if (tabValue == 3)
    {
        showTab('success-stories');
    }
    else if (tabValue == 4)
    {
        showTab('consultant-forms');
    }
    else
    {
        showTab('operating-manuals');
    }
}

function showTab(tableId)
{
    var selectedTable = document.getElementById(tableId);
    var notSelectedTable;  
    
    selectedTable.style.display = 'block';
    
    if (tableId != 'operating-manuals')
    {
        notSelectedTable = document.getElementById('operating-manuals');
        notSelectedTable.style.display = 'none';
    }
    if (tableId != 'faqs')
    {
        notSelectedTable = document.getElementById('faqs');
        notSelectedTable.style.display = 'none';
    }
    if (tableId != 'success-stories')
    {
        notSelectedTable = document.getElementById('success-stories');
        notSelectedTable.style.display = 'none';
    }
    if (tableId != 'consultant-forms')
    {
        notSelectedTable = document.getElementById('consultant-forms');
        notSelectedTable.style.display = 'none';
    }
}

function getSpecificQueryValue(fullQueryString, id)
{
	var queryStringArray = fullQueryString.split("&");

	for (i=0;i<queryStringArray.length;i++)
	{
		currentIdValuePair = queryStringArray[i].split("=");

		if (currentIdValuePair[0] == id)
		{
			return currentIdValuePair[1];
		}
	}
}

function expandText(expandImageDiv,answerDiv)
{
	var expandImage = document.getElementById(expandImageDiv);
	var answer = document.getElementById(answerDiv);

	// expand
	if (expandImage.alt == "expand")
	{
		expandImage.src = "/business/images/faqs/collapse_text.gif";
		expandImage.alt = 'collapse';
		answer.style.display = 'block';
	}
	//collapse
	else
	{
		expandImage.src = "/business/images/faqs/expand_text.gif";
		expandImage.alt = 'expand';
		answer.style.display = 'none';
	}
}





/*

function load_product_tab(tabLabel1)
{

}

function load_product_tab(tabLabel1, tabLabel2)
{

}

function load_product_tab(tabLabel1, tabLabel2, tabLabel3)
{

}

function load_product_tab(tabLabel1, tabLabel2, tabLabel3, tabLabel4)
{

}

*/
