<!--


	
function newCookieParse(k,kvS){
if(!kvS||kvS.length==0) return '';
var kS=k+'=';
var kvL=kvS.length;
var kSI=0;
var v='';
while(kSI<kvL){
var i=kSI+kS.length;
if (kvS.substring(kSI,i)==kS){
var x=kvS.indexOf('&',i);
if(x==-1)x=kvL;
v=kvS.substring(i,x);
return v;
}
kSI=kvS.indexOf('&',kSI)+1;
if(kSI==0)kSI=kvL;
}
return '';
}
var acceptsCookies=false;
if(document.cookie==''){
document.cookie='acceptsCookies=yes';
if(document.cookie.indexOf('acceptsCookies=yes')!=-1)acceptsCookies=true;
}else{
acceptsCookies=true;
}
function setCookie (n,v,h,p,d,s){
if(h){
if ((typeof(h)=='string')&&Date.parse(h)){
var hN=h;
}else if(typeof(h)=='number'){
var hN=(new Date((new Date()).getTime()+h*3600000)).toGMTString();
}
}
document.cookie=n+'='+escape(v)+((hN)?(';expires='+hN):'')+((p)?';path='+p:'')+((d)?';domain='+d:'')+((s&&(s==true))?';secure':'');
}
function readCookie(n) {
n+='=';
if(document.cookie==''){
return false;
}else{
var a,z;
var c=document.cookie;
a=c.indexOf(n);
var i=c.indexOf(n);
var j=c.substring(i-1,i);
if (j!=''&&j!=' '){
n=' '+n;
a=c.indexOf(n);
}
if(a!=-1){
if(a!=-1)a+=n.length;
z=c.indexOf(';',a);
if(z==-1)z=c.length;
return unescape(c.substring(a,z));
}else{
return false;
}
}
}
function killCookie(n,p,d){
var v=readCookie(n);
if(v) document.cookie=n+'='+v+';expires=Fri,13-Apr-1970 00:00:00 GMT'+((p)?';path='+p:'')+((d)?';domain='+d:'');
}
function sharedCookieExists(c, cc) {
return ((cc.indexOf(c + "=") == 0) || (cc.indexOf("&" + c + "=") > 0))
}
function updateCookieShared (n,c,v){
var cS=readCookie(n);
var cSc=c+"="+v+"&";
if (readCookie(n)==""){
var cSn=cSc;
}else{
var tries = 0;
while (sharedCookieExists(c,cS) && tries++ < 100) {
var thisChip=c+"="+newCookieParse(c,cS)+"&";
cS=cS.replace(thisChip,'');
}
var cSn=cS+cSc;
}
if(n=='PC' || n=='search')var e='Wed, 29 Dec 2010 23:23:59 GMT';
else var e='';
setCookie(n,cSn,e,'/','.iwon.com');
}
function deleteCookieShared (n,c){
var cS=readCookie(n);
var cSc=newCookieParse(c,readCookie(n));
if (cS!=""||cS!="false"){
if(cSc!=""&&cSc!="undefined"&&cSc!=null){
var thisChip=c+"="+cSc+"&";
cSn=cS.replace(thisChip,"");
if(cSn=="") var cSn="foo&";
setCookie(n,cSn,'Wed, 29 Dec 2010 23:23:59 GMT','/','.iwon.com');
}
}
}
var CookieSC=readCookie('SC');
function readCookieSC (c){
return (newCookieParse(c,CookieSC));
}
function updateCookieSC (c,v){
updateCookieShared('SC',c,v);
}
function deleteCookieSC (c){
deleteCookieShared('SC',c);
}
var CookiePC=readCookie('PC');
function readCookiePC (c){
return (newCookieParse(c,CookiePC));
}
function updateCookiePC (c,v){
updateCookieShared('PC',c,v);
}
function deleteCookiePC	(c){
deleteCookieShared('PC',c);
}
var CookieSearch=readCookie('search');
function readCookieSearch (c){
return (newCookieParse(c,CookieSearch));
}
function updateCookieSearch (c,v){
updateCookieShared('search',c,v);
}
function deleteCookieSearch	(c){
deleteCookieShared('search',c);
}
function isCanadian(){
country=newCookieParse('Q',readCookie('P'));
if (country.toUpperCase()=="CA"){return true;}else{return false;}
}

