function ChekLoginFields(){
  var theLogin = document.getElementById("ctl00_txtUserID").value;
  var thePassword = document.getElementById("ctl00_txtPassword").value;
	if (theLogin == "" || theLogin == "<email>" || thePassword == "" || thePassword == "<password>"){
		alert("You did not enter your User ID or Password.  Please try again.");
		return false;
	}
	return true;
}

// navigation related
function RefreshPage(){
	document.location.href = document.location.href;
}
function GoToPage(sPage){
	if (document.location.href != sPage) document.location.href = sPage;
}

//cookie related
function isCookieLive(cookieValue){
  return ((cookieValue!=null) && (cookieValue!='') && (cookieValue!='undefined'))
}
function GetCookie(sName){
	var aCookie = document.cookie.split("; ");
	for (var i=0;i<aCookie.length;i++){
		var aCrumb = aCookie[i].split("=");
		if (sName == aCrumb[0]) return unescape(aCrumb[1]);
	}
	return null;
}
function DelCookie(sName){
	document.cookie = sName + "=; expires=Fri, 31 Dec 1900 23:59:59 GMT;";
}
function SetCookie(sName, sValue){
	DelCookie(sName);
	if (sValue != null) document.cookie = sName + "=" + escape(sValue) + ";path=/;";
}

//jscript rendering
function TblBeg(){return '<table cellpadding="0" cellspacing="0"><tr>';}
function TblEnd(){return '</tr></table>';}
function TblBeg100(){return '<table cellpadding="0" cellspacing="0" style="width:100%"><tr>';}

function AllGameLink(gameUrl, gameName, gameTitle, gameDesc){ 
  var s = '<div>' + TblBeg() + '<td><div style="padding-top:5px;padding-bottom:5px;padding-right:25px;">' + TblBeg();
  s += '<td><a href="games/' + gameUrl + '/"><img src="games/' + gameUrl + '/small_logo.gif" width="108px" height="76px" /></td>';
  s += '<td><div style="padding-left:12px; height:76px;overflow:hidden;">';
  s += '<div class="allGameBoxName"><a href="games/'+gameUrl+'/">' + gameName + '</a></div>';
  s += '<div class="allGameBoxDesc">' + gameDesc + '</div>';
  s += '<div><a class="boxLink" href="games/' + gameUrl + '/">Play</a></div>';
  s += '</div></td></tr></table></div></td><td class="sepLine"></td></tr></table></div>';
  document.write(s);
}
function AllAlterGameLink(gameUrl, gameName, gameTitle, gameDesc){ 
  var s = '<div>' + TblBeg() + '<td><div style="padding-top:5px;padding-bottom:5px;">' + TblBeg();
  s += '<td><a href="games/' + gameUrl + '/"><img src="games/' + gameUrl + '/small_logo.gif" width="108px" height="76px" /></td>';
  s += '<td><div style="padding-left:12px; height:76px;overflow:hidden;">';
  s += '<div class="allGameBoxName"><a href="games/'+gameUrl+'/">' + gameName + '</a></div>';
  s += '<div class="allGameBoxDesc">' + gameDesc + '</div>';
  s += '<div><a class="boxLink" href="games/' + gameUrl + '/">Play</a></div>';
  s += '</div></td></tr></table></div></td></tr></table></div>';
  document.write(s);
}

function UserFavGames(fileName, gameName, score, isTrophyWinner){
  var trophy = '';
  if (isTrophyWinner == 1){
    var altText = 'Trophy Winner';
		trophy = '<td width=5></td><td valign=bottom><img src="' + siteBaseUrl + '/img/medal.gif" alt="' + altText + '" title="' + altText + '"></td>';
  }
  var style = ' style="color:black;font-size:12px"';
  var s = '<div style="height:21px;">' + TblBeg100() + '<td ' + style + '>';
  s += '<div style="padding-left:20px;OVERFLOW:hidden;width:155px;">' + TblBeg() + '<td valign=bottom><a class="lnkLeader" href="' + siteBaseUrl + '/games/' + fileName +'"><nobr>' + gameName;
	s += '</nobr></a></td>' + trophy + '</tr></table></div></td><td width=10></td><td align=left valign=bottom ' + style + '><b>' + score + '</b></td><td width="15px"></td><td class="sepLine" style="height:21px;"></td>' + TblEnd() + '</div>';
  document.write(s);
}

