// 2007.08.13 KJD: Document created

var NortonTab_tempBox			= "";
var thisTabSet					= 0;
var NortonTabList 				= new Array();
var NortonIsFirstTabName		= "";
var NortonIsFirstTabOnNextLine 	= "";  // this is my favorite variable name ;)

var NortonPageName				= "";
var NortonTabListByID			= new Array();

// 2007.08.13 KJD:
function NortonTab_Adjust( tabname )
{
	var thisTab					= document.getElementById( tabname );
	var thisOuterTab			= document.getElementById( tabname + '_outer' );
	var thisTabBottom			= document.getElementById( tabname + '_bottom' );
	
	
	thisOuterTab.style.width 	= thisTab.offsetWidth + 10;
	thisTab.style.display 		= "block";	
	thisTabBottom.style.width	= thisTab.offsetWidth;
	

	// 2007.08.14 KJD: Check browser type
	var thisNav = navigator.userAgent.toLowerCase();

	if( thisNav.indexOf( "msie" ) == -1 )
	{
		var thisWidth = thisOuterTab.offsetWidth;
		thisTabBottom.style.width = thisOuterTab.offsetWidth + "px";
	}
}

// 2007.08.13 KJD:
function NortonTab_CreateTab( tabID, tabText, tabCall )
{
	var thisString = "";
	
	var thisCall = "";
	if( typeof tabCall != 'undefined' )
	{
		thisCall += tabCall;
	}
	else
	{
		thisCall = "NortonTab_Select( this.id );" + tabCall;
	}
	
	// 2007.08.15 KJD: Check if extra style declared
	var ExtraTabStyle = "";
	if( typeof NortonTabStyle != 'undefined' ){ ExtraTabStyle = " STYLE=\"" + NortonTabStyle + "\""; }
	
	thisString = ""
		+ "<DIV CLASS='TabBox_outer_off' ID='" + tabID + "_outer' "
			+ "onClick		=\"" + thisCall + "\""
			+ ">"
		
		+ Norton_CreateCurve( "NortonTab_BdyTop", "top", "#F5F5F5" )

		+ "	<DIV ID='" + tabID + "' CLASS='Tab_Off'"
		+ ExtraTabStyle 
		+ "> &nbsp;" + tabText 
		+ "&nbsp;</DIV>"
		+ "<DIV ID='" + tabID + "_bottom' CLASS='NortonTab_Bottom_Off'></DIV>"
		
		+ Norton_CreateCurve( "NortonTab_BdyBtm", "bottom", "#E7E7E7" )
		
		+ "</DIV><DIV STYLE='display:block;border:none;width:10px;height:40px;float:left'></DIV>";
	
	document.write( thisString );

	NortonCheckIfMultiLineTab( tabID );

	
	NortonTab_Adjust( tabID );
	
	
	NortonTab_tempBox = tabID;
	NortonTabList[ NortonTabList.length ] = tabID;
	
	NortonTabListByID[ NortonTabListByID.length ] = tabID + "####" + tabText;
	
	NortonCheckIfFirstTab( tabID );
	NortonCheckIfNextLineTab( tabID );
	
	
}

// 2007.08.14 KJD: Check if multiple line
function NortonCheckIfMultiLineTab( tabID, oversent )
{
	var thisTab		= document.getElementById( tabID );
	var thisWidth	= thisTab.offsetWidth;

	if( thisTab.offsetHeight > 20 )
	{
		thisWidth += 5;

		thisTab.style.width = thisWidth + "px";

		setTimeout( "NortonCheckIfMultiLineTab( '" + tabID + "', 1 )", 1 );
	}
	else if( oversent )
	{
		NortonIsFirstTabOnNextLine = "";
		NortonTab_Adjust( tabID );
		NortonCheckIfFirstTab( tabID );
		NortonCheckIfNextLineTab( tabID );
		
		// 2007.08.14 KJD: Adjust box
		thisWidth += 10;
		thisTab.style.width = thisWidth + "px";

		// 2007.08.14 KJD: Adjust highlight
		document.getElementById( tabID + '_bottom' ).style.width = thisWidth;
	}
}


// 2007.08.13 KJD:
function NortonCheckIfFirstTab( tabID )
{
	if( !( NortonIsFirstTabName ) )
	{
		NortonIsFirstTabName = tabID;
	}
}