var useSecureImg = 0;
if (parent.frames.length != 0) {
	 for (var i=0; i < eval(parent.frames); i++) {
		var httpRequest = parent.frames[i].location.href;
		if (httpRequest.substring(0,5) == "https") var useSecureImg = 1
	}
} else {
	 var httpRequest = parent.location.href;
	if (httpRequest.substring(0,5) == "https") var useSecureImg = 1
}
if (useSecureImg == 0) {
	var bagImage = "http://ak.imgfarm.com/images/cash_bones2.gif"
} else {
	var bagImage = "https://mycashpoints.iwon.com/cash_points/images/cash_bones2.gif"
}
var inSignin = false;
var inRegistration = false;
var boneCountFormat;
var boneOutputBox;
var boneOutputValues;
var dollars = "---";
var user_num;
rndToday=new Date();
rndSeed=rndToday.getTime();
function getCookie (name) {
    var cname = name + "=";
    var clen = document.cookie.length;
    var cbegin = 0;
    while (cbegin < clen) {
		var vbegin = cbegin + cname.length;
		if (document.cookie.substring(cbegin, vbegin) == cname) { 
		    var vend = document.cookie.indexOf (";", vbegin);
		    if (vend == -1) vend = clen;
		    return unescape(document.cookie.substring(vbegin, vend));
		}
		cbegin = document.cookie.indexOf(" ", cbegin) + 1;	
		if(cbegin == 0) cbegin = clen;
    }
    return null;
}
function newCookieParse(key, keyvalStr){ 
	var keyStr = key + "="; 
	var kvLen = keyvalStr.length;  
	var keyStrIndex = 0; 
	var val = ""; 
	while (keyStrIndex < kvLen){ 
		var myIndex = keyStrIndex + keyStr.length;
		if (keyvalStr.substring(keyStrIndex,myIndex) == keyStr){ 
			var myVarEnd = keyvalStr.indexOf ("&", myIndex); 
			if (myVarEnd == -1) myVarEnd = kvLen; 
			val = keyvalStr.substring(myIndex,myVarEnd); 
			return val; 
		} 
		keyStrIndex = keyvalStr.indexOf("&", keyStrIndex) + 1; 		
		if(keyStrIndex == 0) keyStrIndex = kvLen; 
	}
	return ""; 
}
function addCommas(num) {
	var numWithCommas = ""	
	if(num.length <= 3) {
		return num;
	}
	for(var i = num.length - 3;  i > 0;  i -= 3) {
		numWithCommas = "," + num.substring(i, i+3) + numWithCommas;
	}
	numWithCommas = num.substring(0, Math.abs(3+i)) + numWithCommas;	
	return numWithCommas;
}
function TruncateName(name){
	var truncName = ""
	if (name.length > 10){ 
	truncName = name.substring(0,10) + "...";
	}else{
	truncName = name;
	}
	return truncName
}

var ssuid 		= getCookie('ssuid');
var user_num 	= getCookie('user_num');
var b_cookie 	= getCookie('b');
if(b_cookie == null) {
	var errorcode = getCookie('errorcode');
} else {
	var errorcode = newCookieParse('e',b_cookie);
}
	