function UserAlterFavGames(fileName, gameName, score, isTrophyWinner){
  var trophy = '';
  if (isTrophyWinner == 1){
    var altText = 'Trophy Winner';
		trophy = '<td width=5></td><td valign=top><img src="' + siteBaseUrl + '/img/medal.gif" alt="' + altText + '" title="' + altText + '"></td>';
  }
  var style = ' style="color:black;font-size:12px"';
  var s = '<div style="height:21px;">' + TblBeg100() + '<td ' + style + '>';
  s += '<div style="padding-left:20px;OVERFLOW:hidden;width:155px;">' + TblBeg() + '<td valign=bottom><a class="lnkLeader" href="' + siteBaseUrl + '/games/' + fileName +'"><nobr>' + gameName;
	s += '</nobr></a></td>' + trophy + '</tr></table></div></td><td width=10></td><td align=left valign=bottom ' + style + '><b>' + score + '</b></td>' + TblEnd() + '</div>';
  document.write(s);
}



function HomeGame(gameUrl, gameName, userID, screenName, score, playTimes){
  var s = TblBeg100() + '<td valign=top style="width:108px"><a href="games/' + gameUrl + '/"><img src="games/' + gameUrl + '/small_logo.gif" width="108" height="76" /></a></td>';
  s += '<td style="width:5px"></td><td><table cellpadding="0" cellspacing="0">';
  if (gameName != '') s += '<tr><td><a class="lnkLeader" href="games/' + gameUrl + '/">' + gameName + '</a></td></tr>';
  if (screenName != '')	s += '<tr><td class="todayHigh"><a class="lnkLeader" href="users/memberprofile.aspx?userID=' + userID +'">' + screenName + '</a></td></tr><tr><td class="boxText todayHigh">' + score + ' tokens</td></tr><tr><td style="height:5px"></td></tr>';
  if (playTimes != '') s += '<tr><td class="boxText todayHigh">' + playTimes + ' plays</td></tr>';
	s += '<tr><td style="height:5px"></td></tr><tr><td><a class="boxLink" href="games/' + gameUrl + '/">Play</a></td>';	
	s += TblEnd() + '</td>' + TblEnd();
  document.write(s);
}
function DailyFunGame(gameUrl){
  var s = '<a href="games/' + gameUrl + '/"><img src="games/' + gameUrl + '/label_logo.jpg" /></a>';
  document.write(s);
}

function GetAvatarURL(puppetID, size, userName, puppetName, color){
  var style = '';
  switch (size){
    case '': style = '355'; break;
    case 'l': style = '198'; break;
    case 'm': style = '72'; break;
    case 'ms': style = '50'; break;
    case 's': style = '30'; break;
  }
  if (style != '') style = ' style="width:' + style + 'px;height:' + style + 'px"';
  var alt = userName  + (puppetName == '' ? '' : ' (' + puppetName + ')');
	var ret = '<img src="' + fileUploadUrl + '/bagpuppet/' + puppetID + (size == '' ? '' : '_') + size +'.png" alt="' + alt + '" title="' + alt + '" ' + style + ' />';
	if (puppetID > 0) ret = '<a href="' + siteBaseUrl + '/bagpuppet/ratepuppet.aspx?avatarID=' + puppetID + '">' + ret + '</a>';
	if (color != '') ret = '<div style="border:1px solid ' + color + ';" ' + style + '>' + ret + '</div>';
	return ret;
}
function GetUserURL(userID, userName){
	return '<a class="lnkLeader" href="' + siteBaseUrl + '/users/memberprofile.aspx?userID=' + userID + '">' + userName + '</a>';
}
function GetTrophy(hasTrophy, n){
  var ret = '';
  if (hasTrophy == 1) ret = '<div style="padding-left:2px;padding-top:4px;"><img src="' + siteBaseUrl + '/img/medal' + n + '.gif" alt="Trophy Winner" title="Trophy Winner" /></div>';
  return ret;
}


