// Document created

var RmspTab_tempBox			= "";
var thisTabSet					= 0;
var RmspTabList 				= new Array();
var RmspIsFirstTabName		= "";
var RmspIsFirstTabOnNextLine 	= "";  // this is my favorite variable name ;)

var RmspPageName				= "";
var RmspTabListByID			= new Array();


function RmspTab_Adjust( tabname )
{
	var thisTab					= document.getElementById( tabname );
	var thisOuterTab			= document.getElementById( tabname + '_outer' );
	var thisTabBottom			= document.getElementById( tabname + '_bottom' );
	
	/*try
	{*/
		if( tabname == 'RmspTab1' )
		{				
			thisOuterTab.style.width 	= 99 + 20 + "px";
			thisTabBottom.style.width	= 119 + "px";
		}
		else if( tabname == 'RmspTab2' )
		{
			thisOuterTab.style.width 	= 107 + 20 + "px";
			thisTabBottom.style.width	= 127 + "px";
		}
		else if( tabname == 'RmspTab3' )
		{
			thisOuterTab.style.width 	= 99 + 20 + "px";
			thisTabBottom.style.width	= 119 + "px";
		}
		else if( tabname == 'RmspTab4' )
		{
			thisOuterTab.style.width 	= 50 + 20 + "px";
			thisTabBottom.style.width	= 70 + "px";
		}
		else if( tabname == 'RmspTab5' )
		{
			thisOuterTab.style.width 	= 124 + 20 + "px";
			thisTabBottom.style.width	= 144 + "px";
		} 
	/*}
	catch(e)
	{
		alert(e.message);
	}*/
		/*
	alert(tabname);
	alert(thisTab.offsetWidth); 
	alert(thisTab.offsetWidth);
	*/
	
	
	/*
	thisOuterTab.style.width 	= thisTab.offsetWidth + 20 + "px";
	thisTab.style.display 		= "block";	
	thisTabBottom.style.width	= thisTab.offsetWidth + "px";
	
	alert(thisTab.offsetWidth);
	alert(thisOuterTab.style.width);
	alert(thisTabBottom.style.width); */
	
	thisTab.style.display 		= "block";	
	

}


function RmspTab_CreateTab( tabID, tabText, tabCall )
{
	var thisString = "";
	
	var thisCall = "";
	if( typeof tabCall != 'undefined' )
	{
		thisCall += tabCall;
	}
	else
	{
		thisCall = "RmspTab_Select( this.id );" + tabCall;
	}
	
	// Check if extra style declared
	var ExtraTabStyle = "";
	if( typeof RmspTabStyle != 'undefined' ){ ExtraTabStyle = " STYLE=\"" + RmspTabStyle + "\""; }
	
	thisString = ""
		+ "<DIV CLASS='TabBox_outer_off' ID='" + tabID + "_outer' "
			+ "onClick		=\"" + thisCall + "\""
			+ ">"
		+ "	<DIV ID='" + tabID + "' CLASS='Tab_Off'"
		+ ExtraTabStyle 
		+  ">" + tabText + "</DIV>"
		+ "<DIV ID='" + tabID + "_bottom' CLASS='RmspTab_Bottom_Off'></DIV>"
		
		+ "</DIV><DIV STYLE='display:block;border:none;width:10px;height:40px;float:left'></DIV>";
	
	document.write( thisString );

	RmspCheckIfMultiLineTab( tabID );

	
	RmspTab_Adjust( tabID );
	
	
	RmspTab_tempBox = tabID;
	RmspTabList[ RmspTabList.length ] = tabID;
	
	RmspTabListByID[ RmspTabListByID.length ] = tabID + "####" + tabText;
	
	RmspCheckIfFirstTab( tabID );
	RmspCheckIfNextLineTab( tabID );
	
	
}

// Check if multiple line
function RmspCheckIfMultiLineTab( tabID, oversent )
{
	var thisTab		= document.getElementById( tabID );
	var thisWidth	= thisTab.offsetWidth;
	
	if( tabID == 'RmspTab1' )
	{				
		thisWidth 	= 99;
	}
	else if( tabID == 'RmspTab2' )
	{
		thisWidth 	= 107;
	}
	else if( tabID == 'RmspTab3' )
	{
		thisWidth 	= 99;
	}
	else if( tabID == 'RmspTab4' )
	{
		thisWidth 	= 50;
	}
	else if( tabID == 'RmspTab5' )
	{
		thisWidth 	= 124;
	}

	if( thisTab.offsetHeight > 50 )
	{
		thisWidth += 5;

		thisTab.style.width = thisWidth + "px";

		setTimeout( "RmspCheckIfMultiLineTab( '" + tabID + "', 1 )", 1 );
	}
	else if( oversent )
	{
		RmspIsFirstTabOnNextLine = "";
		RmspTab_Adjust( tabID );
		RmspCheckIfFirstTab( tabID );
		RmspCheckIfNextLineTab( tabID );
		
		// Adjust box
		thisWidth += 10;
		thisTab.style.width = thisWidth + "px";

		// Adjust highlight
		document.getElementById( tabID + '_bottom' ).style.width = thisWidth;
	}
}



