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="#000000"
document.getElementById("users").style.color="#FFFFFF"
document.getElementById("singles").style.color="#FFFFFF"
document.getElementById("favorites").style.background="#FFFFFF"
document.getElementById("users").style.background="#CCCCCC"
document.getElementById("singles").style.background="#CCCCCC"


}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="#FFFFFF"
document.getElementById("users").style.color="#000000"
document.getElementById("singles").style.color="#FFFFFF"
document.getElementById("favorites").style.background="#CCCCCC"
document.getElementById("users").style.background="#FFFFFF"
document.getElementById("singles").style.background="#CCCCCC"

}
else{
document.getElementById("favoriteCommonDiv").style.display="none"	
document.getElementById("userDiv").style.display="none"	
document.getElementById("singleDiv").style.display=""
document.getElementById("favorites").style.color="#FFFFFF"
document.getElementById("users").style.color="#FFFFFF"
document.getElementById("singles").style.color="#000000"
document.getElementById("favorites").style.background="#CCCCCC"
document.getElementById("users").style.background="#CCCCCC"
document.getElementById("singles").style.background="#FFFFFF"
}
}

function switchUserFavoriteDiv1(type){
if(type == 'favorite'){
document.getElementById("favoriteDiv").style.display=""	
document.getElementById("userDiv").style.display="none"
document.getElementById("favorites").style.color="#000000"
document.getElementById("users").style.color="#FFFFFF"
document.getElementById("favorites").style.background="#FFFFFF"
document.getElementById("users").style.background="#CCCCCC"
}else {
document.getElementById("favoriteDiv").style.display="none"	
document.getElementById("userDiv").style.display=""	
document.getElementById("favorites").style.color="#FFFFFF"
document.getElementById("users").style.color="#000000"
document.getElementById("favorites").style.background="#CCCCCC"
document.getElementById("users").style.background="#FFFFFF"
}
}

function switchUserFavoriteDiv2(type){
if(type == 'singles'){
document.getElementById("singleDiv").style.display=""	
document.getElementById("userDiv").style.display="none"
document.getElementById("singles").style.color="#000000"
document.getElementById("users").style.color="#FFFFFF"
document.getElementById("singles").style.background="#FFFFFF"
document.getElementById("users").style.background="#CCCCCC"
}else {
document.getElementById("singleDiv").style.display="none"	
document.getElementById("userDiv").style.display=""	
document.getElementById("singles").style.color="#FFFFFF"
document.getElementById("users").style.color="#000000"
document.getElementById("singles").style.background="#CCCCCC"
document.getElementById("users").style.background="#FFFFFF"
}
}

