function updateRTLScroll()
{
	if ((!document.all) && document.body.dir == "rtl" ) 
	{	
		document.body.scrollLeft = document.body.scrollWidth;
	}
}
function updateFormAction()
{
	if (ToolbarId)
	{
		var frm = document.forms[0]; 
		frm.action = "LandingPage.aspx/" + ToolbarId;
	}
}
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();
	for(var i=0; i<arr.length; i++) 
	{ 
		document.preImgsArgsArr[i]=new Image;
		document.preImgsArgsArr[i].src=arr[i];
	}
}

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) ? 76 : 84);
	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;
}
