Array.prototype.findIdx = function(value){
for(var i=0; i < this.length; i++){
if(this[i] == value){
return i;
}}}


function switchUserFavoriteDiv(type){
if(type == 'favorite'){
document.getElementById("favoriteCommonDiv").style.display=""	
document.getElementById("userDiv").style.display="none"
document.getElementById("singleDiv").style.display="none"
document.getElementById("favorites").style.color="#001743"
document.getElementById("users").style.color="#CCCCCC"
document.getElementById("singles").style.color="#CCCCCC"
document.getElementById("favorites").style.background="#CCCCCC"
document.getElementById("users").style.background="#FFFFFF"
document.getElementById("singles").style.background="#FFFFFF"
}else if (type == 'user'){
document.getElementById("favoriteCommonDiv").style.display="none"	
document.getElementById("userDiv").style.display=""	
document.getElementById("singleDiv").style.display="none"
document.getElementById("favorites").style.color="#CCCCCC"
document.getElementById("users").style.color="#001743"
document.getElementById("singles").style.color="#CCCCCC"
document.getElementById("favorites").style.background="#FFFFFF"
document.getElementById("users").style.background="#CCCCCC"
document.getElementById("singles").style.background="#FFFFFF"
}
else{
document.getElementById("favoriteCommonDiv").style.display="none"	
document.getElementById("userDiv").style.display="none"	
document.getElementById("singleDiv").style.display=""
document.getElementById("favorites").style.color="#CCCCCC"
document.getElementById("users").style.color="#CCCCCC"
document.getElementById("singles").style.color="#001743"
document.getElementById("favorites").style.background="#FFFFFF"
document.getElementById("users").style.background="#FFFFFF"
document.getElementById("singles").style.background="#CCCCCC"
}
}

function switchUserFavoriteDiv1(type){
if(type == 'favorite'){
document.getElementById("favoriteDiv").style.display=""	
document.getElementById("userDiv").style.display="none"	
document.getElementById("favorites").style.color="#001743"
document.getElementById("users").style.color="#CCCCCC"
document.getElementById("favorites").style.background="#CCCCCC"
document.getElementById("users").style.background="#FFFFFF"

}else {
document.getElementById("favoriteDiv").style.display="none"	
document.getElementById("userDiv").style.display=""
document.getElementById("favorites").style.color="#CCCCCC"
document.getElementById("users").style.color="#001743"
document.getElementById("favorites").style.background="#FFFFFF"
document.getElementById("users").style.background="#CCCCCC"
}
}

function switchFavoriteDivs(type){
if(type == 'albums'){
document.getElementById("favoriteDiv").style.display=""	
document.getElementById("favorite1Div").style.display="none"
document.getElementById("favoriteAlbums").style.color="#001743"
document.getElementById("favoriteTracks").style.color="#CCCCCC"
document.getElementById("favoriteAlbums").style.background="#CCCCCC"
document.getElementById("favoriteTracks").style.background="#FFFFFF"
}
else{
document.getElementById("favoriteDiv").style.display="none"	
document.getElementById("favorite1Div").style.display=""	
document.getElementById("favoriteAlbums").style.color="#CCCCCC"
document.getElementById("favoriteTracks").style.color="#001743"
document.getElementById("favoriteAlbums").style.background="#FFFFFF"
document.getElementById("favoriteTracks").style.background="#CCCCCC"
}
}
function switchCommunityDiv(type){
if(type == 'community'){
document.getElementById("communityDiv").style.display=""	
document.getElementById("communitySingleDiv").style.display="none"
document.getElementById("community").style.color="#001743"
document.getElementById("communitySingle").style.color="#CCCCCC"
document.getElementById("community").style.background="#CCCCCC"
document.getElementById("communitySingle").style.background="#FFFFFF"
}else {
document.getElementById("communityDiv").style.display="none"	
document.getElementById("communitySingleDiv").style.display=""	
document.getElementById("community").style.color="#CCCCCC"
document.getElementById("communitySingle").style.color="#001743"
document.getElementById("community").style.background="#FFFFFF"
document.getElementById("communitySingle").style.background="#CCCCCC"
}
}

