function rotateImage( pid, color_name, current_view, direction )
{
	var request = new Ajax.Request('/cart/imageserver.php?cmd=rotate_image&pid=' + pid + '&color_name=' + encodeURIComponent(color_name) + '&current_view=' + current_view + '&direction=' + direction, {
			method: 'get',
			onSuccess: doRotation
		});
		function doRotation( response )
		{
		}
}

function preloadRotationImages( pid, color_name )
{
	var request = new Ajax.Request('/cart/imageserver.php?cmd=preload_images&pid=' + pid + '&color_name=' + encodeURIComponent(color_name), {
			method: 'get',
			onSuccess: preloadImages
		});
		
	function preloadImages( response )
	{
	}
}

function SetDefaultImage( pid, color_name )
{
	//document.forms['mForm'].elements['currentView'].value = 'F';
	var request = new Ajax.Request('/cart/imageserver.php?cmd=set_default_image&pid=' + pid + '&color_name=' + encodeURIComponent(color_name), {
			method: 'get',
			onSuccess: setDefault
		});
		
	function setDefault( response )
	{
	}
}

function setColorSelect( select_key, color_name)
{
	window.document.forms['mForm'].elements['currentColor'].value = color_name;
	var fld = window.document.forms['mForm'].elements['color_select'];
	
	
	for(i = 0; i < fld.options.length; i++)
	{
	
		//Issue: When clicking on a swatch color, it would not change the drop-down color. This was caused by the dropdown value being encoded and not matching.
		//Fix: decode the dropdown value
		var escaped_fld = unescape(fld.options[i].value);
		var decoded_fld = escaped_fld.replace(/\+/g, ' ');
		
		var fixed_color_name = color_name.replace(/\®/g, '&reg;');
	
		if(decoded_fld == fixed_color_name)
		{
			fld.options[i].selected = true;
		}
	}
}
