/**
    * Get object (For current browser)
    **/
function fnGetObj(elementId)
{
	if (document.getElementById)
	{
		return document.getElementById(elementId);
	}
	else if (document.all)
	{
		return document.all[elementId];
	}
	else if (document.layers)
	{
		return document.layers[elementId];
	}
}

/**
    * Rotate testimonial text in specific layer
    **/
function clsTestimonialRotate()
{
	this.m_aTestimonials = new Array();
	this.m_sTestimonialElement = "";
	this.m_nMaxReturnTestimonials = 1;
	this.m_nMaxNumOfChars = 180;
}

	clsTestimonialRotate.prototype.add_Testimonials = function(p_aTestimonials)
	{
		this.m_aTestimonials = p_aTestimonials;
	}
	
	clsTestimonialRotate.prototype.set_TestimonialElement = function(p_sTestimonialElement)
	{
		this.m_TestimonialElement = p_sTestimonialElement;
		this.m_objTestimonialElement = fnGetObj(this.m_TestimonialElement);
	}
	
	clsTestimonialRotate.prototype.wrapTxt = function(p_sTxt)
	{
		if (p_sTxt.length > this.m_nMaxNumOfChars)
		{
			nPositionOfSpace = p_sTxt.indexOf(" ", this.m_nMaxNumOfChars);
			sTxt = p_sTxt.substring(0, nPositionOfSpace) + " ...";

			return sTxt;
		}
		else
		{
			return p_sTxt;
		}
	}
	
	clsTestimonialRotate.prototype.set_Testimonials = function()
	{					
		sHtmlOutput = "";
		
		for (var i = 0; i < this.m_nMaxReturnTestimonials; i++)
		{
			nNumberOfTestimonials = this.m_aTestimonials.length;
			nRandom = Math.floor(Math.random() * (nNumberOfTestimonials));
								
			sHtmlOutput += "<STRONG>" + this.m_aTestimonials[nRandom].name + "</STRONG>";
			sHtmlOutput += "<P>";
			sHtmlOutput += this.wrapTxt(this.m_aTestimonials[nRandom].message);
			sHtmlOutput += "</P>";
			
			this.m_aTestimonials.splice(nRandom, 1);
		}
		this.m_objTestimonialElement.innerHTML = sHtmlOutput;
	}

/**
    * Rotate banners  in specific layer
    **/
function clsBannerRotate()
{
	this.m_aBanners = new Array();
	this.m_sBannerElement = "";
	this.m_nMaxReturnBanners = 3;
}

	clsBannerRotate.prototype.add_Banners = function(p_aBanners)
	{
		this.m_aBanners = p_aBanners;
	}
	
	clsBannerRotate.prototype.set_BannerElement = function(p_sBannerElement)
	{
		this.m_BannerElement = p_sBannerElement;
		this.m_objBannerElement = fnGetObj(this.m_BannerElement);
	}
	
	clsBannerRotate.prototype.set_Banners = function()
	{					
		sHtmlOutput = "";
		
    // --- Set one banner as first and outside of rotation
		//sHtmlOutput += "<a href='" + this.m_aBanners[0].link + "'><object class='banner' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' width='" + this.m_aBanners[0].width + "' height='" + this.m_aBanners[0].height + "'><param name='movie' value='" + this.m_aBanners[0].image + "'><param name='quality' value='high'><embed src='" + this.m_aBanners[0].image + "' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='" + this.m_aBanners[0].width + "' height='" + this.m_aBanners[0].height + "'></embed></object></a>";
		//sHtmlOutput += "<br>";
		//this.m_aBanners.splice(0, 1);
		
		/*sHtmlOutput += "<a href='" + this.m_aBanners[1].link + "'><object class='banner' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' width='" + this.m_aBanners[1].width + "' height='" + this.m_aBanners[1].height + "'><param name='movie' value='" + this.m_aBanners[1].image + "'><param name='quality' value='high'><embed src='" + this.m_aBanners[1].image + "' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='" + this.m_aBanners[1].width + "' height='" + this.m_aBanners[1].height + "'></embed></object></a>";
		sHtmlOutput += "<br>";
		this.m_aBanners.splice(1, 1);
		*/
		
		for (var i = 0; i < this.m_nMaxReturnBanners; i++)
		{
			nNumberOfBanners = this.m_aBanners.length;
			nRandom = Math.floor(Math.random() * (nNumberOfBanners));
			
			//sHtmlOutput += "<A HREF='" + this.m_aBanners[nRandom].link + "'><IMG SRC='" + this.m_aBanners[nRandom].image + "'></STRONG>";
			sHtmlOutput += "<a href='" + this.m_aBanners[nRandom].link + "'><object class='banner' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' width='" + this.m_aBanners[nRandom].width + "' height='" + this.m_aBanners[nRandom].height + "'><param name='movie' value='" + this.m_aBanners[nRandom].image + "'><param name='quality' value='high'><embed src='" + this.m_aBanners[nRandom].image + "' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='" + this.m_aBanners[nRandom].width + "' height='" + this.m_aBanners[nRandom].height + "'></embed></object></a>";
			sHtmlOutput += "<br>";			
			this.m_aBanners.splice(nRandom, 1);
		}
		
		this.m_objBannerElement.innerHTML = sHtmlOutput;
	}
	

	function loadFlash()
	{
		document.write("<object class='banner' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' width='341' height='82'><param name='movie' value='images/banners/animation_specials2.swf'><param name='quality' value='high'><embed src='images/banners/animation_specials2.swf' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='341' height='82'></embed></object>");
	}

	
	
	