$(document).ready(function(){
	$('#mediaNavDav').addClass('mediaNavDav_bkgnd');
	//$('#statusDiv').click(function() {			   
  	//	$('#lightsOutWrapper').fadeIn('slow', function() {
        // Animation complete
	//	$('#mediaNavDav').removeClass('mediaNavDav_bkgnd').addClass('mediaNavDav_bkgnd_light');
    //  });
	//});
	setTimeout('mag_initEvent();', 300);

	var hubHeight = $("#hubContainer").height();
	updatePlaylist();
	
	$(".thinkingLink").click(function(){
		$("#loadingDiv").show();
		//specific to CA Overview page
		$('#player_ca').hide();
	});
	$(".overviewCALink").click(function(){
		//specific to CA Overview page
		$('#player_ca').remove();
	});
	$('#publishButton').click(function(){
		updatePlaylist();
		$('#form1').submit();
	});
	$("#field_submit").click(function(){
		$("#loadingDiv").show();
	});

	$("#magnetHolder .magnetDiv div").click(function(){
		return false;
	});
	$("#magnetHolder_hubView .magnetDiv div").click(function(){
		return false;
	});
	
	$("#mediaNavDav li").mouseover(function(){
		$(this).children('div').show();
	}).mouseout(function(){
		$(this).children('div').hide();
	});
	$("#mediaNavInTab li").mouseover(function(){
		$(this).children('div').show();
	}).mouseout(function(){
		$(this).children('div').hide();
	});
	// MAGNETIC - LIGHTS SWITCH
	$("#lightSwitchONLi").hide();
	//$("#lightSwitchOFFLi").hide(); //COMMENT TO ENABLE
	
	$('#lightsOutChannelName').text($('#userInfo h2').text());
	
	$("#lightSwitchOFFLi").click(function(){
		$(this).hide();
		$("#lightSwitchONLi").show();
		$('#lightsOutWrapper').fadeIn('slow', function() {
		$('#mediaNavDav').removeClass('mediaNavDav_bkgnd').addClass('mediaNavDav_bkgnd_light');
		$('#lightsOutVideoNavBox').fadeIn('slow');
		$('#lightsOutVideoTextBox').fadeIn('slow');
		});
	});
	$("#lightSwitchONLi").click(function(){
		$(this).hide();
		$("#lightSwitchOFFLi").show();
		$('#mediaNavDav').removeClass('mediaNavDav_bkgnd_light').addClass('mediaNavDav_bkgnd');
		$('#lightsOutVideoTextBox').fadeOut('slow');
		$('#lightsOutVideoNavBox').fadeOut('slow');
		$('#lightsOutWrapper').fadeOut('slow', function() {
		});
	});
	// MAGNETIC - WE ARE STARTING PAGE LOAD WITH CONTINUOUS PLAY ON
	mag_setPlayState('on');
	mag_setautoPlay('false');
	
	$("#continuousPlayLi").hide();
	$("#continuousPlayLi").click(function(){
		$(this).hide();
		$("#continuousPlayOnLi").show();
		mag_setPlayState('on');
	});
	$("#continuousPlayOnLi").click(function(){
		$(this).hide();
		$("#continuousPlayLi").show();
		mag_setPlayState('off');
	});
	$("#feedContPlay").hide();
	$("#feedContPlay").click(function(){
		$(this).hide();
		$("#feedContPlayOn").show();
		mag_setPlayState('on');
	});
	$("#feedContPlayOn").click(function(){
		$(this).hide();
		$("#feedContPlay").show();
		mag_setPlayState('off');
	});
	
	$("#leftControlsDiv .magHubToolLink").mouseover(function(){
		$(this).find("div").show();
	}).mouseout(function(){
		$(this).find("div").hide();
	});
	$("#rightControlsDiv .magHubToolLink").mouseover(function(){
		$(this).find("div").show();
	}).mouseout(function(){
		$(this).find("div").hide();
	});
	
	// magnets LINKS
	$(".mag_linkMag").mouseover(function(){
				$('.mag_linkMagTop').removeClass("open");
				$(this).addClass("open");
		}).mouseout(function(){
				$('.mag_linkMagTop').addClass("open");
				$(this).removeClass("open");
	});
	$(".mag_linkMagTop").mouseover(function(){
				$(this).addClass("open");
				$('.mag_linkMag').removeClass("open");
	}).mouseout(function(){
				$(this).addClass("open");
	});
	// magnets DOWNLOADS
	$(".mag_dlMag").mouseover(function(){
				$('.mag_dlMagTop').removeClass("open");
				$(this).addClass("open");
		}).mouseout(function(){
				$('.mag_dlMagTop').addClass("open");
				$(this).removeClass("open");
	});
	$(".mag_dlMagTop").mouseover(function(){
				$(this).addClass("open");
				$('.mag_dlMag').removeClass("open");
	}).mouseout(function(){
				$(this).addClass("open");
	});
	// magnets PRODUCTS
	$(".mag_prodMag").mouseover(function(){
				$('.mag_prodMagTop').removeClass("open");
				$(this).addClass("open");
		}).mouseout(function(){
				$('.mag_prodMagTop').addClass("open");
				$(this).removeClass("open");
	});
	$(".mag_prodMagTop").mouseover(function(){
				$(this).addClass("open");
				$('.mag_prodMag').removeClass("open");
	}).mouseout(function(){
				$(this).addClass("open");
	});
	// magnets LIVE / REMINDS ME OF
	$(".mag_liveMag").mouseover(function(){
				$('.mag_liveMagTop').removeClass("open");
				$(this).addClass("open");
		}).mouseout(function(){
				$('.mag_liveMagTop').addClass("open");
				$(this).removeClass("open");
	});
	$(".mag_liveMagTop").mouseover(function(){
				$(this).addClass("open");
				$('.mag_liveMag').removeClass("open");
	}).mouseout(function(){
				$(this).addClass("open");
	});
	
	$("#activityCommentsDiv .tabDiv ul li").click(function(){
		$("#activityCommentsDiv .tabDiv ul li").removeClass("inTab");
		$(this).addClass("inTab");
		return false;
	});

	$("#feedChannelsDiv .tabDiv ul li").click(function(){
		$("#feedChannelsDiv .tabDiv ul li").removeClass("inTab");
		$(this).addClass("inTab");
		return false;
	});

	$("#librarySortDiv ul li").click(function(){
		$("#librarySortDiv ul li").removeClass("selectedLi");
		$(this).addClass("selectedLi");
	});

	$("#activityLi").click(function(){
		$("#activityDiv").css("visibility","visible");
		$("#commentsInputDiv").hide();
		$("#commentsDiv").css("visibility","hidden");
		return false;
	});

	$("#commentsLi").click(function(){
		$("#commentsDiv").css("visibility","visible");
		$("#commentsInputDiv").show();
		$("#activityDiv").css("visibility","hidden");
		return false;
	});

	$("#myChannelLi").click(function(){
		$("#myFeedPageNo").hide();
		$("#myChannelPageNo").show();
		if ($("#channelTotalSpan").text() == "0") {
			$("#myChannelPageNo").hide();
		}
		$("#channelDiv").css("visibility","visible");
		$(".styledDropdownDiv").show();
		$("#myFeedDiv").css("visibility","hidden");

		$(".myFeedBrowse").hide();
		$(".myChannelBrowse").show();
		return false;
	});

	$("#myFeedLi").click(function(){
		$("#myChannelPageNo").hide();
		$("#myFeedPageNo").show();
		if ($("#feedTotalSpan").text() == "0") {
			$("#myFeedPageNo").hide();
		}
								  
		$("#myFeedDiv").css("visibility","visible");
		$(".styledDropdownDiv").hide();
		$("#channelDiv").css("visibility","hidden");

		$(".myFeedBrowse").show();
		$(".myChannelBrowse").hide();
		return false;
	});


	$("#backingTypeSwitch").click(function(){
		if ($(this).hasClass('img')){
			$(this).removeClass().addClass('color');
			$("#solidColorConatinerDiv").show();
			$("#imageBackgroundsContainerDiv").hide();
		} else {
			$(this).removeClass().addClass('img');
			$("#imageBackgroundsContainerDiv").show();
			$("#solidColorConatinerDiv").hide();
		}
	});

	$("#fauxTableBody .txtmessages, #fauxTableBody .emails").click(function(){
		if ($(this).hasClass('switchOff')){
			$(this).removeClass('switchOff').addClass('switchOn');
		} else {
			$(this).removeClass('switchOn').addClass('switchOff');
		}
	});

	$("#fauxTableBody .checkLi").click(function(){
		if ($(this).hasClass('checked')){
			$(this).removeClass('checked').addClass('unchecked');
		} else {
			$(this).removeClass('unchecked').addClass('checked');
		}
	});



	$("#hubCaroContainer ul li a").click(function(){
		$("#hubCaroContainer ul li").removeClass("playingMovieLi");
		$(this).parents("li").addClass("playingMovieLi");
		if( $(this).parents("li:last-child").hasClass("playingMovieLi") ){
			$("#nextFeedVideoArrow").addClass("disabledArrow");
			$("#prevFeedVideoArrow").removeClass("disabledArrow");
		} else if( $(this).parents("li:first-child").hasClass("playingMovieLi")) {
			$("#prevFeedVideoArrow").addClass("disabledArrow");
			$("#nextFeedVideoArrow").removeClass("disabledArrow");
		} else {
		}
	});

// now playing overlay for the channel section - pergl might return?

$(" .videoDiv a").click(function(){
		$(".videoDiv").removeClass("playingNow");
		$(this).parent("div").addClass("playingNow");
		
	});
$(" .videoInfoDiv a").click(function(){
		$(".videoInfoDiv").removeClass("playingNow");
		$(this).parent("div").addClass("playingNow");
		
	});
$(" .lessInfoDiv a").click(function(){
		$(".lessInfoDiv").removeClass("playingNow");
		$(this).parent("div").addClass("playingNow");
		
	});
	
$(" .videoInfoDiv a").click(function(){
		$(".lessInfoDiv").removeClass("playingNow");
		$(this).parent("div").addClass("playingNow");
		
	});
$(" .lessInfoDiv a").click(function(){
		$(".videoInfoDiv").removeClass("playingNow");
		$(this).parent("div").addClass("playingNow");
		
	});
// end

	$("#hubFeedCaro ul li:eq(4)").addClass('focusedLi');

	$("#hubfeedTimelineContainer .prevDiv").click(function(){
		var focusedAway = $("#hubfeedTimelineContainer #hubFeedCaro ul").children().index($('.focusedLi')[0]);

		if(focusedAway == 4){
		} else if (focusedAway > 4) {
			$("#hubFeedCaro ul .focusedLi").removeClass("focusedLi").prev("li").prev("li").prev("li").prev("li").prev("li").addClass("focusedLi");

			var numberOfFocusedDiv = $("#hubFeedCaro ul").children().index($('.focusedLi')[0]);
			var howFarToTheLeft = (numberOfFocusedDiv-4)*-189;

			var theMagicValue = (howFarToTheLeft+"px");
			$("#hubFeedCaro").animate({"left": theMagicValue}, 1000);
			if (theMagicValue == "-945px") {
			$("#hubFeedCaro").removeClass().addClass("viewingPage_2");
			} else if (theMagicValue == "-1890px") {
			$("#hubFeedCaro").removeClass().addClass("viewingPage_3");
			} else {
			$("#hubFeedCaro").removeClass().addClass("viewingPage_1");
			}
		} else {
		}
		return false;
	});
	
	$("#hubfeedTimelineContainer .nextDiv").click(function(){
		var focusedAway = $("#hubfeedTimelineContainer #hubFeedCaro ul").children().index($('.focusedLi')[0]);
		
		if(focusedAway == 14){
		} else if (focusedAway < 14) {
			$("#hubFeedCaro ul .focusedLi").removeClass("focusedLi").next("li").next("li").next("li").next("li").next("li").addClass("focusedLi");

			var numberOfFocusedDiv = $("#hubFeedCaro ul").children().index($('.focusedLi')[0]);
			var howFarToTheLeft = (numberOfFocusedDiv-4)*-189;

			var theMagicValue = (howFarToTheLeft+"px");
			$("#hubFeedCaro").animate({"left": theMagicValue}, 1000);
			if (theMagicValue == "-945px") {
			$("#hubFeedCaro").removeClass().addClass("viewingPage_2");
			} else if (theMagicValue == "-1890px") {
			$("#hubFeedCaro").removeClass().addClass("viewingPage_3");
			} else {
			$("#hubFeedCaro").removeClass().addClass("viewingPage_1");
			}
		} else {
		}
		return false;
	});

	$("#hubfeedContainer #prevFeedVideoArrow").addClass("disabledArrow");
	$("#hubfeedContainer #prevFeedVideoArrow.disabledArrow, #hubfeedContainer #nextFeedVideoArrow.disabledArrow").click(function(){
		return false;
	});
	$("#hubfeedContainer #prevFeedVideoArrow").click(function(){
		if($("#hubCaroContainer #popular-videos li:first").hasClass("playingMovieLi")){
			return false;
		} else {
			$(".playingMovieLi").removeClass("playingMovieLi").prev("li").children().find("a:first").click();
			$("#nextFeedVideoArrow").removeClass("disabledArrow");
			return false;
		}
	});
	
	$("#hubfeedContainer #nextFeedVideoArrow").click(function(){
		if($("#hubCaroContainer #popular-videos li:last").hasClass("playingMovieLi")){
			return false;
		} else {
			$(".playingMovieLi").removeClass("playingMovieLi").next("li").children().find("a:first").click();
			$("#prevFeedVideoArrow").removeClass("disabledArrow");
			return false;
		}
	});

	
	/* this is for the channel manager actions area */
	$("#channelUlDiv a").click(function () { 
		return false;
	});

	
	/* this is for the channel manager actions area */
	$('.garbageDiv .droptrue').bind('sortreceive', function(event, ui) {
		$("#libraryModalDiv").show();
		$("#deleteVideoDiv").show();
		$(".garbageDiv .droptrue li div").addClass('draggedDiv');
	});	
	
	$("#libraryModalDiv #deleteVideoDiv .deleteBtnP").click(function(){
		clearTrash();		
	});
	
	$("#libraryModalDiv #deleteVideoDiv .cancelBtnP").click(function(){
		$('.garbageDiv li').remove();
		$("#libraryModalDiv").hide();
		$("#deleteVideoDiv").hide();
	});

	$(".clearLibraryDiv").click(function () { 
		//$("#videoLibraryCollection ul li").remove();
		//$("#videoLibraryCollection ul").html("<li id='liDeleteAnchor'></li>");
		return false;
	});

	$("#closeDiv").click(function(){
		$("#modalContainer").hide();
		$("#channelManagerPreviewDiv .previewHolder").show();
		$("#mainMediaNavDiv #videoplayerswf").show();
		return false
	});

	$("#loginStepOne .fanPath .continueBtn").click(function(){
		$("#loginStepOne").hide();
		$("#loginStepTwoFan").show();
		return false
	});
	$("#loginStepOne .bandPath .continueBtn").click(function(){
		$("#loginStepOne").hide();
		$("#loginStepTwoBand").show();
		return false
	});


	$("#loginStepTwoFan .startChannelBtn").click(function(){
		$("#loginStepTwoFan").hide();
		$("#loginStepThreeFan").show();
		return false
	});
	
	$("#loginStepTwoBand .startChannelBtn").click(function(){
		$("#loginStepTwoBand").hide();
		$("#loginStepThreeBand").show();
		return false
	});


	$("#loginStepThreeBand a, #loginStepThreeFan a").click(function(){
		$("#loginStepThreeBand").hide();
		$("#loginStepThreeFan").hide();
		$("#loginThanks").show();
		return false
	});

	$("#videoLibraryCollection .singleVideoDiv .infoDiv").click(function(){
		//$("#libraryModalDiv").show();
		$("#videoInfoModalDiv").show();
	});

	$("#libraryModalContentDiv #videoInfoModalDiv .closeModalDiv").click(function(){
		$("#libraryModalDiv").hide();
		$("#videoInfoModalDiv").hide();
	});

	$("#belowVideoDiv ul li").click(function(){
		$("#belowVideoDiv ul li").removeClass();
		$(this).addClass("selected");
	});

	//browse tabs
	var magCheckCoolirisFeed;
	$(".browseTab").click(function(){
		$("#browseTopContentTabs ul li").removeClass("browseTab_set").addClass("browseTab");
		$(this).removeClass("browseTab").addClass("browseTab_set");
	});
	
	checkExternalSearch = $("#browseTopContentTabs").attr("searchterm");
    if (checkExternalSearch != "SEARCH" && checkExternalSearch != "") {
	  $("#cooliris_popular").addClass("browseTab").removeClass("browseTab_set");
	  $("#cooliris_all").addClass("browseTab").removeClass("browseTab_set");
    } else {
		$("#cooliris_popular").removeClass("browseTab").addClass("browseTab_set");
	}
	
	$("#cooliris_all").click(function(){
		magCheckCoolirisFeed = $("#browseTopContentTabs").attr("feed");
		if (magCheckCoolirisFeed != "all") {
			cooliris.embed.setFeedURL("magneticBrowse_all_Xml.php");
			$("#browseTopContentTabs").attr("feed", "all");
			$("#cooliris_search").hide();
			$("#search").val('SEARCH');
		}
	});
	$("#cooliris_popular").click(function(){
		magCheckCoolirisFeed = $("#browseTopContentTabs").attr("feed");
		if (magCheckCoolirisFeed != "popular") {
			cooliris.embed.setFeedURL("magneticBrowse_popular_Xml.php");
			$("#browseTopContentTabs").attr("feed", "popular");
			$("#cooliris_search").hide();
			$("#search").val('SEARCH');
		}
	});
	$("#cooliris_artists").click(function(){
		magCheckCoolirisFeed = $("#browseTopContentTabs").attr("feed");								 
		if (magCheckCoolirisFeed != "artists") {
			cooliris.embed.setFeedURL("magneticBrowse_artists_Xml.php");
			$("#browseTopContentTabs").attr("feed", "artists");
			$("#cooliris_search").hide();
			$("#search").val('SEARCH');
		}
	});
	$("#cooliris_fans").click(function(){
		magCheckCoolirisFeed = $("#browseTopContentTabs").attr("feed");							   
		if (magCheckCoolirisFeed != "fans") {
			cooliris.embed.setFeedURL("magneticBrowse_fans_Xml.php");
			$("#browseTopContentTabs").attr("feed", "fans");
			$("#cooliris_search").hide();
			$("#search").val('SEARCH');
		}
	});

	// init setup
	$("#hubMagnetsCaro").hide();
	$("#hubActivityCaro").hide();
	$("#hubCommentsCaro").hide();
	$("#hubfeedTimelineContainer").show();

	$("#belowVideoDiv #hubFeedLi").click(function(){
		$("#hubMagnetsCaro").hide();
		$("#hubActivityCaro").hide();
		$("#hubCommentsCaro").hide();
		$("#hubfeedTimelineContainer").show();
		//$("#hubFeedDiv .sectionalDropdown").show();
		//$(".prevDiv, .nextDiv").show();
		//$("#hubFeedDiv .sectionHeader").show();
	});
	$("#belowVideoDiv #hubMagnetLi").click(function(){
		$("#hubMagnetsCaro").show();
		$("#hubActivityCaro").hide();
		$("#hubCommentsCaro").hide();
		$("#hubfeedTimelineContainer").hide();
		
		//$("#hubCaroContainer").children("div").hide();
		//$("#hubMagnetsCaro").show();
		//$("#hubFeedDiv .sectionalDropdown").hide();
		//$(".prevDiv, .nextDiv").hide();
		//$("#hubFeedDiv .sectionHeader").hide();
	});
	$("#belowVideoDiv #hubActivityLi").click(function(){
		$("#hubMagnetsCaro").hide();
		$("#hubActivityCaro").show();
		$("#hubCommentsCaro").hide();
		$("#hubfeedTimelineContainer").hide();										  
		//$("#hubCaroContainer").children("div").hide();
		//$("#hubActivityCaro").show();
		//$("#hubFeedDiv .sectionalDropdown").hide();
		//$(".prevDiv, .nextDiv").show();
		//$("#hubFeedDiv .sectionHeader").show();
	});
	$("#belowVideoDiv #hubCommentsLi").click(function(){
		$("#hubMagnetsCaro").hide();
		$("#hubActivityCaro").hide();
		$("#hubCommentsCaro").show();
		$("#hubfeedTimelineContainer").hide();
		//$("#hubCaroContainer").children("div").hide();
		//$("#hubCommentsCaro").show();
		//$("#hubFeedDiv .sectionalDropdown").hide();
		//$(".prevDiv, .nextDiv").show();
		//$("#hubFeedDiv .sectionHeader").show();
	});

//Channel playArrow show
  //  $(".singleVideoDiv").click(function(){
//		$(this).find(".imgOverlay").show();
 //   }).mouseout(function(){
//		$(this).find(".imgOverlay").hide();
 //   });



 //rollover show arrow just problems?
//$(".videoInfoDiv a").mouseover(function(){
	//	$(this).find(".imgOverlay").show();
  //  }).mouseout(function(){
	//	$(this).find(".imgOverlay").hide();
 //   });
    
//the PlayingMovie overlay
$("#hubfeedTimelineContainer #hubCaroContainer ul li.playingMovieLi div .videoInfoDiv img.imgOverlay").css("display","block");

// for channel section
$("#myFeedContainerDiv.singleVideoDiv .videoDiv .playingNow .imgOverlay").css("display","block");

	$(".singleThemeDiv").click(function(){
		$(".singleThemeDiv").removeClass("selectedThemeDiv");
		$(this).addClass("selectedThemeDiv");
		
		var themeID = $(this).attr("id");
		$("#imageThemeID").val(themeID);

		var themePrevImg = $(this).children("img").attr("src").split("_thumb").join("_prev");
		$("#imageLargerContainerDiv").css({backgroundImage:'url('+themePrevImg+')'});
	});

});


