//
//------------------------------------------------------------------------------------------------------
// 	Banner class [ based on script: http://www.quirksmode.org/js/rotate.html]
//	Constructor Params:  
//		bannerName - name of the html contrainer where the banner will reside
//		rotationInterval - rotation interval in mil sec
//		methodName - the name of the method + obj. ref. that does the rotation [usually the o.Rotate]
//		aHeaderBannerImages - array of banner images to display
//		aHeaderBannerLinkx - array of links that banners point
//		showInNewWindow - 1 yes, 0 in the same win
//------------------------------------------------------------------------------------------------------
//
function CBanner (bannerName, rotationInterval, methodName, aHeaderBannerImages, aHeaderBannerLinkx, showInNewWindow)
{
	//
	//--------------------------------------------------------------------------------
	// Properties
	//--------------------------------------------------------------------------------
	//
	// init banners
	var m_aBanners = aHeaderBannerImages;
	var m_aLinx = aHeaderBannerLinkx;
	// init indexes
	var m_oldIdx = 0;
	var m_currentIdx = 0;
	// name of the banner tag in the source html page
	var m_bannerName = bannerName;
	var m_rotationInterval = rotationInterval;
	var m_methodName = methodName;
	var m_showInNewWindow = showInNewWindow;
	//
	//--------------------------------------------------------------------------------
	// properties  holding  'function pointers' to the worker funcs
	this.Rotate = rotate;
	this.SendToPage = sendPage;
	//
	//--------------------------------------------------------------------------------
	// Methods
	//--------------------------------------------------------------------------------
	//
	//---Rotate Banners
	function rotate()
	{
		if (!document.images) return
		while ( m_currentIdx == m_oldIdx )
		{
			m_currentIdx = Math.floor( Math.random() * m_aBanners.length );
		}
		m_oldIdx = m_currentIdx;
		document.images[m_bannerName].src = m_aBanners[m_currentIdx];
		setTimeout(m_methodName, m_rotationInterval);
	} // End of method rotate
	//
	//---Send to page, after click
	function sendPage()
	{
		if (m_showInNewWindow == 1)
		{
			// open popup
			window.open(m_aLinx[m_currentIdx]);
		}
		else 
		{
			// open in same win
			location.href = m_aLinx[m_currentIdx];		
		}
	} // End of method sendPage
}// End of class CBanner