function TopPuppets(userID, userName, puppetID, puppetName, rate){
  var s = '<div style="padding-left:10px;padding-bottom:2px;">' + TblBeg();
  s += '<td valign="top" style="vertical-align:top">'  + GetAvatarURL(puppetID, 'm', userName, puppetName, 'gray') + '</td>';
  s += '<td style="width:20px;"></td><td valign="top" style="vertical-align:top;text-align:left;"><div style="padding-top:9px;">' + GetRatingImgUrl(rate);
  s += '<div>' + GetUserURL(userID, userName) + '</div><div class="boxText todayHigh" style="width:170px;color:#6e6969;overflow:hidden">' + puppetName + '</div>';
  s += '</div></td></tr></table></div>';
  document.write(s);
}
function RateTopPuppets(userID, userName, puppetID, puppetName, points){
  var s = '<div style="padding-left:20px">' + TblBeg();
  s += '<td style="text-align:center">'  + GetAvatarURL(puppetID, 'ms', userName, puppetName, '#D3D3D3') + '</td></tr>';
  s += '<tr><td style="height:10px"></td></tr>'
  s += '<tr><td style="text-align:center"><div>' + GetUserURL(userID, userName) + '</div>';
  s += '<div class="boxText todayHigh" style="width:100px;color:#6e6969;overflow:hidden">' + puppetName + '</div>'
  s += '<div class="boxText todayHigh" style="color:#6e6969;white-space:nowrap">' + points + ' tokens</div></td></tr>'
  s += '</table></div>';
  document.write(s);
}
function GetRatingImgUrl(rate){
    var alt = 'Average Rating ' + rate + ' out of 5';
  return '<img src="' + siteBaseUrl + '/img/baloon' + Math.round(rate) + '.gif" alt="' + alt + '"  title="' + alt + '" width="41px" height="28px" />'; 
}
function AllPuppets(userID, userName, puppetID, puppetName, rate){
  var s = '<div style="padding:3px 10px;height:120px">' + TblBeg();
  s += '<td style="text-align:center"><div style="width:41px;height28px;overflow:hidden;margin-bottom:3px">' + GetRatingImgUrl(rate) + '</td></tr>';
  s += '<tr><td style="text-align:center">'  + GetAvatarURL(puppetID, 'ms', userName, puppetName, '#D3D3D3') + '</td></tr>';
  s += '<tr><td><div style="border-bottom:solid 1px #e0e5e8;height:3px;"></div></td></tr>'
  s += '<tr><td style="text-align:center"><div class="boxText todayHigh" style="width:100px;color:#6e6969;overflow:hidden;white-space:nowrap">' + puppetName + '</div>';
  s += '<div style="white-space:nowrap;">' + GetUserURL(userID, userName) + '</div>'
  s += '</td></tr></table></div>';
  document.write(s);
}
function UserPuppets(userName, puppetID, puppetName, smallPuppetName, isDefault, isPublic, rating, isEditable){
  var borderStyle = isDefault == 1 ? 'style="border-color:#ec7229"' : 'style="border-color:#e3dfdf"';
  
  if(isDefault == 1) document.getElementById('currentAvatarID').value = puppetID;
  
  var clickable = 'onclick="javascript:setAvatarAsDefault(' + puppetID + ',\'' + puppetName + '\',' + isPublic + ',' + isEditable + ');"';
  var alt = userName  + (puppetName == '' ? '' : ' (' + puppetName + ')');
  var style = 'style="cursor:pointer;"';
  
  var s = '<div id="div_' + puppetID + '" class="avatarBorder" ' + borderStyle + '><div style="margin:2px;">';      
  s += '<img width="50px" height="50px" src="' + fileUploadUrl + '/bagpuppet/' + puppetID + '_ms.png" ' + (puppetID > 0 ? clickable : "") + ' alt="' + alt + '" title="Average Rating ' + rating + ' out of 5" ' + (puppetID > 0 ? style : "") + ' />'; // GetAvatarURL(puppetID, 'ms', userName, puppetName, '');
  s += '</div></div>';
  s += '<div style="width:54px;">';
  s += '<table cellpadding="0" cellspacing="0" style="text-align:center;" width="100%"><tr style="height:20px;">';
  s += '<td style="text-align:center;" nowrap><div style="font-size:9px;color:#6e6969;width:58px;overflow:hidden">' + (smallPuppetName == '' ? puppetName : smallPuppetName) + '</div></td>';
  s += '</tr></table>';
  s += '</div>';
    
  document.write(s);
}