function pagination(currentPage,type,page,searchFunc,searchValue,pageLoad,userType){
//Show/Hide Divs
var communityId = document.getElementById("communityIdVar").innerHTML
if (type == 'favoriteAction' ||type == 'favoriteActionAudio' || type == 'favoriteActionAlbum' ){
	if(type == 'favoriteActionAudio'){
		var favoriteActionAudio = 1;
		var favoriteActionAlbum = 0;
	}else if(type == 'favoriteActionAlbum'){
		var favoriteActionAudio = 0;
		var favoriteActionAlbum = 1;
	}
	var favoriteAction = 1
	if (userType == 'fan' && page == 'audio'){
		type = 'favorite';
	}else{
		type = 'user'
	}
	
	if(page == 'audio' && userType != 'fan' ){
		switchUserFavoriteDiv('favorite')
		switchFavoriteDivs('albums');
	}else if(userType != 'fan'){
			switchUserFavoriteDiv1('favorite')
	}
}
else{
	var favoriteAction = 0
}
if(type == 'user' && page=='audio' && userType != 'fan'){
switchUserFavoriteDiv('user');
}else{
if(type == 'user' && userType != 'fan'){	
switchUserFavoriteDiv1('user');
}
}
if(type == 'community' && page == 'audio'){
switchCommunityDiv('community');
}

if(type !='favorite' && type !='favorite1' && type !='single' && type !='communitySingle'){
document.getElementById(type+'Div').style.display='none';
document.getElementById(type+'DivLoader').style.display='';
}
//Jump to top of page
if(pageLoad != 0){
window.location = '#top';
}

//Call CFC Function
var paginationVar = new paginationClassFav;
//Set User Type
if(userType != 'fan' && type != 'favorite' && type != 'favorite1'){
	//var userType = 'notFan';
	var paginationVar = new paginationClass;
}


/*if(page == "feed" && userType == 'notFan'){
	var paginationReturn = paginationVar.feedPagination(type,searchFunc,searchValue);
}else*/
if(page == "feed"){// && userType == 'fan'){
	var paginationReturn = paginationVar.feedPagination(type,searchFunc,searchValue,communityId);
}else if(page == "events"){
var paginationReturn = paginationVar.eventsPagination(type,searchFunc,searchValue,communityId);

}else if(page == "audio"){
	/*if(type == 'community'){
		var paginationReturn = paginationVar.audioPagination1(type,searchFunc,searchValue);
	}
	else{*/

		var paginationReturn = paginationVar.audioPagination(type,searchFunc,searchValue,communityId);

	//}
}else if(page == "photos"){
var paginationReturn = paginationVar.photosPagination(type,searchFunc,searchValue,communityId);
}else if(page == "video"){
var paginationReturn = paginationVar.videoPagination(type,searchFunc,searchValue,communityId);
}else if(page == "profile"){
var paginationReturn = paginationVar.inboxPagination(type,searchFunc,searchValue,communityId);
}

//Determine the total number of pages that are needed
if(paginationReturn.DATA.length % 10 != 0){
	var totalPages = parseInt((paginationReturn.DATA.length/10)+1);
}else{
	var totalPages = parseInt((paginationReturn.DATA.length/10));
}

if(currentPage > totalPages){ var currentPage = 1; }

//Set starting number
var startNum = (currentPage * 10) - 9;

//Set ending number
var endNum = currentPage * 10;
if(endNum > paginationReturn.DATA.length){ var endNum = paginationReturn.DATA.length; }

//INSERT DIV DATA
window[page](currentPage,type,page,paginationReturn,startNum,endNum,pageLoad,userType);

//if(type == 'user'){ var currentPage = 1;}



//START PAGINATION
if(totalPages >= 10){
//IF THE NUMBER OF PAGES ARE OVER 10
//Hide buttons that will not be used
for(i=7;i<=9;i++){
document.getElementById(type+'Buttons'+i).style.display='none';
}

var startPage = currentPage - 2;
var endPage = currentPage + 2;

//Determine if the "continued dots" for the first button should be displayed or not
if(startPage <= 1){
var startPage = 1;
document.getElementById(type+'Buttons1').style.display = 'none';
document.getElementById(type+'ButtonStartDots').style.display = 'none';
}else if(startPage <= 2){
document.getElementById(type+'Buttons1').style.display = '';
document.getElementById(type+'ButtonStartDots').style.display = 'none';
var onClickVar = "pagination(1,'"+type+"','"+page+"','"+searchFunc+"','"+searchValue+"','1','"+userType+"');";
if(type == 'community'){ var pageVar = '#page1'; }else{ var pageVar = '#nav'; }
document.getElementById(type+'Buttons1').innerHTML = '<a href="'+pageVar+'"><span onClick="'+onClickVar+'">1</span></a>';
document.getElementById(type+'Buttons1').style.fontWeight='normal';
}else{
document.getElementById(type+'Buttons1').style.display = '';
document.getElementById(type+'ButtonStartDots').style.display = '';
var onClickVar = "pagination(1,'"+type+"','"+page+"','"+searchFunc+"','"+searchValue+"','1','"+userType+"');";
var pageVar = '#page1';
//if(type == 'community'){ var pageVar = '#page1'; }else{ var pageVar = '#nav'; }
document.getElementById(type+'Buttons1').innerHTML = '<a href="'+pageVar+'"><span onClick="'+onClickVar+'">1</span></a>';
document.getElementById(type+'Buttons1').style.fontWeight='normal';
}

//Determine if the "continued dots" for the last button should be displayed or not
if(endPage >= totalPages){
document.getElementById(type+'Buttons10').style.display = 'none';
document.getElementById(type+'ButtonEndDots').style.display = 'none';
}else if(endPage >= (totalPages-1)){
document.getElementById(type+'Buttons10').style.display = '';
document.getElementById(type+'ButtonEndDots').style.display = 'none';
var onClickVar = "pagination("+totalPages+",'"+type+"','"+page+"','"+searchFunc+"','"+searchValue+"','1','"+userType+"');";
if(type == 'community'){ var pageVar = '#page'+totalPages; }else{ var pageVar = '#nav'; }
document.getElementById(type+'Buttons10').innerHTML = '<a href="'+pageVar+'"><span onClick="'+onClickVar+'">'+totalPages+'</span></a>';
document.getElementById(type+'Buttons10').style.fontWeight='normal';
}else{
document.getElementById(type+'Buttons10').style.display = '';
document.getElementById(type+'ButtonEndDots').style.display = '';
var onClickVar = "pagination("+totalPages+",'"+type+"','"+page+"','"+searchFunc+"','"+searchValue+"','1','"+userType+"');";
if(type == 'community'){ var pageVar = '#page'+totalPages; }else{ var pageVar = '#nav'; }
document.getElementById(type+'Buttons10').innerHTML = '<a href="'+pageVar+'"><span onClick="'+onClickVar+'">'+totalPages+'</span></a>';
document.getElementById(type+'Buttons10').style.fontWeight='normal';
}

//Get the page to start from for the buttons between the "continued dots"
var pageCounter = startPage;
if((pageCounter + 4) > totalPages){	var pageCounter = totalPages - 4; }

//Display buttons
for(i=2;i<=6;i++){
document.getElementById(type+'Buttons'+i).style.display = '';
var onClickVar = "pagination("+pageCounter+",'"+type+"','"+page+"','"+searchFunc+"','"+searchValue+"','1','"+userType+"');";
if(type == 'community'){ var pageVar = '#page'+pageCounter; }else{ var pageVar = '#nav'; }
document.getElementById(type+'Buttons'+i).innerHTML = '<a href="'+pageVar+'"><span onClick="'+onClickVar+'">'+pageCounter+'</span></a>';
document.getElementById(type+'Buttons'+i).style.fontWeight='normal';
if(pageCounter == currentPage){ 
alert(pageCounter + 'first')
document.getElementById(type+'Buttons'+i).style.fontWeight='bold'; }
var pageCounter = pageCounter + 1;
}

}else{
	
//ELSE IF THE NUMBER OF PAGES ARE UNDER 10
document.getElementById(type+'ButtonStartDots').style.display = 'none';
document.getElementById(type+'ButtonEndDots').style.display = 'none';

for(i=1;i<=10;i++){

if(i <= totalPages){
		
	document.getElementById(type+'Buttons'+i).style.display = '';
	var onClickVar = "pagination("+i+",'"+type+"','"+page+"','"+searchFunc+"','"+searchValue+"','1','"+userType+"');";
	if(type == 'community'){ var pageVar = '#page'+i; }else{ var pageVar = '#nav'; }
	document.getElementById(type+'Buttons'+i).innerHTML = '<a href="'+pageVar+'"><span onClick="'+onClickVar+'">'+i+'</span></a>';
	document.getElementById(type+'Buttons'+i).style.fontWeight='normal';
	if(i == currentPage){ 
	document.getElementById(type+'Buttons'+i).style.fontWeight='bold'; }
}else{
	document.getElementById(type+'Buttons'+i).style.display = 'none';
}
}

}
//END PAGINATION

//Show/Hide Previous/Next buttons
if(currentPage == totalPages){
document.getElementById(type+'NextOn').style.display = 'none';
document.getElementById(type+'NextOff').style.display = '';
}else{
var nextPage = currentPage + 1;
document.getElementById(type+'NextOff').style.display = 'none';
document.getElementById(type+'NextOn').style.display = '';

var onClickVar = "pagination("+nextPage+",'"+type+"','"+page+"','"+searchFunc+"','"+searchValue+"','1','"+userType+"');";
if(type == 'community'){ var pageVar = '#page'+nextPage; }else{ var pageVar = '#nav'; }
document.getElementById(type+'NextOn').innerHTML = '<a href="'+pageVar+'"><span class="paginationButton" onClick="'+onClickVar+'">Next <span style="font-size:8px;">>></span></span></a>';
}

if(currentPage == 1){
document.getElementById(type+'PrevOn').style.display = 'none';
document.getElementById(type+'PrevOff').style.display = '';
}else{
var prevPage = currentPage - 1;
document.getElementById(type+'PrevOff').style.display = 'none';
document.getElementById(type+'PrevOn').style.display = '';

var onClickVar = "pagination("+prevPage+",'"+type+"','"+page+"','"+searchFunc+"','"+searchValue+"','1','"+userType+"');";
if(type == 'community'){ var pageVar = '#page'+prevPage; }else{ var pageVar = '#nav'; }
document.getElementById(type+'PrevOn').innerHTML = '<a href="'+pageVar+'"><span class="paginationButton" onClick="'+onClickVar+'"><span style="font-size:8px;"><<</span> Prev</span></a>';
}

//Show/Hide pagination div
if(totalPages <= 1){ document.getElementById(type+'Pagination').style.display = 'none'; }
else{ document.getElementById(type+'Pagination').style.display = ''; }

setTimeout(function(){
//Show/Hide Divs
if(favoriteAction == 1 && userType !='fan'& page!='audio'){
document.getElementById(type+'DivLoader').style.display='none';
document.getElementById("favoriteDiv").style.display=""	
//document.getElementById("userDiv").style.display="none"
//"border-left:thin ##CCCCCC solid; border-right:thin ##CCCCCC solid; border-top:thin ##CCCCCC solid; border-bottom:##CCCCCC; color:##000000;"
document.getElementById("favorites").style.color="#001743"
document.getElementById("users").style.color="#CCCCCC"
document.getElementById("favorites").style.background="#CCCCCC"
document.getElementById("users").style.background="#FFFFFF"
//document.getElementById("userDiv").style = "border-left:thin #CCCCCC solid; border-right:thin #CCCCCC solid; border-top:thin #CCCCCC solid; border-bottom:#CCCCCC;background-color: #CCCCCC;color:#FFFFFF;display:none"
}else if(favoriteAction == 1 && userType !='fan'& page=='audio'){
document.getElementById("favorites").style.color="#001743"
document.getElementById("users").style.color="#CCCCCC"
document.getElementById("singles").style.color="#CCCCCC"
document.getElementById("favorites").style.background="#CCCCCC"
document.getElementById("users").style.background="#FFFFFF"
	if(favoriteActionAlbum ==1){
		document.getElementById("favoriteDiv").style.display=""	
		document.getElementById("favorite1Div").style.display="none"
		document.getElementById("favoriteAlbums").style.color="#001743"
		document.getElementById("favoriteTracks").style.color="#CCCCCC"
		document.getElementById("favoriteAlbums").style.background="#CCCCCC"
		document.getElementById("favoriteTracks").style.background="#FFFFFF"
	}else{
		document.getElementById("favoriteDiv").style.display="none"	
		document.getElementById("favorite1Div").style.display=""	
		document.getElementById("favoriteAlbums").style.color="#CCCCCC"
		document.getElementById("favoriteTracks").style.color="#001743"
		document.getElementById("favoriteAlbums").style.background="#FFFFFF"
		document.getElementById("favoriteTracks").style.background="#CCCCCC"
	}
}else if(type !='favorite' && type !='favorite1' && type !='single' && type !='communitySingle'){
document.getElementById(type+'Div').style.display='';
document.getElementById(type+'DivLoader').style.display='none';
}
},500);
}








