var req1;

function addToRolodex(useridx) {
       $.get("rolodexXML.php?idx=" + useridx, function(data) {
				alert("user added to your rolodex");       
       });
       
}

function iSupportBand(useridx) {
$.get("fansupportMybandsXML.php?idx=" + useridx, function(data) {
  				alert("This band has been added to your list of bands you support! \nThis band will be displayed on your profile.\nYou can manage/remove Supported bands in the Fan Support section.");
				window.location.href='/fansupportMybands.php';
});
  
}

function addToMailingList(useridx) {
$.get("mailingListXML.php?idx=" + useridx, function(data) { 
				alert("You have been added to this mailing list");

});    
      
}

function toggleLargeImage () {
	if (bigImageShowing) {
		container = document.getElementById("profileImage" + activeThumb);
		container.className = "profileImagesLargeHidden";
		bigImageShowing = false;
		embeds = document.getElementsByTagName('embed');
		for(i = 0; i < embeds.length; i++) {
		    embeds[i].style.visibility = 'visible';
		}
	}
	else {
		container = document.getElementById("profileImage" + activeThumb);
		container.className = "profileImagesLarge";
		embeds = document.getElementsByTagName('embed');
		for(i = 0; i < embeds.length; i++) {
		    embeds[i].style.visibility = 'hidden';
		}
		bigImageShowing = true;
	}
}

function prevProfileImage() {
	//find current index in array
	if (bigImageShowing) {
		toggleLargeImage();
	}
	for (x in imageIndex) {
		if (imageIndex[x] == activeThumb) {
			activeIndex = x;
		}
	}
	if (activeIndex > 0) {
		activeIndex--;
		document.profileImage.src = eval("thumb" + imageIndex[activeIndex] + ".src");
		activeThumb = imageIndex[activeIndex];
	}
}

function nextProfileImage() {
	//find current index in array
	if (bigImageShowing) {
		toggleLargeImage();
	}
	for (x in imageIndex) {
		if (imageIndex[x] == activeThumb) {
			activeIndex = x;
		}
	}
	if (activeIndex < imageIndex.length) {
		activeIndex++;
		document.profileImage.src = eval("thumb" + imageIndex[activeIndex] + ".src");
		activeThumb = imageIndex[activeIndex];
	}
}

function songDetails(idx) {
	if (document.getElementById("songDetails")) {
		var myAjax = new Ajax.Request('songDetails.php?songIdx=' + idx,
    	    		{method: 'get', parameters: "", onComplete: songResponder}
		);			
	}
}

function songResponder(originalRequest) {
	detailsDiv = document.getElementById("songDetails");
	detailsDiv.innerHTML = originalRequest.responseText;
	detailsDiv.className = "songDetails";
	detailsDiv.style.top = (mouseY-150) + "px";
}

function hideSongDetails() {
	detailsDiv = document.getElementById("songDetails");
	detailsDiv.className = "notesHidden";
}

function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

function saveSongRating() {
	songIdx = document.songDetailsForm.itemIdx.value;
	score = getCheckedValue(document.songDetailsForm.ratingScore);
	var myAjax = new Ajax.Request('ratingXML.php?zone=mp3s&idx=' + songIdx + '&score=' + score,
    	    		{method: 'get', parameters: "", onComplete: songRatingResponder});
}

function songRatingResponder(originalRequest) {
	ratingDiv = document.getElementById("songRatingDiv");
	ratingDiv.innerHTML = "<b>Rating: </b> <img src=\"img/rating_" + originalRequest.responseText + ".gif\" border=0>";
	
}

function addtoplaylist(idx) {
	var myAjax = new Ajax.Request('addToPlaylist.php?songIdx=' + idx,
   	    		{method: 'get', parameters: "", onComplete: playlistResponder}
	);			
}

function delfromplaylist(idx) {
	var myAjax = new Ajax.Request('delFromPlaylist.php?songIdx=' + idx,
   	    		{method: 'get', parameters: "", onComplete: playlistResponder}
	);			
}

function playlistResponder(originalRequest) {
	alert(originalRequest.responseText);	
}

