/**
* IP.Tracker 1.3.0
*  - IPS Community Project Developers
* 
* Prototype Javascript
* Last Updated: $Date: 2009-06-12 17:53:19 +0100 (Fri, 12 Jun 2009) $
*
* @author		$Author: alex $
* @copyright	2001 - 2008 Invision Power Services, Inc.
* @license		http://www.invisionpower.com/community/board/license.html
* @package		IP.Tracker
* @subpackage	JavaScript
* @link			http://resources.invisionpower.com
* @version		$Revision: 634 $
*/

var iptracker =
	{
		/* Common Text Variables */
		myStoredSelection: '',
		
		/* Common Array Variables */
		postCache: [],
		ignoreCache: [],
		
		/* Common Integer Variables */
		ajaxLoaded: 1,
		rateValue: 0,
		
		initialize: function()
		{
			/* Check if it has been loaded before we can start */
			document.observe( 'dom:loaded', function()
				{
					iptracker.initEvents();
					//iptracker.resizeImages();
				}
			);
		},
		
		initEvents: function()
		{
			$A( document.getElementsByTagName( 'a' ) ).findAll(
				function( result )
				{
					return ( result.id && result.id.match( /post_([\d]+?)_link/ ) )
				}
			).each(
				function( result )
				{
					var divId = result.id.match( /post_([\d]+?)_link/ );
	
					$( result ).observe( 'click', iptracker.linkToPost.bindAsEventListener( result, divId[1] ) );
				}
			);
			
			/* Set up common delegates */
			ipb.delegate.register( '.bbc_spoiler_show', ipb.global.toggleSpoiler );
			//ipb.delegate.register( '.edit_post', iptracker.ajaxEditShow );
			
			/* Resize Images */
			$$( '.post', '.poll' ).each(
				function( elem )
				{
					ipb.global.findImgs( $( elem ) );
				}
			);
		},
		
		ajaxEditShow: function( e, elem )
		{
			// If user is holding ctrl or command, just submit since they
			// want to open a new tab (requested by Luke)
			if( e.ctrlKey == true || e.metaKey == true || e.keyCode == 91 )
			{
				return false;
			}
			
			Event.stop(e);
			var edit = [];
			
			edit['button'] = elem;
			if( !edit['button'] ){ return; }
			
			edit['pid'] = edit['button'].id.replace('edit_post_', '');
			edit['tid'] = ipb.topic.topic_id;
			edit['fid'] = ipb.topic.forum_id;
			edit['post'] = $( 'post_id_' + edit['pid'] ).down('.post');
			
			// Find post content
			ipb.topic.postcache[ edit['pid'] ] = edit['post'].innerHTML;
	
			url = ipb.vars['base_url'] + 'app=tracker&module=ajax&section=ajax&do=editBoxShow&p=' + edit['pid'] +'&t=' + edit['tid'] +'&f=' + edit['fid'];
			
			// DO TEH AJAX LOL
			new Ajax.Request( url, 
				{
					method: 'post',
					parameters: {
						md5check: 	ipb.vars['secure_hash']
					},
					onSuccess: function(t)
					{
						if( t.responseText == 'nopermission' || t.responseText == 'NO_POST_FORUM' || t.responseText == 'NO_EDIT_PERMS' )
						{
							alert("You don't have permission to edit this post");
							return;
						}
						if( t.responseText == 'error' )
						{
							alert("Error editing this post");
							return;
						}
						
						// Put it in
						edit['post'].update( t.responseText );
						new Effect.ScrollTo( edit['post'], { offset: -50 } );
						
						// Init the editor SKINNOTE: this needs to respect user preference
						ipb.editors[ edit['pid'] ] = new ipb.editor( edit['pid'], USE_RTE );
						
						// Set up events
						if( $('edit_save_' + edit['pid'] ) ){
							$('edit_save_' + edit['pid'] ).observe('click', ipb.topic.ajaxEditSave );
						}
						if( $('edit_switch_' + edit['pid'] ) ){
							$('edit_switch_' + edit['pid'] ).observe('click', ipb.topic.ajaxEditSwitch );
						}
						if( $('edit_cancel_' + edit['pid'] ) ){
							$('edit_cancel_' + edit['pid'] ).observe('click', ipb.topic.ajaxEditCancel );
						}
					}
				}
			);
		},
		
	 	scrollToPost: function( pid )
		{
			if( !pid || !Object.isNumber( pid ) ){ return; }
			$('entry' + pid).scrollTo();
		},
		
		linkToPost: function( e )
		{
			postID = $A(arguments);
			postID.shift();

			temp = prompt( ipb_lang_tt_prompt, ipb.vars['base_url'] + "app=tracker&showissue=" + ipb_input_iid + "&view=findpost&p=" + postID[0] );
			
			Event.stop(e);
			return false;
		},
		
		resizeImages: function()
		{
			if ( ipsclass.settings['do_linked_resize'] != 1 )
			{
				return true;
			}
		
			var images   = document.getElementsByTagName( 'IMG' );
			var _padding = 2;
			var _count   = 0;
			var _img     = '<img src="' + ipb_var_image_url + '/img-resized.png" style="vertical-align:middle" border="0" alt="" />';
			var _img2    = '<img src="' + ipb_var_image_url + '/folder_attach_images/attach_zoom_in.png" style="vertical-align:middle" border="0" alt="" />';
			var _sw      = screen.width * ( parseInt( ipsclass.settings['resize_percent'] ) / 100 );
		
			for ( var i = 0 ; i < images.length; i++ )
			{
				if ( images[i].className == 'linked-image' )
				{
					_count++;

					if ( images[i].width > _sw )
					{
						var _width   = images[i].width;
						var _height  = images[i].height;
						var _percent = 0;

						images[i].width  = _sw;
		
						if ( images[i].width < _width && _width > 0 && images[i].width > 0 )
						{
							_percent = Math.ceil( parseInt( images[i].width / _width * 100 ) );
						}
		
						images[i].id          = '--ipb-img-resizer-' + _count;
						images[i]._resized    = 1;
						images[i]._width      = _width;

						var div = document.createElement( 'div' );
		
						div.innerHTML            = _img + '&nbsp;' + ipsclass.lang_build_string( ipb_global_lang['image_resized'], _percent, _width, _height );
						div.style.width          = images[i].width - ( _padding * 2 ) + 'px';
						div.className            = 'resized-linked-image';
						div.style.paddingTop     = _padding + "px";
						div.style.paddingBottom  = _padding + "px";
						div.style.paddingLeft    = _padding + "px";
						div.style.paddingRight   = _padding + "px";
						div._is_div              = 1;
						div._resize_id           = _count;
						div.onclick              = fix_linked_images_onclick;
						div.onmouseover          = fix_linked_images_mouseover;
						div.title                = ipb_global_lang['click_to_view' ];
						div._src                 = images[i].src;
		
						images[i].parentNode.insertBefore( div, images[i] );
					}
				}
			}
		},
		
		resizeAttachmentImages: function()
		{
			var _img    = '<img src="' + ipb_var_image_url + '/img-resized.png" style="vertical-align:middle" border="0" alt="" />';
			var img_obj = $( 'ipb-attach-img-'   + attach_id );
			var div_obj = $( 'ipb-attach-div-'   + attach_id );
			var ct_obj  = $( 'ipb-attach-ct-'    + attach_id );
			var cb_obj  = $( 'ipb-attach-cb-'    + attach_id );
			var url_obj = $( 'ipb-attach-url-'   + attach_id );
			var tbl_obj = $( 'ipb-attach-table-' + attach_id );
		
			var _width   = parseInt( img_obj.width )  ? parseInt( img_obj.width )  : parseInt( img_obj.style.width );
			var _height  = parseInt( img_obj.height ) ? parseInt( img_obj.height ) : parseInt( img_obj.style.height );
			var _padding = 5;
			var _percent = 0;
		
			if ( is_ie )
			{
				_width  = parseInt( img_obj.currentStyle['width'] );
				_height = parseInt( img_obj.currentStyle['height'] );
			}
		
			if ( is_safari )
			{
				tbl_obj.style.display = 'inline-block';
			}

			if ( width && height )
			{
				_percent = Math.ceil( 100 - parseInt( _width / width * 100 ) );
			}
			
			// Remove IMG class to stop gray border
			img_obj.className     = 'ipb';
			img_obj.title         = ipb_global_lang['click_to_view'];
			img_obj.onmouseover   = fix_attach_images_mouseover;
			img_obj.onclick       = function(event) { ipsclass.pop_up_window( url_obj.href, width + 20, height + 20 ); ipsclass.cancel_bubble(event); };
		
			// Re-style the main div obj
			div_obj.style.width          = ( _width > 140 ? _width : 140 ) + 'px';
			div_obj.style.height         = _height + ( _padding * 2 ) + 28 + 'px';
			div_obj.className            = 'resized-linked-image';
			div_obj.style.paddingTop     = _padding + "px";
			div_obj.style.paddingBottom  = _padding + "px";
			div_obj.style.paddingLeft    = _padding + 3 + "px";
			div_obj.style.paddingRight   = _padding + 3 + "px";
			div_obj.style.textAlign      = 'center';
			div_obj.title                = ipb_global_lang['click_to_view'];
		
			// Add content to the top div
			ct_obj.style.fontSize  = '9px';
			cb_obj.style.fontSize  = '9px';
			cb_obj.style.textAlign = 'center';
		
			if ( _percent > 0 )
			{
				ct_obj.innerHTML = _img + '&nbsp;' + ipsclass.lang_build_string( ipb_global_lang['image_attach_percent'], _percent );
			}
			else
			{
				ct_obj.innerHTML = _img + '&nbsp;' + ipb_global_lang['image_attach_no_percent'];
			}
		
			cb_obj.innerHTML     = "";
		
			if ( width && height )
			{
				cb_obj.innerHTML = ipsclass.lang_build_string( ipb_global_lang['image_attach_dims'], width, height );
			}
		
			cb_obj.innerHTML += ipsclass.lang_build_string( ipb_global_lang['image_attach_size'], file_size );
		},
		
		setPostHidden: function(id)
		{
			if ( $( 'post_id_' + id ).select( '.post_wrap' )[ 0 ] )
			{
				$( 'post_id_' + id ).select( '.post_wrap' )[ 0 ].hide();

				if ( $( 'unhide_post_' + id ) )
				{
					$( 'unhide_post_' + id ).observe( 'click', iptracker.showHiddenPost );
				}
			}
		},
		
		showHiddenPost: function(e)
		{
			link = Event.findElement( e, 'a' );
			id = link.id.replace( 'unhide_post_', '' );
		
			if ( $('post_id_' + id ).select( '.post_wrap' )[ 0 ] )
			{
				elem = $( 'post_id_' + id ).select( '.post_wrap' )[ 0 ];
				new Effect.Parallel( [
					new Effect.BlindDown( elem ),
					new Effect.Appear( elem )
				], { duration: 0.5 } );
			}
		
			if ( $('post_id_' + id ).select( '.post_ignore' )[ 0 ] )
			{
				elem = $( 'post_id_' + id ).select( '.post_ignore' )[ 0 ];
				elem.hide();
			}
		
			Event.stop( e );
		}
	};
	
