//
// is.js
//
var m_isAnCtr = null;
var m_isAnDiv = null;
var m_isAnFin = null;
var m_isAnShd = null;
var m_isCtDiv = null;
var m_isBgDiv = null;
var m_isSmDiv = null;
var m_isImage = null;
var m_isTlImg = null;
var m_isTlTxt = null;
var m_isDesc  = null;
var m_isIntro = null;
var m_isUrl   = null;
var m_isEmail = null;
var m_isCount = 0;
var m_isMode  = "inline";
var m_isSecs  = 7;
var m_isWidth = 728;
var m_isExpnd = true;
var m_isParaFix = /para/;
var m_isStart;
var m_isFinish;

function isShow()
{
	var dhtml = isCSS && ( isIE4 || isGecko || isOpera );

	if( !dhtml || ( isOpera && readOperaVer() < 4 ) )
	{
		return;
	}
	
	isInit();

	if( m_isExpnd )
	{
		setTimeout( "isShow2()", 1000 );
	}
	else
	{
		isCollapse();
		m_isCtDiv.style.display = "block";
	}
}

function isShow2()
{
	isAnimate( 20, 110, m_isSmDiv, m_isBgDiv );
	
	setTimeout( "isAnimClose()", m_isSecs * 1000 );
}

function isWinCheck()
{
	if( typeof(lastPopup) == "undefined" || !lastPopup || !("parent" in lastPopup) )
	{
		setTimeout( "isShow2()", 200 );
	}
}

