
// JavaScript Document

// set class name to hover style on mouse over for inactive tab only
function tabHover(caller,hoverClass, inactiveClassName){
	if (caller.className==inactiveClassName){
		caller.className=  hoverClass;
	}
}

function tabHoverOut(caller,inactiveClassName, hoverClass){
	if(caller.className==hoverClass){
		caller.className= inactiveClassName;
	}
}
//Begin Mod Log, Resman 2013, Aruna
function switchTabForCorp(tabId1, tabId2, callerId, tabId1Content, tabId2Content, tabId3Content, tabId4Content, tabId5Content, tabId6Content)
{
	switchTab(tabId1, tabId2, callerId, tabId1Content, tabId2Content, tabId3Content, tabId4Content, tabId5Content, tabId6Content);
	var callerId = document.getElementById(callerId);	
	createCookie('tabSelectedForCorp',callerId.id,31);
}

function LoadLastSelectedTabForCorp ()
{
	var lastSelectedTabIdForCorp =	getCookie('tabSelectedForCorp');
	if (lastSelectedTabIdForCorp  != "")
	{
		var tabFocusArea = document.getElementById('tabFocusArea');
		var tabProduct = document.getElementById('tabProduct');
		
		if (lastSelectedTabIdForCorp   == "tabProduct"){
			switchTabForCorp('tabFocusArea','tabProduct',tabProduct.id,'tabFocusContent','tabProductContent','focusFeatureBox','productFeatureBox','focusBanner','productBanner'); 
		}		
	}
}
function switchTabForMkt(tabId1, tabId2, callerId, tabId1Content, tabId2Content, tabId3Content, tabId4Content, tabId5Content, tabId6Content)
{
	switchTab(tabId1, tabId2, callerId, tabId1Content, tabId2Content, tabId3Content, tabId4Content, tabId5Content, tabId6Content);
	var callerId = document.getElementById(callerId);
	createCookie('tabSelectedForMkt',callerId.id,31);
}

function LoadLastSelectedTabForMkt ()
{
	var lastSelectedTabIdForMkt =	getCookie('tabSelectedForMkt');
	if (lastSelectedTabIdForMkt  != "")
	{
		var tabFocusArea = document.getElementById('tabFocusArea');
		var tabProduct = document.getElementById('tabProduct');
		
		if (lastSelectedTabIdForMkt   == "tabProduct"){
			switchTabForMkt('tabFocusArea','tabProduct',tabProduct.id,'tabFocusContent','tabProductContent','focusFeatureBox','productFeatureBox','focusBanner','productBanner'); 
		}		
	}
}
//End Mod Log, Resman 2013, Aruna

