/*
* Gallery jscript functions
* By Brandon Farber
*/
var gal_ignore_cache		= new Array();
var addquotebutton     		= ipb_var_image_url + "/p_mq_add.gif";
var removequotebutton  		= ipb_var_image_url + "/p_mq_remove.gif";
var unselectedbutton 		= ipb_var_image_url + "/topic_unselected.gif";
var selectedbutton   		= ipb_var_image_url + "/topic_selected.gif";
var lang_gobutton    		= "With selected";
var gallery_lang_prompt 	= "Link to Image:";
var centerdiv;

var	rate_value				= 0;

var ids_to_imgs				= new Array();

// Image editor stuff
var the_image;
var actual_image;
var text_area 				= new Array();

var quote_start_x 			= 0;
var quote_start_y 			= 0;

var var_image_height 		= 0;
var var_image_width 		= 0;
var meta_loaded				= 0;

var image 					= new Array();

var _this_select_all 		= 0;



/**
* init_image_editor()
*
* Setup the image editor
* @since 2.1.0-2006.04.17
*/
function init_image_editor( img_h, img_w )
{
	//
	// Set hXw
	//
	var_image_height = img_h;
	var_image_width = img_w;
	
	//
	// Image container Div
	//
	actual_image = document.getElementById( 'actualImage' );
	
	//
	// Set some style
	//
	actual_image.style.height = var_image_height + 'px';
	actual_image.style.width = var_image_width + 'px';
	
	//
	// Set the TD container height
	//
	document.getElementById( 'imageContainer' ).style.height = actual_image.style.height + 10 + 'px';
};