function feed(currentPage,type,page,paginationReturn,startNum,endNum,pageLoad,userType){
//Clear data from divs
for(i=1;i<=10;i++){
document.getElementById(type+'Div'+i).style.height = '';
document.getElementById(type+'Div'+i).style.paddingBottom = '';
document.getElementById(type+'Image'+i).innerHTML = '';
document.getElementById(type+'Title'+i).innerHTML = '';
document.getElementById(type+'Name'+i).innerHTML = '';
document.getElementById(type+'Body'+i).innerHTML = '';
document.getElementById(type+'Date'+i).innerHTML = '';
}

//START Insert data into divs
if(paginationReturn.DATA.length == 0){
document.getElementById(type+'Div1').style.height = '110px';
document.getElementById(type+'Div1').style.paddingBottom = '15px';
document.getElementById(type+'Image1').innerHTML = 'No Records Found';
}else{
var counter = 1;
for(i=startNum;i<=endNum;i++){
document.getElementById(type+'Div'+counter).style.height = '110px';
document.getElementById(type+'Div'+counter).style.paddingBottom = '15px';
document.getElementById(type+'Image'+counter).innerHTML = '<img src="'+paginationReturn.DATA[i-1][0]+'_thumb.jpg" style="border:1px solid #9ea9b9;"/>';

//Title string manipulation
if(paginationReturn.DATA[i-1][1].length > 25){
	var titleData = paginationReturn.DATA[i-1][1].slice(0,25)+'...';
}else{
	var titleData = paginationReturn.DATA[i-1][1];
}
document.getElementById(type+'Title'+counter).innerHTML = '<a href="'+page+'.cfm?id='+paginationReturn.DATA[i-1][5]+'" class="defaultLinkHover" style="font-size:14px; font-weight:bold;">'+titleData+'</a>';
document.getElementById(type+'Name'+counter).innerHTML = 'By: <a href="profile.cfm?id='+paginationReturn.DATA[i-1][7]+'&profile=yes" class="defaultLink" style="font-size:11px;">'+paginationReturn.DATA[i-1][2]+'</a>';

//Body string manipulation
if(paginationReturn.DATA[i-1][3].length > 90){
	var bodyData = paginationReturn.DATA[i-1][3].slice(0,90)+'...';
}else{
	var bodyData = paginationReturn.DATA[i-1][3]
}
document.getElementById(type+'Body'+counter).innerHTML = bodyData;

//Show remove link if the user owns the feed, otherwise show the share link
if(type == 'user' && userType != 'fan'){
	removeFunc = "removeItem('"+type+"Div"+counter+"','feed','"+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('FEEDID')]+"');";
	link1 = '<a class="defaultLink" style="font-size:10px; font-weight:normal; color:#ff0000;" onClick="'+removeFunc+'">Delete</a>';
}else{
	//setShareLinks('http://beta.asoundstrategy.com/assiwebsites/site355/feed.cfm?id=' + ,titleData)
	var feedId = paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('FEEDID')]
	link1 = '<a href="javaScript:sharePostPag(\'http://www.jazzworld.com/assiwebsites/site355/feed.cfm?id=' + feedId + '\',\'' + escapeCharacters(titleData) + '\')" class="defaultLink" style="font-size:10px; font-weight:normal;">Share</a>';
}

//Show Favorites link if the user is a Fan, otherwise show Comments link
if(type == 'community' && userType != ''){
	addFavFunc = "addFavorite('feed','"+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('FEEDID')]+"','" + userType + "');";
	link2 = '<a class="defaultLink" style="font-size:10px; font-weight:normal;" onClick="'+addFavFunc+'"><b>Add Favorite</b></a>';
}else if(((userType == 'fan' && type == 'user')|| type == 'favorite')){
	removeFavFunc = "removeFavorite('feed','"+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('FEEDID')]+"','" + userType + "');";
	link2 = '<a class="defaultLink" style="font-size:10px; font-weight:normal; color:#ff0000;" onClick="'+removeFavFunc+'">Remove Favorite</a>';
}else{
	link2 = '<a href="feed.cfm?id='+paginationReturn.DATA[i-1][7]+'&display=comments" class="defaultLink" style="font-size:10px; font-weight:normal;">Comments ('+paginationReturn.DATA[i-1][6]+')</a>';
}
document.getElementById(type+'Date'+counter).innerHTML = dateFormat(paginationReturn.DATA[i-1][4], 'm/dd/yy h:MM TT') +' | '+link1+' | ' +link2;
var counter = counter+1;
}
}
//END Insert data into divs

//Display community data when user is logged in (Prevents errors in javascript by calling the function 'pagination' separately)
if(pageLoad == 0 && type == 'user'){ pagination(currentPage,'favorite','feed','','','0',userType); }
if(pageLoad == 0 && type == 'favorite'){ pagination(currentPage,'community','feed','','','0',userType); }
}