function switchTab(tabId1, tabId2, callerId, tabId1Content, tabId2Content, tabId3Content, tabId4Content, tabId5Content, tabId6Content){

	var tabId1 = document.getElementById(tabId1);
	var tabId2 = document.getElementById(tabId2);
	var callerId = document.getElementById(callerId);	
	var tabId1Content = document.getElementById(tabId1Content);	
	var tabId2Content = document.getElementById(tabId2Content);	
	var tabId3Content = document.getElementById(tabId3Content);	
	var tabId4Content = document.getElementById(tabId4Content);		
	var tabId5Content = document.getElementById(tabId5Content);	
	var tabId6Content = document.getElementById(tabId6Content);
	var tabContentFocusEnd = document.getElementById('tabContentFocusEnd');
	var tabContentProductEnd= document.getElementById('tabContentProductEnd');

// don't switch if caller is on active state

	if ((callerId.className=="focusAreaSelected") || (callerId.className=="focusAreaSelectedSwitchBack")){
		return;
		}
	if (callerId.className=="ProductServicesSelected"){
		return;
		}
//the tabid5Content is the banner image and it should not change to a different image as implemented in the below condition.
		tabId5Content.style.visibility='visible';
		tabId5Content.style.display='block';
		
	if((tabId1.className=="focusAreaSelected") || (tabId1.className=="focusAreaSelectedSwitchBack")){
		tabId1.className="focusAreaDeselected";
		tabId1Content.style.visibility;
		tabId1Content.style.visibility='hidden';
		tabId1Content.style.display='none';		
		tabId3Content.style.visibility='hidden';
		tabId3Content.style.display='none';				
 		tabContentFocusEnd.style.visibility='hidden';	
		tabContentFocusEnd.style.display='none';

	}
	else{
		tabId1.className="focusAreaSelected";
		tabId1Content.style.visibility='visible';
		tabId1Content.style.display='block';
		tabId3Content.style.visibility='visible';
		tabId3Content.style.display='block';
		tabContentFocusEnd.style.visibility='visible';	
		tabContentFocusEnd.style.display='block';
		
	}
	
	if((tabId2.className=="ProductServicesDeselect") || (tabId2.className=="ProductServicesHover")){
		tabId2.className="ProductServicesSelected";
		tabId2Content.style.visibility='visible';
		tabId2Content.style.display='block';
		tabId4Content.style.visibility='visible';
		tabId4Content.style.display='block';
		//tabId6Content.style.visibility='visible';
		//tabId6Content.style.display='block';
		tabContentProductEnd.style.visibility='visible';	
		tabContentProductEnd.style.display='block';

	}
	else{
		tabId2.className="ProductServicesDeselect";
		tabId2Content.style.visibility='hidden';
		tabId2Content.style.display='none';
		tabId4Content.style.visibility='hidden';
		tabId4Content.style.display='none';		
		//tabId6Content.style.visibility='hidden';
		//tabId6Content.style.display='none';		
		tabContentProductEnd.style.visibility='hidden';	
		tabContentProductEnd.style.display='none';
	}
	
//	createCookie('tabSelected',callerId.id,31);
}
//ROW Redesign
function switchTab1(tabId1, tabId2, callerId, tabId1Content, tabId2Content,tabId3Content, tabId4Content){
  
	var tabId1 = document.getElementById(tabId1);
	var tabId2 = document.getElementById(tabId2);
	var callerId = document.getElementById(callerId);	
	var tabId1Content = document.getElementById(tabId1Content);	
	var tabId2Content = document.getElementById(tabId2Content);	
	var tabId3Content = document.getElementById(tabId3Content);	
	var tabId4Content = document.getElementById(tabId4Content);		
	//var tabId5Content = document.getElementById(tabId5Content);	
	//var tabId6Content = document.getElementById(tabId6Content);
	var tabContentFocusEnd = document.getElementById('tabContentFocusEnd');
	var tabContentProductEnd= document.getElementById('tabContentProductEnd');
	
    
// don't switch if caller is on active state

if ((callerId.className=="focusAreaSelected") || (callerId.className=="focusAreaSelectedSwitchBack")){
		
		return;
		}
	if (callerId.className=="ProductServicesSelected"){
		
		return;
		}
		
	if((tabId1.className=="focusAreaSelected") || (tabId1.className=="focusAreaSelectedSwitchBack")){
		
		tabId1.className="focusAreaDeselected";
		tabId1Content.style.visibility='hidden';
		tabId1Content.style.display='none';	
		tabId3Content.style.visibility='hidden';
		tabId3Content.style.display='none';
		//tabId5Content.style.visibility='hidden';
		//tabId5Content.style.display='none';
	    tabContentFocusEnd.style.visibility='hidden';	
		tabContentFocusEnd.style.display='none';
		
	}
	else{
		tabId1.className="focusAreaSelected";
		tabId1Content.style.visibility='visible';
		tabId1Content.style.display='block';
		tabId3Content.style.visibility='visible';
		tabId3Content.style.display='block';
		//tabId5Content.style.visibility='visible';
		//tabId5Content.style.display='block';
		tabContentFocusEnd.style.visibility='visible';	
		tabContentFocusEnd.style.display='block';
		
	}
	
	if((tabId2.className=="ProductServicesDeselect") || (tabId2.className=="ProductServicesHover")){
		
		tabId2.className="ProductServicesSelected";
		tabId2Content.style.visibility='visible';
		tabId2Content.style.display='block';
		tabId4Content.style.visibility='visible';
		tabId4Content.style.display='block';
		//tabId6Content.style.visibility='visible';
		//tabId6Content.style.display='block';
		tabContentProductEnd.style.visibility='visible';	
		tabContentProductEnd.style.display='block';
		
	}
	else{
		tabId2.className="ProductServicesDeselect";
		tabId2Content.style.visibility='hidden';
		tabId2Content.style.display='none';
		tabId4Content.style.visibility='hidden';
		tabId4Content.style.display='none';		
		//tabId6Content.style.visibility='hidden';
		//tabId6Content.style.display='none';		
		tabContentProductEnd.style.visibility='hidden';	
		tabContentProductEnd.style.display='none';
	}
	
	createCookie('tabSelected',callerId.id,31);
}
function colorswap(prop){
	var prop1 = document.getElementById(prop);
		
}
	

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";

}

function getCookie(c_name)
{
  if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=")
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1 
    c_end=document.cookie.indexOf(";",c_start)
    if (c_end==-1) c_end=document.cookie.length
    return unescape(document.cookie.substring(c_start,c_end))
    } 
  }
return ""
}

function LoadLastSelectedTab (){ 

	//Get last selected tab, otherwise, load a random image
	var lastSelectedTabId =	getCookie('tabSelected');
	if (lastSelectedTabId  != ""){
		
		var tabFocusArea = document.getElementById('tabFocusArea');
		var tabProduct = document.getElementById('tabProduct');
		
		if (lastSelectedTabId   == "tabProduct"){
			switchTab('tabFocusArea','tabProduct',tabProduct.id,'tabFocusContent','tabProductContent','focusFeatureBox','productFeatureBox','focusBanner','productBanner'); 
		}
		
		//randomize image on page refresh
		//Productload_banner();
		//focusload_banner();

	}
	else{
		//randomize image on page refresh
		//Productload_banner();
		//focusload_banner();
	}
}


