var pb_debug_tag,  pb_image_tags, pb_iframe_tags ;

// Check for Flash, Set variable for Flash player version
var flash_version = 0;
if (flashIntalledCookieExists()) {
	// If cookie exists, get the value of the cookie
	flash_version = flashIntalledCookieExists();		
} else {
	// Check for flash player
	var flash = new Object();
	flash = flashDetection();
	if (flash.installed == true) {
		writeFlashInstalledCookie(flash.version);
		flash_version = flash.version;
	} else {
		// If no flash player, write cookie with value == 0
		writeFlashInstalledCookie(0);
	}
}

function pbShowPop(pop) {
	pb_iframe_tags = false ;
	pb_url =  "/exit/js/npv2.js?z=0" ;

  if (pb_iframe_tags) {
		pb_tag_src = '<IFRAME frameborder="0" marginwidth="0" marginheight="0" scrolling="no" style="position:absolute; left:1px" WIDTH=1 HEIGHT=1 SRC="' + pb_url + '"></IFRAME>' ;
	} else {
		pb_tag_src = '<SCRIPT TYPE="text/javascript" SRC="' + pb_url + '"><\/SCRIPT>' ;
	}

	if (!pb_debug_tag) {
		document.write(pb_tag_src) ;
	} else {
		pb_tag_src = rmReplace(pb_tag_src, '<', '&lt;') ;
		pb_tag_src = rmReplace(pb_tag_src, '>', '&gt;') ;
		document.write('' + pb_tag_src + '') ;
	}
}

function rmReplace(myString, toReplace, replaceBy) {
	return (myString.replace(new RegExp(toReplace, 'gi'), replaceBy)) ;
}

function flashIntalledCookieExists() {
	var cookieName = "flashInstalled" ;

	if(pbGetCookie(cookieName) == null) {
		return false ;
	} else {
		return pbGetCookie(cookieName) ;
	}
}

function writeFlashInstalledCookie(version) {
	var cookieName = "flashInstalled" ;
	var numdays = 14 ;
	var today = new Date() ;
	var expires = new Date() ;
	expires.setTime(today.getTime() + (1000 * 60 *60*24*numdays)) ;

	var cookieText = cookieName + "=" + version 
		+ "expires=" + expires.toGMTString() + ";" ;
	document.cookie = cookieText ;
	return null ;
}

function flashDetection() {
	var flash=new Object() ;
	flash.installed=false ;
	flash.version='0.0' ;

	if (navigator.plugins && navigator.plugins.length) {
	    for (x=0; x<navigator.plugins.length; x++) {
	        if (navigator.plugins[x].name.indexOf('Shockwave Flash') != -1) {
	            flash.version=navigator.plugins[x].description.split('Shockwave Flash ')[1] ;
	            flash.installed=true ;
	            break ;
	        }
	    }
	} else if (window.ActiveXObject) {
	    for (x=2; x<10; x++) {
	        try {
	            oFlash=eval("new ActiveXObject('ShockwaveFlash.ShockwaveFlash."+x+"');") ;
	            if (oFlash) {
	                flash.installed=true ;
	                flash.version=x+'.0' ;
	            }
	        } catch(e) {}
	    }
	}
	return flash ;
}

// Returns null if cookie doesn't exist. Returns cookie value if it exists.
function pbGetCookie(Name) {
	var search = Name + "=" ;
	var CookieString = document.cookie ;
	var result = null ;
	
	if(CookieString.length > 0) {
		offset = CookieString.indexOf(search) ;
		if(offset != -1) {
			offset += search.length ;
			end = CookieString.indexOf(";", offset) ;
			if(end == -1) {
			   end = CookieString.length ;
			}
			result = unescape(CookieString.substring(offset, end)) ;
	   }
	}
	
	return result ;
}