var updatePlaylist = function(){
	var video_ids = new Array();
	var highlightClass = 'inPlaylist';
	
	// collect all the video ids in the current, possibly unsaved playlist
	$('#timelineContainer ul li .myHiddenGUID').each(function(){
		video_ids.push($(this).val());
	});
	
	// join playlist video ids as a string and set the value of the hidden field
	if (video_ids && video_ids.length==0) {
		$('#playlist_video_ids').val('empty');
	} else {
		$('#playlist_video_ids').val(video_ids.join('|'));
	}
	
	// reset highlighting from library's current page's videos
	$('#libraryCollectionCaro li .singleVideoDiv').each(function(){
		$(this).removeClass(highlightClass);
		$('.singleVideoDiv .infoDiv').css('background-image', 'url(/img/btnSprites/infoSprite_29sq.png)');
		$('.singleVideoDiv .moveDiv').css('background-image', 'url(/img/btnSprites/moveSprite_29sq.png)');
	});
	
	// add highlighting to the library's thumbs of these videos
	for (var i=0; i<=video_ids.length; i++) {
		$('#libraryCollectionCaro li.videoLi-'+video_ids[i]+' .singleVideoDiv').addClass(highlightClass);
		$('#libraryCollectionCaro li.videoLi-'+video_ids[i]+' .singleVideoDiv .infoDiv').css('background-image', 'url(/img/btnSprites/infoSprite_29sq_highlight.png)');
		$('#libraryCollectionCaro li.videoLi-'+video_ids[i]+' .singleVideoDiv .moveDiv').css('background-image', 'url(/img/btnSprites/moveSprite_29sq_highlight.png)');
	}
};

