function updateRTLScroll()
{
	if ((!document.all) && document.body.dir == "rtl" ) 
	{	
		document.body.scrollLeft = document.body.scrollWidth;
	}
}
function UpdateRadio()
{
	try{
		
		var radioElem = IsradioExists();
		if (radioElem == null) return;
		
		UpadateRadioFrame(radioElem);
		UpdateRadioArrow(radioElem);
		
	}
	catch(e)
	{
		//handle exception
	}
}
function preloadImgs() {
	arr=arguments; 
	document.preImgsArgsArr=new Array();
	var img;
	for(var i=0; i<arr.length; i++) 
	{ 
		img = new Image;
		img.src = arr[i];
		document.preImgsArgsArr[i] = img;
	}
}

function RepositionRadioArrow()
{
	try{
	
		var radioElem = IsradioExists();
		if (radioElem == null) return;
		
		UpdateRadioArrow(radioElem);
	
	}
	catch(e)
	{
		//handle exception
	}
}
function UpadateRadioFrame(radioElem)
{
	var radioSource  = RadioPath + "eb_radio_index=1&eb_ct_id=" + ToolbarId + "&eb_preview=0&eb_random=68670&eb_bgcolor=F0EEE1&eb_from=landingpage";
	radioElem.innerHTML = "<iframe id='ifrm_browser_radio' height='20' width='205' FRAMEBORDER='0' SCROLLING='no' src='" + radioSource +"' ></IFRAME>";
}
function IsradioExists()
{

	var radioElem = null;
	var toolbarRow = document.getElementById("ToolbarControl_trButtons");
		
	for (var i = 0 ; i < toolbarRow.cells.length ; i ++)
	{
		if (toolbarRow.cells[i].childNodes[0] && toolbarRow.cells[i].childNodes[0].id && toolbarRow.cells[i].style.display == "")
		{
			if (toolbarRow.cells[i].childNodes[0].id.toLowerCase().indexOf('radio') > 0)
			{
				radioElem = toolbarRow.cells[i];//.childNodes[0];
				break;
			}
		}
	}

	return radioElem;
	
}
function UpdateRadioArrow(radioElem)
{
	var radioSignElem = document.getElementById('radioSign');
	radioSignElem.style.top = findPosY( radioElem ) - ((document.all) ? 78 : 78);
	radioSignElem.style.left = findPosX( radioElem );
 	radioSignElem.src='/images/tryit06.gif'
 	radioSignElem.style.display = 'block';
}
function replaceImage(imgPath,evt)
{
	var elem = SrcElement(evt);
	if (elem) {elem.src = imgPath;}
}


function SrcElement(e)
{
	var targ;
	if (e){
		if (e.target) targ = e.target;
		else if (e.srcElement) 
		{
			targ = e.srcElement;
		}
	}
	return targ;
}
function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}
function VerifySizeIE()
{

	this.totlalSize		= 0;
	this.arrCells		= new Array();
	this.arrCells	    = document.getElementById(trToolbarID).childNodes;
	

	this.Hide = function()
	{
		for (i= 0; i < this.arrCells.length - 1; i++)
		{
			this.totlalSize = this.totlalSize+this.arrCells[i].offsetWidth * 1;	
		}

		if (this.totlalSize > window.screen.width-70)
		{
			for (i=  this.arrCells.length - 1; i>0 && (this.totlalSize > window.screen.width-70); i--)
			{
			
				var td= this.arrCells[i]
				this.totlalSize-= td.offsetWidth * 1;	
				td.style.display="none";
			}
		}
	}
	
	this.GetIfRadio = function()
	{

		var bRadio = false;
		
		for (i= 0; i < this.arrCells.length - 1 && !bRadio; i++)
		{
			td = this.arrCells[i];
			
			if (td.style.display != "none")
			{
				arrDiv = this.arrCells[i].getElementsByTagName("IMG")
				
				for (j =0 ; j < arrDiv.length; j++)
				{
					if (arrDiv[j].id.indexOf('_imgRadio_',0)!=-1)
					{
						bRadio = true
					}
				}
			}
		}
		return bRadio;
	}
	
	this.AddShevron= function()
	{
		bShevron   = false;
		i		   =  0;
		
		for (i=  this.arrCells.length - 1; i>0 && !bShevron; i--)
		{
			var td= this.arrCells[i]
			if (td.style.display!="none")
			{
				bShevron=true;
			}
		}
		if (i < this.arrCells.length - 2)
		{
			oCell			=ToolbarControl_trButtons.insertCell(this.arrCells.length )
			oCell.innerHTML	="&nbsp;<img src='/images/chevron.gif' >";
			oCell.vAlign 	= "top";
			oCell.id		=	"chevron";
		}
	}
}




function VerifySizeFF()
{
//debugger
	this.totlalSize		= 0;
	
	this.Hide = function()
	{
		tr = document.getElementById(trToolbarID)
	
		
		for (i= 0; i < tr.childNodes.length - 1; i++)
		{
			if (typeof tr.childNodes[i].offsetWidth != "undefined")
			{
				this.totlalSize = this.totlalSize+ (tr.childNodes[i].offsetWidth * 1);	
			}
		}
		
		
		
		if (this.totlalSize > window.screen.width-90)
		{
			for (i=  tr.childNodes.length - 1; i>0 && (this.totlalSize > window.screen.width-90); i--)
			{
				if (typeof tr.childNodes[i].offsetWidth != "undefined")
				{
					var td= tr.childNodes[i]
					this.totlalSize-= tr.childNodes[i].offsetWidth * 1;	
					td.style.display="none";
				}	
			}
		}
	}
	
	this.GetIfRadio = function()
	{
	//debugger
		var bRadio = false;
		tr = document.getElementById(trToolbarID)
		
		for (i= 0; i <  tr.childNodes.length  - 1 && !bRadio; i++)
		{
			if (typeof tr.childNodes[i].offsetWidth != "undefined")
			{
				td = tr.childNodes[i];
			
				if (td.style.display != "none")
				{
					for (j =0 ; j < td.childNodes.length; j++)
					{
						if (typeof td.childNodes[j].id != "undefined")
						{
							if ( td.childNodes[j].id.indexOf('_imgRadio_',0)!=-1)
							{
								bRadio = true
							}
						}
					}
				}
			}
		}
		return bRadio;
	}
	
	this.AddShevron= function()
	{
		bShevron   = false;
		i		   =  0;
	
		tr = document.getElementById(trToolbarID)
		
		for (i=   tr.childNodes.length - 1; i>0 && !bShevron; i--)
		{
			var td=  tr.childNodes[i]
			if (typeof tr.childNodes[i].offsetWidth != "undefined")
			{	
				if (td.style.display=="none")
				{
					bShevron=true;
				}
			}
		}
		
		if (bShevron)
		{
			oCell			=tr.insertCell(tr.cells.length )
			oCell.innerHTML	="&nbsp;<img src='/images/chevron.gif' >";
			oCell.vAlign 	= "top";
			oCell.id		=	"chevron";
		}
	}
}
function ToolbarDisplay()
{
	if (ie)
	{
		obj = new VerifySizeIE();
		obj.Hide();
		bRadio = obj.GetIfRadio();
		if (bRadio)
		{
		

			UpdateRadio();
		}
		obj.AddShevron();
	}
	else
	{
		obj = new VerifySizeFF();
		obj.Hide();
		bRadio = obj.GetIfRadio();
		if (bRadio)
		{
			UpdateRadio();
		}
		obj.AddShevron();
	}
	
}