function showFirstBox() {
	if(inRegistration) {
		document.write('<br>');
		boneCountFormat = 2;
	}
	else if(inSignin) {
		document.write('<br>');
		boneCountFormat = 2;
	}
	else if(ssuid == null || user_num == null || user_num == "" || user_num == false || ssuid == '-1' || errorcode == '4' || errorcode == null) {
		boneOutputBox = '<a href="http://www1.iwon.com/home/partner_registration_form/1,1290,,00.html?return_url=http://games.iwon.com/prize_machine/pm2_index.html &external=true" target=_top><font face=Verdana,Sans-Serif size=1 color=ccffff><b>REGISTER NOW!</b></font></a>';
		boneCountFormat = 1;
	}
	else {
		if(errorcode == 1) {
			boneOutputBox = '<font face=Verdana,Sans-Serif size=1 color=ccffff>Hold on, we\'re busy<br>counting your entries.</font>';
			boneCountFormat = 1;
		}
		else if(errorcode == 2) {
			boneOutputBox = '<font face=Verdana,Sans-Serif size=1 color=ccffff>We\'re sorry, we are<br>experiencing some<br>technical difficulties.</font>';
			boneCountFormat = 1;
		}
		else if(errorcode == 3){
			var fname = getCookie('fname');
			boneOutputBox = '<font face=Verdana,Sans-Serif size=2 color=ffffff><b>Hi, ' + TruncateName(fname) + '</b></font>'; 
			boneCountFormat = 0;
		}else{
			var fname = getCookie('fname');
			boneOutputBox = '<font face=Verdana,Sans-Serif size=2 color=ffffff><b>Hi, ' + TruncateName(fname) + '</b></font>'; 
			boneCountFormat = 0;
		}
	}
return boneOutputBox;
}

// jb: START: added for weekend functionality
b_cookie = getCookie('b');

// default values for stuff
var bBarDailyDesc 	= "Chances to win";
var bBarDailyLink 	= "http://winners.iwon.com/winners.html";
var bBarDailyPriz 	= "$10K";
var bBarMonthlyDesc = "Chances to win";
var bBarAnnualDesc 	= "Chances to win";
	
if(b_cookie == null || ssuid == null || user_num == null || ssuid == '-1') {
	// do this for users who don't have a b cookie or are not signed in
	// nothing customized yet (uses defaults above)
} else {
	// do this for users who do have the NEW b cookie
	// i'm still working on this. i'm having trouble accurately telling if the user has an "old" or "new" format.
	// i think my problem is that in the scenario i'm testing, a user has both an "old" and "new" format.
	// that's what happens when a user goes from prod to staging, which is the scenario mike p wants me to test for.
	var Dchip = newCookieParse('D',b_cookie);
	if(Dchip != null) {
		bBarDay = new Array();
		bBarDay[0] = 'Weekend';
		bBarDay[1] = 'Monday';
		bBarDay[2] = 'Tuesday';
		bBarDay[3] = 'Wednesday';
		bBarDay[4] = 'Thursday';
		bBarDay[5] = 'Friday';
		bBarDay[6] = 'Weekend';
		bBarDayIndex   = newCookieParse('D',b_cookie);
		bBarDayName    = bBarDay[bBarDayIndex];
	
		bBarMonth = new Array();
		bBarMonth[0] = 'January';
		bBarMonth[1] = 'February';
		bBarMonth[2] = 'March';
		bBarMonth[3] = 'April';
		bBarMonth[4] = 'May';
		bBarMonth[5] = 'June';
		bBarMonth[6] = 'July';
		bBarMonth[7] = 'August';
		bBarMonth[8] = 'September';
		bBarMonth[9] = 'October';
		bBarMonth[10] = 'November';
		bBarMonth[11] = 'December';
		bBarMonthIndex    = newCookieParse('M',b_cookie);
		bBarMonthName 	  = bBarMonth[bBarMonthIndex];
		
		var bBarDailyDesc 	= bBarDayName;
		var bBarMonthlyDesc = bBarMonthName;
		var bBarAnnualDesc 	= "Annual";
		if (bBarDayIndex == 6 || bBarDayIndex == 0) {
			var bBarDailyPriz 	= "10 x $1K";	
			var bBarDailyLink 	= "http://winners.iwon.com/weekend.html";
		} 
	}
}
// jb: END: added for weekend functionality