function events(currentPage,type,page,paginationReturn,startNum,endNum,pageLoad,userType){

//Clear data from divs
for(i=1;i<=10;i++){
	//alert(type+'Div'+i)
document.getElementById(type+'Div'+i).style.height = '';
document.getElementById(type+'Div'+i).style.paddingBottom = '';
document.getElementById(type+'Image'+i).innerHTML = '';
document.getElementById(type+'Title'+i).innerHTML = '';
document.getElementById(type+'Name'+i).innerHTML = '';
document.getElementById(type+'Body'+i).innerHTML = '';
document.getElementById(type+'Date'+i).innerHTML = '';
document.getElementById(type+'Links'+i).innerHTML = '';
}
//START Insert data into divs
if(paginationReturn.DATA.length == 0){
document.getElementById(type+'Div1').style.height = '110px';
document.getElementById(type+'Div1').style.paddingBottom = '15px';
document.getElementById(type+'Image1').innerHTML = 'No Records Found';
}else{
var counter = 1;
for(i=startNum;i<=endNum;i++){
document.getElementById(type+'Div'+counter).style.height = '110px';
document.getElementById(type+'Div'+counter).style.paddingBottom = '15px';
document.getElementById(type+'Image'+counter).innerHTML = '<img src="'+paginationReturn.DATA[i-1][0]+'_thumb.jpg" style="border:1px solid #9ea9b9;"/>';

//Title string manipulation
if(paginationReturn.DATA[i-1][1].length > 25){
	var titleData = paginationReturn.DATA[i-1][1].slice(0,25)+'...';
}else{
	var titleData = paginationReturn.DATA[i-1][1];
}
document.getElementById(type+'Title'+counter).innerHTML = '<a href="'+page+'.cfm?id='+paginationReturn.DATA[i-1][6]+'" class="defaultLinkHover" style="font-size:14px; font-weight:bold;">'+titleData+'</a>';
document.getElementById(type+'Name'+counter).innerHTML = 'Host: <a href="profile.cfm?id='+paginationReturn.DATA[i-1][8]+'&profile=yes" class="defaultLink" style="font-size:11px;">'+paginationReturn.DATA[i-1][2]+'</a>';

//Body string manipulation
if(paginationReturn.DATA[i-1][3].length > 75){
	var bodyData = paginationReturn.DATA[i-1][3].slice(0,75)+'...';
}else{
	var bodyData = paginationReturn.DATA[i-1][3]
}
document.getElementById(type+'Body'+counter).innerHTML = bodyData;
if( paginationReturn.DATA[i-1][8] == true){
	document.getElementById(type+'Date'+counter).innerHTML = '<span style="color:#278d27;">'+ dateFormat(paginationReturn.DATA[i-1][4], 'ddd, mmm dd') +'</span> - <span style="color:#ff4141;">'+ dateFormat(paginationReturn.DATA[i-1][5], 'ddd, mmm dd') +'</span> ('+ paginationReturn.DATA[i-1][9] + ') ';
}else{
	document.getElementById(type+'Date'+counter).innerHTML = '<span style="color:#278d27;">'+ dateFormat(paginationReturn.DATA[i-1][4], 'ddd, mmm dd h:MM TT') +'</span> - <span style="color:#ff4141;">'+ dateFormat(paginationReturn.DATA[i-1][5], 'ddd, mmm dd h:MM TT') +'</span>';
}

//Show remove link if the user owns the event, otherwise show the share link
if(type == 'user' && (userType != 'fan')){
	removeFunc = "removeItem('"+type+"Div"+counter+"','event','"+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('EVENTID')]+"');";
	link1 = '<a class="defaultLink" style="font-size:10px; font-weight:normal; color:#ff0000;" onClick="'+removeFunc+'">Delete</a>';
}else{
	//setShareLinks()
	var eventId = paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('EVENTID')]
	link1 = '<a href="javaScript:sharePostPag(\'http://www.jazzworld.com/assiwebsites/site355/events.cfm?id=' + eventId + '\',\'' + escapeCharacters(titleData) + '\')" class="defaultLink" style="font-size:10px; font-weight:normal;">Share</a>';
}

//Show Favorites link if the user is a Fan, otherwise show Comments link
if(type == 'community' && userType != ''){
	addFavFunc = "addFavorite('events','"+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('EVENTID')]+"','" + userType + "');";
	link2 = '<a class="defaultLink" style="font-size:10px; font-weight:normal;" onClick="'+addFavFunc+'"><b>Add Favorite</b></a>';
}else if(((userType == 'fan' && type == 'user')|| type == 'favorite')){
	removeFavFunc = "removeFavorite('events','"+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('EVENTID')]+"','" + userType + "');";
	link2 = '<a class="defaultLink" style="font-size:10px; font-weight:normal; color:#ff0000;" onClick="'+removeFavFunc+'">Remove Favorite</a>';
}else{
	link2 = '<a href="profile.cfm?id='+paginationReturn.DATA[i-1][8]+'&display=comments" class="defaultLink" style="font-size:10px; font-weight:normal;">Comments ('+paginationReturn.DATA[i-1][7]+')</a>';
}
document.getElementById(type+'Links'+counter).innerHTML = link1 +' | '+ link2;
var counter = counter+1;
}}
//END Insert data into divs

//Display community data when user is logged in (Prevents errors in javascript by calling the function 'pagination' separately)
if(pageLoad == 0 && type == 'user'){ pagination(currentPage,'favorite','events','','','0',userType); }
if(pageLoad == 0 && type == 'favorite'){ pagination(currentPage,'community','events','','','0',userType); }

}

function audio(currentPage,type,page,paginationReturn,startNum,endNum,pageLoad,userType){

//Clear data from divs
for(i=1;i<=10;i++){
document.getElementById(type+'Div'+i).style.height = '';
document.getElementById(type+'Div'+i).style.paddingBottom = '';
document.getElementById(type+'Image'+i).innerHTML = '';
document.getElementById(type+'Title'+i).innerHTML = '';
document.getElementById(type+'Artist'+i).innerHTML = '';
document.getElementById(type+'Album'+i).innerHTML = '';
document.getElementById(type+'AudioDIV'+i).innerHTML = '';
document.getElementById(type+'Links'+i).innerHTML = '';
}

//Stops audio players
AudioPlayer.embed(type+'Audio1', {soundFile:''});
//START Insert data into divs
if(paginationReturn.DATA.length == 0){
document.getElementById(type+'Div1').style.height = '110px';
document.getElementById(type+'Div1').style.paddingBottom = '15px';
document.getElementById(type+'Image1').innerHTML = 'No Records Found';
}else{
var counter = 1;
for(i=startNum;i<=endNum;i++){
document.getElementById(type+'Div'+counter).style.height = '110px';
document.getElementById(type+'Div'+counter).style.paddingBottom = '15px';


//Title string manipulation
if(paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('TITLE')].length > 25){
	var titleData = paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('TITLE')].slice(0,25)+'...';
}else{
	var titleData = paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('TITLE')];
}
if( titleData != 'Singles'){
	document.getElementById(type+'Image'+counter).innerHTML = '<img src="'+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('IMAGE')]+'_thumb.jpg" style="border:1px solid #9ea9b9;"/>';
}else{
	document.getElementById(type+'Image'+counter).innerHTML = '<img src="'+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('IMAGE')]+'_thumb.jpg" style="border:1px solid #9ea9b9;" width="70"/>';
}
//Determine title url var
if(paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('TYPE')] == 'audio'){
	var typeIcon = '<img src="images/audio.jpg" border="0"/>';
}else{
	var typeIcon = '<img src="images/album.jpg" border="0"/>';
}
if( titleData != 'Singles'){
	document.getElementById(type+'Title'+counter).innerHTML = '<a href="'+page+'.cfm?id='+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('AUDIOID')]+'" class="defaultLinkHover" style="font-size:14px; font-weight:bold;">'+titleData+'</a> ' + typeIcon;
}else{
		document.getElementById(type+'Title'+counter).innerHTML = '<a href="'+page+'.cfm?id='+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('AUDIOID')]+'" class="defaultLinkHover" style="font-size:14px; font-weight:bold;">Individual Tracks</a> '
}

