
var PUenabled = ((ie && !ie3 && !ie4) || nav4 || opera);
//alert(document.cookie);

if (PUenabled && PUhtml) {
	
	// default values for pu dimensions
	if (typeof(PUwinWidth) == 'undefined') {
		var PUwinWidth = '300';
		var PUwinHeight = '300';
	}
	
	// default values for pu scrollbars
	if (typeof(PUscroll) == 'undefined') {
		var PUscroll = 'yes';
	}
	
	
	var PUregion = '';
	var PUname = '1592';
	
	if (typeof(PUcookieName) == 'undefined') {
		var PUcookieName = "PU"+PUid;
	} else {
		PUcookieName = "PU"+PUid+ PUcookieName;
	}
	
	if (typeof(PUtimes) == 'undefined') {
		var PUtimes = 1;
	}
	if (typeof(PUexpiresIn) == 'undefined') {
		var PUexpiresIn = 4 * 60; // in minutes
	}
	
	function PUcheckRef() {
		newDomain = dhtmlTheDomain.replace(/\./gi, '\\.');
		re = new RegExp("^http:\/\/\\w+\."+ newDomain, "i");
		if (re.test(document.referrer)) {
			return true;
		} else {
			return false;
		}
	}
	
	var PUb = dhtmlGetCook(PUcookieName);
	var PUoverTimes = 0;
	if (PUtimes != DHTML_IGNORE_COOKIES) {
		//alert('PUb '+PUb+' DHTML_NO_COOKIES '+DHTML_NO_COOKIES);
		if (PUb == DHTML_NO_COOKIES) {
			PUoverTimes = 1;
		} else {
			if (PUb != false) {
				PUs = dhtmlGetCook(PUcookieName);
				if ((PUs >= PUtimes) || PUcheckRef()) {
					PUoverTimes = 1;
					dhtmlSetCook(PUcookieName, -1, PUexpiresIn);
				} else {
					if ((Math.floor(PUs) + 1) >= PUtimes)
					{
						dhtmlSetCook(PUcookieName, -1, PUexpiresIn);
					}
					else
					{
						dhtmlSetCook(PUcookieName, Math.floor(PUs) + 1, PUexpiresIn);
					}
				}
				
			} else {
				dhtmlSetCook(PUcookieName, 1, PUexpiresIn);
			}
		}
	}
	
	//alert(document.cookie);
	
	function puLaunchPU() {
		var puWinX, puWinY;
		if (parseFloat(navigator.appVersion) >= 4) {
			puWinX = (screen.width - PUwinWidth) / 2;
			puWinY = 50;
		} else {
			puWinX = 15;
			puWinY = 15;
		}
		// PUhtml must be defined in the page
		var PUwin = window.open(
			PUhtml + PUregion + (PUname > 0 ? '' : ''),
			'PUwin', 'location=no,menubar=no,titlebar=no,status=no,toolbar=no,scrollbars='+PUscroll+',resizable=no,'+
			'width='+ PUwinWidth +',height='+ PUwinHeight +','+
			'screenX='+ puWinX +',screenY='+ puWinY +',top='+ puWinY +',left='+ puWinX
		);
		PUwin.blur();
		self.focus();
	}

	if (!PUoverTimes && (typeof(dhtmlPush) == 'function')) {
		dhtmlPush("puLaunchPU");
		//puLaunchPU();//PM
	}
}

