/* Library of web metrics code
*/

//Floodlight tag randomn number to avoid the browser from caching the request
var axel = Math.random()+"";
var a = axel * 10000000000000;

function GetActionTag(URL){
   if(URL){
      // Get the script element.
      var element = document.getElementById(URL);
      var TrackTag = "http://view.atdmt.com/jaction/";
      
	  if(element) document.body.removeChild(element);
      
	  element = document.createElement('script');
      element.setAttribute('id',URL);
      element.setAttribute('type','text/javascript');
      document.body.appendChild(element);
      //document.getElementById("atlas_tag").parentNode.appendChild(element);

	  element.src = TrackTag+URL+ '/?' + Math.random();

	  /*
	  //alert('before sending image beacon');
	  document.write("<script id='"+ URL   +"' type='text/javascript' src='"+ TrackTag+URL+ "/?" + Math.random() + "'/>");
	  //alert('after sending image beacon');
	  */
   }
}

function addPixel(pixelId, retPixel)
{
	if(pixelId)
	{
		var pElement =  document.getElementById(pixelId);
		if(pElement)
		{
			document.body.removeChild(pElement);
		}
		pixelUrl = 'http://bp.specificclick.net?pixid='+pixelId+'&u='+escape(parent.document.location)+'&r='+escape(parent.document.referrer);
		pElement = document.createElement('script');
        pElement.setAttribute('id',pixelId);
        pElement.setAttribute('type','text/javascript');
        document.body.appendChild(pElement);
		
		pElement.src = pixelUrl;
		
		addRETPixel(retPixel);
	}
}

function addRETPixel(pixelId)
{
	if(pixelId)
	{
		var pElement =  document.getElementById(pixelId);
		if(pElement)
		{
			document.body.removeChild(pElement);
		}
		pixelUrl = 'http://pix04.revsci.net/J06575/b3/0/3/noscript.gif?D=DM_EVT%3D'+pixelId
		pElement = document.createElement('img');
        pElement.setAttribute('id',pixelId);
        pElement.setAttribute('height',1);
        pElement.setAttribute('width',1);
        pElement.setAttribute('src',pixelUrl);
        document.body.appendChild(pElement);
		
	}
}

/* resize.js was in dlrWebsite folder */
function changeSwfHeight()
{
	MBHome.height = arguments[0];
}

function changeSwfWidth()
{
	MBHome.width = 978;
	setScrolling();
}

function setScrolling()
{
	var browser = navigator.appName;
	
	if(browser.indexOf('Internet Explorer') != -1 || browser.indexOf('Safari') != -1 )
	{
		document.body.scroll = "yes";
	}
	else
	{
		document.body.style.overflow = "auto";
	}
}

/* Required for MT */	
function moveIFrame(x,y,w,h) 
{
	var frameRef=document.getElementById("content");
	frameRef.style.left=x;
	frameRef.style.top=y;
	frameRef.width=w;
	frameRef.height=h;
}
	
function setIFrameContent( contentSource )
{
	document.getElementById("content").src = contentSource;
}

function hideIFrame()
{
  	document.getElementById("content").style.visibility="hidden";
}

function showIFrame()
{
  	document.getElementById("content").style.visibility="visible";
}	

function openPopup(x, y)
{
	window.open("http://www.mypreownedmercedes.com/matrix.php", "motortrack", "width=995, height=615, left=" + x + ", top=" + y+ "\"");
}

//		appMode=dlr&state=<application_state>&zip= 
//		appMode=dlr&state=<application_state>&vehicleModel=
//		appMode=dlr&state=


