var WO_AD = document.createElement("div");
document.body.appendChild(WO_AD);

var woad_Width = 598; var woad_Height = 231;
function placeWO_Ad(w, h, t, pa, ml, b, f, timer)
{
	WO_AD.style.visible = 'visible';
	WO_AD.style.overflow = 'hidden';
	WO_AD.style.position = 'absolute';
    WO_AD.style.display = 'block';
    //WO_AD.style.backgroundColor = '#000000';
	WO_AD.style.zIndex = 998;
	WO_AD.style.width = w +'px';
	WO_AD.style.height = h + 'px';
	WO_AD.innerHTML = '<img src="http://www.piercemfg.com/PierceMfg/media/PierceMainMediaLibrary/Flash/WebOuts/DashCF_DealerWO/DashCFDealer.png" alt="" name="DashCFHolder" width="598" height="231" border="0" usemap="#DashCFHolderMap" id="DashCFHolder"/><map name="DashCFHolderMap" id="DashCFHolderMap"><area shape="rect" coords="23,84,582,147" href="http://www.piercemfg.com/en/dashcf" target="_blank" /><area shape="rect" coords="40,150,260,180" href="javascript:replayWO();" /><area shape="rect" coords="560,46,580,71" href="javascript:hide_woad();" /></map>';
        
	if(pa == 'left')
	{
            WO_AD.style.left = 0 + 'px';
            WO_AD.style.marginLeft = ml + 'px';        
	}
	else if(pa == 'center')
	{
            WO_AD.style.left =  50 + '%';
            WO_AD.style.marginLeft = -(w/2) + ml + 'px';
	}
	else
	{
            WO_AD.style.left = 100 + '%';
            WO_AD.style.marginLeft = -w + ml + 'px';
	}
        
        woad_Height = h;
        woad_Width = w;
        woad_BottomMargin = b;
        woad_Timer = timer;
	
	if(f == 'true')
	{
	    WO_AD.style.position = 'fixed';
            woad_floatWebOut();
	}
        
        if(woad_Timer > 0)
        {
            var int = setInterval("hide_woad()", woad_Timer * 1000);
        }
}


var woad_PageWidth = 0; var woad_PageHeight = 0; var woad_ScrOfY = 0;
function woad_GetPageDimensions()
{
	if( typeof( window.innerWidth ) == 'number' ) { //Non-IE
	      woad_PageWidth = window.innerWidth; woad_PageHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { //IE 6+ in 'standards compliant mode'
	      woad_PageWidth = document.documentElement.clientWidth; woad_PageHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { //IE 6+ in 'standards compliant mode'
	      woad_PageWidth = document.body.clientWidth; woad_PageHeight = document.body.clientHeight;
	}
	      
	if( typeof( window.pageYOffset ) == 'number' ) { //Netscape compliant
	      woad_ScrOfY = window.pageYOffset;
	} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) { //DOM compliant
	      woad_ScrOfY = document.body.scrollTop;
	} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {//IE6 standards compliant mode
	      woad_ScrOfY = document.documentElement.scrollTop; 
	}
}

function woad_NoFixedFloat()
{
	woad_GetPageDimensions();
	if(woad_PageHeight > woad_Height)
	{
		WO_AD.style.top = (woad_ScrOfY + woad_PageHeight - woad_Height - woad_BottomMargin) + 'px';
	}
	else
	{
		WO_AD.style.top = woad_ScrOfY + 'px';
	}
}

function woad_fixedFloat()
{
	woad_GetPageDimensions();
	if (woad_PageHeight > woad_Height)
	{
		WO_AD.style.position = 'fixed';
		WO_AD.style.bottom = woad_BottomMargin + 'px';
		WO_AD.style.top = 'auto';
	}
	else
	{
		WO_AD.style.position = 'fixed';
		WO_AD.style.top = 0 + 'px';		
	}
}

function woad_floatWebOut()
{
	var isSupported = null;
	if (document.createElement)
	{
		var el = document.createElement("div");
		if (el && el.style)
		{
		      el.style.width = "1px";
		      el.style.height = "1px";
		      el.style.position = "fixed";
		      el.style.top = "10px";
		      var root = document.body;
		      if (root && root.appendChild && root.removeChild)
		      {
			      root.appendChild(el);
			      isSupported = el.offsetTop === 10;
			      root.removeChild(el);
		      }
		      el = null;
		}
	}
	woad_GetPageDimensions();
	
	if (isSupported)
	{
		woad_fixedFloat();
		window.onresize = woad_fixedFloat;
	}	
	else
	{
		WO_AD.style.position = 'absolute';
		woad_NoFixedFloat();
		window.onscroll = woad_NoFixedFloat;
		window.onresize = woad_NoFixedFloat;
	}
}


woad_DisplayOnPageLoad();
function woad_DisplayOnPageLoad()
{
    if(woad_showNever != true && woad_showOnPageLoad == true)
    {
        placeWO_Ad(woad_Width, woad_Height, woad_Top, woad_Align, woad_XOffset, woad_BottomMargin, woad_FloatAd, woad_Timer);
    }
}

function woad_DisplayOnWebOutComplete()
{
    if(woad_showNever != true && woad_showOnWebOutComplete == true)
    {
        placeWO_Ad(woad_Width, woad_Height, woad_Top, woad_Align, woad_XOffset, woad_BottomMargin, woad_FloatAd, woad_Timer);
    }
}

function woad_DisplayOnCookie()
{
    if(woad_showNever != true && woad_showOnCookie == true)
    {
        placeWO_Ad(woad_Width, woad_Height, woad_Top, woad_Align, woad_XOffset, woad_BottomMargin, woad_FloatAd, woad_Timer);
    }
}

function woad_HideOnWebOutPlay()
{
    if(woad_hideOnWebOutLoad == true)
    {
        WO_AD.style.display = 'none';
    }
}

function hide_woad()
{
    WO_AD.style.display = 'none';
}



function getWebOutAdCookie (cookieName) {
  var exp = new RegExp (escape(cookieName) + "=([^;]+)");
  if (exp.test (document.cookie + ";")) {
    exp.exec (document.cookie + ";");
    return unescape(RegExp.$1);
  }
  else return false;
}


function writeWebOutAdCookie (CookieName, CookieValue, periodType, offset) {

  var expireDate = new Date ();
  offset = offset / 1;
  
  var myPeriodType = periodType;
  switch (myPeriodType.toLowerCase()) {
    case "years": 
     var year = expireDate.getYear();     
     // Note some browsers give only the years since 1900, and some since 0.
     if (year < 1000) year = year + 1900;     
     expireDate.setYear(year + offset);
     break;
    case "months":
      expireDate.setMonth(expireDate.getMonth() + offset);
      break;
    case "days":
      expireDate.setDate(expireDate.getDate() + offset);
      break;
    case "hours":
      expireDate.setHours(expireDate.getHours() + offset);
      break;
    case "minutes":
      expireDate.setMinutes(expireDate.getMinutes() + offset);
      break;
  } 
  
  document.cookie = escape(CookieName ) + "=" + escape(CookieValue) + "; expires=" + expireDate.toGMTString() + "; path=/";
}  


if(!getWebOutAdCookie('woad_cookie'))
{
    writeWebOutAdCookie ('woad_cookie', 'True', 'years', 10); 
}
else
{
    woad_DisplayOnCookie();
       
} 