// 2007.08.13 KJD:
function NortonCheckIfNextLineTab( tabID )
{
	if( !( NortonIsFirstTabOnNextLine ) )
	{
		var thisTab = document.getElementById( tabID );
		if( thisTab.offsetTop > 10 )
		{
			NortonIsFirstTabOnNextLine = tabID;
		}
	}
}

// 2007.08.13 KJD:
function TabSection_More( )
{
	NortonTab_DeSelectAll();
	
	NortonTrackTab( "more" );
	
	TabSectionRotate();
}

// 2007.08.13 KJD:
function TabSectionRotate( thisMethod )
{
	var thisTab 		= document.getElementById( 'TabSection' );
	var thisTabPosition = thisTab.style.top;
	var totalHeight		= document.getElementById( NortonTab_tempBox ).offsetHeight + 22;
	
	var stopHeight		= -( totalHeight );
	
	thisTabPosition = parseInt( thisTabPosition );
	
	if( typeof thisMethod == 'undefined' ){ var thisMethod = 'up'; }

	if( thisTabSet == 1 )
	{
		thisMethod = 'down';
	}
	
	if( thisMethod == 'down' )
	{
		if( thisTabPosition < 0 )
		{
			thisTab.style.top	= ( thisTabPosition + 2 ) + "px";
			setTimeout( "TabSectionRotate('down')", 1 );
		}
		else
		{
			thisTab.style.top	= "2px";
			thisTabSet = 0;

			NortonTab_Select( NortonIsFirstTabName );
		}
	}
	else if( thisMethod == 'up' )
	{
		if( thisTabPosition > stopHeight )
		{
			thisTab.style.top	= ( thisTabPosition - 2 ) + "px";
			setTimeout( "TabSectionRotate('up')", 1 );
		}
		else
		{
			thisTabSet = 1;

			NortonTab_Select( NortonIsFirstTabOnNextLine );
		}
	}
}


// 2007.08.13 KJD:
function NortonTab_DeSelect( tabID )
{
	document.getElementById( tabID + "_bottom" ).className	= "NortonTab_Bottom_Off";
	document.getElementById( tabID + "_outer" ).className	= "TabBox_outer_off";
	document.getElementById( tabID ).className 				= "Tab_Off";
}

// 2007.08.13 KJD:
function NortonTab_DeSelectAll()
{
	for( var i=0; i< NortonTabList.length; i++ )
	{
		NortonTab_DeSelect( NortonTabList[ i ] );
	}
}

// 2007.08.13 KJD:
function NortonTab_Select( tabID )
{
	NortonTab_DeSelectAll();
	NortonFadeout();

	var thisName	= tabID;
	thisName		= thisName.replace( "_outer", "" );

	document.getElementById( thisName + "_bottom" ).className	= "NortonTab_Bottom_On";
	document.getElementById( thisName + "_outer" ).className 	= "TabBox_outer_on";
	document.getElementById( thisName ).className 				= "Tab_On";
	
	// 2007.08.14 KJD: Check if first tab
	if( ( thisName == NortonIsFirstTabName ) || ( thisName == NortonIsFirstTabOnNextLine ) )
	{
		document.getElementById( 'NortonTab_cornercover' ).style.visibility = "visible";
	}
	else
	{
		document.getElementById( 'NortonTab_cornercover' ).style.visibility = "hidden";
	}
	
	// 2007.08.15 KJD: Swap Content
	NortonTab_SwapInfo( thisName + "_Content", 'TabSectionContent_text_inner' );


	// 2007.08.14 KJD: Adjust corners
	var thisTextHeight = document.getElementById( 'TabSectionContent_text_inner' ).offsetHeight;
	document.getElementById( 'TabSectionContent_outer' ).style.height = thisTextHeight+55;
	document.getElementById( 'TabSectionContent_text' ).style.height = thisTextHeight+45;
	

	// 2007.08.16 KJD: Adjust the size
	if( window.NortonTabContentAutoSize )
	{
		NortonTab_AdjustContent( thisName );
	}
	
	NortonTab_AdjustBlendLayer();
	NortonFadein();
	
	NortonTrackTab( thisName );

	NortonTabProductTitle();
}

// 2007.08.13 KJD:
function Norton_SetOpacity( itemID, itemAlpha )
{
	if( document.getElementById( itemID ) )
	{
		document.getElementById( itemID ).style.filter	= "alpha( opacity=" + ( 100 * itemAlpha ) + ")";
		document.getElementById( itemID ).style.opacity = itemAlpha;
		
		if( itemAlpha == 1 )
		{
			document.getElementById( itemID ).style.visibility = "visible";
		}
		else if( itemAlpha == 0 )
		{
			document.getElementById( itemID ).style.visibility = "hidden";
		}
	}
}

