var libationNumberOfSet = 0;
var libationCurrentSet = 1;

var djNumberOfDJ = 0;
var djCurrentDJ = 1;

jQuery(window).ready(function () {

	jQuery("#item1").hover(
		function() {
			jQuery("#item1  img").fadeIn(100);
		},
		function() {
			jQuery("#item1  img").fadeOut(100);
		}
	);

	jQuery("#item2").hover(
		function() {
			jQuery("#item2  img").fadeIn(100);
		},
		function() {
			jQuery("#item2  img").fadeOut(100);
		}
	);

	jQuery("#item3").hover(
		function() {
			jQuery("#item3  img").fadeIn(100);
		},
		function() {
			jQuery("#item3  img").fadeOut(100);
		}
	);

	jQuery("#item4").hover(
		function() {
			jQuery("#item4  img").fadeIn(100);
		},
		function() {
			jQuery("#item4  img").fadeOut(100);
		}
	);

	jQuery("#item5").hover(
		function() {
			jQuery("#item5  img").fadeIn(100);
		},
		function() {
			jQuery("#item5  img").fadeOut(100);
		}
	);

	jQuery("#item6").hover(
		function() {
			jQuery("#item6  img").fadeIn(100);
		},
		function() {
			jQuery("#item6  img").fadeOut(100);
		}
	);

	//jQuery("#item7").hover(
		//function() {
		//	jQuery("#item7  img").fadeIn(100);
		//},
		//function() {
		//	jQuery("#item7  img").fadeOut(100);
		//}
	//);


});

function showLibationPopup(theURL, theItem) {
var theOffset = jQuery(""+theItem+"").offset();
var theLeft = theOffset.left+76;
if((theLeft+320)>document.body.clientWidth) {
	theLeft = theOffset.left - 320;
}

var theTop = theOffset.top+10;
	jQuery(".libationPopup").load(theURL, function() {
		jQuery(".libationPopup").css("top", theTop+"px");
		jQuery(".libationPopup").css("left", theLeft+"px");
		jQuery(".libationPopup").fadeIn("fast");
	});
	//return false;
}

function showLibationPopup2(theURL, theItem) {
var theOffset = jQuery(""+theItem+"").offset();
var theLeft = theOffset.left+72;
if((theLeft+320)>document.body.clientWidth) {
	theLeft = theOffset.left - 320;
}

var theTop = theOffset.top+50;
	jQuery(".libationPopup").load(theURL, function() {
		jQuery(".libationPopup").css("top", theTop+"px");
		jQuery(".libationPopup").css("left", theLeft+"px");
		jQuery(".libationPopup").fadeIn("fast");
	});
	//return false;
}

function showLibationPopup3(theURL, theItem) {
var theOffset = jQuery(""+theItem+"").offset();
var theLeft = theOffset.left+120;
if((theLeft+320)>document.body.clientWidth) {
	theLeft = theOffset.left - 240;
}

var theTop = theOffset.top+50;
	jQuery(".libationPopup").load(theURL, function() {
		jQuery(".libationPopup").css("top", theTop+"px");
		jQuery(".libationPopup").css("left", theLeft+"px");
		jQuery(".libationPopup").fadeIn("fast");
	});
	//return false;
}

function hideLibationPopup() {
	jQuery(".libationPopup").css("display","none");
}

function initLibationList(numberOfSet) {
	libationNumberOfSet = numberOfSet;
	jQuery("#libationPrev").click( function() {
		libationPrev();
	});
	jQuery("#libationNext").click( function() {
		 libationNext();
	});
	jQuery("#libationRestriction").hover(function() {
	}, function() {
		hideLibationPopup();
	});
}

function showLibation(libationID) {
	jQuery(".libationWrapper").css("display","none");
	jQuery(""+libationID+"").fadeIn("fast");
}

function libationPrev() {
	if(libationCurrentSet > 1) {
		libationCurrentSet =  libationCurrentSet-1;
		showLibation(".libationSet_"+libationCurrentSet);
	}
	else if(libationCurrentSet ==1) {
		libationCurrentSet =  libationNumberOfSet;
		showLibation(".libationSet_"+libationCurrentSet);
	}
}

