// COMMUNITY FUNCTIONS ----------------------------------------------------------------------------------
path_to_nightlife = "/elements/nightlife/";
var global_utc = 0;
var current_utc = 0;
var current_num = 0;
var limit = (BW == "moz")? 28 : 27;

// EVENTS FUNCTIONS -------------------------------------------------------------------------------------------
function getEvents(utc,num){
	global_utc = utc;
	current_num = num;
/*	$('content1').innerHTML = "Fetching Data...";
	
	var ajax = new Ajax.Updater(
         'content1',        // DIV id (XXX: doesnt work?)
         path_to_nightlife+'events.php',       // URL
         {                // options
         asynchronous: true,
		 method: 'post',
		 postBody: 'utc='+utc+'&limit='+limit+'&num='+num,
		 onComplete: showResponse
		 });

	function showResponse(req){
		$('content1').innerHTML = req.responseText;
		new Effect.Appear('event_content');
	}*/
}

/*
function evGoUp(){
	num = (current_num-limit < 0) ? 0: current_num-limit;
	getEvents(global_utc,num)
}

function evGoDown(){
	getEvents(global_utc,current_num+limit);
}

function showFlyer(flyername){
	if(flyername == undefined){
	}
	else {
		$('calendar').style.display = "none";
		$('flyer').style.display = "block";
		$('flyer').innerHTML = "<br><br><img src=\"/data/flyers/"+flyername+"\">";
	}
}

function hideFlyer(){
	$('flyer').style.display = "none";
	$('calendar').style.display = "block";
}

function getForEventDate(utc){
	if((utc/1000) < (current_utc-88400)){
		window.location.href = "/pics/?stamp="+(utc/1000);
	}
	else{
		getEvents(utc,0);
	}
}
// ----------------------


// PIC FUNCTIONS -----------------------------------------------------------------------------------
function getLastUpdatedParties(){
	$('content2').innerHTML = "Fetching Data...";
	var ajax = new Ajax.Updater(
         'content2',        // DIV id (XXX: doesnt work?)
         path_to_nightlife+'partypics.php?limit='+limit,       // URL
         {                // options
         asynchronous: true,
		 onComplete: showResponse
		 });

	function showResponse(req){
		$('content2').innerHTML = req.responseText;
	}
}

lastid = 0;

function closedSafely(){
	if($('detail'+lastid).style.display == "block"){
		$('detail'+lastid).style.display = "none";
		$('view'+lastid).style.display = "block";
		return true
	}
	else{
		return true;
	}
}

function viewDetails(id,event_id){
	if(closedSafely()){
	$('detail'+id).innerHTML = "";
	$('detail'+id).style.display = "block";
	$('view'+id).style.display = "none";
	}
	lastid = id;
	getPictures(id,event_id);
}

function hideDetails(id) {
	$('detail'+id).style.display = "none";
	$('view'+id).style.display = "block";
}

function getPictures(id,event_id){
	var ajax = new Ajax.Updater(
         'detail'+id,        // DIV id (XXX: doesnt work?)
         path_to_nightlife+'getpics.php',       // URL
         {                // options
         asynchronous: true,
		 method: 'post',
		 postBody: 'id='+event_id,
		 onComplete: showResponse
		 });

	function showResponse(req){
		$('detail'+id).innerHTML = req.responseText;
		new Effect.Appear('pic_holder');
	}
}
//-------------------------------------------------------------------------------------------------

function loadBestofCat(value,pos){
	var ajax = new Ajax.Updater(
         'bestcont'+pos,        // DIV id (XXX: doesnt work?)
         path_to_nightlife+'bestpic.php',       // URL
         {                // options
		 asynchronous: true,
         method: 'post',
		 postBody: 'cat='+value,
		 onComplete: showResponse
		 });

	function showResponse(req){
		$('bestcont'+pos).innerHTML = req.responseText;
		//setTimeout("growDiv("+value+")",2000);
		Effect.Appear('bestcont'+pos, {duration: 2.0});
	}
}

function loadBestof(){
	cat_array = Array(1,2,3,4);
	for(i=1;i<4;i++){
		$('bestcont'+i).style.display = "none";
		loadBestofCat(cat_array.splice(Math.floor(Math.random()*cat_array.length-1),1),i);
	}
}


function viewFlyer(flyername){
	if(flyername == undefined){
	}
	else {
		$('infobox').style.display = "block";
		$('infobox').innerHTML = "<img src=\"/data/flyers/"+flyername+"\" border=\"1\">";
	}
}

function closeFlyer(){
	if($('infobox').style.display == "block"){
		$('infobox').style.display = "none";
	}
	else{
	}
}

*/

document.onmousemove = updateMinipage;
function updateMinipage(e) {
	x = (document.all) ? window.event.x + document.body.scrollLeft : e.pageX;
	y = (document.all) ? window.event.y + document.body.scrollTop  : e.pageY;
	if (document.getElementById("infobox") != null) {
		document.getElementById("infobox").style.left = "50%";
		document.getElementById("infobox").style.marginLeft = "+111px";
		document.getElementById("infobox").style.top 	= (y+20) + "px";
	}
}