function showBoneCount(mode, which) {
	var output = "";
	var title = ""; 
	var w_key = ""; 
	var w_val = ""; 
	var w_keynum ; 
	var w_valnum ; 
	var w_limit = ""; 
	var w_needed = ""; 
	if(boneCountFormat == 0) {
		
		b_cookie = getCookie('b');
		if(b_cookie != null) {
			if(which == "daily") {
				 if (bBarDayIndex != 0) {
					// do this on every day except sunday
					output = newCookieParse('d',b_cookie);
				} else {
					// do this on sunday. today's points is the weekend total minus yesterday's points
					//var sundayPoints = parseInt(newCookieParse('d',b_cookie)) -  parseInt(newCookieParse('P',b_cookie));
					//var sundayPointsStr = ""+sundayPoints+"";
					//output = sundayPointsStr;
					output = newCookieParse('d',b_cookie);
				}
			} else if (which == "weekly") {
				output = b_cookie;
			} else if (which == "monthly") {
				output = newCookieParse('m',b_cookie);
			} else if (which == "yearly") {
				output = newCookieParse('y',b_cookie);
			} else if (which == "dollars") {
				output = newCookieParse('c',b_cookie);
				calc = output * 0.01 + 0.001;
				temp = calc + " ";
				output = temp.substring(0,temp.indexOf(".") + 3);
			} else {
			}
		} else {
			output = getCookie(which);
		}			
		
		if(output == null) {
			output = "--";
		} else {
			if((errorcode == 3) && (which == "daily")) {
				if (bBarDayIndex == 0 && which == "daily") {
					// do this on sunday for the daily count.
					//title = "Total "+newCookieParse('d',b_cookie)+"<br>";
					title = "";
				} else {
					// do this on every day except sunday
					title = "";
				}
			} else if (which == "dollars") {
				title = "";
			} else {
				if (bBarDayIndex == 0 && which == "daily") {
					// do this on sunday for the daily count.
					//title = "Total "+newCookieParse('d',b_cookie)+"<br>";
					title = "";
				} else {
					// do this on every day except sunday
					title = "";
				}
			}
			if (which != "dollars") {
			output = addCommas(output);
			}
			if(output == null) {
				output = "---";
			} 
		}
	}else if(boneCountFormat == 2) {
		output = "&nbsp";
		title = "&nbsp";
	}else if(errorcode == 1) {
		output = "</font></b><font color=FFFFFF size=1>entries...</font>";
		title = "Counting<br>";
	}else if(errorcode == 2) {
		output = "</b></font><font color=FFFFFF size=1>unavailable</font>";
		title = "Temporarily<br>";
	}else if(which == "dollars") {
		output = "---";
	}else {
		output = "</font><font color=FFFFFF size=1><b>---</b></font>";
		title = " ";
	}
	boneOutputValues = '<font face=Verdana,Sans-Serif size=1 color=FFFFFF>' + title + '<b>' + output + '</b></font>';
	return boneOutputValues;
}
function rnd() {
    rndSeed = (rndSeed*9301+49297) % 233280;
    return rndSeed/(233280.0);
}
function rand(number) {
    return Math.ceil(rnd()*number);
}
function getHtmlAds(){
	var user_num = getCookie('user_num');
	var unreg='<a href=http://www1.iwon.com/home/registration_form/1,12057,,00.html?PG=global?SEC=bbar target=_top><font face=Verdana,Sans-Serif size=1 color=000000><b>Win up to $25,000,000</b></font></a></td>';
	var mac='<a href=http://www1.iwon.com/home/companyinfo/iwon_dol/0,3698,,00.html?PG=global?SEC=bbar target=_top><font face=Verdana,Sans-Serif size=1 color=000000><b>New - Reward Points!!!</b></font></a></td>';
	var arrayHtml = new Array('<a href=http://games.iwon.com/casino/index.html?PG=global?SEC=bbar target=_top><font face=Verdana,Sans-Serif size=1 color=000000><b>iWon Casino Play Now!</b></font></a></td>','<a href=http://careers.iwon.com/index.html?PG=global&SEC=bbar target=_top><font face=Verdana,Sans-Serif size=1 color=000000><b>Look for a job now!</b></font></a></td>'
							    );
	var agt=navigator.userAgent.toLowerCase();
	var agtN=navigator.appName.toLowerCase();
	if (agt.indexOf("mac") != -1 && agtN.indexOf("netscape")!=-1){
		return mac;
	}else if(user_num==null){
		return unreg;
	}else{
		var showHtml=arrayHtml[rand(arrayHtml.length)-1];
		return showHtml;
	}
}		
  function getValsfromString(instr) {
  if ( instr.length != 16 ) { return(null) ; }
  val = new Array() ;
  for (x=0 ; x < 16 ; x++) {
    var n = parseInt(instr.charAt(x), 16) ;
    for (y=0 ; y < 4 ; y++) {
      val[x*4+y] = ( (n >> (3-y)) % 2 == 1 ) ? true : false ;
    }
  }
  return(val);
}	

