function addMusicComments()
{
	checkMemberLoggedStatus();
	var sCommentTextValue	= $('#commentText').val();
	var musicId = document.getElementById('musicId').value;
	var sCommentTextLength  = sCommentTextValue.length;
	if ( sCommentTextLength == 0 )   
	{
		document.getElementById("commentText").focus();
		$('#sMsgCounter').show();
		document.getElementById("sMsgCounter").innerHTML = '<font color = "red">Please enter text for Comment</font>';
	}else
	{
		$('#sMsgCounter').show();
		showLoaderImg('sMsgCounter');
		var sUrl = 'musicajax.php?sAction=PostComments&commentText='+sCommentTextValue+'&musicId='+musicId;
		$.get(sUrl, {
			time: Math.random()
		}, function(data){
			var data_arr = data.split('|');
			document.getElementById("commentText").value='';
			if(data_arr[1] != "" || data_arr[2] != "")
			{
				document.getElementById('commentTotal').innerHTML = data_arr[1]; 
				document.getElementById('viewComments').innerHTML = data_arr[2]; 
			}
			document.getElementById('sMsgCounter').innerHTML = data_arr[0]; 
		});
	}
	return false;
}

function checkMemberLoggedStatus()
{
	var locationWindow = window.location.pathname+window.location.search+window.location.hash;
	var userid = getCookie('memberID');
	if(userid==0 || userid == '')
	{
		showItemEditForm("login_div"); 
		$("#login_div").show().load( 'member.php?action=show_login_form&relocate=' + encodeURIComponent( locationWindow) );	
	}
}

function loadIpclSearchResultOnComments(musicid, page){
	showLoaderImg('commentPaging');
	var sUrl	= "musicajax.php"
	sUrl		= sUrl+ '?sAction=viewcomments&musicid='+musicid+'&page='+page;

	$.get(sUrl, { time: Math.random()},
    function(data){
   		$('#viewComments').html(data);
		hideLoaderImg('commentPaging');
   });
}

function limitCharsMusicComment(obj)
{   
	document.getElementById("sMsgCounter").innerHTML = '';
	var mlength = obj.getAttribute ? parseInt(obj.getAttribute("maxlength")) : 500;
	if (obj.getAttribute && obj.value.length > mlength)
	{
		obj.value=obj.value.substring(0,mlength);
	}
	var iLenght = (mlength - obj.value.length) ;
	document.getElementById("sMsgCounter").innerHTML = 'You have ' + iLenght + ' characters left.';
}

function displayMusicList(obj, mode)
{
	var navLinks = document.getElementById('tabColumns').getElementsByTagName("a");
	
	for(var i=0;i<navLinks.length;i++)
	{
		if( navLinks[i] == obj)
		{
			navLinks[i].className = "activeColumnTabs";
			var text = navLinks[i].innerHTML;
			
			if( text == "Search")
			{
				$('#searchMode').show();
				return false;
			}else
			{
				$('#searchMode').hide();
			}
		}else
		{
			navLinks[i].className = "columnTabs"
		}
	}
	
	showLoaderImg('showLoader1');
	var sUrl = 'musicajax.php?sAction=showMusicPageList&cat='+mode;
	$.get(sUrl, {
		time: Math.random()
	}, function(data){
		hideLoaderImg('showLoader1');
		document.getElementById('displaySongsList').innerHTML = data; 
	});
    return false;
}

function showMusicSongsList(mode, page)
{
	showLoaderImg('showLoader1');
	var sUrl = 'musicajax.php?sAction=showMusicPageList&cat='+mode+'&page='+page;
    $.get(sUrl, {
        time: Math.random()
    }, function(data){
		hideLoaderImg('showLoader1');
		document.getElementById('displaySongsList').innerHTML = data; 
    });
    return false;
}

function searchSongs()
{
	var name = document.getElementById('songName').value;
	showSongsLyricsModule(name, '1');
}

function showSongsLyricsModule(condition, page)
{
	showLoaderImg('showLoader1');
	var sUrl = 'musicajax.php?sAction=showLyricsPageMusicList&condition='+condition+'&page='+page;
    $.get(sUrl, {
        time: Math.random()
    }, function(data){
		hideLoaderImg('showLoader1');
		document.getElementById('searchLyricsSongs').innerHTML = data; 
    });
    return false;
}

function getmusicSearch()
{
	var condition = document.getElementById('SearchMusicSong').value;
	searchMusicpageList(condition, '1');
}

function searchMusicpageList(condition, page)
{
	showLoaderImg('showLoader1');
	var sUrl = 'musicajax.php?sAction=showLyricsPageMusicList&condition='+condition+'&page='+page+'&limit=10';
    $.get(sUrl, {
        time: Math.random()
    }, function(data){
		hideLoaderImg('showLoader1');
		document.getElementById('displaySongsList').innerHTML = data; 
    });
    return false;
}

function displaySearchMusicReviewList()
{
	var searchField = document.getElementById('SearchMusicReview').value;
	showmusicSearchReviewModule(searchField, '1');
}

function showmusicSearchReviewModule(condition, page)
{
	showLoaderImg('showLoader1');
	var sUrl = 'musicajax.php?sAction=showSearchMusicReviews&condition='+condition+'&page='+page;
    $.get(sUrl, {
        time: Math.random()
    }, function(data){
		hideLoaderImg('showLoader1');
		document.getElementById('searchMusicReviews').innerHTML = data; 
    });
    return false;
}