function isInit()
{
	// build the animation container
	if( m_isMode != "inline" )
	{
		extra = "; position:absolute";
		
		if( m_isMode == "globalpromo" )
		{
			m_isWidth = 362;
		}
	}
	else
	{
		extra = "";
	}
	
	if( m_isUrl && m_isUrl.toLowerCase().indexOf( "javascript:" ) == 0 )
	{
		// ok.. its a js call... insert the autoclose...
		m_isUrl += ";isAutoClose()";
	}
	
	document.writeln( "<div id=\"is_animctr\" style=\"display:none" + extra + "\">" );
	
	// build the smaller window
	if( m_isMode == "inline" )
	{
		initSmall( "none" );
	}
	
	linkWrapper = "<a href=\"" + m_isUrl + "\">";

	// build the larger window
	if( m_isMode == "globalpromo" )
	{
		document.writeln( "<table id=\"is_large\" cellpadding=\"6\" cellspacing=\"0\" width=\"362\" style=\"border:1px solid #cccccc; background-color:#f2f6ff; display:none\">" );
		document.write( "<tr><td valign=\"top\" width=\"70\">" );

		if( !m_isEmail )
		{
			document.write( linkWrapper );
		}

		document.write( "<img src=\"" + m_isImage + "\" border=\"0\">" );

		if( !m_isEmail )
		{
			document.write( "</a>" );
		}

		document.write( "</td><td valign=\"top\" width=\"268\">" );
	
		if( !m_isEmail )
		{
			document.write( linkWrapper );
		}

		document.write( "<img src=\"" + m_isTlImg + "\" border=\"0\" alt=\"" + m_isTlTxt + "\">" );

		if( !m_isEmail )
		{
			document.write( "</a>" );
		}

		if( m_isDesc )
		{
			document.write( "<div>" + m_isDesc + "</div>" );
		}
		
		document.write( "</td></tr>" );

		if( m_isIntro )
		{
			document.write( "<tr><td colspan=\"2\" class=\"para\">" + m_isIntro + "</td></tr>" );
		}

		document.write( "<tr><td colspan=\"2\" valign=\"bottom\">" );

		writeLink( 350 );
		
		document.write( "</td></tr>" );
	}
	else
	{
		document.writeln( "<table id=\"is_large\" cellpadding=\"6\" cellspacing=\"0\" width=\"" + m_isWidth + "\" style=\"border:1px solid #cccccc; background-color:#f2f6ff; display:none\">" );
		document.write( "<tr><td valign=\"top\" width=\"120\" rowspan=\"2\">" );

		if( !m_isEmail )
		{
			document.write( linkWrapper );
		}

		document.write( "<img src=\"" + m_isImage + "\" border=\"0\">" );

		if( !m_isEmail )
		{
			document.write( "</a>" );
		}

		document.write( "</td><td valign=\"top\" width=\"558\">" );
		
		if( !m_isEmail )
		{
			document.write( linkWrapper );
		}

		document.write( "<img src=\"" + m_isTlImg + "\" border=\"0\" alt=\"" + m_isTlTxt + "\">" );
		
		if( !m_isEmail )
		{
			document.write( "</a>" );
		}

		if( m_isDesc )
		{
			document.write( "<div>" + m_isDesc + "</div>" );
		}

		if( m_isIntro )
		{
			document.write( "<div class=\"para\">" + m_isIntro + "</div>" );
		}

		document.write( "</td></tr>" );

		document.write( "</td></tr><tr><td valign=\"bottom\">" );

		writeLink( 546 );

		document.write( "<tr><td colspan=\"2\" bgcolor=\"#ff6600\" style=\"padding:0\">&nbsp;</td></tr>" );
	}
	
	document.writeln( "</table>" );

	// build the animation window
	document.writeln( "<table id=\"is_anim\" cellpadding=\"2\" cellspacing=\"0\" width=\"" + m_isWidth + "\" style=\"border:1px solid #cccccc; background-color:#f2f6ff; display:none\">" );
	document.write( "<tr><td valign=\"top\" class=\"para_small\">&nbsp;</td></tr>" );
	document.writeln( "</table>" );

	if( isIE4 && m_isMode != "inline" )
	{
		document.writeln( "<div id=\"is_shade\" style=\"display:none\">" );
		for( op = 40; op > 4; op -= 6 )
		{
			document.writeln( "<table cellpadding=\"0\" cellspacing=\"0\" width=\"" + m_isWidth + "\" style=\"background-color:#000000; filter:progid:DXImageTransform.Microsoft.Alpha(opacity=" + op + ")\"><tr><td><img src=\"" + m_imgPfx + "/images/global/general/spacer.gif\" height=\"1\" width=\"1\" alt=\"\" /></td></tr></table>" );
		}
		document.writeln( "</div>" );
		
		m_isAnShd = getRawObject( "is_shade" );
	}

	// close the animation container

	if( m_isMode != "hover" )
	{
		document.writeln( "<div><img src=\"" + m_imgPfx + "/images/global/general/spacer.gif\" height=\"4\" width=\"1\" alt=\"\" /></div>" );
	}

	document.writeln( "</div>" );

	if( m_isMode == "hover" )
	{
		initSmall( "block" );
	}

	// get them back DOM style
	m_isBgDiv = getRawObject( "is_large" );
	m_isAnDiv = getRawObject( "is_anim" );
	m_isCtDiv = getRawObject( "is_animctr" );
}

function writeLink( width )
{
	document.write( "<table cellpadding=\"0\" cellspacing=\"0\" width=\"" + width + "\"><tr><td>" );
	
	if( m_isEmail )
	{
		document.write( m_isEmail );
	}
	else
	{
		document.write( "<a href=\"" + m_isUrl + "\" class=\"lnk_promodetails\"><img src=\"" + m_imgPfx + "/images/global/brand/ui/secondinline.gif\" alt=\"\" border=\"0\">" + m_offerdetail + "</a>" );
	}
	
	document.write( "</td><td>" );
	document.write( "<div align=\"right\"><a href=\"javascript:isCollapse()\" class=\"para_small\"><img src=\"" + m_imgPfx + "/images/global/brand/ui/secondinline.gif\" alt=\"\" border=\"0\">" + m_popClose + "</a></div>" );
	document.write( "</td></tr></table>" );
}