function Member(userID, userName, points, isTrophyWinner, puppetID, puppetName, isGuest, isFirst){
  var aTagOpen = '<a class="lnkLeader" style="font-size:11px;" href="' + siteBaseUrl + '/users/memberprofile.aspx?userID=' + userID + '">';
  var aTagClose = '</a>';
  var alt = 'Click to see my profile'; 
  if (isGuest == 1){
		aTagOpen = '<div style="font-size:11px;color:black">';
		aTagClose = '</div>';
		alt = 'Guest';
  }
  var style = 'color:#707070;font-size:11px';
  if (GetCurrentUser() == userID){
    style = 'font-size:11px;color:black;font-weight:bold';   
		aTagOpen = aTagOpen + '<font style="color:black;">';
		aTagClose = '</font>' + aTagClose;
		alt = 'Me';
  }
  var style_left = ' style="text-align:left;' + style + '"';
  style = ' style="' + style + '"';
  var starUrl = '';
  if (points >= 0  && isGuest == 0) starUrl = GetStarURL(points);
  var trophy = '';
  if (isTrophyWinner == 1) trophy = '<td width=2></td><td style="padding-top:4px;"><img src="' + siteBaseUrl + '/img/medal.gif" alt="Medal Winner" title="Medal Winner" /></td>';
  var firstStyle = isFirst == 1 ? '' : 'border-top:1px solid #d8dddf;';
  var header = isFirst == 0 ? '' : '<table cellpadding="0" cellspacing="0" width="100%" style="font-size:11px;color:#6e6969;font-weight:bold"><tr><td style="text-align:right">Tokens</td></tr></table>';
  var s =  header + '<div style="padding-top:6px;padding-bottom:6px;' + firstStyle + '">' + TblBeg();
  s += '<td ' + style + ' width="150px">' + TblBeg();
	s += '<td width=35 valign=bottom>' + aTagOpen + GetAvatarURL(puppetID, 's', userName, puppetName, '') + aTagClose + '</td>';
	s += '<td>' + aTagOpen  + userName + aTagClose + '</td>' + trophy;
	s += '<td width=2></td><td valign="top" style="vertical-align:top;text-align:left;padding-top:7px;">' + starUrl + '</td>';
	s += '</tr></table></td>';
	if (isGuest == 0)	s += '<td ' + style_left + '>' + points + ' tokens</td>';
	s += '</tr></table>';
  document.write(s);
}

function Leaderboard(rank, userID, userName, score, allPoints, hasTrophy, puppetID, puppetName, isFirst, nTrophy){
  var style = '';
  if (GetCurrentUser() == userID) style = 'color:black;font-weight;font-size:11px';
  //var userURL = '<a class="lnkLeader" style="font-size:11px" style="' + style + '" href="' + siteBaseUrl + '/users/memberprofile.aspx?userID=' + userID + '">' + userName + '</a>';
  var userURL = "<a class='lnkLeader' style='font-size:11px;' href='" + siteBaseUrl + "dashboard.aspx?id=" + userID + "'>" + userName + "</a>";
  if (style == '') style = 'color:#707070;font-size:11px';
  var firstStyle = isFirst == 1 ? '' : 'border-top:1px solid #d8dddf;';
  var style_left = ' style="text-align:left;' + style + '"';
  style = ' style="' + style + '"';
  var s =  '<div style="padding-top:6px;padding-bottom:6px;font-size:11px; background-color:#ffffff;' + firstStyle + '">' + TblBeg();
  s += '<td ' + style + ' width="190px">' + TblBeg();
    s += '<td style="width:13px;"></td>';
	s += '<td style="width:25px;" align="left" class="LBrank">' + rank + '.</td>';
	s += '<td style="width:94px;" align="left" class="LBuserURL">' + userURL + '</td><td align="center" valign="bottom"><div style="float:left; padding:0px 2px;">' + GetTrophy(hasTrophy, nTrophy) + '</div></td><td valign="bottom"><div style="float:right; padding:0px 2px;">' + GetStarURL(allPoints) + '</div></td>';
	s += '</tr></table></td>';
	s += '<td style="width:52px;" align="right" class="LBscore">' + score + '</td></tr></table>';
  document.write(s);
}