function switchFavoriteDivs(type){
if(type == 'albums'){
document.getElementById("favoriteDiv").style.display=""	
document.getElementById("favorite1Div").style.display="none"
document.getElementById("favoriteAlbums").style.color="#000000"
document.getElementById("favoriteTracks").style.color="#FFFFFF"
document.getElementById("favoriteAlbums").style.background="#FFFFFF"
document.getElementById("favoriteTracks").style.background="#CCCCCC"
}
else{
document.getElementById("favoriteDiv").style.display="none"	
document.getElementById("favorite1Div").style.display=""	
document.getElementById("favoriteAlbums").style.color="#FFFFFF"
document.getElementById("favoriteTracks").style.color="#000000"
document.getElementById("favoriteAlbums").style.background="#CCCCCC"
document.getElementById("favoriteTracks").style.background="#FFFFFF"
}
}
function pagination(currentPage,type,page,searchFunc,searchValue,pageLoad,userType,sameUser,userId){
if (type == 'favoriteAction'){
	var favoriteAction = 1
	if (userType == 'fan' && page == 'audio'){
		type = 'favorite';
	}else{
		type = 'user'
	}

}else{
	var favoriteAction = 0
}
//Show/Hide Divs
if(type !='single' && type !='favorite' && type !='favorite1'){
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 paginationProfileClass;
}

/*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,userId);
}else if(page == "events"){
	var paginationReturn = paginationVar.eventsPagination(type,searchFunc,searchValue,userId);
}else if(page == "audio"){
		var paginationReturn = paginationVar.audioPagination(type,searchFunc,searchValue,userId);
}else if(page == "photos"){
var paginationReturn = paginationVar.photosPagination(type,searchFunc,searchValue,userId);
}else if(page == "video"){
var paginationReturn = paginationVar.videoPagination(type,searchFunc,searchValue,userId);
}else if(page == "profile"){
var paginationReturn = paginationVar.inboxPagination(type,searchFunc,searchValue);
}else if(page == "profileFans"){
var paginationReturn = paginationVar.fanPagination(type,searchFunc,searchValue,userId);
}else if(page == "profileFriends"){
var paginationReturn = paginationVar.friendPagination(type,searchFunc,searchValue,userId);
}else if(page == "profileFansOf"){
var paginationReturn = paginationVar.fanOfPagination(type,searchFunc,searchValue,userId);
}


//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,sameUser,userId);

//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+"','"+ sameUser + "','" + userId + "');";
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+"','"+ sameUser + "','" + userId + "');";
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+"','"+ sameUser + "','" + userId + "');";
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+"','"+ sameUser + "','" + userId + "');";
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+"','"+ sameUser + "','" + userId + "');";
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){ 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+"','"+ sameUser + "','" + userId + "');";
	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+"','"+ sameUser + "','" + userId + "');";
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+"','"+ sameUser + "','" + userId + "');";
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 = ''; }
if(type !='single' && type !='favorite' && type !='favorite1'){
setTimeout(function(){
//Show/Hide Divs
document.getElementById(type+'Div').style.display='';
document.getElementById(type+'DivLoader').style.display='none';
},500);
}
}








function feed(currentPage,type,page,paginationReturn,startNum,endNum,pageLoad,userType,sameUser,userId){

//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' && type != 'favorite') && sameUser =='yes'){
	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{
	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(type == 'user' && userType != '' && sameUser =='no' && userType != 'fan'){
	var profileVar = new profileClass;
	var getFavorite = profileVar.checkFavoriteByProfileId(paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('FEEDID')],page)
	if(getFavorite.DATA.length == 0){
		addFavFunc = "addFavorite('feed','"+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('FEEDID')]+"','" + userType + "','" + userId + "');";
		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('FEEDID')]+'&display=comments" class="defaultLink" style="font-size:10px; font-weight:normal;">Comments ('+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('COMMENTS')]+')</a>';
	}else{
		removeFavFunc = "removeFavorite('feed','"+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('FEEDID')]+"','" + userType + "','" + userId + "');";
		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('FEEDID')]+'&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') && (sameUser == 'yes')){
			removeFavFunc = "removeFavorite('feed','"+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('FEEDID')]+"','" + userType + "','" + userId + "');";
			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('FEEDID')]+'&display=comments" class="defaultLink" style="font-size:10px; font-weight:normal;">Comments ('+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('COMMENTS')]+')</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>';
}
//if(sameUser !='no'){
document.getElementById(type+'Date'+counter).innerHTML = dateFormat(paginationReturn.DATA[i-1][4], 'm/dd/yy h:MM TT') +' | '+link1+' | ' +link2;
/*}
else{
document.getElementById(type+'Date'+counter).innerHTML = dateFormat(paginationReturn.DATA[i-1][4], 'm/dd/yy h:MM TT') +' | ' +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','feed','','','0',userType); }
if(pageLoad == 0 && type == 'user'){ pagination(currentPage,'favorite','feed','','','0',userType,sameUser,userId); }
}












function events(currentPage,type,page,paginationReturn,startNum,endNum,pageLoad,userType,sameUser,userId){

//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 = '';
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' && type != 'favorite') && sameUser =='yes'){
	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{
	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(type == 'user' && userType != '' && sameUser =='no' && userType != 'fan'){
	var profileVar = new profileClass;
	var getFavorite = profileVar.checkFavoriteByProfileId(paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('EVENTID')],page)
	if(getFavorite.DATA.length == 0){
		addFavFunc = "addFavorite('events','"+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('EVENTID')]+"','" + userType + "','" + userId + "');";
		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('EVENTID')]+'&display=comments" class="defaultLink" style="font-size:10px; font-weight:normal;">Comments ('+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('COMMENTS')]+')</a>';
	}else{
		removeFavFunc = "removeFavorite('events','"+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('EVENTID')]+"','" + userType + "','" + userId + "');";
		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('EVENTID')]+'&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') && (sameUser == 'yes')){
			removeFavFunc = "removeFavorite('events','"+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('EVENTID')]+"','" + userType + "','" + userId + "');";
			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('EVENTID')]+'&display=comments" class="defaultLink" style="font-size:10px; font-weight:normal;">Comments ('+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('COMMENTS')]+')</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>';
}
//if(sameUser !='no'){
document.getElementById(type+'Links'+counter).innerHTML = link1 +' | '+ link2;
/*}
else{
	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,'community','events','','','0',userType); }
if(pageLoad == 0 && type == 'user'){ pagination(currentPage,'favorite','events','','','0',userType,sameUser,userId); }
}












function audio(currentPage,type,page,paginationReturn,startNum,endNum,pageLoad,userType,sameUser,userId){

//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';
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][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')];
}

//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"/>';
}
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;

//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 = 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 audioReturn = audioVar.getPosterName(paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('AUDIOID')]);
var artistName = 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 = '';
	}
}
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 = 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'){
		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
		if(paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('ALBUMID')] == '0'){
		document.getElementById(type+'Album'+counter).innerHTML = 'Album: <span style="color:#999999;"><i>Single</i></span>';
		}else{
		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;">'+albumReturn.DATA[0][albumReturn.COLUMNS.findIdx('TITLE')]+'</a>';
		}
	}
}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;">'+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' && type != 'favorite' && type != 'favorite1') && sameUser =='yes'){
		//if( userType == 'musician'){
	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{
			removeFunc = "removeItem('"+type+"Div"+counter+"','audio','"+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('AUDIOID')]+"');";
			if(titleData != 'Singles'){
				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')]) + '\',\'' + 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>';
			}else{
				link1 = '<a class="defaultLink" style="font-size:10px; font-weight:normal;" onClick="javascript:displayAddAudio(' + paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('AUDIOID')] + ')">add Audio</a>' 
			}
	}
		//}else{
			//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+'">Remove</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((type == 'user' || type == 'single') && userType != '' && sameUser == 'no' && userType != 'fan'){
	var profileVar = new profileClass;
	var getFavorite = profileVar.checkFavoriteByProfileId(paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('AUDIOID')],page)
	if(getFavorite.DATA.length == 0){
		addFavFunc = "addFavorite('audio','"+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('AUDIOID')]+"','" + userType + "','" + userId + "');";
		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{
		removeFavFunc = "removeFavorite('audio','"+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('AUDIOID')]+"','" + userType + "','" + userId + "');";
		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(((userType == 'fan' && type == 'user')|| type == 'favorite') && (sameUser == 'yes')){
			removeFavFunc = "removeFavorite('audio','"+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('AUDIOID')]+"','" + userType + "','" + userId + "');";
			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{
	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>';
}

//if(sameUser !='no'){
document.getElementById(type+'Links'+counter).innerHTML = 'Plays (<span id="plays'+audioID+'">'+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('PLAYS')]+'</span>) | '+link1+' | '+ link2;
/*}
else{
	document.getElementById(type+'Links'+counter).innerHTML = 'Plays (<span id="plays'+audioID+'">'+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('PLAYS')]+'</span>) | '+ 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','audio','','','0',userType); }
if(pageLoad == 0 && type == 'user'){ pagination(currentPage,'favorite','audio','','','0',userType,sameUser,userId); }
if(pageLoad == 0 && type == 'favorite'){ pagination(currentPage,'favorite1','audio','','','0',userType,sameUser,userId); }
if(pageLoad == 0 && type == 'favorite1'){ pagination(currentPage,'single','audio','','','0',userType,sameUser,userId); }


}




function photos(currentPage,type,page,paginationReturn,startNum,endNum,pageLoad,userType,sameUser,userId){

//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' && type != 'favorite') && sameUser =='yes'){
	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{
	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(type == 'user' && userType != '' && sameUser =='no' && userType != 'fan'){
	var profileVar = new profileClass;
	
	var getFavorite = profileVar.checkFavoriteByProfileId(paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('PHOTOID')],page)
	if(getFavorite.DATA.length == 0){
		addFavFunc = "addFavorite('photos','"+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('PHOTOID')]+"','" + userType + "','" + userId + "');";
		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('PHOTOID')]+'&display=comments" class="defaultLink" style="font-size:10px; font-weight:normal;">Comments ('+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('COMMENTS')]+')</a>';
	}else{
		removeFavFunc = "removeFavorite('photos','"+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('PHOTOID')]+"','" + userType + "','" + userId + "');";
		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('PHOTOID')]+'&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') && (sameUser == 'yes')){
			removeFavFunc = "removeFavorite('photos','"+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('PHOTOID')]+"','" + userType + "','" + userId + "');";
			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('PHOTOID')]+'&display=comments" class="defaultLink" style="font-size:10px; font-weight:normal;">Comments ('+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('COMMENTS')]+')</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>';
}
//if(sameUser !='no'){
document.getElementById(type+'Links'+counter).innerHTML = 'Views ('+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('VIEWS')]+') | '+link1+' | '+ link2;
/*}
else{
	document.getElementById(type+'Links'+counter).innerHTML = 'Views ('+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('VIEWS')]+') | '+ 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','photos','','','0',userType); }
if(pageLoad == 0 && type == 'user'){ pagination(currentPage,'favorite','photos','','','0',userType,sameUser,userId); }
}









function video(currentPage,type,page,paginationReturn,startNum,endNum,pageLoad,userType,sameUser,userId){
//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' && type != 'favorite') && sameUser =='yes'){
	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{
	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(type == 'user' && userType != '' && sameUser =='no' && userType != 'fan'){
	var profileVar = new profileClass;
	var getFavorite = profileVar.checkFavoriteByProfileId(paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('VIDEOID')],page)
	if(getFavorite.DATA.length == 0){
		addFavFunc = "addFavorite('video','"+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('VIDEOID')]+"','" + userType + "','" + userId + "');";
		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('VIDEOID')]+'&display=comments" class="defaultLink" style="font-size:10px; font-weight:normal;">Comments ('+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('COMMENTS')]+')</a>';
	}else{
		removeFavFunc = "removeFavorite('video','"+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('VIDEOID')]+"','" + userType + "','" + userId + "');";
		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('VIDEOID')]+'&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') && (sameUser == 'yes')){
			removeFavFunc = "removeFavorite('video','"+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('VIDEOID')]+"','" + userType + "','" + userId + "');";
			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('VIDEOID')]+'&display=comments" class="defaultLink" style="font-size:10px; font-weight:normal;">Comments ('+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('COMMENTS')]+')</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>';
}


//if(sameUser !='no'){
document.getElementById(type+'Date'+counter).innerHTML = 'Plays ('+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('PLAYS')]+') | '+link1+' | '+ link2;
/*}
else{
	document.getElementById(type+'Date'+counter).innerHTML = 'Plays ('+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('PLAYS')]+') | '+ 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','video','','','0',userType); }
if(pageLoad == 0 && type == 'user'){ pagination(currentPage,'favorite','video','','','0',userType,sameUser,userId); }
}



function profile(currentPage,type,page,paginationReturn,startNum,endNum,pageLoad,userType,sameUser,userId){
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 profileFans(currentPage,type,page,paginationReturn,startNum,endNum,pageLoad,userType,sameUser,userId){
//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+'Name'+i).innerHTML = '';
document.getElementById(type+'CityState'+i).innerHTML = '';
document.getElementById(type+'Country'+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 Fan 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][paginationReturn.COLUMNS.findIdx('PROFILEID')] +'&profile=yes"><img src="'+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('IMAGE')]+'.jpg" border="0" width="85" height="85" style="border:1px solid ##9ea9b9;"/></a>';

//Title string manipulation

	var nameData = paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('FIRSTNAME')] + ' ' + paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('LASTNAME')];

document.getElementById(type+'Name'+counter).innerHTML = '<a href="profile.cfm?id=' + paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('PROFILEID')] +'&profile=yes" class="defaultLinkHover" style="font-weight:bold; font-size:14px;">'+nameData+'</a>';

var cityData =  paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('CITY')]
var stateData =  paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('STATE')]

if(cityData != ''){
	document.getElementById(type+'CityState'+counter).innerHTML = cityData + ',';
}

if(stateData != ''){
	document.getElementById(type+'CityState'+counter).innerHTML = document.getElementById(type+'CityState'+counter).innerHTML + stateData;
}

var countryData =  paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('COUNTRY')]
if(countryData != ''){
	document.getElementById(type+'Country'+counter).innerHTML = countryData;
}
	var counter = counter+1;
}
}
}

function profileFansOf(currentPage,type,page,paginationReturn,startNum,endNum,pageLoad,userType,sameUser,userId){
//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+'Name'+i).innerHTML = '';
document.getElementById(type+'CityState'+i).innerHTML = '';
document.getElementById(type+'Country'+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 Fan 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][paginationReturn.COLUMNS.findIdx('PROFILEID')] +'&profile=yes"><img src="'+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('IMAGE')]+'.jpg" border="0" width="85" height="85" style="border:1px solid ##9ea9b9;"/></a>';

//Title string manipulation

	var nameData = paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('FIRSTNAME')] + ' ' + paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('LASTNAME')];

document.getElementById(type+'Name'+counter).innerHTML = '<a href="profile.cfm?id=' + paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('PROFILEID')] +'&profile=yes" class="defaultLinkHover" style="font-weight:bold; font-size:14px;">'+nameData+'</a>';

var cityData =  paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('CITY')]
var stateData =  paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('STATE')]

if(cityData != ''){
	document.getElementById(type+'CityState'+counter).innerHTML = cityData + ',';
}

if(stateData != ''){
	document.getElementById(type+'CityState'+counter).innerHTML = document.getElementById(type+'CityState'+counter).innerHTML + stateData;
}

var countryData =  paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('COUNTRY')]
if(countryData != ''){
	document.getElementById(type+'Country'+counter).innerHTML = countryData;
}
	var counter = counter+1;
}
}
}

function profileFriends(currentPage,type,page,paginationReturn,startNum,endNum,pageLoad,userType,sameUser,userId){
//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+'Name'+i).innerHTML = '';
document.getElementById(type+'CityState'+i).innerHTML = '';
document.getElementById(type+'Country'+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 Fan 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][paginationReturn.COLUMNS.findIdx('PROFILEID')] +'&profile=yes"><img src="'+paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('IMAGE')]+'.jpg" border="0" width="85" height="85" style="border:1px solid ##9ea9b9;"/></a>';

//Title string manipulation

	var nameData = paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('FIRSTNAME')] + ' ' + paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('LASTNAME')];

document.getElementById(type+'Name'+counter).innerHTML = '<a href="profile.cfm?id=' + paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('PROFILEID')] +'&profile=yes" class="defaultLinkHover" style="font-weight:bold; font-size:14px;">'+nameData+'</a>';

var cityData =  paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('CITY')]
var stateData =  paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('STATE')]

if(cityData != ''){
	document.getElementById(type+'CityState'+counter).innerHTML = cityData + ',';
}

if(stateData != ''){
	document.getElementById(type+'CityState'+counter).innerHTML = document.getElementById(type+'CityState'+counter).innerHTML + stateData;
}

var countryData =  paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('COUNTRY')]
if(countryData != ''){
	document.getElementById(type+'Country'+counter).innerHTML = countryData;
}
if(sameUser == 'yes'){
	link1 = '<a href="javaScript:removeFriend('+ paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('PROFILEID')] + ',' + paginationReturn.DATA[i-1][paginationReturn.COLUMNS.findIdx('FRIENDID')] + ')" class="defaultLinkHover" style="font-size:11px; color:#FF0000;">Remove</a>';
	document.getElementById(type+'Links'+counter).innerHTML =link1;
}
	var counter = counter+1;
}
}
}

 function escapeCharacters(str)
  {
	  if(str != null){
       str = str.replace(/'/gi, '\\\'');
	   str = str.replace(/"/gi, '\\\'');
	   return str;
	  }else{
       return str;
	  }
  }
