var POPUP = new Object();  //namespace to prevent conflicts


window.onload = function () {
	POPUP.setup();
}


POPUP.addEvent = function (elm, evType, fn, useCapture) {
// used to add event listeners
	if (elm.addEventListener) {
      elm.addEventListener(evType, fn, useCapture);
      return true;
    } else if (elm.attachEvent) {
      var r = elm.attachEvent('on' + evType, fn);
      return r;
    } else {
      elm['on' + evType] = fn;
    }
}

POPUP.setup = function () {
// function run on load. Preloads and then hides definitions

	document.getElementById('hider').innerHTML += "<div class='popup' id='FC-DVD-USA'>  <div class='popup_top'></div><div class='popup_middle'>    <h5>Would you like to add:</h5>    <img src='images/WSB.jpg' alt='Wamego Strikes Back' width='63' height='89' border='0' id='prod_img'><span class='filmtitle'>WAMEGO PART TWO:</span><br>    <span class='smalltype'>Wamego Strikes Back<br>    <a href='films/wamego2/default.asp' target='_blank'>view website</a><br>    NTSC DVD<br>Featuring outtakes and deleted scenes <br>from &quot;Firecracker&quot;</span><br>    <p id='offer'>for $10 more (including shipping)?</p>	<table>	<tr>	<td>    <form action='https://www.paypal.com/cgi-bin/webscr' method='post' target='_blank' class='smaller-form-space'>      <input type='hidden' name='cmd' value='_xclick'>      <input type='hidden' name='business' value='sales@dikenga.com'>      <input type='hidden' name='undefined_quantity' value='1'>      <input type='hidden' name='item_name' value='COMBO ---- FIRECRACKER - NTSC DVD + WAMEGO STRIKES BACK - Documentary DVD NTSC - US Addresses only'>      <input type='hidden' name='item_number' value='FC-WSB-DVD-USA'>      <input type='hidden' name='amount' value='24.95'>      <input type='hidden' name='no_shipping' value='2'>      <input type='hidden' name='return' value='http://dikenga.com'>      <input type='hidden' name='no_note' value='1'>      <input type='hidden' name='currency_code' value='USD'>      <input type='hidden' name='lc' value='US'>      <input type='hidden' name='bn' value='PP-BuyNowBF'>      <input type='image' src='http://www.dikenga.com/popup/images/yes.gif' border='0' name='submit2' alt='Make payments with PayPal - it&rsquo;sfast, free and secure!'>	        <img alt='.' border='0' src='https://www.paypal.com/en_US/i/scr/pixel.gif' width='1' height='1'>    </form>	</td>	<td>    <form action='https://www.paypal.com/cgi-bin/webscr' method='post' target='_blank' class='smaller-form-space'>      <input type='hidden' name='cmd' value='_xclick'>      <input type='hidden' name='business' value='sales@dikenga.com'>      <input type='hidden' name='undefined_quantity' value='1'>      <input type='hidden' name='item_name' value='FIRECRACKER - NTSC DVD - US Addresses only'>      <input type='hidden' name='item_number' value='FC-DVD-USA'>      <input type='hidden' name='amount' value='14.95'>      <input type='hidden' name='no_shipping' value='2'>      <input type='hidden' name='return' value='http://dikenga.com'>      <input type='hidden' name='no_note' value='1'>      <input type='hidden' name='currency_code' value='USD'>      <input type='hidden' name='lc' value='US'>      <input type='hidden' name='bn' value='PP-BuyNowBF'>      <input type='image' src='http://www.dikenga.com/popup/images/no.gif' border='0' name='submit2' alt='Make payments with PayPal - it&rsquo;sfast, free and secure!'>      <img alt='.' border='0' src='https://www.paypal.com/en_US/i/scr/pixel.gif' width='1' height='1'>    </form>	</td>	</tr>	</table>  </div>  <div class='popup_bottom'></div></div><div class='popup' id='FC-DVD-INTL'>  <div class='popup_top'></div><div class='popup_middle'>    <h5>Would you like to add:</h5>    <img src='images/WSB.jpg' alt='Wamego Strikes Back' width='63' height='89' border='0' id='prod_img'><span class='filmtitle'>WAMEGO PART TWO:</span><br>    <span class='smalltype'>Wamego Strikes Back<br>    <a href='films/wamego2/default.asp' target='_blank'>view website</a><br>    NTSC DVD<br>Featuring outtakes and deleted scenes <br>from &quot;Firecracker&quot;</span><br>    <p id='offer'>for $10 more (including shipping)?</p>	<table>	<tr>	<td>    <form action='https://www.paypal.com/cgi-bin/webscr' method='post' target='_blank' class='smaller-form-space'>                    <input type='hidden' name='cmd' value='_xclick'>                    <input type='hidden' name='business' value='sales@dikenga.com'>                    <input type='hidden' name='undefined_quantity' value='1'>                    <input type='hidden' name='item_name' value='COMBO ---- FIRECRACKER - REGION 1 NTSC DVD + WAMEGO STRIKES BACK - Documentary DVD NTSC - OUTSIDE US'>                    <input type='hidden' name='item_number' value='FC-WSB-DVD-INTL'>                    <input type='hidden' name='amount' value='29.95'>                    <input type='hidden' name='no_shipping' value='2'>                    <input type='hidden' name='return' value='http://dikenga.com'>                    <input type='hidden' name='no_note' value='1'>                    <input type='hidden' name='currency_code' value='USD'>                    <input type='hidden' name='lc' value='US'>                    <input type='hidden' name='bn' value='PP-BuyNowBF'>                    <input type='image' src='http://www.dikenga.com/popup/images/yes.gif'>                    <img alt='.' border='0' src='https://www.paypal.com/en_US/i/scr/pixel.gif' width='1' height='1'>                  </form>	</td>	<td>    <form action='https://www.paypal.com/cgi-bin/webscr' method='post' target='_blank' class='smaller-form-space'>                    <input type='hidden' name='cmd' value='_xclick'>                    <input type='hidden' name='business' value='sales@dikenga.com'>                    <input type='hidden' name='undefined_quantity' value='1'>                    <input type='hidden' name='item_name' value='FIRECRACKER - REGION 1 NTSC DVD  - OUTSIDE US'>                    <input type='hidden' name='item_number' value='FC-DVD-INTL'>                    <input type='hidden' name='amount' value='19.95'>                    <input type='hidden' name='no_shipping' value='2'>                    <input type='hidden' name='return' value='http://dikenga.com'>                    <input type='hidden' name='no_note' value='1'>                    <input type='hidden' name='currency_code' value='USD'>                    <input type='hidden' name='lc' value='US'>                    <input type='hidden' name='bn' value='PP-BuyNowBF'>                    <input type='image' src='http://www.dikenga.com/popup/images/no.gif'>                    <img alt='.' border='0' src='https://www.paypal.com/en_US/i/scr/pixel.gif' width='1' height='1'>                  </form>	</td>	</tr>	</table>  </div>  <div class='popup_bottom'></div></div><div class='popup' id='WAMDVD-USCA'>  <div class='popup_top'></div><div class='popup_middle'>    <h5>Would you like to add:</h5>    <img src='images/WSB.jpg' alt='Wamego Strikes Back' width='63' height='89' border='0' id='prod_img'><span class='filmtitle'>WAMEGO PART TWO:</span><br>    <span class='smalltype'>Wamego Strikes Back<br>    <a href='films/wamego2/default.asp' target='_blank'>view website</a><br>    NTSC DVD<br>Featuring outtakes and deleted scenes <br>from &quot;Firecracker&quot;</span><br>    <p id='offer'>for $10 more (including shipping)?</p>	<table>	<tr>	<td>    <form action='https://www.paypal.com/cgi-bin/webscr' method='post' target='_blank' class='smaller-form-space'>                    <input type='hidden' name='cmd' value='_xclick'>                    <input type='hidden' name='business' value='sales@dikenga.com'>                    <input type='hidden' name='item_name' value='COMBO ---- WAMEGO: Making Movies Anywhere - documentary DVD NTSC + WAMEGO STRIKES BACK - Documentary DVD NTSC- US/CANADA'>                    <input type='hidden' name='item_number' value='WAM-WSB-DVD-USCA'>                    <input type='hidden' name='amount' value='20'>                    <input type='hidden' name='no_note' value='1'>                    <input type='hidden' name='currency_code' value='USD'>                    <input type='hidden' name='bn' value='PP-BuyNowBF'>                    <input type='hidden' name='shipping' value='0'>                    <input type='hidden' value='1' name='undefined_quantity'> <input type='image' src='http://www.dikenga.com/popup/images/yes.gif' border='0' name='submit4' alt='Make payments with PayPal - it&rsquo;sfast, free and secure!' >                    <img alt='.' border='0' src='https://www.paypal.com/en_US/i/scr/pixel.gif' width='1' height='1'>                  </form>	</td>	<td>    <form action='https://www.paypal.com/cgi-bin/webscr' method='post' target='_blank' class='smaller-form-space'>                    <input type='hidden' name='cmd' value='_xclick'>                    <input type='hidden' name='business' value='sales@dikenga.com'>                    <input type='hidden' name='item_name' value='WAMEGO: Making Movies Anywhere - documentary DVD NTSC - US/CANADA'>                    <input type='hidden' name='item_number' value='WAMDVD-USCA' >                    <input type='hidden' name='amount' value='10'>                    <input type='hidden' name='no_note' value='1'>                    <input type='hidden' name='currency_code' value='USD'>                    <input type='hidden' name='bn' value='PP-BuyNowBF'>                    <input type='hidden' name='shipping' value='0'>                    <input type='hidden' value='1' name='undefined_quantity'> <input type='image' src='http://www.dikenga.com/popup/images/no.gif' border='0' name='submit4' alt='Make payments with PayPal - it&rsquo;sfast, free and secure!'>                    <img alt='.' border='0' src='https://www.paypal.com/en_US/i/scr/pixel.gif' width='1' height='1'>                  </form>	</td>	</tr>	</table>  </div>  <div class='popup_bottom'></div></div><div class='popup' id='WAMDVD-INTL'>  <div class='popup_top'></div><div class='popup_middle'>    <h5>Would you like to add:</h5>    <img src='images/WSB.jpg' alt='Wamego Strikes Back' width='63' height='89' border='0' id='prod_img'><span class='filmtitle'>WAMEGO PART TWO:</span><br>    <span class='smalltype'>Wamego Strikes Back<br>    <a href='films/wamego2/default.asp' target='_blank'>view website</a><br>    NTSC DVD<br>Featuring outtakes and deleted scenes <br>from &quot;Firecracker&quot;</span><br>    <p id='offer'>for $10 more (including shipping)?</p>	<table>	<tr>	<td>    <form action='https://www.paypal.com/cgi-bin/webscr' method='post' target='_blank' class='smaller-form-space'>                    <input type='hidden' name='cmd' value='_xclick'>                    <input type='hidden' name='business' value='sales@dikenga.com'>                    <input type='hidden' name='item_name' value='COMBO ---- WAMEGO: Making Movies Anywhere - documentary DVD NTSC + WAMEGO STRIKES BACK - Documentary DVD NTSC - INTERNATIONAL'>                    <input type='hidden' name='item_number' value='WAM-WSB-DVD-INTL'>                    <input type='hidden' name='amount' value='25'>                    <input type='hidden' name='no_note' value='1'>                    <input type='hidden' name='currency_code' value='USD'>                    <input type='hidden' name='bn' value='PP-BuyNowBF'>                    <input type='hidden' name='shipping' value='0'>                    <input type='hidden' value='1' name='undefined_quantity'> <input type='image' src='http://www.dikenga.com/popup/images/yes.gif' border='0' name='submit5' alt='Make payments with PayPal - it&rsquo;sfast, free and secure!'>                    <img alt='.' border='0' src='https://www.paypal.com/en_US/i/scr/pixel.gif' width='1' height='1'>                  </form>	</td>	<td>    <form action='https://www.paypal.com/cgi-bin/webscr' method='post' target='_blank' class='smaller-form-space'>                    <input type='hidden' name='cmd' value='_xclick'>                    <input type='hidden' name='business' value='sales@dikenga.com'>                    <input type='hidden' name='item_name' value='WAMEGO: Making Movies Anywhere - documentary DVD NTSC - INTERNATIONAL'>                    <input type='hidden' name='item_number' value='WAMDVD-INTL'>                    <input type='hidden' name='amount' value='15'>                    <input type='hidden' name='no_note' value='1'>                    <input type='hidden' name='currency_code' value='USD'>                    <input type='hidden' name='bn' value='PP-BuyNowBF'>                    <input type='hidden' name='shipping' value='0'>                    <input type='hidden' value='1' name='undefined_quantity'> <input type='image' src='http://www.dikenga.com/popup/images/no.gif' border='0' name='submit5' alt='Make payments with PayPal - it&rsquo;sfast, free and secure!'>                    <img alt='.' border='0' src='https://www.paypal.com/en_US/i/scr/pixel.gif' width='1' height='1'>                  </form>	</td>	</tr>	</table>  </div>  <div class='popup_bottom'></div></div>"

	var links = document.getElementsByTagName('input');
	for (var i = 0; i < links.length; i++) {
		if (links[i].className=='offer') {
			this.addEvent(links[i], 'click', this.toggleCatcher, false);
		}
		if ((links[i].src=="http://www.dikenga.com/popup/images/yes.gif") | (links[i].src=="http://www.dikenga.com/popup/images/no.gif")){
			this.addEvent(links[i], 'click', this.closeDiv, false);
		}
		
	}
	
	var divs = document.getElementsByTagName('div');
	for (var i = 0; i < divs.length; i++) {
		if (divs[i].className=='popup') {
			this.toggle(divs[i]);
			divs[i].style.position='absolute';
			divs[i].style.zIndex='3';
		}
	}
}
 

