function redirect( url, timeout ) {
	setTimeout( "document.location.href='"+url+"'", timeout );
}

function matchPasswords( pw1, pw2 ) {
	if( pw1.value == pw2.value ) {
		pw1.style.borderColor = 'lime';
		pw2.style.borderColor = 'lime';
	}
	else {
		pw1.style.borderColor = 'red';
		pw2.style.borderColor = 'red';
	}
}

function popup( url, title, options ) {
	if( url == undefined )
		return;
	if( title == undefined )
		title = url;
	var finalOptions = "height=300,width=400,location=no,menubar=no,toolbar=no,status=no";
	if( options != undefined )
		finalOptions = options + "," + finalOptions;
	var win = window.open( url, title, finalOptions );
	win.focus();
}

function rate( quoteid, rating ) {
	popup( baseURL+"mod=quotes&page=rate&quoteid="+quoteid+"&rating="+rating, "Rate Quote #"+quoteid, "height=150" );
}

function comments( quoteid ) {
	if( quoteid == undefined || quoteid < 1 || !parseInt( quoteid ) )
		return;
	popup( baseURL+"mod=comments&page=show&quoteid="+quoteid, "Comments for Quote #"+quoteid, "height=500,width=820" );
}

function toggleDisplay( id ) {
	var el = document.getElementById( id );
	if( el ) {
		if( el.style.display == 'block' )
			el.style.display = 'none';
		else
			el.style.display = 'block';
	}
}

function goToComment(rawQuoteId) {
	var quoteId = parseInt(rawQuoteId);
	if (quoteId > 0)
		document.location.href='?mod=comments&page=show&quoteid='+quoteId;
}