// 2007.08.13 KJD:
function NortonFadeout()
{
	Norton_SetOpacity( 'Norton_BlendLayer', 1 );

	/*
	setTimeout( "Norton_SetOpacity( 'Norton_BlendLayer', .99 )",	100 );
	setTimeout( "Norton_SetOpacity( 'Norton_BlendLayer', .77 )",	200 );
	setTimeout( "Norton_SetOpacity( 'Norton_BlendLayer', .55 )",	300 );
	setTimeout( "Norton_SetOpacity( 'Norton_BlendLayer', .33 )",	400 );
	setTimeout( "Norton_SetOpacity( 'Norton_BlendLayer', .11 )",	500 );
	setTimeout( "Norton_SetOpacity( 'Norton_BlendLayer', .01 )",	600 );
	*/
}

// 2007.08.16 KJD:
function NortonFadein()
{
	setTimeout( "Norton_SetOpacity( 'Norton_BlendLayer', 1 )",		100 );
	setTimeout( "Norton_SetOpacity( 'Norton_BlendLayer', .77 )",	200 );
	setTimeout( "Norton_SetOpacity( 'Norton_BlendLayer', .55 )",	300 );
	setTimeout( "Norton_SetOpacity( 'Norton_BlendLayer', .33 )",	400 );
	setTimeout( "Norton_SetOpacity( 'Norton_BlendLayer', .11 )",	500 );
	setTimeout( "Norton_SetOpacity( 'Norton_BlendLayer', 0 )",		600 );
}


// 2007.08.14 KJD: Create curve
function Norton_CreateCurve( thisID, thisSection, thisColor )
{
	var thisString = ""
		+ "<STYLE>"
		+ ".curve_" + thisID + "_top, .curve_" + thisID + "_bottom {display:block; background:transparent}"
		+ "	.curve_" + thisID + "_Bdygs1, .curve_" + thisID + "_Bdygs2, .curve_" + thisID + "_Bdygs3, .curve_" + thisID + "_Bdygs4 {display:block; overflow:hidden}"
		+ "	.curve_" + thisID + "_Bdygs1, .curve_" + thisID + "_Bdygs2, .curve_" + thisID + "_Bdygs3 {height:1px}"
		+ "	.curve_" + thisID + "_Bdygs2, .curve_" + thisID + "_Bdygs3, .curve_" + thisID + "_Bdygs4 {background:" + thisColor + "; border:1px solid " + thisColor + "; border-width:0 1px}"
		+ "	.curve_" + thisID + "_Bdygs1 {margin:0 5px; background:" + thisColor + "}"
		+ "	.curve_" + thisID + "_Bdygs2 {margin:0 3px; border-width:0 2px}"
		+ "	.curve_" + thisID + "_Bdygs3 {margin:0 2px}"
		+ "	.curve_" + thisID + "_Bdygs4 {height:2px; margin:0 1px}"
		+ "</STYLE>";
		
	if( thisSection == 'top' )
	{
		thisString += ""
			+ "	<div class='curve_" + thisID + "_" + thisSection + "'>"
			+ "		<div class='curve_" + thisID + "_Bdygs1'><b></b></div>"
			+ "		<div class='curve_" + thisID + "_Bdygs2'></div>"
			+ "		<div class='curve_" + thisID + "_Bdygs3'><b></b></div>"
			+ "		<div class='curve_" + thisID + "_Bdygs4'><b></b></div>"
			+ "	</div>";
	}
	else
	{
		thisString += ""
			+ "	<div class='curve_" + thisID + "_" + thisSection + "'>"
			+ "		<div class='curve_" + thisID + "_Bdygs4'><b></b></div>"
			+ "		<div class='curve_" + thisID + "_Bdygs3'></div>"
			+ "		<div class='curve_" + thisID + "_Bdygs2'><b></b></div>"
			+ "		<div class='curve_" + thisID + "_Bdygs1'><b></b></div>"
			+ "	</div>";
	}
	
	
	return thisString;

}


