
var systemIsWindows=(navigator.appVersion.toLowerCase().indexOf("windows")>-1)
var systemIsMac=(navigator.appVersion.toLowerCase().indexOf("mac")>-1)

var browserIsIE=(navigator.appName.toLowerCase().indexOf("microsoft")>-1)
var browserIsNN4=false
var browserIsNN6Plus=false


if (!browserIsIE)
{
	if (navigator.appVersion.charAt(0)=="4")
	{
		browserIsNN4=true
	}
	else
	{
		browserIsNN6Plus=true
	}
}

var browserVersion=0
if (browserIsNN4 || browserIsNN6Plus)
{
	browserVersion=parseInt(navigator.appVersion.charAt(0))
}
if (browserIsIE)
{
	var tempSplit=navigator.appVersion.split("MSIE ")
	browserVersion=parseInt(tempSplit[1].charAt(0))
}


var browserOk=true

if (browserIsNN4)
{
	browserOk=false
}

if (browserIsIE && browserVersion<5)
{
	browserOk=false
}



// no more browser detection:
browserOk=true

if (!browserOk)
{
	location.replace("/v2/invalidBrowser.html")
}



function generalConfirm(msg)
{
	return customAlertConfirm(msg,null,false)
}

function generalAlert(msg)
{
	customAlertConfirm(msg,"general",true)
}

function errorAlert(msg)
{
	customAlertConfirm(msg,"error",true)
}

function customAlertConfirm(msg,type,isAlert)
{
	// false == never show modal dialog
	if (false && window.showModalDialog && window.systemIsWindows)
	{
		top.focus()
		var ht=90
		ht+=(Math.ceil(msg.length/50)*14) // 45=avg chars per line; 14=font height; 90=overhead pixels 
		if (ht<130)
		{
			ht=130
		}
		var props="dialogHeight:"+ht+"px; dialogWidth:320px; help:no; scroll:no; status:no; "
		var dialogUrl=window.PATH_TO_CUSTOM_ALERT_CONFIRM
		if (isAlert)
		{
			dialogUrl+="alertDialog.php?type="+type
		}
		else
		{
			dialogUrl+="confirmDialog.php"
		}
		var userResponse=window.showModalDialog(dialogUrl, msg, props)
		if (!isAlert)
		{
			// confirm dialogs only (alerts have no return value):
			return userResponse
		}
	}
	else
	{
		if (isAlert)
		{
			alert(msg)
		}
		else
		{
			return confirm(msg)
		}
	}
}


function customConfirm(msg)
{
	return generalConfirm(msg)
}

function randomInt(argLBound,argUBound)
{
	var numRange=argUBound-argLBound+1
	return parseInt(Math.random()*numRange+argLBound)
}












// x-browser stuff:

function getDiv(divName)
{
	var targetDiv
	if (browserIsIE)
	{
		targetDiv=document.all[divName]
	}
	else if (browserIsNN6Plus)
	{
		targetDiv=document.getElementById(divName)
	}
	else if (browserIsNN4)
	{
		targetDiv=document.layers[divName]
		if (!targetDiv)
		{
			var docLayers=document.layers
			for (var i=0; i<docLayers.length; i++)
			{
				targetDiv=docLayers[i].document.layers[divName]
				if (!targetDiv)
				{
					continue
				}
				else
				{
					break
				}
			}
		}
	}
	//alert("returning "+targetDiv)
	return targetDiv

}

function getImage(divName,imgName)
{
	var ret
	if (browserIsIE)
	{
		ret=document.images[imgName]
	}
	else if (browserIsNN6Plus)
	{
		ret=document.getElementById(imgName)

	}
	else if (browserIsNN4)
	{
		ret=document.layers[divName].document.images[imgName]
	}
	return ret
	
}

function getForm(divName,formName)
{
	var ret
	if (browserIsIE)
	{
		ret=document.forms[formName]
	}
	else if (browserIsNN6Plus)
	{
		ret=document.getElementById(formName)
	}
	else if (browserIsNN4)
	{
		ret=document.layers[divName].document.forms[formName]
	}
	return ret
	
}

function writeOrAppendToDiv(divName,divContents,appendText)
{
	var targetDiv=getDiv(divName)
	if (!browserIsNN4)
	{
		if (!appendText)
		{
			targetDiv.innerHTML=divContents+" " // spchar for ie/mac bug
		}
		else
		{
			targetDiv.insertAdjacentHTML("beforeEnd",divContents+" ") // spchar for ie/mac bug
		}
	}
	else
	{
		if (appendText)
		{
			alert("Cannot append text to the end of a div in NN4.")
		}
		targetDiv.document.open()
		targetDiv.document.write(divContents)
		targetDiv.document.close()
	}
}