iptracker.initialize();

function projects_send_marker_update( pid, is_subforum )
{
	//----------------------------------
	// Get current image...
	//----------------------------------

	try
	{
		var imgsrc = document.getElementById( 'p-'+pid ).innerHTML;
		
		if ( imgsrc != '' )
		{
			//----------------------------------
			// Find out what img its using...
			//----------------------------------

			var regex  = new RegExp( "src=['\"](.*/)(" + regex_markers + ")['\"]" );

			var results = imgsrc.match( regex );

			//----------------------------------
			// Got a replacement?
			//----------------------------------

			if ( img_markers[ results[2] ] )
			{
				imgsrc = imgsrc.replace( regex, "src='$1"+img_markers[ results[2] ]+"'" );

				document.getElementById( 'p-' + pid ).innerHTML = imgsrc;
			}
		}
	}
	catch(e){}

	var text_return = 0;

	/*--------------------------------------------*/
	// Main function to do on request
	// Must be defined first!!
	/*--------------------------------------------*/

	do_request_function = function()
	{
		//----------------------------------
		// Ignore unless we're ready to go
		//----------------------------------

		if ( ! xmlobj.readystate_ready_and_ok() )
		{
			// Could do a little loading graphic here?
			return;
		};

		//----------------------------------
		// Do nothing
		//----------------------------------

		text_return = xmlobj.xmlhandler.responseText;
	};

	xmlobj = new ajax_request();
	xmlobj.onreadystatechange( do_request_function );

	xmlobj.process( ipb_var_base_url + 'autocom=tracker&req=xml&do=mark-project-read&pid=' + pid + '&sf=' + is_subforum );
}

