String.format = function()
{
	if (arguments.length == 0) return null;
	var str = arguments[0];
    for(var i=1;i<arguments.length;i++)
    {
       	var re = new RegExp('\\{' + (i-1) + '\\}','gm');
        str = str.replace(re, arguments[i]);
    }
    return str;
}

getAd = function (zoneid, url) 
{
	var m3_u = (location.protocol=='https:'?'https://'+url+'/www/delivery/ajs.php':'http://'+url+'/www/delivery/ajs.php');
	var m3_r = Math.floor(Math.random()*99999999999);
	var output = '', params = '';
	
	if (!document.MAX_used) 
        document.MAX_used = ',';
		
	if (document.MAX_used != ',') 
		params += "&amp;exclude=" + document.MAX_used;
		
	if (document.referrer) 
		params += "&amp;referer=" + escape(document.referrer);

	if (document.context) 
		params += "&context=" + escape(document.context);

	if (document.mmm_fo) 
		params += "&amp;mmm_fo=1";
		
	output += String.format('<script type="text/javascript" src="{0}?zoneid={1}&amp;cb={2}&amp;loc={3}{4}"><\/script>', m3_u, zoneid, m3_r, escape(window.location), params);
	
	return output;
}

expandAd = function (divid, height) 
{
	var expandableDiv = document.getElementById(divid);
	if (expandableDiv) 
		expandableDiv.style.height = height + 'px';
	return false;
}
	
collapseAd = function (divid, height) 
{
	var expandableDiv = document.getElementById(divid);
	if (expandableDiv) 
		expandableDiv.style.height = height + 'px';
	return false;		
}