var clearTrash = function() {
    $('.garbageDiv ul li').each(function() {
        var deleteGUID = $(this).children('.myHiddenUserMediaGUID').val();
        var hiddenGUID = $(this).children('.myHiddenGUID').val();
        var deleteStatus = deleteVideo(deleteGUID);

        if (deleteStatus) {
            $('#libraryCollectionCaro li.videoLi-' + hiddenGUID).remove();
            $('#timelineContainer li.videoLi-' + hiddenGUID).remove();
            updatePlaylist();
        }
        $(this).remove();
        $("#libraryModalDiv").hide();
        $("#deleteVideoDiv").hide();
    });
};
	
var clearPlaylist = function(){
	$('#timelineContainer ul li .moreInfoDiv .closeDiv').click();
};

$(function() {
	$(".closeDiv").click(function () { 
		/* $(this).parent('div').parent('div').parent('div').parent('li').remove(); */
		$(this).parent('div').parent('div').parent('div').parent('div').parent('div').parent('li').remove();
		updatePlaylist();
		return false;
	});
	$(".closeDiv").live('click', function () { 
		/* $(this).parent('div').parent('div').parent('div').parent('li').remove(); */
		$(this).parent('div').parent('div').parent('div').parent('div').parent('div').parent('li').remove();
		updatePlaylist();
		return false;
	});
});

