

var popupLinkConfig = new Array;



	function setupOnePopopen( anc) {
		anc.firstOpen = true;
		anc.isopen = false;
		
		anc.togglePopper = function() {		// you can call this manually
			this.isopen = !this.isopen;
			if ( this.firstOpen) {
				// tracking pixel when the user opens, 1st time only
				var pth=window.location.pathname, trkImg=new Image();
				if ( pth.substr(pth.length-1,1) == '/' ) pth=pth+'default.asp'
				trkImg.src = rootDir() + '_track/popopen.asp?page=' + pth + '~'+this.id;
				this.firstOpen = false;
			}
			toggleVis(this.id+'Pop');		// open the div

			if ( this.isopen )	// swap classes
				replaceClass(this,'popopen','popclosed');
			else
				replaceClass(this,'popclosed','popopen');
		};
		togglePopFunction = function(e) {
			if ( this.preProcess && this.preProcess( !this.isopen))	// preprocessing fnc can terminate this operation
				return false;
			this.togglePopper();
			if ( this.postProcess) this.postProcess( this.isopen);
			cancelEvent(e,false);
			return false;
		};
		addEvent(anc,'click',togglePopFunction,true);
	}

	//	-	-	-	-	-	POPUP WINDOWS	-	-	-	-	-	
	
		function redirectTo(pwin,closePopup,andGoWhere) {
			if (closePopup) {
				try {
					var nm = (pwin.objectName ? pwin.objectName : 'popupWin');
					if ( window[nm] != null) window[nm] = null;
					pwin.objectName = null;
				} catch(xx) {}
				pwin.close();
			}
			if (andGoWhere)
				location.href=andGoWhere;
			else
				window.location.reload(true);
		}
		// use this function from the popup window
		function parentRedir(closePopup,addr) {
			if(window.opener) window.opener.redirectTo(window,closePopup,addr);
		}
	
	function setupOnePopupWin( anc) {
		var	cls = getCls(anc),
			sty = stripMultiCls( cls.substring(8 + cls.indexOf('popupWin'))), sizes, styleArray, scrb, spc;

		// popupWin-STYLE (from array above)
		if (sty.substring(0,1) == '-') {
			styleArray = popupLinkConfig[sty.substring(1)];
			if ( styleArray) {
				var target = styleArray[1] ? styleArray[1] : 'popupWin',
					opts = styleArray[0],
					popFunc1 = function(e) {
						doPopup(this.href,target,opts);
						cancelEvent(e,false);
						return false;
					};
				addEvent( anc, 'click', popFunc1, true);
			}
		}
		// popupWin400x300 (no scrolls) popupWin400x300xS (with scrolls)
		else {
			sizes = sty.split('x');
			if (sizes.length>2) scrb=',scrollbars=yes';
			var popFunc2 = function(e) {
				var opts = 'width='+sizes[0]+',height='+sizes[1]+scrb;
				doPopup(this.href,'popupWin',opts);
				cancelEvent(e,false);
				return false;
			};
			addEvent( anc, 'click', popFunc2, true);
		}
	}
	
	function setupOneParentRedirect( anc) {
		var parClick = function(e) { parentRedir(true,this.href); cancelEvent(e,false); return false; };
		addEvent( anc, 'click', parClick, true);
	}




//	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	

registerAnchorType( {cls:"popopen",			apply:setupOnePopopen} );
registerAnchorType( {clsPartial:"popupWin",	apply:setupOnePopupWin} );

