/*
 * GLOBALS
 */
var xmlHttp = null;

var cACTION_LOAD_HOME = 1;
var cACTION_LOAD_FAQ = 2;
var cACTION_LOAD_BIO = 3;
var cACTION_LOAD_DISCO = 4;
var cACTION_LOAD_LINKS = 5;
var cACTION_LOAD_LENFANT = 6;
var cACTION_LOAD_IMPRESSUM = 7;
var cACTION_LOAD_DATES = 8;
var cACTION_LOAD_RELEASES = 9;
var cACTION_LOAD_VIDEOS_GALLERIES = 10;
var cACTION_LOAD_BLOG = 11;
var cACTION_LOAD_LYRICS = 12;
var cACTION_LOAD_RELEASE_QUIZ = 13;

/**
 * Switches to home menu and displays its content
 *///---------------------------------------------------------------------------
function switchHome() {
	performAjax("sitefuncs.php?action=" + cACTION_LOAD_HOME);
}

/**
 * Switches to home menu and displays its content
 *///---------------------------------------------------------------------------
function switchBlog() {
	performAjax("sitefuncs.php?action=" + cACTION_LOAD_BLOG);
}

/**
 * Switches to home menu and displays its content
 *///---------------------------------------------------------------------------
function switchFaq() {
	performAjax("sitefuncs.php?action=" + cACTION_LOAD_FAQ);
}

/**
 * Switches to home menu and displays its content
 *///---------------------------------------------------------------------------
function switchBio() {
	performAjax("sitefuncs.php?action=" + cACTION_LOAD_BIO);
}

/**
 * Switches to discography menu and displays its content
 *///---------------------------------------------------------------------------
function switchDisco() {
	performAjax("sitefuncs.php?action=" + cACTION_LOAD_DISCO);
}

/**
 * Switches to links
 *///---------------------------------------------------------------------------
function switchLinks() {
	performAjax("sitefuncs.php?action=" + cACTION_LOAD_LINKS);
}

/**
 * Switches to links
 *///---------------------------------------------------------------------------
function switchLenfant() {
	performAjax("sitefuncs.php?action=" + cACTION_LOAD_LENFANT);
}

/**
 * Switches to impressum
 *///---------------------------------------------------------------------------
function switchImpress() {
	performAjax("sitefuncs.php?action=" + cACTION_LOAD_IMPRESSUM);
}


/**
 * Switches to dates
 *///---------------------------------------------------------------------------
function switchDates() {
	performAjax("sitefuncs.php?action=" + cACTION_LOAD_DATES);
}

/**
 * Switches to "Dear Ladies" feature
 *///---------------------------------------------------------------------------
function switchReleases() {
	performAjax("sitefuncs.php?action=" + cACTION_LOAD_RELEASES);
}

/**
 * Switches to "VIDS and Galleries"
 *///---------------------------------------------------------------------------
function switchVidsAndGalleries() {
	performAjax("sitefuncs.php?action=" + cACTION_LOAD_VIDEOS_GALLERIES);
}

/**
 * Switches to "Lyrics" page
 *///---------------------------------------------------------------------------
function switchLyrics() {
	performAjax("sitefuncs.php?action=" + cACTION_LOAD_LYRICS);
}

/**
 * Switches to "Release Quiz" page
 *///---------------------------------------------------------------------------
function switchReleaseQuiz() {
	performAjax("sitefuncs.php?action=" + cACTION_LOAD_RELEASE_QUIZ);
}

/**
 * Default AJAX-onreadystatechanged-Handler
 *///---------------------------------------------------------------------------
function handleDefaultRequest() {
	if (xmlHttp.readyState == 4) {
		document.getElementById("divContent").innerHTML = xmlHttp.responseText;
	}
}

/**
 * Performs the AJAX request
 * @param {String} url
 *///---------------------------------------------------------------------------
function performAjax(url) {
	xmlHttp = getXmlHttpRequest();
	xmlHttp.onreadystatechange = handleDefaultRequest;
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}

/**
 * Tries to create a Request-object, according to browser-type
 * @return  {Object}  XMLHTTP-Request
 *///---------------------------------------------------------------------------