function gallery_meta()
{
	var meta_main    = document.getElementById( 'showmeta' );
	var meta_drag    = document.getElementById( 'meta-drag' );
	var meta_content = document.getElementById( 'meta-content' );
	
	//----------------------------------
	// Not loaded? INIT
	//----------------------------------
	
	if ( ! meta_loaded )
	{
		//----------------------------------
		// Figure width and height
		//----------------------------------
		
		var my_width  = 0;
		var my_height = 0;
		
		if ( typeof( window.innerWidth ) == 'number' )
		{
			//----------------------------------
			// Non IE
			//----------------------------------
		  
			my_width  = window.innerWidth;
			my_height = window.innerHeight;
		}
		else if ( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
		{
			//----------------------------------
			// IE 6+
			//----------------------------------
			
			my_width  = document.documentElement.clientWidth;
			my_height = document.documentElement.clientHeight;
		}
		else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
		{
			//----------------------------------
			// Old IE
			//----------------------------------
			
			my_width  = document.body.clientWidth;
			my_height = document.body.clientHeight;
		}
		
		//----------------------------------
		// Get div height && width
		//----------------------------------
		
		var divheight = parseInt( meta_main.style.Height );
		var divwidth  = parseInt( meta_main.style.Width );
		
		divheight = divheight ? divheight : 400;
		divwidth  = divwidth  ? divwidth  : 400;
		
		//----------------------------------
		// Got it stored in a cookie?
		//----------------------------------
		
		var divxy = my_getcookie( 'ipb-meta-div' );
		var co_ords;
		
		if ( divxy && divxy != null )
		{
			co_ords = divxy.split( ',' );
		
			//----------------------------------
			// Got co-ords?
			//----------------------------------
			
			if ( co_ords.length )
			{
				var final_width  = co_ords[0];
				var final_height = co_ords[1];
				
				if ( co_ords[0] > my_width )
				{
					//----------------------------------
					// Keep it on screen
					//----------------------------------
					
					final_width = my_width - divwidth;
				}
				
				if ( co_ords[1] > my_height )
				{
					//----------------------------------
					// Keep it on screen
					//----------------------------------
					
					final_height = my_height - divheight;
				}
				
				meta_main.style.left = final_width  + 'px';
				meta_main.style.top  = final_height + 'px';
			}
		}
		else
		{
			//----------------------------------
			// Reposition DIV roughly centered
			//----------------------------------
			
			meta_main.style.left = my_width  / 2  - (divwidth / 2)  + 'px';
			meta_main.style.top  = my_height / 2 - (divheight / 2 ) + 'px';
		}
		
		Drag.cookiename = 'ipb-meta-div';
		Drag.init( meta_drag, meta_main );
		
		meta_loaded = 1;
	}
	
  	meta_main.style.position = 'absolute';
	meta_main.style.display  = 'block';
	meta_main.style.zIndex   = 99;
	
	if ( is_ie )
	{
		var html = meta_content.innerHTML;
		
		html = "<iframe id='meta-shim' src='" + ipb_var_image_url + "/iframe.html' class='iframshim' scrolling='no' frameborder='0' style='position:absolute; top:0px; left:0px; right:0px; display: none;'></iframe>" + html;
		
		meta_content.innerHTML = html;
	}
	
	//----------------------------------
	// Stop IE showing select boxes over
	// floating div [ 1 ]
	//----------------------------------
			
	if ( is_ie )
	{
		var drag_html		= meta_drag.innerHTML;
		var main_drag_html 	= "<iframe id='meta-shim-two' src='" + ipb_var_image_url + "/iframe.html' class='iframshim' scrolling='no' frameborder='0' style='position:absolute; top:0px; left:0px; right:0px; display: none;'></iframe>" + drag_html;
		
		meta_drag.innerHTML = main_drag_html;
	}		
	
	//----------------------------------
	// Stop IE showing select boxes over
	// floating div [ 2 ]
	//----------------------------------
	
	if ( is_ie )
	{
		meta_shim               = document.getElementById('meta-shim');
		meta_shim.style.width   = meta_content.offsetWidth;
		meta_shim.style.height  = meta_content.offsetHeight;
		meta_shim.style.zIndex  = meta_content.style.zIndex - 1;
		meta_shim.style.top     = meta_content.style.top;
		meta_shim.style.left    = meta_content.style.left;
		meta_shim.style.display = "block";

		meta_shim_d               = document.getElementById('meta-shim-two');
		meta_shim_d.style.width   = meta_drag.offsetWidth;
		meta_shim_d.style.height  = meta_drag.offsetHeight;
		meta_shim_d.style.zIndex  = meta_drag.style.zIndex - 1;
		meta_shim_d.style.top     = meta_drag.style.top;
		meta_shim_d.style.left    = meta_drag.style.left;
		meta_shim_d.style.display = "block";			
	}
	

}

/**
* save_tags()
*
* Save the image tags
* @since 2.1.0-2006.04.19
**/
function save_tags()
{
	//
	// URL
	//
	var url = ipb_base_url;
	
	//
	// Setup the save handler
	//
	do_request_function = function()
	{
		//----------------------------------
		// Ignore unless we're ready to go
		//----------------------------------
		
		if ( ! xmlobj.readystate_ready_and_ok() )
		{
			xmlobj.show_loading( 'Saving Tags...' );
			return;
		}
		
		xmlobj.hide_loading();
		
		//----------------------------------
		// INIT
		//----------------------------------
		
		var html = xmlobj.xmlhandler.responseText;
	};
	
	xmlobj = new ajax_request();
	xmlobj.onreadystatechange( do_request_function );
	xmlobj.process( url );
	
	//
	// Hide Again
	//
	document.getElementById( 'tag_edit_box' ).style.display = 'none';
};

/**
* create_quote_box()
*
* Start creating a quote box in a certain
* spot on an image
* @since 2.1.0-2006.04.17
*/
function create_quote_box()
{
	//
	// Create the Div
	//
	quote_div = document.getElementById( 'quote_div' );
	
	//
	// Set visible
	//
	quote_div.style.display = 'block';
	
	//
	// Grab the left:top coords of the image box
	//
	image['top'] = _get_obj_toppos( actual_image );
	image['left'] = _get_obj_leftpos( actual_image );
	
	//
	// Now, set the top/left coords
	// of the quote_div to the image + 5
	//
	quote_div.style.top = image['top'] + 5 + 'px';
	quote_div.style.left = image['left'] + 5 + 'px';
	
	//
	// Do some math to figure out bottom+right
	//
	image['right'] = image['left'] + parseInt( var_image_width );
	image['bottom'] = image['top'] + parseInt( var_image_height );
	
	//
	// Knock off the current width of the quote box
	// to create the 'barrier'
	//
	image['right_barrier'] = image['right'] - parseInt( quote_div.style.width );
	image['bottom_barrier'] = image['bottom'] - parseInt( quote_div.style.height );
	
	//
	// Set the box to be draggable
	//
	Drag.init( quote_div, quote_div, image['left'], image['right_barrier'], image['top'], image['bottom_barrier'] );
	
	//
	// Set onmouseup
	//
	quote_div.onmouseup = pop_text_area;
	
	//
	// Change the Link to 'end_quote_box'
	//
	document.getElementById( 'quote_url' ).href = 'javascript:alert( "You have to save the current quote box first." );';
	document.getElementById( 'quote_text' ).innerHTML = '<s>Create Quote Box</s>';
};

/**
* pop_tag_box()
*
* Drop the tag editing box down
* @since 2.1.0-2006.04.18
**/
function pop_tag_box()
{
	//
	// Set display
	//
	document.getElementById( 'tag_edit_box' ).style.display = 'block';
};

/**
* pop_text_area()
*
* Drops the textbox down below the quote div
* @since 2.1.0-2006.04.18
**/
function pop_text_area( event )
{
	//
	// Grab
	//
	text_area['box'] = document.getElementById( 'quote_textarea' );
	text_area['container'] = document.getElementById( 'textarea_div' );
	
	//
	// Send the container div below the quote div
	//
	text_area['container'].style.top =  parseInt( _get_obj_toppos( quote_div ) ) + parseInt( quote_div.style.height ) + 'px';
	text_area['container'].style.left = parseInt( quote_div.style.left ) - 5 + 'px';
	
	//
	// Set display
	// 
	text_area['container'].style.display = 'block';
	text_area['box'].style.display = 'block';
};

/**
* end_quote_box()
*
* End the quotebox, commit to cookie * area map
* @since 2.1.0-2006.04.17
*/
function end_quote_box()
{	
	//
	// URL
	//
	var url = ipb_base_url;
	
	//
	// Setup the save handler
	//
	do_request_function = function()
	{
		//----------------------------------
		// Ignore unless we're ready to go
		//----------------------------------
		
		if ( ! xmlobj.readystate_ready_and_ok() )
		{
			xmlobj.show_loading( 'Saving Quote Box...' );
			return;
		}
		
		xmlobj.hide_loading();
		
		//----------------------------------
		// INIT
		//----------------------------------
		
		var html = xmlobj.xmlhandler.responseText;
	};
	
	xmlobj = new ajax_request();
	xmlobj.onreadystatechange( do_request_function );
	xmlobj.process( url );
	
	//
	// Hide the quote div/text area
	//
	text_area['container'].style.display = 'none';
	quote_div.style.display = 'none';
	
	//
	// Change the Link to 'create_quote_box'
	//
	document.getElementById( 'quote_url' ).href = 'javascript:create_quote_box();';
	document.getElementById( 'quote_text' ).innerHTML = 'Create Quote Box';
};

/**
* track_quote_box()
*
* Track XY stuff
* @since 2.1.0-2006.04.17
*/
function track_quote_box( event )
{
	change_cursor( 'move' );
};

/**
* upload_pane_init()
*
* Run before showing pane, sets up 
* the dragging handles
* @since 2.1.0-2006.04.14
*/
function upload_pane_init()
{
	var pane_main = document.getElementById( 'gallery_upload' );
	var pane_drag = document.getElementById( 'upload-drag' );
	
	//
	// Send to Drag
	//
	Drag.init( pane_drag, pane_main );
};

/**
* gallery_upload_pane()
*
* Pops up the advanced gallery upload pane
* @since 2.1.0-2006.04.14
*/
function gallery_upload_pane()
{
	//
	// Run init routine for dragging
	//
	upload_pane_init();
	
	//
	// Get center routine
	//
	centerdiv = new center_div();
	centerdiv.divname = 'gallery_upload';
	centerdiv.move_div();
};

function gallery_link_to_post(pid,img)
{
	temp = prompt( gallery_lang_prompt, ipb_var_base_url + "autocom=gallery&req=si&img=" + img + "&findpid=" + pid );
	return false;
};

function delete_img(theURL) 
{
	if (confirm( lang_suredelete ))
	{
		window.location.href=theURL;
	}
	else
	{
		alert ( ipb_lang_js_del_2 );
	} 
};

function gallery_toggle_pid( id )
{
	saved = new Array();
	clean = new Array();
	add   = 1;
	
	//-----------------------------------
	// Get form info
	//-----------------------------------
	
	tmp = document.modform.selectedgcids.value;
	
	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.pid"+id+".src=selectedbutton");
	}
	else
	{
		eval(" document.pid"+id+".src=unselectedbutton");
	}
	
	newvalue = clean.join(',');
	
	my_setcookie( 'modgcids', newvalue, 0 );
	
	document.modform.selectedgcids.value = newvalue;
	
	newcount = stacksize(clean);
	
	document.modform.gobutton.value = lang_gobutton + '(' + newcount + ')';
	
	return false;
};