function initSmall( mode )
{
	document.writeln( "<table id=\"is_small\" cellpadding=\"2\" cellspacing=\"0\" width=\"728\" style=\"border:1px solid #cccccc; background-color:#f2f6ff; display:" + mode  +"\">" );
	document.write( "<tr><td valign=\"top\" align=\"right\">" );
	
	document.write( "<a href=\"" + m_isUrl + "\" class=\"lnk_promo\">" + m_isTlTxt + "</a>" );
	if( m_isDesc )
	{
		document.write( "<span class=\"para_small\">&nbsp;" + m_isDesc.replace( m_isParaFix, "para_small" ) + "</span>" );
	}

	document.write( "</td><td align=\"right\"><a href=\"javascript:isExpand()\" class=\"para_small\">" + m_popExpand + "</a>" );
	
	document.write( "</td></tr></table>" );

	if( m_isMode == "hover" )
	{
		document.writeln( "<div><img src=\"" + m_imgPfx + "/images/global/general/spacer.gif\" height=\"4\" width=\"1\" alt=\"\" /></div>" );
	}

	m_isSmDiv = getRawObject( "is_small" );
}

function isExpand()
{
	m_isAnDiv.style.display = "none";

	if( m_isMode == "inline" )
	{
		m_isSmDiv.style.display = "none";
	}
	
	m_isBgDiv.style.display = "block";

	if( m_isAnShd )
	{
		m_isAnShd.style.display = "block";
	}
}

function isAutoClose()
{
	if( m_isBgDiv.style.display == "block" )
	{
		isCollapse();
	}
}

function isCollapse()
{
	m_isAnDiv.style.display = "none";
	m_isBgDiv.style.display = "none";

	if( m_isAnShd )
	{
		m_isAnShd.style.display = "none";
	}

	if( m_isSmDiv )
	{
		m_isSmDiv.style.display = "block";
	}
}

function isAnimClose()
{
	if( m_isBgDiv.style.display == "block" )
	{
		if( m_isMode != "hover" )
		{
			isAnimate( m_isBgDiv.offsetHeight, 20, m_isBgDiv, m_isSmDiv );
		}
		else
		{
			isAnimate( m_isBgDiv.offsetHeight, 0, m_isBgDiv, m_isSmDiv );
		}
		
		if( m_isAnShd )
		{
			m_isAnShd.style.display = "none";
		}
	}
}

function isAnimate( start, finish, from, obj )
{
	m_isStart	= start;
	m_isFinish	= finish;
	
	if( from && m_isMode != "hover" )
	{
		from.style.display = "none";
	}
	
	m_isBgDiv.style.display = "none";
	m_isAnDiv.style.display = "none";
	m_isAnDiv.style.height= m_isStart;
	m_isAnDiv.style.display = "block";

	if( m_isAnShd )
	{
		m_isAnShd.style.display = "block";
	}
	
	m_isCount = ( m_isStart < m_isFinish ) ? 15 : -50;
	
	if( m_isAnCtr )
	{
		clearTimeout( m_isAnCtr );
	}
	
	m_isAnFin = obj;
	m_isAnCtr = setInterval( "isAdjust()", 40 );
	m_isCtDiv.style.display = "block";
	isAdjust();
}

function isAdjust()
{
	m_isStart += m_isCount;
	
	if( ( m_isCount < 0 && m_isStart < m_isFinish ) || ( m_isCount > 0 && m_isStart > m_isFinish ) )
	{
		m_isStart = m_isFinish;
		clearTimeout( m_isAnCtr );
		m_isAnCtr = null;
	}
	else
	{
		m_isAnDiv.style.height= m_isStart;
	}
	
	if( m_isAnCtr == null )
	{
		m_isAnDiv.style.display = "none";
		if( m_isAnFin )
		{
			m_isAnFin.style.display = "block";
		}
	}
}

// -------------------------------------------------------------
// end of is.js
// -------------------------------------------------------------