function writeToDiv(divName,divContents)
{
	writeOrAppendToDiv(divName,divContents,false)
}

function appendToDiv(divName,divContents)
{
	writeOrAppendToDiv(divName,divContents,true)
}

function setDivStyle(divName,styleName,styleValue)
{
	if (!browserIsNN4)
	{
		getDiv(divName).style[styleName]=styleValue
	}
	else
	{
		styleValue=""+styleValue
		if (styleName=="visibility")
		{
			if (styleValue=="visible")
			{
				styleValue="show"
			}
			else if (styleValue=="hidden")
			{
				styleValue="hide"
			}
		}
		if (styleValue.indexOf("px")>-1)
		{
			styleValue=styleValue.substring(0,styleValue.indexOf("px"));
		}
		getDiv(divName)[styleName]=styleValue
	}
}



// cookie stuff:


function setCookie (name,value,expires,path,domain,secure)
{
	document.cookie = name + "=" + escape (value) +
		((expires) ? "; expires=" + expires.toGMTString() : "") +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		((secure) ? "; secure" : "");
}

function getCookieVal (offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1) endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr))
}


function getCookie (name) {
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen) { 
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg) return getCookieVal (j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break;
	}
	return null
}

function perSessionCookiesEnabled()
{
	var testCookieValue=uniqueNumericString()
	setCookie("perSessionCookieTest",testCookieValue)
	var newCookieValue=getCookie("perSessionCookieTest")
	if (newCookieValue==null)
	{
		return false;
	}
	return (newCookieValue.toString()==testCookieValue.toString())
}

function doBooleanCookieCheck()
{
	if (!perSessionCookiesEnabled())
	{
		location.replace("/f650csPromo/incompat.jsp?r=c")
	}
	browserId=getCookie("browserId")
	if (browserId==null || browserId=="")
	{
		browserId=uniqueNumericString()
		var yearFromNow=new Date()
		yearFromNow.setTime(yearFromNow.getTime()+1000*60*60*24*365)
		setCookie("browserId",browserId,yearFromNow,"/")
	}
}









shortUserNames=new Array
(
	"john999",
	"FGibson",
	"wmDaniils",
	"edChapman2",
	"frankKelley2",
	"RMellencmp",
	"plx33",
	"jamesR56",
	"gracePiazza",
	"brainstem",
	"spiceGurrrl2",
	"lucy56",
	"Jason_Shaw",
	"baby_jesus",
	"blanket",	
	"subliminable5",
	"mark9",
	"robertParker",
	"daly_lisa",
	"frankM",
	"ben_Farrell",
	"dogg9",
	"J_newman",
	"F_nahtanoj",
	"likeButtuh9",
	"juliamartin",
	"joelD",
	"sanford3",
	"kms",
	"srKevin",
	"gooding_j",
	"leftField",
	"matrix2",
	"xoxoxo88",
	"fBunton",
	"Jefferson_W",
	"coleGray",
	"mrMojoRison47221",
	"downeyWR",
	"chrisE",
	"DBeal",
	"Windsor29",
	"userX802",
	"pete_f",
	"lilyS4",
	"449dawg",
	"rmNixon",
	"rrrrR",
	"katie9",
	"pwLevinson",
	"wagner3",
	"v_barnes",
	"bingo3",
	"John_Cotton",
	"word4",
	"werner",
	"uhHuhHuhHuh",
	"umLikeSure",
	"zzzNathan",
	"prn4",
	"fred121"
)