/*--------------------------------------------*/
// Multi quote ( From ibf_topic.js )
/*--------------------------------------------*/

function multiquote_add(id)
{
	saved = new Array();
	clean = new Array();
	add   = 1;
	
	//-----------------------------------
	// Get any saved info
	//-----------------------------------
	
	if ( tmp = my_getcookie('gal_pids') )
	{
		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");
	}
	else
	{
		eval(" document.mad_"+id+".src=addquotebutton");
	}
	
	my_setcookie( 'gal_pids', clean.join(','), 0 );
	
	return false;
};

function gallery_toggle_img( id )
{
	saved = new Array();
	clean = new Array();
	add   = 1;
	
	//-----------------------------------
	// Get form info
	//-----------------------------------
	
	tmp = document.modform.selectedimgids.value;
	
	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.img"+id+".src=selectedbutton");
	}
	else
	{
		eval(" document.img"+id+".src=unselectedbutton");
	}
	
	newvalue = clean.join(',');
	
	my_setcookie( 'modimgids', newvalue, 0 );
	
	document.modform.selectedimgids.value = newvalue;
	
	newcount = stacksize(clean);
	
	document.modform.gobutton.value = ipsclass.html_entity_decode( lang_gobutton ) + ' (' + newcount + ')';
	
	return false;
};