function deleteVideo(umguid) {
    var passfail = false;
    $.ajax({
        type: 'POST',
        url: '/ajax_delete.php',
        data: ({ 'id': umguid }),
        dataType: 'json',
        async: false,
        success: function(data) {            
            passfail = true;
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
            alert('There was an internal error. Please try again.');            
        }
    });
    return passfail;
};
 
var submitAjax = function(action, params, callback){
	$.ajax({
		type: 'POST',
		url: action,
		data: params,
		dataType: 'json',
		success: function(data, textStatus){
			if (data.success){
				if (callback){
					callback(data.message);
				} else {	// default - used for register
					alert(data.message);
					$("#formBandPageDiv").fadeOut();
					$("#formPageDiv").fadeOut();
					setTimeout('$("#thankYouDiv").fadeIn()', 1000);
				}
			} else {
				$('#regisErrors').attr('style', 'display:inline');
				$('#mag_uplErrAlertBox').attr('style', 'display:inline');
				$('#regisErrors').html(data.message);
				$("#loadingDiv").hide();
			}
		},
		error: function(XMLHttpRequest, textStatus, errorThrown){
			alert('There was an internal error. Please try again. Status: '+textStatus+' Error: '+errorThrown);
		}
	});  
};
var uploadYouTube = function(message){
	//alert('callback says: ' + message);
	var token = message.token;
	var post = message.post;
	var nexturl = window.location.href;
	var action = post + '?nexturl=' + encodeURIComponent(nexturl);
	
	$("#uploadPartTwo-File form").attr('action', action);
	$("#uploadPartTwo-File form #token").val(token);
	
	$('#uploadPartOne-MetaData').fadeOut();
	//CONTEST BANNER CODE
	//$('#embed_contestPromo').fadeOut();
	$("#loadingDiv").hide();
	//CONTEST BANNER CODE
	//setTimeout('$(".instruct_uploadGuidelinesDiv").fadeIn()', 500);
	setTimeout('$("#uploadPartTwo-File").fadeIn()', 500);
	setTimeout('$("#upload_step1").removeClass("stepActive").addClass("stepInactive")', 500);
	setTimeout('$("#upload_step2").removeClass("stepInactive").addClass("stepActive")', 500);
	
	//alert(token);
	//alert(post);
}

