/* 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);
      
      
      
	  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 createGAEventTag(category, action, label)
{
	if (typeof(_gaq)  != "undefined")
	{
		_gaq.push(['_trackEvent', category, action, label]);
	}
	return true;

}

function createGAPageTag(label)
{
	if (typeof(_gaq)  != "undefined")
	{
		_gaq.push(['_trackPageview', label]);
	}
	return true;

}

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 addDoubleClickPixel(pixelParamUrl)
{
	var axel = Math.random()+"";
	var a = axel * 10000000000000;
	var pixelUrl = "http://ad.doubleclick.net/activity;"+pixelParamUrl+"num="+ a + "?";
	
	var pElement = document.createElement('img');
    pElement.setAttribute('height',1);
    pElement.setAttribute('width',1);
    pElement.setAttribute('border',0);
    pElement.setAttribute('src',pixelUrl);
    document.body.appendChild(pElement);

}

function addSpecificClickPixel(pixelParamUrl)
{
	var pixelUrl = 'http://bp.specificclick.net?'+pixelParamUrl+'&u='+escape(parent.document.location)+'&r='+escape(parent.document.referrer);
	var pElement = document.createElement('img');
    pElement.setAttribute('height',1);
    pElement.setAttribute('width',1);
    pElement.setAttribute('border',0);
    pElement.setAttribute('src',pixelUrl);
    document.body.appendChild(pElement);

}

function addAudienceSciencePixel(pixelParamUrl)
{
	var pixelUrl = "http://ads.revsci.net/adserver/ako?"+pixelParamUrl;
	var pElement = document.createElement('img');
    pElement.setAttribute('height',1);
    pElement.setAttribute('width',1);
    pElement.setAttribute('border',0);
    pElement.setAttribute('src',pixelUrl);
    document.body.appendChild(pElement);

}

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=