function AllGL(userID, userName, score, allPoints, isTrophyWinner, gameName, fileName, isFirst){
  var aTagOpen = '<a class="lnkLeader" style="font-size:11px;" href="' + siteBaseUrl + 'dashboard.aspx?id=' + userID + '">';
  //var aTagOpen = '';
  var aTagClose = '</a>';
  //var aTagClose = '';
  var alt = 'Click to see my profile'; 
  var style = 'color:#707070;font-size:11px';
  if (GetCurrentUser() == userID){
    style = 'font-size:11px;color:black;font-weight:bold';
		aTagOpen = aTagOpen + '<font style="color:black;">';
		aTagClose = '</font>' + aTagClose;
		alt = 'Me';
  }
  var starUrl = '';
  if (allPoints >= 0) starUrl = GetStarURL(allPoints);
  var trophy = '';
  if (isTrophyWinner == 1) trophy = '<td width=2></td><td style="padding-top:4px;"><img src="' + siteBaseUrl + '/img/medal.gif" alt="Medal Winner" title="Medal Winner" /></td>';
  var firstStyle = isFirst == 1 ? '' : 'border-top:1px solid #d8dddf;';
  var style_left = ' style="text-align:left;' + style + '"';
  style = ' style="' + style + '"';
  var s =  '<div style="height:30px;padding-top:6px;padding-bottom:6px;' + firstStyle + '"><table cellpadding=0 cellspacing=0 height="100%"><tr>';
  s += '<td style="width:17px;"><td>';
  s += '<td><div style="overflow:hidden; width:110px;"><a class="LgameName" style="font-weight:normal;" href="' + siteBaseUrl + 'games/' + fileName + '.aspx"><nobr>' + gameName + '</nobr></a></div></td>';
  s += '<td>' + TblBeg();
	s += '<td style="width:96px;" class="LBuserURL">' + aTagOpen  + userName + aTagClose + '</td>' /*+ trophy*/;
	//s += '<td width=2></td><td valign="top" style="vertical-align:top;text-align:left;padding-top:7px;">' + starUrl + '</td>';
	s += '</tr></table></td>';
	s += '<td class="LBscore">' + score + '</td></tr></table>';
  document.write(s);
}

function GetStarURL(treatsScore){
	if (treatsScore < 1000) return BuildStarURL('green', '0', '999');
	if (treatsScore < 10000) return BuildStarURL('blue', '1,000', '9,999');
	if (treatsScore >= 10000) return BuildStarURL('red', '10,000', 'more');
	//if (treatsScore < 500000) return BuildStarURL('red', '100,000', '499,999');
	//if (treatsScore < 1000000) return BuildStarURL('yellow', '500,000', '999,999');
	//if (treatsScore >= 1000000) return BuildStarURL('violet', '1,000,000', 'more');
	return '';
}
function BuildStarURL(starColor, pointsFrom, pointsTo){
  var alt = 'Tokens are ' + pointsFrom + ' to ' + pointsTo;
  if (pointsTo == 'more') alt = 'Tokens are ' + pointsFrom + ' or more';
  //return '<a href="' + siteBaseUrl + '/leaderboard.aspx"><img src="' + siteBaseUrl + '/img/star_' + starColor + '.gif" alt="' + alt + '" title="' + alt + '" width=19 height=18></a>';
  return '<img src="' + siteBaseUrl + '/img/star_' + starColor + '.gif" alt="' + alt + '" title="' + alt + '" width=19 height=18 />';
}
function Leader(position, userID, screenName, score, treats){
  var starUrl = GetStarURL(treats);
  var style = '';
  if (GetCurrentUser() == userID) style = ' style="color:red"';
	var sWrite = '<table celpadding=0 cellspacing=0 width="98%"><tr><td' + style + '><div class=leaderName>' + TblBeg() +'<td width=25>' + position;
	sWrite += '</td><td><a class=lnkLeader ' + style + ' href="../users/memberprofile.aspx?userID=' + userID + '">' + screenName;
	sWrite += '</a></td><td width=5></td><td valign=bottom>' + starUrl + '</td></tr></table></div></td><td width=10></td><td align=left' + style + '><b>' + score + '</b></td>' + TblEnd();
  document.write(sWrite);
}