/*--------------------------------------------*/
// Toggle selection (copy/paste man!!)
/*--------------------------------------------*/

function gallery_select_all()
{
	clean                = new Array();
	saved                = new Array();
	var topics_this_page = new Array();
	
	tmp = document.modform.selectedimgids.value;
	
	if ( tmp != "" )
	{
		saved = tmp.split(",");
	}
	
	if( _this_select_all == 0 )
	{
		var the_topics = document.getElementsByTagName('input');
		
		for ( var i = 0 ; i <= the_topics.length ; i++ )
		{
			var e = the_topics[i];
			
			if ( e && (e.type == 'hidden') && (! e.disabled) )
			{
				var s = e.id;
				var a = s.replace( /^img_(.+?)$/, "$1" );
				//alert(a);
				if ( a )
				{
					try
					{
						document.getElementById( 'img' + a ).src = selectedbutton;
						clean[clean.length]   = a;
						topics_this_page[ a ] = 1;
					}
					catch(err)
					{
					}
				}
			}
		}
		
		document.getElementById( 'imgs-all' ).src = selectedbutton;
		
		_this_select_all = 1;
	}
	else
	{
		var the_topics = document.getElementsByTagName('input');
		
		for ( var i = 0 ; i <= the_topics.length ; i++ )
		{
			var e = the_topics[i];
			
			if ( e && (e.type == 'hidden') && (! e.disabled) )
			{
				var s = e.id;
				var a = s.replace( /^img_(.+?)$/, "$1" );
				//alert(a);
				if ( a )
				{
					try
					{
						document.getElementById( 'img' + a ).src = unselectedbutton;
						topics_this_page[ a ] = 1;
					}
					catch(err)
					{
					}
				}
			}
		}
		
		document.getElementById( 'imgs-all' ).src = unselectedbutton;
		
		_this_select_all = 0;
	}
	
	for( i = 0 ; i < saved.length; i++ )
	{
		if ( saved[i] != "" && topics_this_page[ saved[i] ] != 1 )
		{
			clean[clean.length] = saved[i];
		}
	}		
	
	newvalue = clean.join(',');
	
	my_setcookie( 'modimgids', newvalue, 0 );
	
	document.modform.selectedimgids.value = newvalue;
	
	newcount = stacksize(clean);
	
	document.modform.gobutton.value = ipsclass.html_entity_decode( lang_gobutton ) + ' (' + newcount + ')';
	
	return false;	
}


add_onload_event( fix_linked_image_sizes );


/*--------------------------------------------*/
// Fix linked images (normal IMGs)
/*--------------------------------------------*/