//Artist Information

if(paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('ARTISTID')] != '0'){
var audioVar = new audioClass;
var audioReturn = audioVar.getUserNames(paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('AUDIOID')]);
var artistName = escapeCharacters(audioReturn.DATA[0][audioReturn.COLUMNS.findIdx('ARTISTNAME')]);
var artistLink = '<a href="profile.cfm?id='+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('ARTISTID')]+'&profile=yes" class="defaultLink" style="font-size:11px;">';
var closeLink = '</a>';
}else{
	var audioVar = new audioClass;
	var audioUserType = audioVar.getUserType(paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('POSTERID')]);
	
	if(audioUserType.DATA[0][audioUserType.COLUMNS.findIdx('ACCOUNTTYPE')] == 'musician'){
		var audioReturn = audioVar.getPosterName(paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('AUDIOID')]);
		var artistName = escapeCharacters(audioReturn.DATA[0][audioReturn.COLUMNS.findIdx('POSTERNAME')]);
	}else{
	var audioReturn = audioVar.getPosterName(paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('AUDIOID')]);
	var artistName = escapeCharacters(paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('ARTISTNAME')]);
		}
	if(paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('ARTISTLINK')] != ''){
		var artistLink = '<a href="'+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('ARTISTLINK')]+'" class="defaultLink" style="font-size:11px;" target="_blank">';
		var closeLink = '</a>';
	}else{
		var artistLink = '';
		var closeLink = '';
	}
}
if( titleData != 'Singles'){
document.getElementById(type+'Artist'+counter).innerHTML = 'Artist: '+artistLink+''+artistName+''+closeLink;
}

//START Audio Insert
//IF THE AUDIO TYPE IS AN ALBUM
if(paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('TYPE')] != 'album'){
var audioID = paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx("AUDIOID")];
var pathVar = paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('PATH')];
var titleVar = escapeCharacters(paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('TITLE')]);

document.getElementById(type+'AudioDIV'+counter).innerHTML = '<span id="'+type+'Audio'+audioID+'"></span>';
AudioPlayer.embed(type+'Audio'+audioID, {soundFile:pathVar,titles:titleVar,artists:artistName,remaining:"yes"});
}
//END Audio Insert


if(paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('ARTISTID')] == paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('POSTERID')]){
	if(paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('TYPE')] == 'album'){
		if( titleData != 'Singles'){
			document.getElementById(type+'Album'+counter).innerHTML = '<b>Release Date:</b> '+dateFormat(paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('RELEASEDATE')], 'mmm d, yyyy');
		}else{
			document.getElementById(type+'Album'+counter).innerHTML = 'Posted By: <a href="profile.cfm?id='+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('POSTERID')]+'&profile=yes" class="defaultLink" style="font-size:11px;">'+escapeCharacters(audioReturn.DATA[0][audioReturn.COLUMNS.findIdx('POSTERNAME')])+'</a>';
		}
	}else{
		//Album name, either (Single) or the Album Title
		var albumVar = new audioClass;
		var albumReturn = albumVar.getAlbumTitle(paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('ALBUMID')]);
		if( albumReturn.DATA[0][albumReturn.COLUMNS.findIdx('TITLE')] != 'Singles'){
			document.getElementById(type+'Album'+counter).innerHTML = 'Album: <a href="audio.cfm?albumid='+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('ALBUMID')]+'" class="defaultLink" style="font-size:11px;">'+escapeCharacters(albumReturn.DATA[0][albumReturn.COLUMNS.findIdx('TITLE')])+'</a>';
		}
	}
}else{
	if(paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('TYPE')] == 'album'){
		document.getElementById(type+'Album'+counter).innerHTML = '<b>Release Date:</b> '+dateFormat(paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('RELEASEDATE')], 'mmm d, yyyy');
	}else{
		//Album name, either (Single) or the Album Title
		var albumVar = new audioClass;
		var albumReturn = albumVar.getAlbumTitle(paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('ALBUMID')]);
		document.getElementById(type+'Album'+counter).innerHTML = 'Album: <a href="audio.cfm?albumid='+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('ALBUMID')]+'" class="defaultLink" style="font-size:11px;">'+escapeCharacters(albumReturn.DATA[0][albumReturn.COLUMNS.findIdx('TITLE')])+'</a>';
	}
document.getElementById(type+'Album'+counter).innerHTML = 'Posted By: <a href="profile.cfm?id='+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('POSTERID')]+'&profile=yes" class="defaultLink" style="font-size:11px;">'+escapeCharacters(audioReturn.DATA[0][audioReturn.COLUMNS.findIdx('POSTERNAME')])+'</a>';
}

//Show remove link if the user owns the audio, otherwise show the share link
if((type == 'user' || type == 'single') && (userType != 'fan')){
	
	if(type == 'single'){
		removeFunc = "removeItem('"+type+"Div"+counter+"','audio','"+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('AUDIOID')]+"');";
		link1 = '<a class="defaultLink" style="font-size:10px; font-weight:normal; color:#ff0000;" onClick="'+removeFunc+'">Delete</a>';
	}else{
	
		if( titleData != 'Singles'){
			removeFunc = "removeItem('"+type+"Div"+counter+"','audio','"+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('AUDIOID')]+"');";
			link1 = '<a class="defaultLink" style="font-size:10px; font-weight:normal; color:#ff0000;" onClick="'+removeFunc+'">Delete</a>| <a class="defaultLink" style="font-size:10px; font-weight:normal;" onClick="javascript:displayAddAudio(' + paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('AUDIOID')] + ',\'' + escapeCharacters(paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('TITLE')]) + '\',\'' + escapeCharacters(paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('ARTISTNAME')]) + '\', \'' + userType + '\')">add Audio</a> | <a class="defaultLink" style="font-size:10px; font-weight:normal;" onClick="javacript:displayEditAudioAlbum('+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('AUDIOID')] + ',\'' + escapeCharacters(paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('TITLE')]) + '\',\'' + paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('RELEASEDATE')] + '\',\'' + escapeCharacters(paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('COPYRIGHT')]) + '\',\'' + escapeCharacters(paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('DESCRIPTION')]) + '\',\'' + escapeCharacters(paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('ARTISTNAME')]) + '\',\'' + escapeCharacters(paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('ARTISTLINK')])+ '\',\'' + userType + '\')">Edit Album</a> | <a class="defaultLink" style="font-size:10px; font-weight:normal;" onClick="javacript:displayUploadImage(' + paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('AUDIOID')] + ',\'audio\');">Edit Image</a>';
		//document.getElementById('addArtist1').style.display = "none"
		//document.addAudioForm.artist.value = 'testing'
		}else{
	link1 = '<a class="defaultLink" style="font-size:10px; font-weight:normal;" onClick="javascript:displayAddAudio(' + paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('AUDIOID')] +  ',\'' + escapeCharacters(paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('TITLE')]) + '\',\'' + escapeCharacters(paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('ARTISTNAME')]) + '\', \'' + userType + '\')">add Audio</a>';
		}
	}
}else{
	if( titleData != 'Singles'){
	//setShareLinks()
		var AID = paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('AUDIOID')]
		link1 = '<a href="javaScript:sharePostPag(\'http:/www.jazzworld.com/assiwebsites/site355/audio.cfm?id=' + AID + '\',\'' + titleData + '\')" class="defaultLink" style="font-size:10px; font-weight:normal;">Share</a>';
	}else{
		link1 = '';
		}
}