function TLeader(position, userID, screenName, score, treats, isTrophyWinner, isCurrentUser, isFirstRow){
  var trophy = '';
  if (isTrophyWinner == 1){
    var altText = 'Trophy Winner';
		trophy = '<td width=5></td><td valign=bottom><img src="' + siteBaseUrl + '/img/medal.gif" alt="' + altText + '" title="' + altText + '"></td>';
  }
  var style = '';
  var currentUserClass = '';
  if (isCurrentUser == 1){
    style = ' style="color:black;font-weight:bold"';
    currentUserClass = ' class="currentUserBorder"';
  }
  var s= '';
  if (isFirstRow == 0){
    s += '<div style="height:1px;overflow:hidden;background-color:#d8dddf;margin:3px 0 3px 0;"></div>';
  }
  s += '<div style="height:21px;"' + currentUserClass + '><table celpadding=0 cellspacing=0 width="100%"><tr><td ' + style + '><div class="leaderName">' + TblBeg() + '<td width=25 valign=bottom class="leaderText"' + style + '><b>' + position;
  s += '.</b></td><td valign=bottom><a class="lnkLeader" href="' + siteBaseUrl + '/users/memberprofile.aspx?userID=' + userID + '"><nobr>' + screenName + '</nobr>';
  s += '</a></td>' + trophy + '<td width=5></td><td valign=bottom>' + GetStarURL(treats) + '</td></tr></table></div></td><td width=10></td><td align=left valign=bottom class="leaderText"' + style + '>' + score + '</td>' + TblEnd() + '</div>';
  document.write(s);
}
function UserGreatestGames(fileName, gameName, score, isTrophyWinner){
  var trophy = '';
  if (isTrophyWinner == 1){
    var altText = 'Trophy Winner';
		trophy = '<td width=5></td><td valign=bottom><img src="' + siteBaseUrl + '/img/medal.gif" alt="' + altText + '" title="' + altText + '"></td>';
  }
  var style = ' style="color:black;font-size:12px"';
  var s = '<div style="height:21px;">' + TblBeg100() + '<td ' + style + '>';
  s += '<div style="padding-left:20px;OVERFLOW:hidden;width:155px;">' + TblBeg() + '<td valign=bottom><a class="lnkLeader" href="' + siteBaseUrl + '/games/' + fileName +'"><nobr>' + gameName;
	s += '</nobr></a></td>' + trophy + '</tr></table></div></td><td width=10></td><td align=left valign=bottom ' + style + '><b>' + score + '</b></td>' + TblEnd() + '</div>';
  document.write(s);
}

function Trophy(gameName,scoreTypeID,weekOfYear,year,pageName) {
  var altText = (scoreTypeID == 7 || scoreTypeID == 9) ? 'SCORE' : 'TOKENS';
  var imgTrophySrc = siteBaseUrl + '/games/' + pageName + '/trophy.jpg';
  var imgTrophyAlt = 'TOP ' + altText + '<br>' + gameName + '<br><font style="font-size:9px">Week ' + weekOfYear + ', ' + year + '</font>'; 
  var s = '<table celpadding=0 cellspacing=0 style="width:75px"><tr>';
  s += '<td valign="top" style="vertical-align:top;text-align:center;"><img src="' + imgTrophySrc + '"></td></tr>'
  s += '<tr><td style="text-align:center;" class="trophyLabel">' + imgTrophyAlt + '</td></tr>'
  s += '</table>';
  document.write(s);
}

function CheckLogin(){
   return IsLogged('To rate Bag Puppets, please login or register to become a new Fandango Fun member.');
   //return true;
}
function IsLogged(msg){
  if (!UserIsLogged()){
    alert(msg);
    return false;
  }
  return true
}
function UserIsLogged(){
  var auth = GetCookie('userNameCookie');
  if (!isCookieLive(auth)){
    return false;
  }
  return true
}

function RunInPopUp(externalGameUrl){
  var wnd = window.open(externalGameUrl);
  if (wnd) wnd.focus();
}


