var relURL = "/";
var ajax_load = relURL + "images/load.gif";
var closeBtn  = relURL + "images/closeicon.gif";

function menuPop(spot, func) { 
	if (spot == 'sl') 
		if (func == 'show')
			document.getElementById('slPop').style.visibility = 'visible';
		else
			document.getElementById('slPop').style.visibility = 'hidden';
	else
		if (func == 'show')
			document.getElementById('mrPop').style.visibility = 'visible';
		else
			document.getElementById('mrPop').style.visibility = 'hidden';
}

$(function() {
	$('.rollover').hover(function() {
		var currentImg = $(this).attr('src');
		$(this).attr('src', $(this).attr('hover'));
		$(this).attr('hover', currentImg);
	}, function() {
			var currentImg = $(this).attr('src');
			$(this).attr('src', $(this).attr('hover'));
			$(this).attr('hover', currentImg);
		});
});

function swapImages(imgNum) {
	if (imgNum == 1) {
		document.getElementById('slide1').style.zIndex=1;
		document.getElementById('slide2').style.zIndex=0;
		document.getElementById('slide3').style.zIndex=0;
	}
	else if (imgNum == 2) {
		document.getElementById('slide1').style.zIndex=0;
		document.getElementById('slide2').style.zIndex=1;
		document.getElementById('slide3').style.zIndex=0;
	}
	else {
		document.getElementById('slide1').style.zIndex=0;
		document.getElementById('slide2').style.zIndex=0;
		document.getElementById('slide3').style.zIndex=1;
	}
}

function closeTB() {
	document.getElementById('closeMe').click();
}

function setPopupDisplay (element, row, action, total) {
	if (action == 'show') {
		for (i=1; i<=total; i++) {
			var incID='popup'+i;
			try {
				if (i != row) 
					document.getElementById(incID).style.display = 'none';
			}
			catch(err) {
			}
		}

		if ((document.getElementById(element).style.display == '') || (document.getElementById(element).style.display == 'none'))
			document.getElementById(element).style.display = 'block';
		else
			document.getElementById(element).style.display = 'none';
	}
	else 
		document.getElementById(element).style.display = 'none';
}

function ajaxAddBand(bandID,showID, uID) {
	var hldID = "." + bandID;
	var lblID = ".a" + bandID;
	var currImg = $(hldID).attr("src");
	var BandCount = $("#BandCount").html();
	var closeImg = "#c" + showID;
	
	if (currImg.indexOf("CheckMarkSmall") > 0) {
		var func="REMOVE";
		var nfunc="SAVE";
		BandCount--;
	}
	else {
		var func="SAVE";
		var nfunc="REMOVE";
		BandCount++;
	}
	
	$(closeImg).attr({src:ajax_load});
	$.post(
			relURL + "myrockness/process/processmr.cfm",
			{f: "addbandtouser", userid: uID, bandID: bandID, func:func},	
	 		function(data){
				$(hldID).attr({src:data});
				$(lblID).attr('innerHTML', nfunc);
				$("#BandCount").attr('innerHTML', BandCount);
				$(closeImg).attr({src:closeBtn});
			}
		  );		  
}

function ajaxAddBandSimple(bandID, uID) {
	var hldID = "." + bandID;
	var BandCount = $("#BandCount").html();
	BandCount++
	
	$.post(
			relURL + "myrockness/process/processmr.cfm",
			{f: "addbandtousersimple", userid: uID, bandID: bandID},	
	 		function(data){
				$(hldID).attr({src:data});
				$(hldID).attr({hover:data});
				$("#BandCount").attr('innerHTML', BandCount);
			}
	);	
}

function ajaxAddBandSimpleWithTotal(bandID, uID) {
	var hldID = "." + bandID;
	var addID = ".add" + bandID;
	var BandCount = $("#BandCount").html();
	var TotalCount = $(hldID).html();
	BandCount++;
	TotalCount++;

	$.post(
			relURL + "myrockness/process/processmr.cfm",
			{f: "addbandtousersimple", userid: uID, bandID: bandID},	
	 		function(data){
				$(addID).attr({src:data});
				$(addID).attr({hover:data});
				$(addID).attr({onclick:''});
				$("#BandCount").attr('innerHTML', BandCount);
				$(hldID).attr('innerHTML', TotalCount);
			}
	);	
}


function ajaxAddShow(showID,uID) {
	var hldID = "." + showID;
	var addID = ".add" + showID;
	var lblID = ".a" + showID;
	var currImg = $(hldID).attr("src");
	var showCount = $("#ShowCount").html();
	var usrCount = $(".p-"+showID).html();
	var closeImg = "#c" + showID;
	
	if (usrCount == null)
		usrCount = 0;
	
	if (currImg.indexOf("CheckMarkSmall") > 0) {
		var func="REMOVE";
		var nfunc="SAVE";
		showCount--;
		usrCount--;
	}
	else {
		var func="SAVE";
		var nfunc="REMOVE";
		showCount++;
		usrCount++;
	}

	$(closeImg).attr({src:ajax_load});
	$.post(
			relURL+ "myrockness/process/processmr.cfm",
			{f: "addshowtouser", userid: uID, showID: showID, func:func},	
	 		function(data){
				var imgs=data.split("~");
				$(hldID).attr({src:imgs[0]});
				$(addID).attr({src:imgs[1]});
				$(lblID).attr('innerHTML', nfunc);
				$("#ShowCount").attr('innerHTML', showCount);
				if (usrCount == 0) {
					$(".p-"+showID).attr('innerHTML', '');
					$(".ds"+showID).attr('innerHTML', '');
				}
				else {
					$(".p-"+showID).attr('innerHTML', usrCount);
					$(".ds"+showID).attr('innerHTML', 'saved');
				}
				$(closeImg).attr({src:closeBtn});
			}
		  );		  
}

function ajaxAddShowNotList(showID,uID) {
	var hldID = "." + showID;
	var currImg = $(hldID).attr("src");
	var showCount = $("#ShowCount").html();
	var usrCount = $(".p-"+showID).html();
	
	showCount++;
	usrCount++;
	$.post(
			relURL+ "myrockness/process/processmr.cfm",
			{f: "addshowtousernolist", userid: uID, showID: showID},	
	 		function(data){
				$(hldID).attr({src:data});
				$(hldID).attr({hover:data});
				$("#ShowCount").attr('innerHTML', showCount);
				$(".p-"+showID).attr('innerHTML', usrCount);
			}
		  );	
}



