function returnElement(id)
{
	return document.getElementById(id);
}

// !!
function nowa(){
	return value;
}

function play(uri, title)
{
	value = '/tracks/' + uri + '||' + title;
	document.mpplayer.Play();
}

function clearText(objectId)
{
	object = document.getElementById(objectId);
	object.style.color = '#000000';
	object.value = '';
}

function toogleText(objectId, text)
{
	object = document.getElementById(objectId);
	
	if(object.value == '')
	{
		object.style.color = '#AFAFAF';
		object.value = text;
	}else{
		if(object.value == text){
			object.style.color = '#000000';
			object.value = '';
		}else{

		}
	}
}

function toogleVis(objectId)
{
	$('#'+objectId).slideToggle();
}

function confirmDelete(url, message)
{
  if(confirm(message))
  {
    location.href=url;
  }
}

/*
----------------------------------------------------*/

$(document).ready(function() 
{
	// ready to use srtable's
	var sortableArrows = '<img src="/files/hSortUp.gif" alt="" class="up"/><img src="/files/hSortDown.gif" alt="" class="down"/>';
	
	/*
	User's tracks
	----------------------------*/
	
	$("#userTrackList").tablesorter({ 
		//debug : true,
		headers : { 
		//	2: { sorter: 'datentime' } , 
		//	3: { sorter: 'filesize' } , 
		2: { sorter:false }}, 
			
		widgets : ["zebra"], 
		widgetZebra : { css : ['odd', 'even']}
	})
	.tablesorterPager( 
		{container: $("#userTrackListPager"), positionFixed: false, size: 10} 
	);
	
	$("#userTrackList th").append( sortableArrows );
	
	/*
	User's table
	----------------------------*/
	
	$("#utable").tablesorter({ 
		//debug : true,
		headers : { 
		//	2: { sorter: 'datentime' } , 
		//	3: { sorter: 'filesize' } , 
		4: { sorter:false }}, 
			
		widgets : ["zebra"], 
		widgetZebra : { css : ['odd', 'even']}
	})
	.tablesorterPager( 
		{container: $("#utablePager"), positionFixed: false, size: 10} 
	);
	
	/*
	News table
	----------------------------*/
	
	$("#newsTable").tablesorter({ 
		//debug : true,
		headers : { 
		//	2: { sorter: 'datentime' } , 
		//	3: { sorter: 'filesize' } , 
		6: { sorter:false }}, 
		
		textExtraction: 'complex',
		sortList: [[0,1]],
		widgets : ["zebra"], 
		widgetZebra : { css : ['odd', 'even']}
	})
	.tablesorterPager( 
		{container: $("#newsPager"), positionFixed: false, size: 10} 
	);
	
	
	/*
	Music/like listing
	----------------------------*/
	
	$.tablesorter.addParser({
		id: 'customDate',
		is: function(s) {
			return false;
		},
		
		format: function(s) {
			//console.log( $(s).html());
			//return $('span',s).html();
		},
		
		type: 'numeric'
	});
	
	$("#itemslist").tablesorter({ 
		//debug : true,
		headers : { 
			1: { sorter:false }
		},

		textExtraction: 'complex',

		//eof//
		widgets : ["zebra"], 
		widgetZebra : { css : ['odd', 'even']}
	})
	.tablesorterPager( 
		{container: $("#itemslistPager"), positionFixed: false, size: 10} 
	);
	
	
	$('#aboutSite').toggle(
		function()
		{
			$('#textAboutMP').fadeIn('slow');
		},
		function()
		{
			$('#textAboutMP').fadeOut('slow');
		}
	);
	
	
/*
Accordion
----------------------------------------------------*/	

	$('#infoBox ul li ul.default').css('display', 'block');
	$('#infoBox ul li ul li:odd:not(.top):not(.bottom)').addClass('odd');
	
	$('#infoBox ul li.iMenuItem div').click(function()
	{
		var display = function(object)
		{
			$('ul', object).slideDown();
		}
		
		var activeElement = $(this).next();
		
		if($(activeElement).css('display') != 'block')
		{
			var visibleObjects = $('#infoBox ul li ul:visible');
			
			if(!visibleObjects.html())
			{
				$(activeElement).slideDown();
			}else{
				visibleObjects.slideUp('normal', function(){
					$(activeElement).slideDown();
				});
			}
		}else{
			$(activeElement).slideUp();
		}
		
		
	});
	
/*
musicCategoriesSection
----------------------------------------------------*/	

	var mCatListItem = $('#musicCategoriesSection ul li');

	mCatListItem.mouseover(function(){
		$(this).addClass('hover');
	});
	
	mCatListItem.mouseout(function(){
		$(this).removeClass('hover');
	});
	
	
/*
acp special section
----------------------------------------------------*/
	
	$('div.adminCP div h2').click( function(){
		
		var currentElement = $('+div.section.special',this);
		
		$('div.adminCP div.section.special').not( currentElement ).slideUp();
		
		currentElement.slideToggle();
		
	});
	
/*
publisher
----------------------------------------------------*/
	
	
	$('#newsEditor').submit( function(){
		
		if(confirm('Are you sure ?'))
		{
			//location.href=url;
			document.myform.submit();
		}else{
			
			return false;
			
		}
		
	});

	$('.readMore:parent').click(function(){
		
		$(this).parents().next('div').fadeIn('slow');
		$(this).fadeOut();
		
	});


});

