var W3CDOM = (document.createElement && document.getElementsByTagName);

function initUploadFields() {
	if (!W3CDOM) return;
	var fakeFileUpload = document.createElement('div');
	fakeFileUpload.className = 'fakefile';
	fakeFileUpload.appendChild(document.createElement('input'));
	var image = document.createElement('img');
	image.src='/reeses/elvis/images/btn-browse.gif';
	fakeFileUpload.appendChild(image);
	var x = document.getElementsByTagName('input');
	for (var i=0;i<x.length;i++) {
		if (x[i].type != 'file') continue;
		if (x[i].getAttribute('noscript')) continue;
		if (x[i].parentNode.className != 'fileinputs') continue;
		x[i].className = 'file invisible';
		var clone = fakeFileUpload.cloneNode(true);
		x[i].parentNode.appendChild(clone);
		x[i].relatedElement = clone.getElementsByTagName('input')[0];
		if (x[i].value)
			x[i].onchange();
		x[i].onchange = x[i].onmouseout = x[i].onkeypress = function () {
			this.relatedElement.value = this.value;
		}
	}
	document.getElementById('file').className = 'file invisible transparent';
}

function launch_npn() {
	popup('no-purchase-necessary.asp', 'NPN', 500, 350, 0, 0);
}


/* === POPUPS === */

function popup(cPopUrl, cPopName, iPopWidth, iPopHeight, bScrollBars, resizable) {
	var iPopLeft, iPopTop;
	var oPopWindow = null;
	if (!oPopWindow || oPopWindow.closed){
		//Center popup window inside parent window.
		iPopLeft = (window.screen.width/2) - ((iPopWidth/2) + 10);
		iPopTop = (window.screen.height/2) - ((iPopHeight/2) + 50);
		//Open popup window
		oPopWindow=open(cPopUrl, cPopName,"height="+ iPopHeight +",width="+ iPopWidth +",left=" + iPopLeft + ",top=" + iPopTop + ",screenX=" + iPopLeft + ",screenY=" + iPopTop + ",scrollbars=" + bScrollBars + ",resizable=" + resizable + ", status=yes");
		oPopWindow.location.href = cPopUrl;
		oPopWindow.focus()
    } else {
    	oPopWindow.focus()
	}
}