/*--------------------------------------------*/
// Initiate topic hide
/*--------------------------------------------*/

function issue_init_ignored_post( pid )
{
	try
	{
		// Set up
		var post_main   = document.getElementById( 'post-main-'   + pid );
		var post_ignore = document.getElementById( 'post-ignore-' + pid );
		
		// Cache it...
		ignore_cache[ pid ] = post_main.innerHTML;
		
		// Display "ignored" msg
		post_main.innerHTML = post_ignore.innerHTML;
	}
	catch( e )
	{
		//alert( e );
	}
}

/*--------------------------------------------*/
// Add onload event
/*--------------------------------------------*/

//add_onload_event( fix_linked_image_sizes );

/*--------------------------------------------*/
// Fix linked images (attach thumbs)
/*--------------------------------------------*/

function fix_linked_image_sizes_attach_thumb( attach_id, width, height, file_size )
{
}

/*--------------------------------------------*/
// Fix linked images (normal IMGs)
/*--------------------------------------------*/

function fix_linked_image_sizes()
{
	if ( ipsclass.settings['do_linked_resize'] != 1 )
	{
		return true;
	}

	var images   = document.getElementsByTagName( 'IMG' );
	var _padding = 2;
	var _count   = 0;
	var _img     = '<img src="' + ipb_var_image_url + '/img-resized.png" style="vertical-align:middle" border="0" alt="" />';
	var _img2    = '<img src="' + ipb_var_image_url + '/folder_attach_images/attach_zoom_in.png" style="vertical-align:middle" border="0" alt="" />';
	var _sw      = screen.width * ( parseInt( ipsclass.settings['resize_percent'] ) / 100 );

	for ( var i = 0 ; i < images.length; i++ )
	{
		if ( images[i].className == 'linked-image' )
		{
			//-----------------------------------------
			// Inc. counter
			//-----------------------------------------

			_count++;

			//-----------------------------------------
			// Set up basics...
			//-----------------------------------------

			if ( images[i].width > _sw )
			{
				//-----------------------------------------
				// Grab some details...
				//-----------------------------------------

				var _width   = images[i].width;
				var _height  = images[i].height;
				var _percent = 0;

				//-----------------------------------------
				// Work out percentage
				//-----------------------------------------

				images[i].width  = _sw;

				if ( images[i].width < _width && _width > 0 && images[i].width > 0 )
				{
					_percent = Math.ceil( parseInt( images[i].width / _width * 100 ) );
				}

				images[i].id          = '--ipb-img-resizer-' + _count;
				images[i]._resized    = 1;
				images[i]._width      = _width;

				//-----------------------------------------
				// Add in wrapper
				//-----------------------------------------

				var div = document.createElement( 'div' );

				div.innerHTML            = _img + '&nbsp;' + ipsclass.lang_build_string( ipb_global_lang['image_resized'], _percent, _width, _height );
				div.style.width          = images[i].width - ( _padding * 2 ) + 'px';
				div.className            = 'resized-linked-image';
				div.style.paddingTop     = _padding + "px";
				div.style.paddingBottom  = _padding + "px";
				div.style.paddingLeft    = _padding + "px";
				div.style.paddingRight   = _padding + "px";
				div._is_div              = 1;
				div._resize_id           = _count;
				div.onclick              = fix_linked_images_onclick;
				div.onmouseover          = fix_linked_images_mouseover;
				div.title                = ipb_global_lang['click_to_view' ];
				div._src                 = images[i].src;

				//-----------------------------------------
				// Add it all...
				//-----------------------------------------

				//if ( is_ie && ! is_ie7 )
				//{
				//	images[i].outerHTML = div.outerHTML + images[i].outerHTML;
				//}
				//else
				//{
					images[i].parentNode.insertBefore( div, images[i] );
				//}
			}
		}
	}
}