var user_num = getCookie('user_num');
//var act_string = readCookiePC('a');
b_cookie = getCookie('b');
if (b_cookie != null) {
	HexString = newCookieParse('h',b_cookie);	
	var ParsedString = getValsfromString(HexString);
	errorcode = newCookieParse('e',b_cookie);
} else {
	var ParsedString = 'null';
	var errorcode = 'null';
}
if (user_num != null && errorcode != null && errorcode != 'null' && errorcode != 1 && errorcode != 2) {
	  if (ParsedString != null && ParsedString != 'null' && ParsedString[62] == true && ParsedString[63] == false) {
		var documentLocation = escape(document.location);
		if (documentLocation.indexOf("/user_registration/manual_login/process_sign_in_redirect") < 0) updateCookieSC('D',documentLocation);
		document.location.replace('http://www1.iwon.com/ro/apr/splash/0,1963,,00.html');
	}
}  var bonebar = '<table id=bonenav name=bonenav border=0 cellpadding=1 cellspacing=0 width=100% bgcolor=FFFFFF>' +
	'<tr valign=middle>' +
		'<td bgcolor=3366CC width=16% nowrap align=center>' +
		'<table border=0 cellpadding=1 cellspacing=0><tr><td align=center>' +
			showFirstBox() +
		'</td></tr></table></td>' +
		'<td bgcolor=ffbb05 width=17% nowrap align=center>' +
		'<table border=0 cellpadding=1 cellspacing=0><tr><td align=center nowrap>' +
			'<a href="http://prizemachine.games.iwon.com/pm3_splash.html?PG=global?SEC=bbar" target=_top><font face=Verdana,Sans-Serif size=1 color=000000><b>Spin to Win!</b></font></a><b><font size=1>&nbsp;</font>' +
		'</td></tr></table></td>' +
		'<td bgcolor=ff9900 width=17% nowrap align=center>' +
		'<table border=0 cellpadding=1 cellspacing=0><tr><td align=center>' +
			'<a href="'+bBarDailyLink+'?PG=global?SEC=bbar" target=_top><font face=Verdana,Sans-Serif size=1 color=000000><b>'+bBarDailyDesc+'</b></font></a><b><font size=1>&nbsp;</font>' +
			showBoneCount('0','daily') +
		'</td></tr></table></td>' +
		'<td bgcolor=ff6600 width=17% nowrap align=center>' +
		'<table border=0 cellpadding=1 cellspacing=0><tr><td align=center>' +
			'<a href="http://monthlyprizes.iwon.com/mp/overview.jsp?PG=global&SEC=bbar" target=_top><font face=Verdana,Sans-Serif size=1 color=000000><b>'+bBarMonthlyDesc+'</b></font></a><b><font size=1>&nbsp;</font>' +
			showBoneCount('0','monthly') +
		'</td></tr></table></td>' +
		'<td bgcolor=ff0000 width=17% nowrap align=center>' +
		'<table border=0 cellpadding=1 cellspacing=0><tr><td align=center>' +
			'<font face=Verdana,Sans-Serif size=1><a href="http://winners.iwon.com/annual.html?PG=global?SEC=bbar" target=_top><font color=000000><b>'+bBarAnnualDesc+'</b></font></a><b><font size=1>&nbsp;</font>' +
			showBoneCount('0','yearly') +
		'</td></tr></table></td>' +
	'</tr>' +
'</table>' ;
document.write(bonebar);
//-->