// form styling fun
$(function() {
	$("#profileDropdownDiv ul").addClass("showOne");
	$("#profileDropdownDiv li").addClass("unselected");

	if($("#profileDropdownDiv li").hasClass("selected")){
		$("#profileDropdownDiv .selected").removeClass().addClass("selected");
	} else {
		$("#profileDropdownDiv li:first").removeClass().addClass("selected");
	}
	

	$("#dropdownHandle").bind("click", function(){
		if($("#dropdownHandle").hasClass('showOne')){
			$("#dropdownHandle").removeClass().addClass('showAll');
			$("#dropdownHandle li").removeClass('selected').addClass('unselected').addClass('show');
		} else {
			$("#dropdownHandle li").removeClass('show');
			$("#dropdownHandle").removeClass().addClass('showOne');
		}
	});

	$("#dropdownHandle li").bind("click", function(){
		if($(this).hasClass('unselected')){
			$("#dropdownHandle li").removeClass('show');
			$(this).removeClass().addClass('selected');
			fauxDropDownProfile();
		} else {
		}
	});

	/* generalized version of the dropdown */
	$(".styledDropdownDiv ul").addClass("showOne");
	//$(".styledDropdownDiv li").addClass("unselected");
	$(".styledDropdownDiv li:first").removeClass("unselected").addClass("selected");

	$(".styledDropdownDiv ul").bind("click", function(){
		if($(this).hasClass('showOne')){
			$(this).removeClass().addClass('showAll');
			$(this).children("li").removeClass('selected').addClass('unselected').addClass('show');
		} else {
			$(this).children("li").removeClass('show');
			$(this).removeClass().addClass('showOne');
		}
	});

	$(".styledDropdownDiv ul li").bind("click", function(){
		if($(this).hasClass('unselected')){
			$(this).children("li").removeClass('show');
			$(this).removeClass().addClass('selected');
		} else {
		}
	});
	
});

function fauxDropDownProfile(){	// for fan manager too now
	if($('#dropdownHandle #ActivityFauxOption').hasClass('selected')){
		self.location="profile_activity.php"; 
	} else if($('#dropdownHandle #ThemeFauxOption').hasClass('selected')){
		self.location="profile_background.php"; 
	} else if($('#dropdownHandle #UserInfoFauxOption').hasClass('selected')){
		self.location="profile_fan.php"; 
	} else if($('#dropdownHandle #bandInfoFauxOption').hasClass('selected')){
		self.location="profile_band.php"; 
	} else if($('#dropdownHandle #privacyFauxOption').hasClass('selected')){
		self.location="profile_privacy.php"; 
	
		// for fan manager too now:
	} else if($('#dropdownHandle #fansForFauxOption').hasClass('selected')){
		self.location="fan_manager_for.php"; 
	} else if($('#dropdownHandle #fansOfFauxOption').hasClass('selected')){
		self.location="fan_manager.php"; 
	}
}


// this is for the newer carousel WITHOUT JCAROUSEL
$(function() {

	var numberOfChannelColumns = $("#channelDiv .caroDiv").children(".caroColumnDiv").length;
	var numberOfFeedColumns = $("#myFeedDiv .caroDiv").children(".caroColumnDiv").length;
	var variWidthColumn = $(".caroDiv").children(".caroColumnDiv").width();
	
	var widthOfChannelContainer = numberOfChannelColumns*variWidthColumn;
	var widthOfFeedContainer = numberOfFeedColumns*variWidthColumn;
	$("#channelDiv .caroDiv").css({"width": widthOfChannelContainer});
	$("#myFeedDiv .caroDiv").css({"width": widthOfFeedContainer});

	//initializer POWERUP
	$("#myFeedDiv .caroDiv .caroColumnDiv:first").addClass("focusedFeedDiv");
	$("#channelDiv .caroDiv .caroColumnDiv:first").addClass("focusedDiv");
	$("#feedTotalSpan").text(numberOfFeedColumns);
	//$("#channelTotalSpan").text(numberOfChannelColumns);	// because paging
	if ($("#feedTotalSpan").text() == "0" || $("#feedTotalSpan").text() == "--") {
			$("#myFeedPageNo").hide();
	}
	if ($("#channelTotalSpan").text() == "0") {
			$("#myChannelPageNo").hide();
	}
	
	$(".myFeedBrowse .browseFwdDiv").bind("click", function(){
		if( $("#myFeedDiv .caroDiv .caroColumnDiv:last").hasClass("focusedFeedDiv") ){
//			alert("NO MORE FWD");
		} else {
			var numberOfFocusedDiv = $("#myFeedDiv .caroDiv").children().index($('.focusedFeedDiv')[0]) + 1 ;
			var howFarToTheLeft = (numberOfFocusedDiv)*-227;
			
			var theMagicValue = (howFarToTheLeft+"px");
			$("#myFeedDiv .caroDiv").animate({"left": theMagicValue}, 500);
				
			$("#myFeedDiv .caroDiv .focusedFeedDiv").removeClass("focusedFeedDiv").next("div").addClass("focusedFeedDiv");
			$("#feedCurrentSpan").text(numberOfFocusedDiv + 1);
		}
	});

	$(".myFeedBrowse .browseBackDiv").bind("click", function(){
		if( $("#myFeedDiv .caroDiv .caroColumnDiv:first").hasClass("focusedFeedDiv") ){
//			alert("NO MORE BACK");
		} else {
			var numberOfFocusedDiv = $("#myFeedDiv .caroDiv").children().index($('.focusedFeedDiv')[0]) - 1 ;
			var howFarToTheLeft = (numberOfFocusedDiv)*-227;
		
			var theMagicValue = (howFarToTheLeft+"px");
			$("#myFeedDiv .caroDiv").animate({"left": theMagicValue}, 500);

			$("#myFeedDiv .caroDiv .focusedFeedDiv").removeClass("focusedFeedDiv").prev("div").addClass("focusedFeedDiv");
			$("#feedCurrentSpan").text(numberOfFocusedDiv + 1);
		}
	});

	
	/*$(".myChannelBrowse .browseFwdDiv").bind("click", function (){
		if( $("#channelDiv .caroDiv .caroColumnDiv:last").hasClass("focusedDiv") ){
//			alert("NO MORE FWD");
		} else {
			var numberOfFocusedDiv = $("#channelDiv .caroDiv").children().index($('.focusedDiv')[0]) + 1 ;
			var howFarToTheLeft = (numberOfFocusedDiv)*-227;
			
			var theMagicValue = (howFarToTheLeft+"px");
			$("#channelDiv .caroDiv").animate({"left": theMagicValue}, 500);
				
			$("#channelDiv .caroDiv .focusedDiv").removeClass("focusedDiv").next("div").addClass("focusedDiv");
			//$("#channelCurrentSpan").text(numberOfFocusedDiv + 1);	// because of paging
		}
	});

	$(".myChannelBrowse .browseBackDiv").bind("click", function (){
		if( $("#channelDiv .caroDiv .caroColumnDiv:first").hasClass("focusedDiv") ){
//			alert("NO MORE BACK");
		} else {
			var numberOfFocusedDiv = $("#channelDiv .caroDiv").children().index($('.focusedDiv')[0]) - 1 ;
			var howFarToTheLeft = (numberOfFocusedDiv)*-227;
		
			var theMagicValue = (howFarToTheLeft+"px");
			$("#channelDiv .caroDiv").animate({"left": theMagicValue}, 500);

			$("#channelDiv .caroDiv .focusedDiv").removeClass("focusedDiv").prev("div").addClass("focusedDiv");
			//$("#channelCurrentSpan").text(numberOfFocusedDiv + 1);	// because of paging
		}
	});*/

});