function getXmlHttpRequest() {
	var req = null;
	try {
		req = new XMLHttpRequest();
	}
	catch (e) {
		try {
			req = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) {
			try {
				req = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e) {
				alert("HTTPRequest-Object could not be created!");
				req = null;
			}
		}
	}
	return (req);
}

/*
 * POPUP-related
 */

var scrWidth = screen.width;
var scrHeight = screen.height;

var scrAvailWidth = screen.availWidth;
var scrAvailHeight = screen.availHeight;

var winWidth 	= parseInt(scrAvailWidth  - (scrAvailWidth * 0.3));
var winHeight = parseInt(scrAvailHeight - (scrAvailHeight* 0.3));

var winLeftPos= parseInt((scrWidth / 2) - (winWidth / 2));
var winTopPos	= parseInt((scrHeight / 2) - (winHeight/ 2));

winTopPos = parseInt(winTopPos - (winTopPos / 2));

/*
alert(	"scrWidth: " + scrWidth + "\n"
			+ "scrHeight: " + scrHeight + "\n"
			+	"scrAvailWidth: " + scrAvailWidth + "\n"
			+ "scrAvailHeight: " + scrAvailHeight + "\n"
			+	"winWidth: " + winWidth + "\n"
			+	"winHeight: " + winHeight + "\n"
			+	"winLeftPos: " + winLeftPos + "\n"
			+	"winTopPos: " + winTopPos + "\n"
		 );

*/
var popupWin = null;
var cGALLERY_ATTRIBS = 	"location=no, menubar=no, toolbar=no, status=no, "
											+	"resizable=yes,scrollbars=no,"
											+	"width=" + winWidth + ","
											+ "height="+ winHeight
											;

/**
 * Launches <code>url</code> in a popup window
 * @param {String} url, URL to open in popup
 *///---------------------------------------------------------------------------
function showGallery(url) {
	openPopUp("galleries/" + url);
}

/**
 * Closes the popup window in case it's open
 *///---------------------------------------------------------------------------
function closePopUp() {
	if ((popupWin == null) || (typeof(popupWin) != "object")) {
		return;
	}
	if (popupWin.closed) {
		return;
	}

	// store properties of popup
	winWidth = popupWin.outerWidth;
	winHeight = popupWin.outerHeight;

	popupWin.close();
}

/**
 * Opens <code>url</code> in a popup window
 * @param {String} url, URL to open in popup
 *///---------------------------------------------------------------------------
function openPopUp(url) {
	// closePopUp();
	popupWin = window.open(	url,
													"popup",
													"location=no, menubar=no, toolbar=no, status=no, "
												+	"resizable=yes,scrollbars=no,"
												+	"width=" + winWidth + ","
												+ "height="+ winHeight + ","
												+	"left=" + winLeftPos + ","
												+ "top="+ winTopPos
												);
	popupWin.focus();
}

/**
 * Object-Constructor for a floating div that obeys window-scrolling
 * @param {Object} id
 * @param {Object} xPos
 * @param {Object} yPos
 *///---------------------------------------------------------------------------
 /*
function FloatingDiv(id, xPos, yPos) {
	var obj = document.getElementById(id);
	var pxSuff = document.layers ? "" : "px";

	window[id + "_obj"] = obj;

	// define the object
	obj.floatSteps = 2;
	obj.timerInterval = 40;

	if (document.layers) {
		obj.style = obj;
	}

	obj.cy = obj.yPos = yPos;

	// Float function
	obj.floatIt = function() {
		var pY;
		var clWidth = document.documentElement.clientWidth;

		pY	= (document.documentElement && document.documentElement.scrollTop) 
				?  document.documentElement.scrollTop 
				:		document.body.scrollTop
				;

		if (this.yPos < 0) {
			pY += (document.documentElement && document.documentElement.clientHeight) 
					? document.documentElement.clientHeight 
					: document.body.clientHeight
					;
		}
		this.cy += (pY + this.yPos - this.cy) / this.floatSteps;
		this.style.top = this.cy + pxSuff;
		setTimeout(this.id + "_obj.floatIt()", this.timerInterval);
	}

	return obj;
}
*/