function fix_linked_images_onclick(e)
{
	//-----------------------------------------
	// Div clicked 
	//-----------------------------------------

	PopUp( this._src, 'popup',screen.width,screen.height,1,1,1);

	e = ipsclass.cancel_bubble_all( e );

	return false;
};

function fix_attach_images_mouseover(e)
{
	//-----------------------------------------
	// Change cursor...
	//-----------------------------------------

	try
	{
		this.style.cursor='pointer';
	}
	catch(acold)
	{
	}
}

function fix_linked_images_mouseover(e)
{
	try
	{
		this.style.cursor='pointer';
	}
	catch(acold)
	{
	}

}

/*--------------------------------------------*/
// Ajax: Use full editor
/*--------------------------------------------*/

function ajax_fulleditor_for_edit( post_id )
{
	if ( post_id && ipb_input_t && ipb_input_f )
	{
		var _form = document.getElementById( 'quick-edit-form-' + post_id );
		var _url  = ipb_var_base_url + 'autocom=tracker&req=postedit&pid=' + ipb_input_pid + '&iid=' + ipb_input_iid + '&p=' + post_id + '&st=' + ipb_var_st + '&_from=quickedit';

		_form.action = _url;
		_form.method = 'POST';

		_form.submit();

		xmlobj.show_loading();

		return false;
	}
	else
	{
		return false;
	}
}