$(function() {
    if ($("#feedCarousel li").length > 1) {
        $("#feedCarousel li:first").addClass("focusedLi");
    }
    if ($("#feedCarousel li").length > 4) {
        recountWidth();
    }

    $("#myFeedTimelineDiv .prevArrowDiv").hover(function() {
        slideTimelinePrev();
    });


    $("#myFeedTimelineDiv .nextArrowDiv").hover(function() {
        slideTimelineNext();
    });


    $("#channelUlDiv #toFirstLi").bind("click", function() {
        if ($("#feedCarousel li").length < 6) {
            //			alert('first cant be done if less then 6');
        } else {
            $("#feedCarousel").animate({ "left": "0px" }, 1000);
            $("#feedCarousel .focusedLi").removeClass("focusedLi");
            $("#feedCarousel li:eq(0)").addClass("focusedLi");
        }
        return false;
    });

    $("#channelUlDiv #fiveLeftLi").bind("click", function() {
        var focusedAway = $("#feedCarousel").children().index($('.focusedLi')[0]);

        if ($("#feedCarousel li").length < 6) {
            //			alert('first cant be done if less then 6');
        } else if (focusedAway < 4) {
            $("#feedCarousel").animate({ "left": "0px" }, 1000);
            $("#feedCarousel .focusedLi").removeClass("focusedLi");
            $("#feedCarousel li:eq(0)").addClass("focusedLi");
        } else {
            $("#feedCarousel .focusedLi").removeClass("focusedLi").prev("li").prev("li").prev("li").prev("li").addClass("focusedLi");

            var numberOfFocusedDiv = $("#feedCarousel").children().index($('.focusedLi')[0]);
            var howFarToTheLeft = (numberOfFocusedDiv) * -190;

            var theMagicValue = (howFarToTheLeft + "px");
            $("#feedCarousel").animate({ "left": theMagicValue }, 1000);
        }
        return false;
    });

    $("#channelUlDiv #fiveRightLi").bind("click", function() {
        var focusedAway = $("#feedCarousel").children().index($('.focusedLi')[0]);
        var carouAmount = $("#feedCarousel").children("li").length;
        var fiveRightCap = carouAmount - focusedAway;

        if ($("#feedCarousel li").length < 6) {
            //			alert('first cant be done if less then 6');
        } else if (fiveRightCap < 9) {
            var numberOfFocusedLi = $("#feedCarousel").children().index($('.focusedLi')[0]);
            var amountOfCaroLi = $("#feedCarousel").children("li").length;

            var howFarToTheLeft = (amountOfCaroLi - 5) * -190;

            var theMagicValue = (howFarToTheLeft + "px");
            $("#feedCarousel").animate({ "left": theMagicValue }, 1000);

            $("#feedCarousel .focusedLi").removeClass("focusedLi");
            $("#feedCarousel li:eq(" + (amountOfCaroLi - 5) + ")").addClass("focusedLi");
        } else {
            $("#feedCarousel .focusedLi").removeClass("focusedLi").next("li").next("li").next("li").next("li").addClass("focusedLi");

            var numberOfFocusedDiv = $("#feedCarousel").children().index($('.focusedLi')[0]);
            var howFarToTheLeft = (numberOfFocusedDiv) * -190;

            var theMagicValue = (howFarToTheLeft + "px");
            $("#feedCarousel").animate({ "left": theMagicValue }, 1000);
        }
        return false;
    });

    $("#channelUlDiv #toLastLi").bind("click", function() {
        if ($("#feedCarousel li").length < 6) {
            //			alert('first cant be done if less then 6');
        } else {
            var numberOfFocusedLi = $("#feedCarousel").children().index($('.focusedLi')[0]);
            var amountOfCaroLi = $("#feedCarousel").children("li").length;

            var howFarToTheLeft = (amountOfCaroLi - 5) * -190;

            var theMagicValue = (howFarToTheLeft + "px");
            $("#feedCarousel").animate({ "left": theMagicValue }, 1000);

            $("#feedCarousel .focusedLi").removeClass("focusedLi");
            $("#feedCarousel li:eq(" + (amountOfCaroLi - 5) + ")").addClass("focusedLi");
        }
        return false;
    });

    setupMyLibrary();
    $("ul, li").disableSelection();
});



function slideTimelinePrev() {
var focusedAway = $("#feedCarousel").children().index($('.focusedLi')[0]);
//		alert(focusedAway);
		
		if($("#feedCarousel li").length == 1){
//			alert('no more prevs please');
		} else if($("#feedCarousel li:first").hasClass("focusedLi")) {
//			alert('uh oh no more prevs :(')
		} else {
			var numberOfFocusedDiv = $("#feedCarousel").children().index($('.focusedLi')[0]) - 1 ;
			var howFarToTheLeft = (numberOfFocusedDiv)*-190;
			
			var theMagicValue = (howFarToTheLeft+"px");
			$("#feedCarousel").animate({"left": theMagicValue}, 1000);
			
			$("#feedCarousel .focusedLi").removeClass("focusedLi").prev("li").addClass("focusedLi");
		}
	}