function fix_linked_image_sizes()
{
	if ( ipsclass.settings['do_linked_resize'] != 1 )
	{
		return true;
	}
	else if( popup_type == 'new' )
	{
		return true;
	}
	else if( popup_type == 'lightbox' )
	{
		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="" />';
	
	for ( i = 0 ; i < images.length; i++ )
	{
		if ( images[i].className == 'galattach' )
		{
			//-----------------------------------------
			// Inc. counter
			//-----------------------------------------
			
			_count++;
			
			//-----------------------------------------
			// Grab some details...
			//-----------------------------------------

			var _width   = images[i].width;
			var _height  = images[i].height;
			var _percent = 0;
			var _href	 = images[i].parentNode.href;

			if( _href != 'undefined' && images[i].parentNode.className == 'gal' )
			{
				if( popup_type == 'popup' )
				{
					images[i]._src 		= _href;
					images[i].onclick		= fix_linked_images_onclick;
					images[i].onmouseover	= fix_linked_images_mouseover;
					images[i].title		= ipb_global_lang['click_to_view'];
				}
				else
				{
					var img = document.createElement( 'img' );
					
					//img.onmouseover = fix_linked_images_mouseover;
					//img.onclick     = fix_linked_images_onclick;
					img.id          = '--ipb-img-resizer-' + _count;
					img.title       = ipb_global_lang['click_to_view'];
					img.src			= images[i].src;
					img.className	= images[i].className;
					img.width		= images[i].width;				
					img.height		= images[i].height;
					
					//-----------------------------------------
					// Add in wrapper
					//-----------------------------------------
		
					var div = document.createElement( 'div' );
					
					div.innerHTML            = _img + '&nbsp;' + lang_clickme;
					div.style.width          = img.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.style.position 		 = 'relative';
					div._is_div              = 1;
					div._resize_id           = _count;
					div._src				 = _href;
					
					div.onclick              = fix_linked_images_onclick;
					div.onmouseover          = fix_linked_images_mouseover;
					div.title                = ipb_global_lang['click_to_view'];
					div.appendChild( img );
					
					images[i].parentNode.href = '#';
					images[i].parentNode.className = '';
					
					images[i].parentNode.parentNode.appendChild( div, images[i].parentNode );
					
					images[i].parentNode.parentNode.removeChild( images[i].parentNode );
				}
			}
		}
	}
};

function fix_linked_images_onclick(e)
{
	//-----------------------------------------
	// Div clicked or image?
	//-----------------------------------------
	
	PopUp( this._src, 'popup',screen.width,screen.height,1,1,1);
	
	e = ipsclass.cancel_bubble_all( e );
	
	return false;
};

function fix_linked_images_mouseover(e)
{
	try
	{
		this.style.cursor='pointer';
	}
	catch(acold)
	{
	}
};

/*--------------------------------------------*/
// Show hidden post
/*--------------------------------------------*/

function show_ignored_post( pid )
{
	try
	{
		// Set up
		var post_main   = document.getElementById( 'post-main-'   + pid );
		var post_ignore = document.getElementById( 'post-ignore-' + pid );

		// Show it
		post_main.innerHTML = gal_ignore_cache[ pid ];
	}
	catch( e )
	{
		//alert( e );
	}
	
	return false;
};


/*--------------------------------------------*/
// Initiate topic hide
/*--------------------------------------------*/

function 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...
		gal_ignore_cache[ pid ] = post_main.innerHTML;

		// Display "ignored" msg
		post_main.innerHTML = post_ignore.innerHTML;
	}
	catch( e )
	{
		//alert( e );
	}
};


/*--------------------------------------------*/
// Photostrip
/*--------------------------------------------*/

var photostrip_cell_ids 	= new Array();
var cur_left				= 0;
var cur_right				= 0;
var cur_image				= 0;
var most_left				= 0;
var most_right				= 0;