/*--------------------------------------------*/
// Ajax: Cancel for edit
/*--------------------------------------------*/

function ajax_cancel_for_edit( post_id )
{
	if ( post_cache[ post_id ] != "" )
	{
		document.getElementById( 'post-'+post_id ).innerHTML = post_cache[ post_id ];
	}

	return false;
}

/*--------------------------------------------*/
// Ajax: Save for edit
/*--------------------------------------------*/

function ajax_save_for_edit( post_id )
{
	//----------------------------------
	// INIT
	//----------------------------------

	var url    = ipb_var_base_url+'autocom=tracker&req=xml&do=post-edit-save&p='+post_id+'&iid='+ipb_input_iid+'&pid='+ipb_input_pid;
	var fields = new Array();

	//----------------------------------
	// Populate fields
	//----------------------------------

	fields['md5check']         = ipb_md5_check;
	fields['iid']              = ipb_input_iid;
	fields['pid']              = ipb_input_pid;
	fields['p']                = post_id;
	fields['autocom']          = 'tracker';
	fields['req']              = 'xml';
	fields['do']               = 'post-edit-save';
	fields['Post']             = document.getElementById( post_id + '_textarea' ).value;
	fields['std_used']         = 1;  // Make sure STD BBCode parser is used

	//-----------------------------------------
	// Got a reason to be jolly?
	//-----------------------------------------

	try
	{
		fields['post_edit_reason'] = document.getElementById( 'post_edit_reason' ).value;
	}
	catch(err)
	{
	}

	//----------------------------------
	// Is there a post?
	//----------------------------------

	var post_check = fields['Post'];

	if ( post_check.replace( /^\s*|\s*$/g, "" ) == "" )
	{
		alert( js_no_empty_post );
		return false;
	}

	/*--------------------------------------------*/
	// Main function to do on request
	// Must be defined first!!
	/*--------------------------------------------*/

	do_request_function = function()
	{
		//----------------------------------
		// Ignore unless we're ready to go
		//----------------------------------

		if ( ! xmlobj.readystate_ready_and_ok() )
		{
			xmlobj.show_loading();
			return;
		}

		xmlobj.hide_loading();

		//----------------------------------
		// INIT
		//----------------------------------

		var html = xmlobj.xmlhandler.responseText;

		//-----------------------------------------
		// Execute JS...
		//-----------------------------------------

		if ( html == 'nopermission' )
		{
			alert( js_error_no_permission );
			document.getElementById( 'post-'+post_id ).innerHTML = post_cache[ post_id ];
		}
		else if ( html != 'error' )
		{
			document.getElementById( 'post-'+post_id ).innerHTML = html;
			xmlobj.execute_javascript( html );
			fix_linked_image_sizes();
		}
	};

	//----------------------------------
	// LOAD XML
	//----------------------------------

	xmlobj = new ajax_request();
	xmlobj.onreadystatechange( do_request_function );
	var xmlreturn = xmlobj.process( url, 'POST', xmlobj.format_for_post(fields) );

	return false;
}

/*--------------------------------------------*/
// Ajax: Prep for edit
/*--------------------------------------------*/