function RunGame(name, width, height){
  if (width < 728) width = 728;
  width += 47;
  height += 168;
  var url = '../games/' + name + '/'+ name +'.aspx';
  var wnd = window.open(url, AZ(name), 'width=' + width + 'px,height=' + height + 'px,status=0,resizable=0,location=0,scrollbars=0');
  if (wnd) wnd.focus();
}
function AZ(text){
  var ret = '';
  for(var i=0;i<text.length;i++){
    var code = text.charCodeAt(i); 
    var s = text.substr(i,1); 
    if (code >=65 && code <= 90) ret += s; //A-Z	
    if (code >=97 && code <= 122) ret += s; //a-z	
    if (code >=48 && code <= 57) ret += s;  //0-9	
  }
  return ret;
}
function IsWindowExist(objWnd){
  try{
    objWnd.IsAlive();
    return true;
  }catch(e){
    return false;
  }
}
function GetFlashObj(objName){
	if (navigator.appName.indexOf ("Microsoft") != -1) {
	  return document.getElementById(objName);
	}	else {
	  return document[objName];
	}
}
function GetFormObj(objName){
	if (window.navigator.appName.toLowerCase().indexOf("microsoft") > -1)
			return document.getElementById(objName)
	else 
			return document.forms[objName];
}
function GetNumeric(objValue){
  var theRet = 0;
  try{
    theRet = parseInt(objValue);
  }catch(e){}
  if (isNaN(theRet)) theRet = 0;
  return theRet;
}
function GetCurrentUser(){return GetNumeric(GetCookie('userCookie'));}

function WinnerCircle(sweepStakeName, winners, winnerID){
  var s = '<div class="prizeText" style="padding-left:10px;padding-bottom:2px"><div style="width:100%">';
  s += TblBeg100()+ '<td><a class="lnkLeader" href="' + siteBaseUrl + '/users/memberprofile.aspx?userID=' + winnerID + '">' + winners + '</a></td>';
  s += '<td></td><td style="text-align:right;" class="prizeText">' + sweepStakeName + '</td>';
  s += '</tr></table></div></div>';
  document.write(s);
}
function CreateCountDown(){
  msecondsPerMinute = 1000 * 60;
  msecondsPerHour = msecondsPerMinute * 60;
  msecondsPerDay = msecondsPerHour * 24;
  var interval = diffInterval;
  days = Math.floor( interval / msecondsPerDay );
  interval = interval - (days * msecondsPerDay );
  hours = Math.floor( interval / msecondsPerHour );
  interval = interval - (hours * msecondsPerHour );
  minutes = Math.floor( interval / msecondsPerMinute );
  interval = interval - (minutes * msecondsPerMinute );
  seconds = Math.floor( interval / 1000 );
  var jsCountDown = days + 'd : ' + hours + 'h : ' + minutes + 'min : ' + seconds + 's';
  document.getElementById('countDown').innerHTML = jsCountDown;
  diffInterval -= 1000;
}
function TxHeader(){
	var s = '<table celpadding=0 cellspacing=0 border=0 width=98% align=center><tr>';
	s += '<td width=22% class=txTblHeader>Date</td>';
	s += '<td width=20% class=txTblHeader>Type</td>';
	s += '<td width=40% class=txTblHeader>Comment</td>';
	s += '<td width=9% class=txTblHeader align=right>Amount</td>';
	s += '<td width=9% class=txTblHeader align=right>Balance</td>';
	s += '</tr></table>';
	document.write(s);
}
function TxBody(date, type, comment, amount, balance, isLast){
	var body1Style = 'txTblBody1';
	var body2Style = 'txTblBody2';
	if (isLast == 1){
		body1Style = 'txTblBodyL1';
		body2Style = 'txTblBodyL2';
	}
	var s = '<table celpadding=0 cellspacing=0 border=0 width=98% align=center><tr>';
	s += '<td width=22% class=' + body1Style + '>' + date + '</td>';
	s += '<td width=20% class=' + body1Style + '>' + type + '</td>';
	s += '<td width=40% class=' + body1Style + '>' + comment + '</td>';
	s += '<td width=9% class=' + body1Style + ' align=right>' + amount + '</td>';
	s += '<td width=9% class=' + body2Style + ' align=right>' + balance + '</td>';
	s += '</tr></table>';
	document.write(s);
}
