function popunder()

{
$('#flash').css('visibility', 'hidden');
	// Check if the DOM is supported

	if(!document.getElementById || !document.createTextNode){return;}

	// Define variables

	var pa=document.getElementById('popad');

	var ft=document.getElementById('popad_footage');

	var closeLinkTitle='Skip Movie';

	var closeLinkId='popad_close';

	var closeLinkText='Skip Movie [x]';

	var dynamicClass='dynamic';

	// check if all elements are available

	if(!pa || !ft){return;}

	// set class to indicate dynamic functionality

	pa.className=dynamicClass;

	// function to remove the ad

	function killad(e)

	{

		// if the link is the close link, don't follow it.

		if(this.id==closeLinkId)

		{	
$('#flash').css('visibility', 'visible');
			stoplink(e);

		}

		// if the  link has a rel external, then open it in a new window

		if(this.rel=='external')

		{

			window.open(this.href);				

			stoplink(e);

		}

		pa.parentNode.removeChild(pa);

	}

	// create new link to close the ad, and set its attributes 			

	var closelink=document.createElement('a');

	closelink.setAttribute('href','#');

	closelink.setAttribute('title',closeLinkTitle);

	closelink.setAttribute('id',closeLinkId);

	closelink.appendChild(document.createTextNode(closeLinkText));

	ft.getElementsByTagName('a')[0]?ft.insertBefore(closelink,ft.firstChild):ft.appendChild(closelink);

	// append the kill ad function

	var popadlinks=pa.getElementsByTagName('a');

	for(var i=0;i<popadlinks.length;i++)

	{

		addEvent(popadlinks[i],'click',killad)

	}

}

function addEvent(obj,type,fn)

{

	if (obj.addEventListener) 

	{

		obj.addEventListener( type, fn, false );

	} else if (obj.attachEvent) {

		obj["e"+type+fn] = fn;

		obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }

		obj.attachEvent( "on"+type, obj[type+fn] );

	}

}

function stoplink(e)

{

	if (window.event) {

      window.event.cancelBubble = true;

      window.event.returnValue = false;

    }

    if (e && e.stopPropagation && e.preventDefault) {

      e.stopPropagation();

      e.preventDefault();

    }

}

addEvent(window,'load',popunder)