// 2007.08.15 KJD: Swap the div info
function NortonTab_SwapInfo( sourceDiv, targetDiv )
{
	var thisHTML = document.getElementById( sourceDiv ).innerHTML;
	document.getElementById( targetDiv ).innerHTML = "";
	document.getElementById( targetDiv ).innerHTML = thisHTML;
}

// 2007.08.16 KJD: Adjust the content area
function NortonTab_AdjustContent( sourceDiv )
{
	var thisInnerDiv	= document.getElementById( 'TabSectionContent_text_inner' );

	// 2007.08.16 KJD: This corrects issues with divs within 
	var thisHTML = "<DIV ID=\"NortonTab_ContentCorrected\" class='tabcontent'>" + thisInnerDiv.innerHTML + "</div>";
	thisInnerDiv.innerHTML = thisHTML;

	var thisParentDiv	= document.getElementById( 'TabSectionContent_text' );
	var thisGrandDiv	= document.getElementById( 'TabSectionContent_outer' );
	
	var newDiv = document.getElementById( 'NortonTab_ContentCorrected' );
	
	
	// 2007.08.14 KJD: Check browser type
	var thisNav = navigator.userAgent.toLowerCase();

	// 2007.08.20 KJD: for non-IE
	if( thisNav.indexOf( "msie" ) == -1 )
	{
		thisInnerDiv.style.height	= newDiv.offsetHeight + 0;
		thisParentDiv.style.height	= newDiv.offsetHeight + 23;
		thisGrandDiv.style.height	= newDiv.offsetHeight + 37;
	}
	else
	{
		thisInnerDiv.style.height	= newDiv.offsetHeight + 0;
		thisParentDiv.style.height	= newDiv.offsetHeight + 28;
		thisGrandDiv.style.height	= newDiv.offsetHeight + 38;
	}
	
}

// 2007.08.16 KJD: Adjust the Blend Layer
function NortonTab_AdjustBlendLayer()
{
	var thisInnerDiv	= document.getElementById( 'TabSectionContent_text_inner' );
	
	if( document.getElementById( 'Norton_BlendLayer' ) )
	{
		document.getElementById( 'Norton_BlendLayer' ).style.height = thisInnerDiv.offsetHeight - 1 ;
	}
}

// 2007.08.16 KJD: Track the tab in use

var IsTracked = 0;

function NortonTrackTab( thisName )
{
	if( !( NortonPageName ) )
	{
		if( !( typeof s == 'undefined' ) )
		{
			// 2007.08.16 KJD: Pagename hasn't been set yet, so set it
			NortonPageName = s.pageName;
		}
		
		// 2007.08.16 KJD: Keep checking
		setTimeout( "NortonTrackTab( \"" + thisName + "\" )", 1000 );
	}
	else
	{
		var thisNortonPageName = "";
	
		if( thisName != 'more' )
		{
			for( var i = 0; i < NortonTabListByID.length; i++ )
			{
				var thisTabArray = NortonTabListByID[ i ].split( "####" );
				if( thisTabArray[0] == thisName )
				{
					thisNortonPageName = NortonPageName + ": " + thisTabArray[1];
				}
			}
		}
		else
		{
			thisNortonPageName = NortonPageName + ": More";
		}
	
			
		s.prop31 = thisNortonPageName;
		
		if( IsTracked )
		{
			void( s.t() );
		}
		else
		{
			// 2007.08.20 KJD: So we skip the first time
			IsTracked = 1;
		}
	}
}

// 2007.08.23 KJD: Check the Product Title width's
function NortonTabProductTitle()
{
	var thisObj = document.getElementsByName( 'TabSectionContent_ProductTitle' );
	
	if( thisObj.length > 0 )
	{
		for( var i = 0; i < thisObj.length; i++ )
		{
			// 2007.08.23 KJD: Set width
			thisObj[ i ].style.width	= "285px";
			
			NortonTabProductTitleAdjust( thisObj[ i ] );
		}
	}
}

// 2007.08.23 KJD: Adjust the font size of the product title
function NortonTabProductTitleAdjust( thisName )
{
	// 2007.08.23 KJD: Check height
	if( thisName.offsetHeight > 30 )
	{
		
		var thisFontSize = parseInt( thisName.style.fontSize );
		if( !( thisFontSize ) )
		{
			thisFontSize = 15;
		}
		else
		{
			thisFontSize--;
		}
		
		thisName.style.fontSize = thisFontSize + "px";
		
		setTimeout( "NortonTabProductTitle()", 10 );
	}
}