//Show Favorites link if the user is a Fan, otherwise show Comments link
if(type == 'community' && userType != ''){
	addFavFunc = "addFavorite('audio','"+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('AUDIOID')]+"','" + userType + "','" + paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('TYPE')] + "');";
	link2 = '<a class="defaultLink" style="font-size:10px; font-weight:normal;" onClick="'+addFavFunc+'"><b>Add Favorite</b></a>|<a href="audio.cfm?id='+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('AUDIOID')]+'&display=comments" class="defaultLink" style="font-size:10px; font-weight:normal;">Comments ('+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('COMMENTS')]+')</a>';
}else if((userType == 'fan' && type == 'user')|| type == 'favorite'  || type == 'favorite1'){
	removeFavFunc = "removeFavorite('audio','"+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('AUDIOID')]+"','" + userType + "','" + paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('TYPE')] + "');";
	link2 = '<a class="defaultLink" style="font-size:10px; font-weight:normal; color:#ff0000;" onClick="'+removeFavFunc+'">Remove Favorite</a>|<a href="audio.cfm?id='+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('AUDIOID')]+'&display=comments" class="defaultLink" style="font-size:10px; font-weight:normal;">Comments ('+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('COMMENTS')]+')</a>';
}else{
	if(type != 'communitySingle'){
		link2 = '<a href="audio.cfm?id='+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('AUDIOID')]+'&display=comments" class="defaultLink" style="font-size:10px; font-weight:normal;">Comments ('+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('COMMENTS')]+')</a>';
	}else{
		link2 = ''	
	}
}
/*document.getElementById(type+'Links'+counter).innerHTML = 'Plays (<span id="plays'+audioID+'">'+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('PLAYS')]+'</span>) | '+link1+' | '+ link2;*/

document.getElementById(type+'Links'+counter).innerHTML = link1 
if (link1 != '' && link2 != ''){
	document.getElementById(type+'Links'+counter).innerHTML=document.getElementById(type+'Links'+counter).innerHTML + ' | '
}
document.getElementById(type+'Links'+counter).innerHTML=document.getElementById(type+'Links'+counter).innerHTML + link2
var counter = counter+1;
}
}
//END Insert data into divs

//Display community data when user is logged in (Prevents errors in javascript by calling the function 'pagination' separately)
if(pageLoad == 0 && type == 'user'){ pagination(currentPage,'favorite','audio','','','0',userType); }
if(pageLoad == 0 && type == 'favorite'){ pagination(currentPage,'favorite1','audio','','','0',userType); }
if(pageLoad == 0 && type == 'favorite1'){ pagination(currentPage,'single','audio','','','0',userType); }
if(pageLoad == 0 && type == 'single'){ 
switchCommunityDiv('community');
pagination(currentPage,'community','audio','','','0',userType); }
if(pageLoad == 0 && type == 'community'){ pagination(currentPage,'communitySingle','audio','','','0',userType);}
}




function photos(currentPage,type,page,paginationReturn,startNum,endNum,pageLoad,userType){

//Clear data from divs
for(i=1;i<=10;i++){
document.getElementById(type+'Div'+i).style.height = '0px';
document.getElementById(type+'Div'+i).style.paddingBottom = '0px';
document.getElementById(type+'Image'+i).innerHTML = '';
document.getElementById(type+'Title'+i).innerHTML = '';
document.getElementById(type+'Name'+i).innerHTML = '';
document.getElementById(type+'Body'+i).innerHTML = '';
document.getElementById(type+'Links'+i).innerHTML = '';
}

//START Insert data into divs
if(paginationReturn.DATA.length == 0){
document.getElementById(type+'Div1').style.height = '110px';
document.getElementById(type+'Div1').style.paddingBottom = '15px';
document.getElementById(type+'Image1').innerHTML = 'No Records Found';
}else{
var counter = 1;
for(i=startNum;i<=endNum;i++){
document.getElementById(type+'Div'+counter).style.height = '110px';
document.getElementById(type+'Div'+counter).style.paddingBottom = '15px';
if(paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('SITEMASTER')] == true){
	document.getElementById(type+'Image'+counter).innerHTML = '<img src="'+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('SITEMASTERTHUMBNAIL')]+'" style="border:1px solid #9ea9b9;" width="100px"/>';	
}else{
	document.getElementById(type+'Image'+counter).innerHTML = '<img src="'+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('SOURCE')]+'_thumb.jpg" style="border:1px solid #9ea9b9;"/>';
}
//Title string manipulation
if(paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('TITLE')].length > 25){
	var titleData = paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('TITLE')].slice(0,25)+'...';
}else{
	var titleData = paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('TITLE')];
}
document.getElementById(type+'Title'+counter).innerHTML = '<a href="'+page+'.cfm?id='+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('PHOTOID')]+'" class="defaultLinkHover" style="font-size:14px; font-weight:bold;">'+titleData+'</a>';
document.getElementById(type+'Name'+counter).innerHTML = 'By: <a href="profile.cfm?id='+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('POSTERID')]+'&profile=yes" class="defaultLink" style="font-size:11px;">'+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('POSTERNAME')]+'</a>';

//Body string manipulation
if(paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('DESCRIPTION')].length > 90){
	var bodyData = paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('DESCRIPTION')].slice(0,90)+'...';
}else{
	var bodyData = paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('DESCRIPTION')];
}
document.getElementById(type+'Body'+counter).innerHTML = bodyData;

//Show remove link if the user owns the photo, otherwise show the share link
if(type == 'user' && (userType != 'fan')){
	removeFunc = "removeItem('"+type+"Div"+counter+"','photo','"+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('PHOTOID')]+"');";
	link1 = '<a class="defaultLink" style="font-size:10px; font-weight:normal; color:#ff0000;" onClick="'+removeFunc+'">Delete</a> | <a class="defaultLink" style="font-size:10px; font-weight:normal;" onClick="javascript:displayAddPhotos(' + paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('PHOTOID')] + ')">add Photo</a> | <a class="defaultLink" style="font-size:10px; font-weight:normal;" onClick="javascript:displayEditAlbum(' + paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('PHOTOID')] + ')">Edit Album</a>';
}else{
	//setShareLinks( )
	var photoId = paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('PHOTOID')],titleData
	link1 = '<a href="javaScript:sharePostPag(\'http://www.jazzworld.com/assiwebsites/site355/photos.cfm?id=' + photoId + '\',\'' + escapeCharacters(titleData)+ '\')" class="defaultLink" style="font-size:10px; font-weight:normal;">Share</a>';
}