POPUP.toggle = function (def, term) {
//toggles the definition div
	if (def.style.display!='none')
		def.style.display='none';
		else {
		def.style.display='block';
		var coors = POPUP.findPos(term);
		coors[1] += 25;
		var width;
		if (self.innerWidth) // all except Explorer
		{
			width = self.innerWidth;
		}
		else if (document.documentElement && document.documentElement.clientWidth)
			// Explorer 6 Strict Mode
		{
			width = document.documentElement.clientWidth;
		}
		else if (document.body) // other Explorers
		{
			width = document.body.clientWidth;
		}
		if ((width - coors[0]) <= 450)
			coors[0] -= 450 - (width - coors[0]) + 25;
			coors[1] -= 100;
		def.style.top = coors[1] + 'px';
		def.style.left = coors[0] + 'px';
		}
}

POPUP.toggleCatcher = function (e) {
// Used to pass appropriate paramaters from event listeners to the toggle function
	var targ = POPUP.getTarget(e);
	def = document.getElementById(targ.parentNode.item_number.value);
	POPUP.toggle(def, targ);
	if (!e) var e = window.event;
	e.cancelBubble = true;
	if (e.stopPropagation) e.stopPropagation();
	if (e && e.preventDefault)
	e.preventDefault();
	return false;
}

POPUP.getTarget = function (e){
// gets the target of an event
	var target = window.event ? window.event.srcElement : e ? e.target : null;
	if (!target){return false;}
	while(target.nodeType!=1 && target.nodeName.toLowerCase()!='body'){
		target=target.parentNode;
	}
	return target;
}


POPUP.findPos = function (obj) {
// finds the current position of an object
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

POPUP.closeDiv = function (e){
	var targ = POPUP.getTarget(e);
	targ.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.className = 'hide';
}