function slide_init()
{
	if( cur_left > 0 )
	{
		document.getElementById( 'slide_left_buttons' ).style.display = '';
		document.getElementById( 'slide_left_td' ).onmouseover 	= display_mouseover;
		document.getElementById( 'slide_left_td' ).onmouseout	= display_mouseout;
		document.getElementById( 'slide_left_td' ).onclick		= do_onclick_left;
	}
	else
	{
		document.getElementById( 'slide_left_buttons' ).style.display 	= 'none';
		document.getElementById( 'slide_left_td' ).style.cursor 		= 'default';
		document.getElementById( 'slide_left_td' ).className			= 'post1';
		document.getElementById( 'slide_left_td' ).onmouseover 			= '';
		document.getElementById( 'slide_left_td' ).onmouseout 			= '';
		document.getElementById( 'slide_left_td' ).onclick 				= '';
	}
	
	if( cur_right > 0 )
	{
		document.getElementById( 'slide_right_buttons' ).style.display = '';
		document.getElementById( 'slide_right_td' ).onmouseover = display_mouseover;
		document.getElementById( 'slide_right_td' ).onmouseout	= display_mouseout;
		document.getElementById( 'slide_right_td' ).onclick		= do_onclick_right;
	}
	else
	{
		document.getElementById( 'slide_right_buttons' ).style.display 	= 'none';
		document.getElementById( 'slide_right_td' ).style.cursor 		= 'default';
		document.getElementById( 'slide_right_td' ).className			= 'post1';
		document.getElementById( 'slide_right_td' ).onmouseover 		= '';
		document.getElementById( 'slide_right_td' ).onmouseout 			= '';	
		document.getElementById( 'slide_right_td' ).onclick 			= '';
	}
};


function display_mouseover()
{
	this.className 		= 'post2';
	this.style.cursor 	= 'pointer';
};

function display_mouseout()
{
	this.className 		= 'post1';
};

function do_onclick_left( event )
{
	slide_right( event );
};

function do_onclick_right( event )
{
	slide_left( event );
};


function slide_left( event )
{
	global_cancel_bubble( event, true );

	var url = ipb_var_base_url+'autocom=gallery&req=quickch&op=slide_left&img='+cur_right+'&cur_img='+cur_image;

	do_request_function = function()
	{
		if ( ! xmlobj.readystate_ready_and_ok() )
		{
			xmlobj.show_loading( '' );
			return;
		}
		
		xmlobj.hide_loading();
		
		var html = xmlobj.xmlhandler.responseText;

		if ( html == 'nopermission' )
		{
			alert( js_error_no_permission );
		}
		else if ( html != 'nopermission' )
		{
			var data = html.split( '~|~' );
			
			tablerow 	= document.getElementById('photostrip');
			tablerow.deleteCell(1);
			
			var newCell	= tablerow.insertCell(5);
			newCell.width 			= '20%';
			newCell.style.height 	= data[1] +  'px';
			newCell.style.minHeight = data[1] +  'px';
			newCell.align 			= 'center';
			newCell.valign			= 'middle';
			newCell.className		= data[2];
			newCell.id				= data[0];
			newCell.innerHTML		= data[3];
			
			reset_current_ids( tablerow );
			slide_init();
		}
	};

	xmlobj = new ajax_request();
	xmlobj.onreadystatechange( do_request_function );
	
	xmlobj.process( url );
	
	return false;
		
};
	

function slide_right( event )
{
	global_cancel_bubble( event, true );

	var url = ipb_var_base_url+'autocom=gallery&req=quickch&op=slide_right&img='+cur_left+'&cur_img='+cur_image;

	do_request_function = function()
	{
		if ( ! xmlobj.readystate_ready_and_ok() )
		{
			xmlobj.show_loading( '' );
			return;
		}
		
		xmlobj.hide_loading();
		
		var html = xmlobj.xmlhandler.responseText;

		if ( html == 'nopermission' )
		{
			alert( js_error_no_permission );
		}
		else if ( html != 'nopermission' )
		{
			var data = html.split( '~|~' );
			
			tablerow 	= document.getElementById('photostrip');
			tablerow.deleteCell(5);
			
			var newCell	= tablerow.insertCell(1);
			newCell.width 			= '20%';
			newCell.style.height 	= data[1] +  'px';
			newCell.style.minHeight = data[1] +  'px';
			newCell.align 			= 'center';
			newCell.valign			= 'middle';
			newCell.className		= data[2];
			newCell.id				= data[0];
			newCell.innerHTML		= data[3];
			
			reset_current_ids( tablerow );
			slide_init();
		}
	};

	xmlobj = new ajax_request();
	xmlobj.onreadystatechange( do_request_function );
	
	xmlobj.process( url );
	
	return false;
};


function pixel_left_move()
{
};
	

function reset_current_ids( tablerow )
{
	for( var j = 0; j < tablerow.cells.length; j++ )
	{
		if( j == 1 )
		{
			cur_left = tablerow.cells[ j ].id;
		}
		
		if( j == 5 )
		{
			cur_right = tablerow.cells[ j ].id;
		}
	}
};
