//Functions for new PSF Grids called from xmlgrid_proxy.html located in daily_us\common
function processData(args)
{
	try
	{
		var h = parseInt(args.height);
		var p1 = parseInt(args.price1);
		var p2 = parseInt(args.price2);
		var loc = args.location;
		var iframe = document.getElementById('pricegrid');
		iframe.style.visibility = 'visible';
		iframe.style.display = 'block';
		iframe.style.height = h + 'px';
		sendAdCallData(loc);
		sendFromPrices('fromPrices', p1, p2);		
	}
	catch (e)
	{
		window.status = e.description;
	}
}

function sendAdCallData(data)
{
	try
	{
		if (data != '' && typeof(onGridUpdate) == 'function')
		{
			onGridUpdate(data);
		}		
	}
	catch (e)
	{
		window.status = e.description;
	}
}

function sendFromPrices(elId, p1, p2)
{
	try
	{
		var replaceAry = [{
			price:p1,
			replaceString:'[PRICE1]'
		},{
			price:p2,
			replaceString:'[PRICE2]'
		}];
		var el = document.getElementById(elId);
		if (el == null)
		{
			return;
		}
		var html = el.innerHTML;
		var input = null;
		for (var i=0;i<replaceAry.length;i++)
		{
			input = null;
			if (html.indexOf(replaceAry[i].replaceString) >= 0)
			{
				
				if (replaceAry[i].price != null && replaceAry[i].price != "0" && replaceAry[i].price != "99999")
				{
					html = html.replace(replaceAry[i].replaceString, replaceAry[i].price);
				}
			}
		}
		if (html != el.innerHTML)
		{
			el.innerHTML = html;
		}
		el.style.display = 'block';		
	}
	catch (e)
	{
		window.status = e.description;
	}
}
