// set cookies from javascript using this - swiped from
http://www.dustindiaz.com/top-ten-javascript/
function setcookie(name, value, expires)
{
if(typeof expires == 'undefined') {
expires = 0;
}
var today = new date();
today.settime(today.gettime());
if(expires) {
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new date(today.gettime() + expires);
document.cookie = name + '=' + escape(value) + ((expires) ? ';expires='+expires_date.togmtstring() : '' ) + ';path=/;domain=.newgrounds.com';
}
function divswap(old_div_id, new_div_id)
{
var old_div = $(old_div_id);
var new_div = $(new_div_id);
if((old_div) && (new_div)) {
new_div.style.display = "block";
old_div.style.display = "none";
}
}
function issoftloggedin()
{
return((returncookie(string.fromcharcode(118,109,107,49,100,117,53,108,56,109)) != null) || (returncookie(string.fromcharcode(118,109,107,108,100,117,53,73,56,109)) != null));
}
function loadloginbox()
{
// let's make sure the browser isn't preserving some weird state
if(!(typeof request_in_progress == 'undefined')) {
// this variable may not have been loaded yet, since it's coming from a .js file
request_in_progress = false;
}
// always see if they've got a username cookie to put as a default value in the login box
var username = returncookie(u_cookie);
if(username != null) {
$('lb_username').value = username;
}
// also always check for a # of unread pms, handed off from php
if(unread_pm_count != null) {
// got a value, set it and store it in a cookie
setunreadpmcount(unread_pm_count);
} else {
// didn't get a value. see if we've got anything stored from before, in a cookie
var unread_pm_count_cookie = returncookie(pm_count_cookie_name);
if((unread_pm_count_cookie != null) && (unread_pm_count_cookie > 0)) {
setunreadpmcount(unread_pm_count_cookie);
}
}
// now swap in the appropriate box
if(!(issoftloggedin())) {
// they're not logged in, so show the login form
divswap('loginbox', 'loginbox_notloggedin');
} else {
// they are logged in, so show their account options
// gotta do this here, so the username displays properly on page refreshes
setloggedinusername(username);
divswap('loginbox', 'loginbox_loggedin');
}
}
function setunreadpmcount(value)
{
var new_count = '';
if(value > 0) {
new_count = ' (' + formatnumber(value) + ')';
}
$('unread_pm_count_display').innerhtml = new_count;
setcookie(pm_count_cookie_name, value);
}
function setloggedinusername(name)
{
$('loginbox_username').innerhtml = '<a href="http://' + name.tolowercase() + '.newgrounds.com/">' + name + '</a>';
$(username_fieldname).value = name; // also set the name in the login text field
}
/* disabled for now
document.observe('dom:loaded', function() {
new ajax.autocompleter('topsearch_terms', 'searchhint', '/ajax/searchsuggestion.php', {
onshow: function(e, u) {
$('topsuperbanner').style.visibility = 'hidden';
// positioning is taken care of in css. disregard the search element.
effect.appear(u,{duration:0.15});
},
onhide: function(e, u) {
$('topsuperbanner').style.visibility = 'visible';
new effect.fade(u,{duration:0.15});
},
minchars: 3,
frequency: 0.1,
callback: function(terms) {
return 'topsearch_terms=' + escape(terms.value) + '&topsearch_type=' + $f('topsearch_type');
}
});
});
*/
// assume ads are blocked until imported javascript tells us otherwise
// ]]>
</script>