function RmspCheckIfFirstTab( tabID )
{
	if( !( RmspIsFirstTabName ) )
	{
		RmspIsFirstTabName = tabID;
	}
}


function RmspCheckIfNextLineTab( tabID )
{
	if( !( RmspIsFirstTabOnNextLine ) )
	{
		var thisTab = document.getElementById( tabID );
		if( thisTab.offsetTop > 30 )
		{
			RmspIsFirstTabOnNextLine = tabID;
		}
	}
}


function RmspTab_DeSelectAll()
{
	for( var i=0; i< RmspTabList.length; i++ )
	{
		RmspTab_DeSelect( RmspTabList[ i ] );
	}
}

function RmspTab_DeSelect( tabID )
{
	document.getElementById( tabID + "_bottom" ).className	= "RmspTab_Bottom_Off";
	document.getElementById( tabID + "_outer" ).className	= "TabBox_outer_off";
	document.getElementById( tabID ).className 				= "Tab_Off";
}


function RmspTab_Select( tabID )
{
	RmspTab_DeSelectAll();
	RmspFadeout();

	var thisName	= tabID;
	thisName		= thisName.replace( "_outer", "" );

	document.getElementById( thisName + "_bottom" ).className	= "RmspTab_Bottom_On";
	document.getElementById( thisName + "_outer" ).className 	= "TabBox_outer_on";
	document.getElementById( thisName ).className 				= "Tab_On";
	
	// Check if first tab
	if( ( thisName == RmspIsFirstTabName ) || ( thisName == RmspIsFirstTabOnNextLine ) )
	{
		document.getElementById( 'RmspTab_cornercover' ).style.visibility = "visible";
	}
	else
	{
		document.getElementById( 'RmspTab_cornercover' ).style.visibility = "hidden";
	}
	
	// Swap Content
	RmspTab_SwapInfo( thisName + "_Content", 'TabSectionContent_text_inner' );


	// Adjust the size
	if( window.RmspTabContentAutoSize )
	{
		RmspTab_AdjustContent( thisName );
	}
	
	RmspTab_AdjustBlendLayer();
	RmspFadein();
	
	RmspTrackTab( thisName );

	RmspTabProductTitle();
	RmspTabProductTitle2();
}


function Rmsp_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";
		}
	}
}


function RmspFadeout()
{
	Rmsp_SetOpacity( 'Rmsp_BlendLayer', 1 );
}


function RmspFadein()
{
	setTimeout( "Rmsp_SetOpacity( 'Rmsp_BlendLayer', 1 )",		100 );
	setTimeout( "Rmsp_SetOpacity( 'Rmsp_BlendLayer', .77 )",	200 );
	setTimeout( "Rmsp_SetOpacity( 'Rmsp_BlendLayer', .55 )",	300 );
	setTimeout( "Rmsp_SetOpacity( 'Rmsp_BlendLayer', .33 )",	400 );
	setTimeout( "Rmsp_SetOpacity( 'Rmsp_BlendLayer', .11 )",	500 );
	setTimeout( "Rmsp_SetOpacity( 'Rmsp_BlendLayer', 0 )",		600 );
}


// Create curve
function Rmsp_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:2 0px; background:" + thisColor + "; border:1px solid " + thisColor + "; border-width:2px 1px 2px}"
		+ "	.curve_" + thisID + "_Bdygs1 {margin:0 0px; background:" + thisColor + "}"
		+ "	.curve_" + thisID + "_Bdygs2 {margin:0 3px; border-width:0 2px}"
		//+ "	.curve_" + thisID + "_Bdygs2 {margin:0 3px; border-width:0 2px; background:" + thisColor + "; border:1px solid " + thisColor + "; border-width:1px 1px 1px}"
		+ "	.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>";
	}
	
/*	
	if( thisID == 'RmspTopTabBoxBottom' || thisID == 'RmspTopTabContentInnerTextBottom' || thisID == 'RmspTopTabContentInnerBottom' )
	{
		thisString		= thisString.replace( "border-width:0 1px", "border-width:1px 1px 1px" );
	}
	else if ( thisID == 'RmspTopTabBoxTop' || thisID == 'RmspTopTabContentInnerTextTop' || thisID == 'RmspTopTabContentInnerTop' )
	{
		thisString		= thisString.replace( "border-width:0 2px", "border-width:0 2px; background:" + thisColor + "; border:1px solid " + thisColor + "; border-width:1px 1px 1px" );
	} */
