
jQuery(function($) {

	$('#reg').replaceWith('<button id="reg" type="button" class="button">Register</button>'); /* This is an IE bugfix to replace the link which doesn't get drawn properly */
	$('#reg').click(function(){
		window.location = 'http://dinetoread.ie/forums/register.php';
	});

	$('#postform').submit(function () {
		if ( $('#topic').length && !$('#topic').focus().val() ) {
			alert( 'Please enter a topic title.' );
			return false;
		} else if ( !$('#post_content').focus().val() ) {
			alert( 'Please enter some content for your post!' );
			return false;
		}
	});

	$('#bookmeta a.delete').click(function(){
		if ( confirm( 'Remove this book from this topic?' ) ) {
			strHref = $(this).attr('href');
			$.post(wpListL10n.url, {
				action      : 'remove_topic_book',
				topic_id    : $.getURLParam( '_id', strHref ),
				_ajax_nonce : $.getURLParam( '_wpnonce', strHref )
			});
			$('#bookmeta').css('background','#f00').slideUp('slow');
		}
		return false;
	});

} );


/* Copyright (c) 2006 Mathias Bank (http://www.mathias-bank.de)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) 
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 * 
 * Thanks to Hinnerk Ruemenapf - http://hinnerk.ruemenapf.de/ for bug reporting and fixing.
 */
jQuery.extend({
	/**
	* Returns get parameters.
	*
	* If the desired param does not exist, null will be returned
	*
	*/ 
	getURLParam : function(strParamName,strHref) {
		var rtn = null;
		if ( !strHref )
			var strHref = window.location.href;
		var cmpstring = strParamName + '=';
		var cmplen = cmpstring.length;

		if ( strHref.indexOf('?') > -1 ){
			var aQueryString = strHref.substr( strHref.indexOf('?') + 1 ).split('&');
			for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
				if (aQueryString[iParam].substr(0,cmplen)==cmpstring){
					var aParam = aQueryString[iParam].split('=');
					rtn = aParam[1];
					break;
				}
			}
		}
		return rtn;
	}
});