//Show Favorites link if the user is a Fan, otherwise show Comments link
if(type == 'community' && userType != ''){
	addFavFunc = "addFavorite('photos','"+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('PHOTOID')]+"','" + userType + "');";
	link2 = '<a class="defaultLink" style="font-size:10px; font-weight:normal;" onClick="'+addFavFunc+'"><b>Add Favorite</b></a>';
}else if(((userType == 'fan' && type == 'user')|| type == 'favorite')){
	removeFavFunc = "removeFavorite('photos','"+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('PHOTOID')]+"','" + userType + "');";
	link2 = '<a class="defaultLink" style="font-size:10px; font-weight:normal; color:#ff0000;" onClick="'+removeFavFunc+'">Remove Favorite</a>';
}else{
	link2 = '<a href="'+page+'.cfm?id='+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('PHOTOID')]+'&display=comments" class="defaultLink" style="font-size:10px; font-weight:normal;">Comments ('+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('COMMENTS')]+')</a>';
}
document.getElementById(type+'Links'+counter).innerHTML = 'Views ('+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('VIEWS')]+') | '+link1+' | '+ link2;
var counter = counter+1;
}
}
//END Insert data into divs

//Display community data when user is logged in (Prevents errors in javascript by calling the function 'pagination' separately)

if(pageLoad == 0 && type == 'user'){ pagination(currentPage,'favorite','photos','','','0',userType); }
if(pageLoad == 0 && type == 'favorite'){ pagination(currentPage,'community','photos','','','0',userType); }

}









function video(currentPage,type,page,paginationReturn,startNum,endNum,pageLoad,userType){
//Clear data from divs
for(i=1;i<=10;i++){
document.getElementById(type+'Div'+i).style.height = '';
document.getElementById(type+'Div'+i).style.paddingBottom = '';
document.getElementById(type+'Image'+i).innerHTML = '';
document.getElementById(type+'Title'+i).innerHTML = '';
document.getElementById(type+'Name'+i).innerHTML = '';
document.getElementById(type+'Body'+i).innerHTML = '';
document.getElementById(type+'Date'+i).innerHTML = '';
}

//START Insert data into divs
if(paginationReturn.DATA.length == 0){
document.getElementById(type+'Div1').style.height = '110px';
document.getElementById(type+'Div1').style.paddingBottom = '15px';
document.getElementById(type+'Image1').innerHTML = 'No Records Found';
}else{
var counter = 1;
for(i=startNum;i<=endNum;i++){
document.getElementById(type+'Div'+counter).style.height = '110px';
document.getElementById(type+'Div'+counter).style.paddingBottom = '15px';
document.getElementById(type+'Image'+counter).innerHTML = '<img src="'+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('IMAGE')]+'_thumb.jpg" style="border:1px solid #9ea9b9;"/>';

//Title string manipulation
if(paginationReturn.DATA[i-1][1].length > 25){
	var titleData = paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('TITLE')].slice(0,25)+'...';
}else{
	var titleData = paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('TITLE')];
}
document.getElementById(type+'Title'+counter).innerHTML = '<a href="'+page+'.cfm?id='+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('VIDEOID')]+'" class="defaultLinkHover" style="font-size:14px; font-weight:bold;">'+titleData+'</a>';
document.getElementById(type+'Name'+counter).innerHTML = 'By: <a href="profile.cfm?id='+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('POSTERID')]+'&profile=yes" class="defaultLink" style="font-size:11px;">'+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('POSTERNAME')]+'</a>';

//Body string manipulation
if(paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('DESCRIPTION')].length > 90){
	var bodyData = paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('DESCRIPTION')].slice(0,90)+'...';
}else{
	var bodyData = paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('DESCRIPTION')];
}
document.getElementById(type+'Body'+counter).innerHTML = bodyData;

//Show remove link if the user owns the video, otherwise show the share link
if(type == 'user' && (userType != 'fan')){
	removeFunc = "removeItem('"+type+"Div"+counter+"','video','"+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('VIDEOID')]+"');";
	link1 = '<a class="defaultLink" style="font-size:10px; font-weight:normal; color:#ff0000;" onClick="'+removeFunc+'">Delete</a>';
}else{
	//setShareLinks()
	var videoId = paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('VIDEOID')]
	link1 = '<a href="javaScript:sharePostPag(\'http://www.jazzworld.com/assiwebsites/site355/feed.cfm?id=' + videoId + '\',\'' + escapeCharacters(titleData) + '\')" class="defaultLink" style="font-size:10px; font-weight:normal;">Share</a>';
}

//Show Favorites link if the user is a Fan, otherwise show Comments link
if(type == 'community' && userType != ''){
	addFavFunc = "addFavorite('video','"+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('VIDEOID')]+"','" + userType + "');";
	link2 = '<a class="defaultLink" style="font-size:10px; font-weight:normal;" onClick="'+addFavFunc+'"><b>Add Favorite</b></a>';
}else if(((userType == 'fan' && type == 'user')|| type == 'favorite')){
	removeFavFunc = "removeFavorite('video','"+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('VIDEOID')]+"','" + userType + "');";
	link2 = '<a class="defaultLink" style="font-size:10px; font-weight:normal; color:#ff0000;" onClick="'+removeFavFunc+'">Remove Favorite</a>';
}else{
	link2 = '<a href="video.cfm?id='+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('VIDEOID')]+'&display=comments" class="defaultLink" style="font-size:10px; font-weight:normal;">Comments ('+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('COMMENTS')]+')</a>';
}
document.getElementById(type+'Date'+counter).innerHTML = 'Plays ('+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('PLAYS')]+') | '+link1+' | '+ link2;
var counter = counter+1;
}
}
//END Insert data into divs
//Display community data when user is logged in (Prevents errors in javascript by calling the function 'pagination' separately)
if(pageLoad == 0 && type == 'user'){ pagination(currentPage,'favorite','video','','','0',userType); }
if(pageLoad == 0 && type == 'favorite'){ pagination(currentPage,'community','video','','','0',userType); }

}



