SITEPATH = 'http://www.artworks4you.co.uk/';
$(function()
{
		if ($('.popup').length)
		{
			$('.popup').click(function(){

				var counter = $(this).attr('name');
				

				$('#DialogDetails'+counter).dialog({
				bgiframe: true, autoOpen: false, modal: true, width: 500, resizable: false,
				buttons: 
					{
						'Close': function(){
							$(this).dialog('close');
						}
					}
				});

				$('#DialogDetails'+counter).dialog('open');

				return false;

			});

			$('.popup').hover(function(){
				//alert('ff');
				var counter = $(this).attr('name');
				var artID = $('#ArtistID').val();
				
				$.ajax({
					url: SITEPATH + 'index.php?a=Ajax&b=HoverImage&c='+counter+'&d='+artID,
					success: function(data){
						$('#JQueryImage').html(data);

					}
				});

			});

			$('.dialog').dialog({
				bgiframe: true, autoOpen: false, modal: true, width: 500, resizable: false,
				buttons: 
					{
						'Close': function(){
							$(this).dialog('close');
						}
					}
				});
		}

		if ($('#StartDate').length || $('#EndDate').length)
		{
			$('#StartDate').datepicker({
				dateFormat: "dd/mm/yy",
				gotoCurrent: true,
				hideIfNoPrevNext: true
			});
			$('#EndDate').datepicker({
				dateFormat: "dd/mm/yy",
				gotoCurrent: true,
				hideIfNoPrevNext: true
			});
		}


		//sortable list feedback internal
		$('#sortable').sortable({
			axis: 'y',
			cursor: 'pointer',
			distance: 5,
			opacity: 0.6,
			tolerance: 'pointer',
			update: function(event, ui){
				$.ajax({
					url: SITEPATH + 'index.php?a=Ajax&b=ReorderImage',
					type: 'POST',
					data: $('#sortable').sortable('serialize')
				});
			}
		});

}); //document ready