function ajax_prep_for_edit( post_id, event )
{
	//----------------------------------
	// Cancel bubble (Prevent IE scroll...)
	//----------------------------------

	global_cancel_bubble( event, true );

	var post_main_obj = document.getElementById( 'post-main-' + post_id );
	var post_box_top  = _get_obj_toppos( post_main_obj );

	//----------------------------------
	// INIT
	//----------------------------------

	var url = ipb_var_base_url+'autocom=tracker&req=xml&do=post-edit-show&p='+post_id+'&iid='+ipb_input_iid+'&pid='+ipb_input_pid;

	post_cache[ post_id ] = document.getElementById( 'post-'+post_id ).innerHTML;

	//----------------------------------
	// Attempt to close open menus
	//----------------------------------

	try
	{
		menu_action_close();
	}
	catch(e)
	{
		//alert( e );
	}

	/*--------------------------------------------*/
	// Main function to do on request
	// Must be defined first!!
	/*--------------------------------------------*/

	do_request_function = function()
	{
		//----------------------------------
		// Ignore unless we're ready to go
		//----------------------------------

		if ( ! xmlobj.readystate_ready_and_ok() )
		{
			xmlobj.show_loading();
			return;
		}

		xmlobj.hide_loading();

		//----------------------------------
		// INIT
		//----------------------------------

		var html = xmlobj.xmlhandler.responseText;

		if ( html == 'nopermission' )
		{
			alert( js_error_no_permission );
		}
		else if ( html != 'error' )
		{
			if ( post_box_top )
			{
				scroll( 0, post_box_top - 30 );
			}

			document.getElementById( 'post-' + post_id ).innerHTML = html;

			//-----------------------------------------
			// Set up new editor
			//-----------------------------------------

			IPS_Lite_Editor[ post_id ] = new ips_text_editor_lite( post_id );
			IPS_Lite_Editor[ post_id ].init();
		}
	};

	//----------------------------------
	// LOAD XML
	//----------------------------------

	xmlobj = new ajax_request();
	xmlobj.onreadystatechange( do_request_function );

	xmlobj.process( url );

	return false;
}

/*--------------------------------------------*/
// check selection
/*--------------------------------------------*/

function checkselection()
{
	var myselection = '';

	if ( window.getSelection )
	{
		myselection = window.getSelection();
	}
	else if ( document.selection )
	{
		myselection = document.selection.createRange().text;
	}
	else if ( document.getSelection )
	{
		myselection = document.getSelection();
	}

	if ( myselection != '' && myselection != null )
	{
		if ( myselection != mystored_selection )
		{
			document.getElementById('fastreply-pastesel').style.display = '';
			mystored_selection = (myselection.toString() != '') ? myselection.toString() : null;
		}
	}
	else
	{
		mystored_selection = null;
	}
}

/*--------------------------------------------*/
// Paste selection
/*--------------------------------------------*/

function pasteselection()
{
	if ( mystored_selection != '' && mystored_selection != null )
	{
		var fr = document.getElementById('fastreplyarea');
		if (fr)
		{
			fr.value += '[quote]'+mystored_selection+'[/quote]\n';
			fr.focus();
		}
	}

	return false;
}

/*--------------------------------------------*/
// Delete post
/*--------------------------------------------*/

function delete_post(theURL)
{
	if (confirm( ipb_lang_js_del_1 ))
	{
		window.location.href=theURL;
	}
	else
	{
		alert ( ipb_lang_js_del_2 );
	} 
}

/*--------------------------------------------*/
// Multi quote
/*--------------------------------------------*/

function multiquote_add(id)
{
	saved = new Array();
	clean = new Array();
	add   = 1;

	//-----------------------------------
	// Get any saved info
	//-----------------------------------

	if ( tmp = my_getcookie('mqtids') )
	{
		saved = tmp.split(",");
	}

	//-----------------------------------
	// Remove bit if exists
	//-----------------------------------

	for( i = 0 ; i < saved.length; i++ )
	{
		if ( saved[i] != "" )
		{
			if ( saved[i] == id )
			{
				 add = 0;
			}
			else
			{
				clean[clean.length] = saved[i];
			}
		}
	}

	//-----------------------------------
	// Add?
	//-----------------------------------

	if ( add )
	{
		clean[ clean.length ] = id;
		eval("document.mad_"+id+".src=removequotebutton");
		eval("document.mad_"+id+".title='-'");
	}
	else
	{
		eval(" document.mad_"+id+".src=addquotebutton");
		eval("document.mad_"+id+".title='+'");
	}

	my_setcookie( 'mqtids', clean.join(','), 0 );

	return false;
}