function profile(currentPage,type,page,paginationReturn,startNum,endNum,pageLoad,userType){
var messageVar = new messageClass;

//Clear data from divs
for(i=1;i<=10;i++){
document.getElementById(type+'Div'+i).style.height = '';
document.getElementById(type+'Div'+i).style.paddingBottom = '';
document.getElementById(type+'Div'+i).style.padding = '';
document.getElementById(type+'Image'+i).innerHTML = '';
document.getElementById(type+'Title'+i).innerHTML = '';
document.getElementById(type+'Name'+i).innerHTML = '';
document.getElementById(type+'Date'+i).innerHTML = '';
document.getElementById(type+'Links'+i).innerHTML = '';
}

//START Insert data into divs
if(paginationReturn.DATA.length == 0){
document.getElementById(type+'Div1').style.padding = '10px';
document.getElementById(type+'Div1').style.height = '110px';
document.getElementById(type+'Div1').style.paddingBottom = '15px';
document.getElementById(type+'Image1').innerHTML = 'No Messages Found';
}else{
var counter = 1;
for(i=startNum;i<=endNum;i++){
document.getElementById(type+'Div'+counter).style.height = '110px';
document.getElementById(type+'Div'+counter).style.paddingBottom = '15px';
document.getElementById(type+'Div'+counter).style.padding = '10px';

document.getElementById(type+'Image'+counter).innerHTML = '<a href="profile.cfm?id=' + paginationReturn.DATA[i-1][2] +'&profile=yes"><img src="'+paginationReturn.DATA[i-1][9]+'.jpg" border="0" width="85" height="85" style="border:1px solid ##9ea9b9;"/></a>';

//Title string manipulation
if(paginationReturn.DATA[i-1][1].length > 25){
	var titleData = paginationReturn.DATA[i-1][0].slice(0,25)+'...';
}else{
	var titleData = paginationReturn.DATA[i-1][0];
}
document.getElementById(type+'Title'+counter).innerHTML = '<a href="javaScript:showDetailMessage(' +  paginationReturn.DATA[i-1][4] + ',\'' + paginationReturn.DATA[i-1][0] + '\',\'' + paginationReturn.DATA[i-1][1] + '\',' + paginationReturn.DATA[i-1][2] + ','  + paginationReturn.DATA[i-1][3] +')" class="defaultLinkHover" style="font-weight:bold; font-size:14px;">'+titleData+'</a>';

document.getElementById(type+'Name'+counter).innerHTML = 'From : '+paginationReturn.DATA[i-1][7] + '(' + paginationReturn.DATA[i-1][8] + ')';

//Body string manipulation
//if(paginationReturn.DATA[i-1][3].length > 75){
	//var bodyData = paginationReturn.DATA[i-1][3].slice(0,75)+'...';
//}else{
//	var bodyData = paginationReturn.DATA[i-1][3]
//}
//document.getElementById(type+'Body'+counter).innerHTML = bodyData;
document.getElementById(type+'Date'+counter).innerHTML = '<span style="color:#278d27;">'+ dateFormat(paginationReturn.DATA[i-1][5], 'ddd, mmm dd h:MM TT') +'</span>';

//Show remove link if the user owns the event, otherwise show the share link
//if(type == 'user' && userType != 'fan'){
	//removeFunc = "removeItem('"+type+"Div"+counter+"','event','"+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('EVENTID')]+"');";
	link1 = '<a  href="javascript:replyMessageFunc(' +  paginationReturn.DATA[i-1][4] + ',' + paginationReturn.DATA[i-1][2] + ','  + paginationReturn.DATA[i-1][3] + ',\'' + paginationReturn.DATA[i-1][0] + '\')" class="defaultLinkHover" style="font-size:11px;">Reply</a>';
	
//}else{
	//link1 = '<a href="#" class="defaultLink" style="font-size:10px; font-weight:normal;">Share</a>';
//}

//Show Favorites link if the user is a Fan, otherwise show Comments link
//if(userType == 'fan' && type == 'community'){
	//addFavFunc = "addFavorite('events','"+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('EVENTID')]+"');";
	link2 = '<a href="javaScript:deleteMessage('+  paginationReturn.DATA[i-1][4] + ')" class="defaultLinkHover" style="font-size:11px;">Delete</a>'
//}else if(userType == 'fan' && type == 'user'){
	//removeFavFunc = "removeFavorite('events','"+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('EVENTID')]+"');";
	//link2 = '<a class="defaultLink" style="font-size:10px; font-weight:normal; color:#ff0000;" onClick="'+removeFavFunc+'">Remove Favorite</a>';
//}else{
	//link2 = '<a href="profile.cfm?id='+paginationReturn.DATA[i-1][8]+'&display=comments" class="defaultLink" style="font-size:10px; font-weight:normal;">Comments ('+paginationReturn.DATA[i-1][7]+')</a>';
//}
	var countMsg = messageVar.getConversationCount(paginationReturn.DATA[i-1][4])
	if(countMsg > 1){
		link3 = '<a href="javaScript:viewConversation(' + paginationReturn.DATA[i-1][4] + ',' + paginationReturn.DATA[i-1][2] + ')" class="defaultLinkHover" style="font-size:11px;">View Conversation</a>'
		document.getElementById(type+'Links'+counter).innerHTML = link1 +' | '+ link2 + ' | ' + link3;
	}else{
		document.getElementById(type+'Links'+counter).innerHTML = link1 +' | '+ link2;
	}
	var counter = counter+1;
}
}
//END Insert data into divs

//Display community data when user is logged in (Prevents errors in javascript by calling the function 'pagination' separately)
//if(pageLoad == 0 && type == 'user'){ pagination(currentPage,'community','events','','','0',userType); }
}


function setShareLinks(path, title){
document.getElementById("googleLink").href = 'http://www.google.com/bookmarks/mark?op=edit&bkmk=' + escape(path) + '&title=' + escape(title)	
document.getElementById("redditLink").href = 'http://reddit.com/submit?url=' + escape(path) + '&title=' + escape(title)	
document.getElementById("buzzLink").href = 'http://buzz.yahoo.com/submit?submitUrl=' + escape(path) + '&submitHeadline=' +escape(title)	
document.getElementById("linkagogoLink").href = 'http://www.linkagogo.com/go/AddNoPopup?title=' + escape(title) + '&url=' + escape(path)	
document.getElementById("simpyLink").href = 'http://simpy.com/simpy/LinkAdd.do?note=' + escape(title) + '&href=' + escape(path)	
document.getElementById("deliciousLink").href = 'http://del.icio.us/post?url='  + escape(path) + '&title=' + escape(title)
document.getElementById("linkedInLink").href = 'http://www.linkedin.com/shareArticle?mini=true&url=' + escape(path) + '&title=' + escape(title) + '&ro=false&summary=&source=' 	
document.getElementById("squidooLink").href = 'http://www.squidoo.com/lensmaster/bookmark?' + escape(path)
document.getElementById("diggLink").href = 'http://digg.com/submit?url=' + escape(path) + '&title=' + escape(title) 	
document.getElementById("liveLink").href = 'https://favorites.live.com/quickadd.aspx?url=' + escape(path) + '&title=' + escape(title) 
document.getElementById("stumbleUponLink").href = 'http://www.stumbleupon.com/submit?url=' + escape(path) + '&title=' + escape(title) 	
document.getElementById("diigoLink").href = 'http://www.diigo.com/post?url=' + escape(path) + '&title=' + escape(title) 	
document.getElementById("mixxLink").href = 'http://www.mixx.com/submit?page_url='+ escape(path) 
document.getElementById("technoratiLink").href = 'http://technorati.com/faves?add='+ escape(path)
document.getElementById("facebookLink").href = 'http://www.facebook.com/sharer.php?u=' + escape(path) + '&t=' + escape(title)	
document.getElementById("myspaceLink").href = 'http://www.myspace.com/Modules/PostTo/Pages/?l=3&u=' + escape(path) + '&t=' + escape(title)	
document.getElementById("twitterLink").href = 'http://twitter.com/home?status=' +escape(path)	
document.getElementById("feedMeLinksLink").href ='http://feedmelinks.com/categorize?from=toolbar&op=submit&name=' +  escape(title) + '&url= ' + escape(path)	
document.getElementById("netvouzLink").href = 'http://www.netvouz.com/action/submitBookmark?url=' + escape(path) + '&title=' + escape(title) +'&popup=no' 	
document.getElementById("yahooLink").href = 'http://myweb2.search.yahoo.com/myresults/bookmarklet?t=' + escape(title) + '&u=' + escape(path)	
document.getElementById("furlLink").href = 'http://www.furl.net/storeIt.jsp?t=' + escape(title) + '&u=' + escape(path)
document.getElementById("newsvineLink").href = 'http://www.newsvine.com/_wine/save?popoff=0&u=' + escape(path) + '&h=' + escape(title)
}

 function escapeCharacters(str)
  {
	  if(str != null){
       str = str.replace(/'/gi, '\\\'');
	   str = str.replace(/"/gi, '\\\'');
	   return str;
	  }else{
       return str;
	  }
  }
