// <--
var imagedir = '/images/icons';

// Show hide text ------------------------------------------------------------------------------------------------------- //
function toggleText() {
	var $type  = $(this).attr('rel');
	//alert($type);
	$($type).toggle();
	
	return false;
}

// Delete item --------------------------------------------------------------------------------------------------------- //
function deleteItem() {
	var $me = $(this);
	var $original = $me.html();
	
	// Get parent to delete
	var $type  = $(this).attr('rel');
	var $parent = $(this).parents($type);
	var $url = $(this).attr('rev');
	
	var id = $parent.attr('id');
		
	//alert($me.html());	
	//alert("Type:"+ $type +" Url:"+ $url +" Id:"+ id);	
	
	if( confirm("Are you sure you want to delete this item?") ) {
		
		$me.html('<img src="'+ imagedir +'/loader.gif" alt="Loading" class="absmiddle" border="0" />');
		
		$.post($url, { item_id: id, type: $type, deleteItem: "1" },
					function (data) {
						if (data == 'ok') {
							// deleted
							$parent.fadeOut("slow");
						} else {
							// not deleted
							alert("Sorry we could not delete this item. Please try again later.");
							$me.html($original);
						}											
					}
		);		
	}
	
	return false;
}

// Toggle item --------------------------------------------------------------------------------------------------------- //
function updateFlag() {
	var $me = $(this);
	var $original = $me.html();
	
	// Get parent to delete
	var $class  = $(this).attr('rel');
	var $parent = $(this).parents($class);
	var $url = $(this).attr('rev');
	
	var id = $parent.attr('id');
	var status = $('img',$me).attr('alt');
	
	//alert($me.html());	
	//alert("Class:"+ $class +" Url:"+ $url +" Id:"+ id +" Status:"+ status);		
	
	$.post($url, { item_id: id, status_id: status, toggleItem: "1" },
					function (data) {
						if (data != '') {
							// change image
							$me.html(data);	
						} else {
							// not deleted
							alert("Sorry we could not edit this item. Please try again later.");
							$me.html($original);
						}											
					}
	);	
		
	return false;
}

// -------------------------------- Show Progress of Upload ---------------------------------- //
function showProgress() {
	document.getElementById('uploadprogress').style.display = 'block';    
   	return true;
}
// -->