function slideTimelineNext() {
var focusedAway = $("#feedCarousel").children().index($('.focusedLi')[0]) + 1;

		var focusedAway = $("#feedCarousel").children().index($('.focusedLi')[0]);
		var carouAmount = $("#feedCarousel").children("li").length;
		var fiveRightCap = carouAmount - focusedAway;
		
		if($("#feedCarousel li").length == 1){
//			alert('no more nexts please');
		} else if($("#feedCarousel li:last").hasClass("focusedLi")) {
//			alert('uh oh no more nexts :(')
		} else if(fiveRightCap < 6) {
//			alert('cant let you go right >:|')
		} else {
			var numberOfFocusedDiv = $("#feedCarousel").children().index($('.focusedLi')[0]) + 1 ;
			var howFarToTheLeft = (numberOfFocusedDiv)*-190;
			
			var theMagicValue = (howFarToTheLeft+"px");
			$("#feedCarousel").animate({"left": theMagicValue}, 1000);
			
			$("#feedCarousel .focusedLi").removeClass("focusedLi").next("li").addClass("focusedLi");
		}
}

////////////////////////////
//BEGIN PAGINATION EFFECTS//
////////////////////////////
var myChannelPaginate = function(){ //Adds Slide Effect and Magnet Calls to My Channel Section of Channel Page
	/*$(".myChannelBrowse .browseFwdDiv").bind("click", function (){
		if( $("#channelDiv .caroDiv .caroColumnDiv:last").hasClass("focusedDiv") ){
//			alert("NO MORE FWD");
		} else {
			var numberOfFocusedDiv = $("#channelDiv .caroDiv").children().index($('.focusedDiv')[0]) + 1 ;
			var howFarToTheLeft = (numberOfFocusedDiv)*-227;
			
			var theMagicValue = (howFarToTheLeft+"px");
			$("#channelDiv .caroDiv").animate({"left": theMagicValue}, 500);
				
			$("#channelDiv .caroDiv .focusedDiv").removeClass("focusedDiv").next("div").addClass("focusedDiv");
			//$("#channelCurrentSpan").text(numberOfFocusedDiv + 1);	// because of paging
		}
	});

	$(".myChannelBrowse .browseBackDiv").bind("click", function (){
		if( $("#channelDiv .caroDiv .caroColumnDiv:first").hasClass("focusedDiv") ){
//			alert("NO MORE BACK");
		} else {
			var numberOfFocusedDiv = $("#channelDiv .caroDiv").children().index($('.focusedDiv')[0]) - 1 ;
			var howFarToTheLeft = (numberOfFocusedDiv)*-227;
		
			var theMagicValue = (howFarToTheLeft+"px");
			$("#channelDiv .caroDiv").animate({"left": theMagicValue}, 500);

			$("#channelDiv .caroDiv .focusedDiv").removeClass("focusedDiv").prev("div").addClass("focusedDiv");
			//$("#channelCurrentSpan").text(numberOfFocusedDiv + 1);	// because of paging
		}
	});*/
}

//////////////////////////
//END PAGINATION EFFECTS//
//////////////////////////


function recountWidth(){
	var widthOfCaroLi = $("#feedCarousel .singleVideoDiv").width();
	var numberOfLis = ($("#feedCarousel .singleVideoDiv").length) + 1;
	var productOfWidthAndNum = widthOfCaroLi*numberOfLis;

	if(numberOfLis > 4) {
		$("#feedCarousel").css("width",productOfWidthAndNum);
	}
	
	var videoTimelineNumber = $("#feedCarousel .focusedLi").index(this);
	$(".videoNumberSpan").html(videoTimelineNumber);
}

var videoClickEvent = function(){
	var genre_id = $(this).children(".genre_id").text();
	$("#magnetHolder .magnetDiv div").fadeOut(645);
	$("#magnetHolder_hubView .magnetDiv div").fadeOut(645);
	setTimeout('$("#magnetHolder .magnetDiv div").remove()', 645);
	setTimeout('$("#magnetHolder_hubView .magnetDiv div").remove()', 645);
	setTimeout('refreshMagnets("'+genre_id+'")', 1100);
	return false;
}

$zt(function() {
	$(".singleVideoDiv .videoDiv").unbind('click', videoClickEvent);
	$(".singleVideoDiv .videoDiv").click(videoClickEvent);

	$(".videoInfoDiv").unbind('click', videoClickEvent);
	$(".videoInfoDiv").click(videoClickEvent);
});

//$(function(){
//});

var mag_initEvent = function(){
	// MAGNETIC - if channel empty, hide share and cont play
	$("#mediaNavDav ul").addClass("mediaNavDav_widthAdj_6");
	if ($("#channelDiv .emptyChannelDiv").attr('status') == "empty" || $("#channelDiv .emptyMyChannelDiv").attr('status') == "empty") {
		$("#shareLi").hide();
		$("#mediaNavDav ul").removeClass("mediaNavDav_widthAdj_6").addClass("mediaNavDav_widthAdj_5");
	} else {
		$("#shareLi").show();
		$("#mediaNavDav ul").removeClass("mediaNavDav_widthAdj_5").addClass("mediaNavDav_widthAdj_6");
	}
	// Continue to setup the channel
	var feedExistsArray = $("#myFeedDiv .singleVideoDiv");
	if (feedExistsArray && feedExistsArray.length >= 1){	// there IS a feed (ie, my own channel) AND a channel playlist, just do feed
		setTimeout('$("#initialFeedPlay").click()', 650);
		setTimeout('$("#myFeedDiv .videoDiv:first").addClass("playingNow")', 650);
		setTimeout('$("#myFeedLi").click()', 650);
		//setTimeout('$("#myFeedDiv .videoDiv:first a:first").click()', 650); 
	} else {	// no feed, just channel playlist
		setTimeout('$("#initialChannelPlay").click()', 650);
		setTimeout('$("#channelDiv .videoDiv:first").addClass("playingNow")', 650);
		setTimeout('$("#myChannelLi").click()', 650);
		//setTimeout('$("#channelDiv .videoDiv:first a:first").click()', 650); 
	}
	setTimeout('$("#initialHubPopularPlay").click()', 650);
	setTimeout('$("#hubFeedCaro #popular-videos li:first").addClass("playingMovieLi")',650);
	//setTimeout('$("#hubFeedCaro #popular-videos li:first a:first").click()',650);
}

// OK so now we want to try to make clicks update with the genre id, or go to default if the xml doesn't exist for a genre

