function _style(t)
{
	switch( t )
	{
		case 'Add to Cart'		:	$('#dialog').css(
												{
													background: '#fbc587',	color: '#574d56'
												});
		case 'Add to Lightbox'	:	$('#dialog').css(
												{
												
												});
		case 'Confirm'			:	$('#dialog').css(
												{
												
												});
	}
}
	
function showDialog(t, c)
{		
	if( !$('#dialog').length)
	{
		$('body')
			.append('<div id="dialog"></div>');
			
		$('#dialog')
			.css({display: 'none'});
	}
	
	// add style to the dialog
	_style(t);
	
	if( t == 'Add to Cart' )
	{
		var item_type = $('.item-type').html().split('-');
		$("#dialog")
		.html('<img src="' + loadingImage.src + '"/> loading please wait...')
		.load('ajax/cart.php', 'item_type=' + item_type[(item_type.length-1)])
		
		.dialog({
			bgiframe: false,
			title: t,
			width: 570,
			height: 350,
			minHeight: 350,
			minWidth: 570,
			maxHeight: 450,
			maxWidth: 802,
			zIndex: 10001,
			modal: true,
			resizable: true,
			closeOnEscape: true,
			buttons: 
			{
				'Add to Cart': function() 
				{
					alert('added to your cart');
					$(this).dialog('close');
					$('.ui-dialog').remove();
				},
				Cancel: function() 
				{
					$(this).dialog('close');
					$('.ui-dialog').remove();
				}
			},
			close: function() 
			{
				//action.enable();
				$('.ui-dialog').remove();
			}
		});
	}
	else if( t == 'Get Price' )
	{
		var itemtype = $('#get-price').html();
		var itemtitle = $('.item-title').find('span:first').html();
		$("#dialog")
		.html('<img src="' + loadingImage.src + '"/> loading please wait...');
		
		function handleData(data, status)
		{
			var ar = data.split('||')
			priceObject = eval(ar[0]);
			
			$("#dialog")
			.html(ar[1]);
			
			$('.get-price-section-list')
			.find('select[rel=formats]')
			.bind('change', function()
			{
				getPrice();
			});
						
			$('.get-price')
			.bind('click', function()
			{
				getPrice();
			});
				
		}
		
		function handleError(XHR, error, except)
		{
			if( error == 'Timeout' )
			{
				alert("Your request has timed out. Please try again.");
			}
			else
			{
				alert(error + ' : ' + except);
			}
		}
		
		function handleComplete(XHR, status)
		{
			//alert('Completed: ' + status);
		}
		
		function handleFilter(data, type)
		{
			return data;
		}
		
		$.ajax(
		{
			type		:	'GET',
			url			:	getpriceDataSrc,
			dataType	: 	'html',
			data		:	({item_type: itemtype, item_title: itemtitle}),
			success		:	handleData,
			cache		:	true,
			async		:	true,
			error		:	handleError,
			complete	:	handleComplete,
			dataFilter	:	handleFilter,
			timeout		:	20000
		});
		
		//.load('ajax/get_price.php', 'item_type=' + item_type + '&item_title=' + item_title)
		
		var obj = $('a[rel=cart]');
		if( $(obj).hasClass('remove') )
		{
			$("#dialog")
			.dialog({
				bgiframe: false,
				title: t,
				width: 670,
				height: 490,
				minHeight: 490,
				minWidth: 670,
				maxHeight: 600,
				maxWidth: 475,
				zIndex: 10001,
				modal: true,
				resizable: true,
				closeOnEscape: true,
				buttons: 
				{
					'Remove from Cart': function() 
					{
						if( !$(obj).hasClass('add') )
							$(obj).addClass('remove');
						cart(obj);
						$('.ui-dialog').remove();
					},
					
					Cancel: function() 
					{
						$(this).dialog('close');
						$('.ui-dialog').remove();
					}
					
				},
				close: function() 
				{
					//action.enable();
					$('.ui-dialog').remove();
				}
			});
		}
		else
		{
			$("#dialog")
			.dialog({
				bgiframe: false,
				title: t,
				width: 670,
				height: 490,
				minHeight: 490,
				minWidth: 670,
				maxHeight: 600,
				maxWidth: 475,
				zIndex: 10001,
				modal: true,
				resizable: true,
				closeOnEscape: true,
				buttons: 
				{
					'Add to Cart': function() 
					{
						if( !$(obj).hasClass('remove') )
							$(obj).addClass('add');
						cart(obj);
						$('.ui-dialog').remove();
					},
					
					Cancel: function() 
					{
						$(this).dialog('close');
						$('.ui-dialog').remove();
					}
					
				},
				close: function() 
				{
					//action.enable();
					$('.ui-dialog').remove();
				}
			});
		}
	}
	else if( t == 'Add to Lightbox' )
	{
		$("#dialog")
		.html(c)
		.dialog({
			bgiframe: true,
			title: t,
			width: 502,
			height: 250,
			minHeight: 250,
			minWidth: 502,
			maxHeight: 550,
			maxWidth: 802,
			zIndex: 10001,
			modal: true,
			closeOnEscape: true,
			buttons: 
			{
				'Add to Lightbox': function() 
				{
					alert('added to your lightbox');
					$(this).dialog('close');
					$('.ui-dialog').remove();
				},
				Cancel: function() 
				{
					$(this).dialog('close');
					$('.ui-dialog').remove();
				}
			},
			close: function() 
			{
				//action.enable();
				$('.ui-dialog').remove();
			}
		});
	}
	else if( t == 'Confirm' )
	{
		$("#dialog")
		.html(c)
		.dialog({
			bgiframe: true,
			title: t,
			width: 502,
			height: 250,
			minHeight: 250,
			minWidth: 502,
			maxHeight: 550,
			maxWidth: 802,
			zIndex: 10001,
			modal: true,
			closeOnEscape: true,
			buttons: 
			{
				'Ok': function() 
				{
					alert('Confirmed');
					$(this).dialog('close');
					$('.ui-dialog').remove();
				},
				Cancel: function() 
				{
					$(this).dialog('close');
					$('.ui-dialog').remove();
				}
			},
			close: function() 
			{
				//action.enable();
				$('.ui-dialog').remove();
			}
		});
	}
	else
	{
		$("#dialog")
		.html(c)
		.dialog({
			bgiframe: true,
			title: t,
			width: 502,
			height: 250,
			minHeight: 250,
			minWidth: 502,
			maxHeight: 550,
			maxWidth: 802,
			zIndex: 10001,
			modal: true,
			closeOnEscape: true,
			buttons: 
			{
				Close: function() 
				{
					$(this).dialog('close');
					$('.ui-dialog').remove();
				}
			},
			close: function() 
			{
				//action.enable();
				$('.ui-dialog').remove();
			}
		});
	}
}