function isUserFlashEnabled()
{
  thisBrowser=navigator.appName.charAt(0)
  thisVersion=navigator.appVersion.charAt(0)
  if (isIeWithFlash3plus==1) { isIeWithFlash3plus=true }

  isNsWithFlash3plusEnabled=false


  if(thisBrowser=="N" && thisVersion>"2") { // if this is Netscape 3 or higher...
        for (var i=0; i<navigator.plugins.length; i++) { //loop through installed plugins...
				plugin = navigator.plugins[i];
                if (plugin.name.indexOf("Shockwave Flash")!=-1) { // if this plugin is flash (any version)...
                        for (var j=0; j<plugin.description.length; j++) { // loop through each character of the plugin description...
                                if ("1234567890".indexOf(plugin.description.charAt(j))!=-1) { // until a numeral is found...
                                        if (plugin.description.charAt(j)>="3") // if the first (and only the first) numeral is 3 or greater, then the user has at least Flash 3...
												//check to see if Flash 3, which is installed, is also enabled...
												numTypes = plugin.length;
                  								for (j = 0; j < numTypes; j++) {
                     							mimetype = plugin[j];
                     								if (mimetype) {
														if (mimetype.enabledPlugin && (mimetype.suffixes.indexOf("swf") != -1)) { // If there is an enabled plugin for this mime type AND it's Flash (.swf)...
                           									isNsWithFlash3plusEnabled=true;
														}
                        								if (navigator.mimeTypes["application/x-shockwave-flash"] == null) {// Mac wierdness (set isNsWithFlash3plusEnabled back to false if Flash mimetype doesn't exist)...
                           									isNsWithFlash3plusEnabled=false;
														}
													}
                                        }
                                        break // break out of the j for loop (we don't care about any but the first numeral found)
                                }
                        }
                }
        }
  }
  if (isNsWithFlash3plusEnabled || isIeWithFlash3plus) {
  	return true
  }
  else {
    return false
  }
}


// changeStatusText type constants:
var CLEAR=0
var NEW_WIN_STANDARDS=1
var NEW_WIN_FEATURES=2
var BOX_STANDARDS=3
var CLOSE_BOX=4
var BATTERY_OPEN=5
var BATTERY_CLOSE=6
var REGULAR_LINK=7

function changeStatusText(type,detailText)
{
	var s=""
	if (type!=CLEAR)
	{
		s+="bcompile:"
		if (type==NEW_WIN_STANDARDS)
		{
			s+="WLOAD[4342]["+detailText+"][std][3][2]"
		}
		else if(type==NEW_WIN_FEATURES)
		{
			s+="WLOAD[4342]["+detailText+"][ftr][0][2]"
		}
		else if(type==BOX_STANDARDS)
		{
			s+="LDISP[prmRXr]["+detailText+"][ftr][mod\\'NMDL']"
		}		
		else if(type==CLOSE_BOX)
		{
			s+="LDISP[prmRXrf][][ftr][mod\\'H']"
		}		
		else if(type==BATTERY_OPEN)
		{
			s+="PN[PWSUP2][mod\\1]"
		}		
		else if(type==BATTERY_CLOSE)
		{
			s+="PN[PWSUP2][mod\\0]"
		}			
		else if(type==REGULAR_LINK)
		{
			s+="LOAD[4342]["+detailText+"][NULL][0][2]"
		}	
	}
	window.status=s
	window.defaultStatus=s
	return true
}

 

function openWin(arg_winInstance,arg_winName,arg_doc,arg_properties)
{
	window[arg_winInstance]=null
	try {
		window[arg_winInstance]=window.open(arg_doc,arg_winName,arg_properties)
	}
	catch (e) {}

	if (window[arg_winInstance]==null) {
		alert("Please disable your popup blocker for 'www.theavocadopapers.com'.  The Avocado Papers never opens ads in popup or pop-under windows, but it does display content in popup windows, so if you block popups from 'www.theavocadopapers.com', you won't be able to see the content, but your friends will, and eventually you'll end up with no friends.  And nobody wants to be friends with someone who doesn't have any friends.")
	}

}




function launchContentWin(arg_width,arg_height,arg_url,arg_altAttrStr,arg_useFrame)
{
	var s=""
	if (typeof arg_altAttrStr=="undefined")
	{
		arg_altAttrStr="toolbar=0,location=1,directories=0,status=1,menubar=0,scrollbars=0,resizable=0"
	}
	s+=arg_altAttrStr
	if (typeof arg_useFrame=="undefined")
	{
		arg_useFrame=true
	}
	if ((""+arg_useFrame)=="true") {
		arg_useFrame=true
	}
	else {
		arg_useFrame=false
	}

	var thisDate=new Date()
	var thisTime=thisDate.getTime()
	s+=",width="+arg_width+",height="+arg_height
	if (arg_url.indexOf("webmissive")==-1)
	{
		if (arg_useFrame) {
			openWin("contentWin"+thisTime,"contentWindow"+thisTime,PATH_TO_CONTENT_HOLDER+"unless.you.have.a.car-if.you.have.a.car.that.changes.everything.html?"+arg_url+"&prmRw="+arg_width,s)
		}
		else {
			openWin("contentWin"+thisTime,"contentWindow"+thisTime,arg_url,s)
		}
	}
	// SPECIAL CASES...
	else
	{
		openWin("contentWin"+thisTime,"contentWindow"+thisTime,arg_url,s)
	}
	
}