boardScript = '/cgi-bin/newboard/admin.cgi';
mTest = /message:(\d+)/i;
bTest = /board:(\d+)/i;
$( function () {
	$('span#vitc').wrap( '<a href="' + boardScript + '?vitc=1" title="Click to edit..."></a>' );
	// maxSize = 400;
	// images = $('.gbbs img').not('.icon');
	// for (	i = 0; i < images.length; i ++ ) {
	// 	img = $(images[i]);
	// 	if (	img.width() > maxSize ) {
	// 		// d( i + ': ' + img.width()) + ', resizing';
	// 		img.attr( { alt: 'Too big, attempted to resize! Also if you are seeing this instead of the image, ' + img.src() + ' is not loading. Click to try again.', width: maxSize + 'px' } ).css( { width: maxSize + 'px', border: '#f00 2px solid' } ).wrap( '<a title="Too big - click to view..." href="' + img.src() + '"></a>' );
	// 	}
	// }
	$('img[@maxwidth]').each( function () {
		if (	$(this).width( ) > 600 ) {
			$(this).width( '600px' );
		}
	} );
	if (	1 == 0 && $.browser.mozilla && window.user && s[window.user] ) { // works in other browser, but too slow to render
		$('.message').not('.reply').addClass('draggable').Draggable( {
			handle: 'h4',
			zIndex: 1000,
			// ghosting: true,
			opacity: 0.7,
			cursorAt: {
				top: 5,
				left: 5
			},
			revert: true
		} );
		$('.message').not('.reply').append('<ul class="dropInstructions"><li>Drop a message here to attach it to this thread</li></ul>').Droppable( {
			accept : 'message',
			activeclass: 'dropzoneactive',
			hoverclass: 'dropzonehover',
			ondrop: function ( drag ) {
				dragId = 0;
				dropId = 0;
				if (	mTest.test( $(drag).id() ) == true ) {
					dragId = RegExp.$1;
				}
				if (	mTest.test( $(this).id() ) == true ) {
					dropId = RegExp.$1;
				}
				if (	dragId && dropId && dragId != dropId && confirm( 'Really attach #' + dragId + ' to #' + dropId + '?' )) {
					$.post( boardScript,
						{ table: 'message', mode: 'move', key: dragId, confirm: 1, newParent: dropId },
						function( data ) {
							$(drag).empty().parent().slideUp('slow');
							// data = data.replace( /</g, '[' );
							// data = data.replace( />/g, ']' );
							d( 'data was ' + data.length + ' chars' );
							d( '<pre>' + data + '</pre>' );
						}
					);
				}
				// else {	d( "failed" );
				// }
			},
			fit: true // no trailing comma
		} );
		$('#header a.board').Droppable( {
			accept : 'message',
			activeclass: 'dropzoneactive',
			hoverclass: 'dropzonehover',
			ondrop: function ( drag ) {
				dragId = 0;
				dropId = 0;
				if (	mTest.test( $(drag).id() ) == true ) {
					dragId = RegExp.$1;
				}
				if (	bTest.test( $(this).attr('class') ) == true ) {
					dropId = RegExp.$1;
				}
				if (	dragId && dropId && dragId != dropId && confirm( 'Really move #' + dragId + ' to board ' + dropId + '?' )) {
					$.post( boardScript,
						{ table: 'message', mode: 'move', key: dragId, confirm: 1, newBoard: dropId },
						function( data ) {
							$(drag).empty().parent().slideUp('slow');
							// data = data.replace( /</g, '[' );
							// data = data.replace( />/g, ']' );
							// d( 'data was ' + data.length + ' chars' );
							// d( '<pre>' + data + '</pre>' );
						}
					);
				}
				// else {	d( "failed" );
				// }
			},
			fit: true // no trailing comma
		} );
	}
} );