function refreshMagnets(genre_id) {
	if (!genre_id) return;
	
	var linksFile = '/fxml/links_'+genre_id+'.xml';
	var downloadsFile = '/fxml/downloads_'+genre_id+'.xml';
	var productsFile = '/fxml/products_'+genre_id+'.xml';
	var remindsFile = '/fxml/reminds_'+genre_id+'.xml';

	$.get(linksFile, function(links){
		$(links).find('links').each(function(){
			var $img = $(this); 
			var title = $img.attr('title');
			var link = $img.attr('link');
			$('.magnetDiv:eq(3)').append('<a href="' + link + '" target="_blank"><div><p class="title">' + title + '</p></div></a>');
			$('.magnetDiv:eq(3)').find('div').addClass("mag_linkMag");
			$('.magnetDiv:eq(3)').find('div:first').removeClass("mag_linkMag").addClass("mag_linkMagTop");
			$('.magnetDiv:eq(3)').find('div:first').addClass('open');
		});
		
		$(".magnetDiv:eq(3) .mag_linkMag").mouseover(function(){
				$('.magnetDiv:eq(3) .mag_linkMagTop').removeClass("open");
				$(this).addClass("open");
		}).mouseout(function(){
				$('.magnetDiv:eq(3) .mag_linkMagTop').addClass("open");
				$(this).removeClass("open");
		});
		$(".magnetDiv:eq(3) .mag_linkMagTop").mouseover(function(){
				$(this).addClass("open");
				$('.magnetDiv:eq(3) .mag_linkMag').removeClass("open");
		}).mouseout(function(){
				$(this).addClass("open");
		});
	});
	

	$.get(downloadsFile, function(dl){	
		$(dl).find('dlimg').each(function(){
			var $img = $(this); 
			
			var imageurl = $img.attr('imageurl');
			var title = $img.attr('title');
			var info = $img.attr('info');
			var link = $img.attr('link');
			var image = '<img alt="" height="60" src="' + imageurl + '" />';

			$('.magnetDiv:eq(0)').append('<a href="' + link + '" target="_blank"><div>' + image + '<p class="title">' + title + '</p><p>' + info + '</p></div></a>');
			$('.magnetDiv:eq(0)').find('div').addClass("mag_dlMag");
			$('.magnetDiv:eq(0)').find('div:first').removeClass("mag_dlMag").addClass("mag_dlMagTop");
			$('.magnetDiv:eq(0)').find('div:first').addClass('open');
		});

		$(".magnetDiv:eq(0) .mag_dlMag").mouseover(function(){
				$('.magnetDiv:eq(0) .mag_dlMagTop').removeClass("open");
				$(this).addClass("open");
		}).mouseout(function(){
				$('.magnetDiv:eq(0) .mag_dlMagTop').addClass("open");
				$(this).removeClass("open");
		});
		$(".magnetDiv:eq(0) .mag_dlMagTop").mouseover(function(){
				$(this).addClass("open");
				$('.magnetDiv:eq(0) .mag_dlMag').removeClass("open");
		}).mouseout(function(){
				$(this).addClass("open");
		});

	});
	
	$.get(productsFile, function(pro){
		$(pro).find('products').each(function(){
			var $img = $(this); 
			
			var imageurl = $img.attr('imageurl');
			var title = $img.attr('title');
			var info = $img.attr('info');
			var link = $img.attr('link');
			var image = '<img alt="" height="60" src="' + imageurl + '" />';

			$('.magnetDiv:eq(1)').append('<a href="' + link + '" target="_blank"><div>' + image + '<p class="title">' + title + '</p><p>' + info + '</p></div></a>');
			$('.magnetDiv:eq(1)').find('div').addClass("mag_prodMag");
			$('.magnetDiv:eq(1)').find('div:first').removeClass("mag_prodMag").addClass("mag_prodMagTop");
			$('.magnetDiv:eq(1)').find('div:first').addClass('open');
		});

		$(".magnetDiv:eq(1) .mag_prodMag").mouseover(function(){
				$('.magnetDiv:eq(1) .mag_prodMagTop').removeClass("open");
				$(this).addClass("open");
		}).mouseout(function(){
				$('.magnetDiv:eq(1) .mag_prodMagTop').addClass("open");
				$(this).removeClass("open");
		});
		$(".magnetDiv:eq(1) .mag_prodMagTop").mouseover(function(){
				$(this).addClass("open");
				$('.magnetDiv:eq(1) .mag_prodMag').removeClass("open");
		}).mouseout(function(){
				$(this).addClass("open");
		});
		
	});

	$.get(remindsFile, function(rmo){
		$(rmo).find('reminds').each(function(){
			var $img = $(this); 
			
			var imageurl = $img.attr('imageurl');
			var title = $img.attr('title');
			var info = $img.attr('info');
			var link = $img.attr('link');
			var image = '<img alt="" height="60" src="' + imageurl + '" />';

			$('.magnetDiv:eq(2)').append('<a href="' + link + '" target="_blank"><div>' + image + '<p class="title">' + title + '</p><p>' + info + '</p></div></a>');
			$('.magnetDiv:eq(2)').find('div').addClass("mag_liveMag");
			$('.magnetDiv:eq(2)').find('div:first').removeClass("mag_liveMag").addClass("mag_liveMagTop");
			$('.magnetDiv:eq(2)').find('div:first').addClass('open');
		});

		$(".magnetDiv:eq(2) .mag_liveMag").mouseover(function(){
				$('.magnetDiv:eq(2) .mag_liveMagTop').removeClass("open");
				$(this).addClass("open");
		}).mouseout(function(){
				$('.magnetDiv:eq(2) .mag_liveMagTop').addClass("open");
				$(this).removeClass("open");
		});
		$(".magnetDiv:eq(2) .mag_liveMagTop").mouseover(function(){
				$(this).addClass("open");
				$('.magnetDiv:eq(2) .mag_liveMag').removeClass("open");
		}).mouseout(function(){
				$(this).addClass("open");
		});
	});
}
function setupMyLibrary() {
    $(".droptrue").sortable({
        handle: '.moveDiv',
        connectWith: 'ul',
        opacity: 0.5,
        scroll: false,
        helper: 'clone',
		over: function(event, ui) {
 		 $(".garbageDiv").addClass('garbageDiv-hover');
		},
		out: function(event, ui) {
		 $(".garbageDiv").removeClass('garbageDiv-hover');
		},
        change: function(event, ui) {
        	updatePlaylist();
        },
        receive: function(event, ui) {
            updatePlaylist();
            recountWidth();
        }
    });
    $(".draggable").draggable({
        handle: '.moveDiv',
        connectToSortable: '.droptrue',
        helper: 'clone',
        revert: 'invalid',
        receive: function(event, ui) {
            updatePlaylist();
        }
    });
    $(" .lessInfoDiv a").click(function() {
        $(".lessInfoDiv").removeClass("playingNow");
        $(this).parent("div").addClass("playingNow");

    });
}

