// JavaScript Documentvar defaultUsername = 'Username';var test_cookie = true;function getCookieVal( offset ){	var endstr = document.cookie.indexOf ( ";", offset );	if ( endstr == -1 )	{		endstr = document.cookie.length;	}	return unescape( document.cookie.substring( offset, endstr ) );} function setCookie( name, value ){	var argv = setCookie.arguments;	var argc = setCookie.arguments.length;	var expires = (argc > 2) ? argv[2] : null;	var path = (argc > 3) ? argv[3] : null;	var domain = (argc > 4) ? argv[4] : null;	var secure = (argc > 5) ? argv[5] : false;	document.cookie = name + "=" + escape (value) +	( ( expires == null ) ? "" : ( "; expires=" + expires.toGMTString() ) ) +	( ( path == null ) ? "" : ( "; path=" + path ) ) +	( ( domain == null ) ? "" : ( "; domain=" + domain ) ) +	( ( secure == true ) ? "; secure" : "" );}function deleteCookie ( name ){	var exp = new Date();	exp.setTime ( exp.getTime() - 1 );	setCookie( name, "", exp, cookiePath );} 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 testCookie(){	var expDate = new Date();	//valid one minute	expDate.setTime( expDate.getTime() + ( 60 * 1000 ) );	setCookie( "testCookie", "OK", expDate );	testing = getCookie( "testCookie" );	if ( testing == "OK" )	{		return true;	}	else	{		return false;	}}// Once DOM has loaded$(document).ready(function(){		// Show more comments		$('#more_comments').hide();		$('#show_comments').show().click(function(){			$(this).hide();			$('#more_comments').slideDown(function(){				$('#hide_comments').show();			});		});				$('#hide_comments').click(function(){			$(this).hide();			$('#more_comments').slideUp();			$('#show_comments').show();		});				// Disable submit buttons on click		$('input[type=submit]').click(function(){			$(this).addClass('submit_hidden').hide().clone().insertAfter(this).show().attr('disabled',true).attr('value','Please wait...').addClass('submit_clone');		});		// Login construct		$('#login #pass').hide();		$('#login #dummy_pass').show();		$('#login #user').addClass('pre');		$('p.jhide').hide();						// Login slide		if(window.location.hash == '#l')		{					}		else		{			//$('#login .form').hide();		}				$('#login .head h2 a').click(function(){				$('#login .form').slideToggle(300);				//setTimeout("document.getElementById('user').focus()",300);				});				// Login form submit		$('#login_form').submit(function(){				var uname = document.getElementById('user').value;				var pass = document.getElementById('pass').value;								$.post("dologin.php?ajax=1", { uname: uname, pass: pass },				function(data){					if(data.login.complete == true)					{						window.location.reload();					}					else					{						$('#login .login_error').html('<p>'+ data.login.error +'</p>').show();						$('input[type=submit].submit_clone').remove();						$('input[type=submit].submit_hidden').show().removeClass('submit_hidden');					}				}, "json");								return false;		});				});// Once entire page has loaded$(window).load(function(){				// Login construct		$('#login #user').attr('value',defaultUsername);				// Login fields				$('#login #user').focus(function(){						if($(this).attr('value') == defaultUsername)						{							$(this).removeClass('pre').attr('value','');						}						});				$('#login #dummy_pass').focus(function(){						$(this).hide();						$('#login #pass').show();						document.getElementById('pass').focus();						});				$('#login #user').blur(function(){						if($(this).attr('value') == '')						{							$(this).addClass('pre');							$(this).attr('value',defaultUsername);						}						});				$('#login #pass').blur(function(){						if($(this).attr('value') == '')						{							$(this).hide();							$('#dummy_pass').show();						}						});				// Test for cookies		test_cookie = testCookie();				if(test_cookie !== true)		{			$('#login .cookies_error').html('<p>Cookies are not enabled, please adjust your browser\'s security settings to be able to log in.</p>').show();		}				// Autoexpand textarea		$('textarea.expanding').autogrow();});