/*	else if (thisID == 'RmspTopTabContentInnerBottom' )
	{
		thisString		= thisString.replace( "border-width:0 1px", "border-width:1px 1px 1px" );		
	}
	else if (thisID == 'RmspTopTabContentInnerTop' )
	{
		thisString		= thisString.replace( "border-width:0 2px", "border-width:0 2px; background:" + thisColor + "; border:1px solid " + thisColor + "; border-width:1px 1px 1px" );	
	} */
	
	return thisString;

}
function Rmsp_CreateCurveSmallRgt( 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 4px 0 0; background:" + thisColor + "}"
		+ "	.curve_" + thisID + "_Bdygs2 {margin:0 2px 0 0; border-width:0 2px}"
		+ "	.curve_" + thisID + "_Bdygs3 {margin:0 1px 0 0}"
		+ "	.curve_" + thisID + "_Bdygs4 {height:1px; margin:0 1px 0 0}"
		+ "</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>";
	}
	
	/*
	if( thisID == 'TabSectionContent_ProductRight_Mid2' && thisSection == 'bottom' )
	{
		//thisString		= thisString.replace( "border-width:0 1px", "border-width:2px 1px 0px" );
		thisString		= thisString.replace( "border-width:0 1px", "border-width:2px 2px 0px 0px" ); //2.5px 2px 2.5px" );
	}
	else if ( thisID == 'TabSectionContent_ProductRight_Mid2' && thisSection == 'top' )
	{
		//thisString		= thisString.replace( "border-width:0 2px", "border-width:0 2px; background:" + thisColor + "; border:1px solid " + thisColor + "; border-width:2px 1px 2px" );
	} 
	*/
	return thisString;

}


// Swap the div info
function RmspTab_SwapInfo( sourceDiv, targetDiv )
{
	var thisHTML = document.getElementById( sourceDiv ).innerHTML;
	document.getElementById( targetDiv ).innerHTML = "";
	document.getElementById( targetDiv ).innerHTML = thisHTML;
}

// Adjust the content area
function RmspTab_AdjustContent( sourceDiv )
{
	var thisInnerDiv	= document.getElementById( 'TabSectionContent_text_inner' );

	// This corrects issues with divs within 
	var thisHTML = "<DIV STYLE=\"position:absolute;\" ID=\"RmspTab_ContentCorrected\" STYLE='border:solid white 1px;'>" + thisInnerDiv.innerHTML + "</div>";
	thisInnerDiv.innerHTML = thisHTML;

	var thisParentDiv	= document.getElementById( 'TabSectionContent_text' );
	var thisGrandDiv	= document.getElementById( 'TabSectionContent_outer' );
	
	var newDiv = document.getElementById( 'RmspTab_ContentCorrected' );
	
}

// Adjust the Blend Layer
function RmspTab_AdjustBlendLayer()
{
	var thisInnerDiv	= document.getElementById( 'TabSectionContent_text_inner' );

}

// Track the tab in use

var IsTracked = 0;

function RmspTrackTab( thisName )
{
	if( !( RmspPageName ) )
	{
		if( !( typeof s == 'undefined' ) )
		{
			// Pagename hasn't been set yet, so set it
			RmspPageName = s.pageName;
		}
		
		// Keep checking
		setTimeout( "RmspTrackTab( \"" + thisName + "\" )", 1000 );
	}
	else
	{
		var thisRmspPageName = "";
	
		if( thisName != 'more' )
		{
			for( var i = 0; i < RmspTabListByID.length; i++ )
			{
				var thisTabArray = RmspTabListByID[ i ].split( "####" );
				if( thisTabArray[0] == thisName )
				{
					thisRmspPageName = RmspPageName + ": " + thisTabArray[1];
				}
			}
		}
		else
		{
			thisRmspPageName = RmspPageName + ": More";
		}
	
			
		s.prop31 = thisRmspPageName;
		
		if( IsTracked )
		{
			void( s.t() );
		}
		else
		{
			// So we skip the first time
			IsTracked = 1;
		}
	}
}

// Check the Product Title width's
function RmspTabProductTitle()
{
	var thisObj = document.getElementsByName( 'TabSectionContent_ProductTitle' );
	
	if( thisObj.length > 0 )
	{
		for( var i = 0; i < thisObj.length; i++ )
		{
			// Set width
			thisObj[ i ].style.width	= "285px";
			
			RmspTabProductTitleAdjust( thisObj[ i ] );
		}
	}
}
// Check the Product Title width's
function RmspTabProductTitle2()
{
	var thisObj = document.getElementsByName( 'TabSectionContent_ProductTitle2' );
	
	if( thisObj.length > 0 )
	{
		for( var i = 0; i < thisObj.length; i++ )
		{
			// Set width
			thisObj[ i ].style.width	= "210px";
			
			RmspTabProductTitleAdjust( thisObj[ i ] );
		}
	}
}

// Adjust the font size of the product title
function RmspTabProductTitleAdjust( thisName )
{
	// Check height
	if( thisName.offsetHeight > 30 )
	{
		
		var thisFontSize = parseInt( thisName.style.fontSize );
		if( !( thisFontSize ) )
		{
			thisFontSize = 15;
		}
		else
		{
			thisFontSize--;
		}
		
		thisName.style.fontSize = thisFontSize + "px";
		
		setTimeout( "RmspTabProductTitle()", 10 );
	}
}