function libationNext() {
	if(libationCurrentSet < libationNumberOfSet) {
		libationCurrentSet =  libationCurrentSet+1;
		showLibation(".libationSet_"+libationCurrentSet);
	}
	else if(libationCurrentSet == libationNumberOfSet) {
		libationCurrentSet =  1;
		showLibation(".libationSet_"+libationCurrentSet);
	}
}

function registerLibationButton (libationURL, libationID) {
	jQuery(""+libationID+"").hover(
	function(){
		showLibationPopup(libationURL,libationID);
	}
	, function() {
		hideLibationPopup();
	});
}

function switchTrack(songTitle, songURL, buttonID) {
	jQuery(".playerSWFContainer").html(outputPlayerSWF(songTitle, songURL));
	jQuery(".trackButton").css("backgroundPosition","0 0");
	jQuery(""+buttonID+"").css("backgroundPosition","0 -13px");
}

function outputPlayerSWF(songTitle, songURL) {
	var theOutput = '<object type="application/x-shockwave-flash" width="247" height="33" data="images/v2_images/xspf_player_slim.swf?song_url='+songURL+'&amp;song_title='+songTitle+'&amp;autoplay=true" wmode="transparent"><param name="movie" value="images/v2_images/xspf_player_slim.swf?song_url='+songURL+'&amp;song_title='+songTitle+'&amp;autoplay=true" /><param name="wmode" value="transparent" /></object>';

	return theOutput;
}

function initializeDJ(numberOfDJ) {
	djNumberOfDJ = numberOfDJ;
	jQuery("#djPrev").click(function() {
		djPrev();
	});
	jQuery("#djNext").click(function() {
		djNext();
	});
}

function showDJ(djID) {
	var randCode = Math.floor(Math.random()*100);
	jQuery("#djDetails").css("display","none");
	jQuery("#djDetails").html( jQuery("#djDetails"+djID).html() );
	jQuery("#djDetails").fadeIn("fast");
	jQuery("#playerContent").load("djcontent/dj_playlist_"+djID+".html"+"?rand="+randCode);
}

function djPrev() {
	if(djCurrentDJ > 1) {
		djCurrentDJ = djCurrentDJ-1;
	}
	else if(djCurrentDJ==1) {
		djCurrentDJ = djNumberOfDJ;
	}

	showDJ(djCurrentDJ);
}

function djNext() {
	if(djCurrentDJ < djNumberOfDJ) {
		djCurrentDJ = djCurrentDJ+1;
	}
	else if(djCurrentDJ==djNumberOfDJ) {
		djCurrentDJ = 1;
	}

	showDJ(djCurrentDJ);

}

function djShowDetails(djURL) {
	
}

function highlightGSpot(gspotID) {
	jQuery(".gspots").css("display","none");
	jQuery(""+gspotID+"").fadeIn("fast");
	jQuery(".gspotPopupWrapper").fadeIn("fast");
}

function hideGSpot() {
	jQuery(".gspots").css("display","none");
	jQuery(".gspotPopupWrapper").css("display","none");
}

function initGSpot(gSpotID) {
	jQuery("#gspot_actual").hover(
		function() {
			highlightGSpot(""+gSpotID+"");
		},
		function() {
			hideGSpot();
		}
	);
}

function showDJDetails(djURL, djLinkID) {
	jQuery(".djPopup").load(djURL, function() {
		var djDetailOffset = jQuery(""+djLinkID+"").offset();
		jQuery(".djPopup").css("top", djDetailOffset.top+11+"px");
		jQuery(".djPopup").css("left", djDetailOffset.left+"px");
		jQuery(".djPopup").slideDown("fast");
		//jQuery("#debugBox").html(djDetailOffset.top+" "+djDetailOffset.left+" "+djLinkID);
	});
}

function hideDJDetail() {
	jQuery(".djPopup").css("display","none");
}
