function getHTTPObject() {
    if (typeof XMLHttpRequest != 'undefined') {
	return new XMLHttpRequest();
    }
    try {
	return new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
	try {
	    return new ActiveXObject("Microsoft.XMLHTTP");
	} catch (e) {}
    }
    return false;
}

var xmlhttp = getHTTPObject();

function rewriteMenu(template)
{
	strHTML  = "";
	if(template == "news"){
		strHTML  =  strHTML+"<a href=\"javascript: void(0);\" onclick=\"getNews()\"><img src=\"components/images/menu/menu_news_over.gif\" height=\'30\' width=\'111\' alt=\"go to news\"/></a><br/>";
	}
	else{
		strHTML  =  strHTML+"<a href=\"javascript: void(0);\" onclick=\"getNews()\"><img src=\"components/images/menu/menu_news.gif\" onmouseover=\"this.src=\'components/images/menu/menu_news_over.gif\'\" onmouseout=\"this.src=\'components/images/menu/menu_news.gif\'\" height=\'30\' width=\'111\' alt=\"go to news\"/></a><br/>";	
	}
	if(template == "audio"){
		strHTML  =  strHTML+"<a href=\"javascript: void(0);\" onclick=\"getAudio()\"><img src=\"components/images/menu/menu_audio_over.gif\" height=\'30\' width=\'111\' alt=\"go to audio\"/></a><br/>";
	}
	else{
		strHTML  =  strHTML+"<a href=\"javascript: void(0);\" onclick=\"getAudio()\"><img src=\"components/images/menu/menu_audio.gif\" onmouseover=\"this.src=\'components/images/menu/menu_audio_over.gif\'\" onmouseout=\"this.src=\'components/images/menu/menu_audio.gif\'\" height=\'30\' width=\'111\' alt=\"go to audio\"/></a><br/>";	
	}
	if(template == "video"){
		strHTML  =  strHTML+"<a href=\"javascript: void(0);\" onclick=\"getVideo()\"><img src=\"components/images/menu/menu_video_over.gif\" height=\'30\' width=\'111\' alt=\"go to video\"/></a><br/>";
	}
	else{
		strHTML  =  strHTML+"<a href=\"javascript: void(0);\" onclick=\"getVideo()\"><img src=\"components/images/menu/menu_video.gif\" onmouseover=\"this.src=\'components/images/menu/menu_video_over.gif\'\" onmouseout=\"this.src=\'components/images/menu/menu_video.gif\'\" height=\'30\' width=\'111\' alt=\"go to video\"/></a><br/>";	
	}
	if(template == "gallery"){
		strHTML  =  strHTML+"<a href=\"javascript: void(0);\" onclick=\"getGallery()\"><img src=\"components/images/menu/menu_gallery_over.gif\" height=\'30\' width=\'111\' alt=\"go to gallery\"/></a><br/>";
	}
	else{
		strHTML  =  strHTML+"<a href=\"javascript: void(0);\" onclick=\"getGallery()\"><img src=\"components/images/menu/menu_gallery.gif\" onmouseover=\"this.src=\'components/images/menu/menu_gallery_over.gif\'\" onmouseout=\"this.src=\'components/images/menu/menu_gallery.gif\'\" height=\'30\' width=\'111\' alt=\"go to gallery\"/></a><br/>";	
	}
	if(template == "tourdates"){
		strHTML  =  strHTML+"<a href=\"javascript: void(0);\" onclick=\"getTourdates()\"><img src=\"components/images/menu/menu_tourdates_over.gif\" height=\'30\' width=\'111\' alt=\"go to tourdates\"/></a><br/>";
	}
	else{
		strHTML  =  strHTML+"<a href=\"javascript: void(0);\" onclick=\"getTourdates()\"><img src=\"components/images/menu/menu_tourdates.gif\" onmouseover=\"this.src=\'components/images/menu/menu_tourdates_over.gif\'\" onmouseout=\"this.src=\'components/images/menu/menu_tourdates.gif\'\" height=\'30\' width=\'111\' alt=\"go to tourdates\"/></a><br/>";	
	}
	if(template == "biography"){
		strHTML  =  strHTML+"<a href=\"javascript: void(0);\" onclick=\"getBiography()\"><img src=\"components/images/menu/menu_biography_over.gif\" height=\'30\' width=\'111\' alt=\"go to biography\"/></a><br/>";
	}
	else{
		strHTML  =  strHTML+"<a href=\"javascript: void(0);\" onclick=\"getBiography()\"><img src=\"components/images/menu/menu_biography.gif\" onmouseover=\"this.src=\'components/images/menu/menu_biography_over.gif\'\" onmouseout=\"this.src=\'components/images/menu/menu_biography.gif\'\" height=\'30\' width=\'111\' alt=\"go to biography\"/></a><br/>";	
	}
	if(template == "shop"){
		strHTML  =  strHTML+"<a href=\"javascript: void(0);\" onclick=\"getShop()\"><img src=\"components/images/menu/menu_shop_over.gif\" height=\'30\' width=\'111\' alt=\"go to shop\"/></a><br/>";
	}
	else{
		strHTML  =  strHTML+"<a href=\"javascript: void(0);\" onclick=\"getShop()\"><img src=\"components/images/menu/menu_shop.gif\" onmouseover=\"this.src=\'components/images/menu/menu_shop_over.gif\'\" onmouseout=\"this.src=\'components/images/menu/menu_shop.gif\'\" height=\'30\' width=\'111\' alt=\"go to shop\"/></a><br/>";	
	}
	if(template == "press"){
		strHTML  =  strHTML+"<a href=\"javascript: void(0);\" onclick=\"getPress()\"><img src=\"components/images/menu/menu_press_over.gif\" height=\'30\' width=\'111\' alt=\"go to press\"/></a><br/>";
	}
	else{
		strHTML  =  strHTML+"<a href=\"javascript: void(0);\" onclick=\"getPress()\"><img src=\"components/images/menu/menu_press.gif\" onmouseover=\"this.src=\'components/images/menu/menu_press_over.gif\'\" onmouseout=\"this.src=\'components/images/menu/menu_press.gif\'\" height=\'30\' width=\'111\' alt=\"go to press\"/></a><br/>";	
	}
	if(template == "contact"){
		strHTML  =  strHTML+"<a href=\"javascript: void(0);\" onclick=\"getContact()\"><img src=\"components/images/menu/menu_contact_over.gif\" height=\'30\' width=\'111\' alt=\"go to contact\"/></a><br/>";
	}
	else{
		strHTML  =  strHTML+"<a href=\"javascript: void(0);\" onclick=\"getContact()\"><img src=\"components/images/menu/menu_contact.gif\" onmouseover=\"this.src=\'components/images/menu/menu_contact_over.gif\'\" onmouseout=\"this.src=\'components/images/menu/menu_contact.gif\'\" height=\'30\' width=\'111\' alt=\"go to contact\"/></a><br/>";	
	}
	if(template == "links"){
		strHTML  =  strHTML+"<a href=\"javascript: void(0);\" onclick=\"getLinks()\"><img src=\"components/images/menu/menu_links_over.gif\" height=\'30\' width=\'111\' alt=\"go to links\"/></a><br/>";
	}
	else{
		strHTML  =  strHTML+"<a href=\"javascript: void(0);\" onclick=\"getLinks()\"><img src=\"components/images/menu/menu_links.gif\" onmouseover=\"this.src=\'components/images/menu/menu_links_over.gif\'\" onmouseout=\"this.src=\'components/images/menu/menu_links.gif\'\" height=\'30\' width=\'111\' alt=\"go to links\"/></a><br/>";	
	}
	document.getElementById("menuitems").innerHTML = strHTML;
}

function serveerGet(template, target, action, parentcontentid, contentid, indicator){

	/* 
	this function requires the following parameters:
		template = name of frontside template
		target = target div for serveer content
		action = action to be taken such as mail, post, etc.
		parentcontentid = serveer parentContentID
		contentid = serveer contentID
		indicator = show loading graphic true / false
	*/
	
	rewriteMenu(template)
	
	//stop musicplayer just in case
	flashProxy.call('StopSong');
	
	// clear old content
	if(indicator)
	{
		document.getElementById(target).innerHTML  = "<img src='components/images/loading.gif' alt='' style='margin-top: 20px; margin-left: 20px;'/>";
	}
	
	// get new content through serveerConnector.php
	xmlhttp.open("GET", "serveerConnector.php?template="+template+"&action="+action+"&parentcontentid="+parentcontentid+"&contentid="+contentid, true);
	xmlhttp.onreadystatechange=function(){
		if (xmlhttp.readyState==4){
				response = xmlhttp.responseText;
				document.getElementById(target).innerHTML = response;
				/* if a dhtml script is used it needs to be initialised here (dynamic drive, mootools, etc) */
				// change background color
				if(template=='news'){
					changeBGImage("body","url('components/images/giovanca_back_home.gif')");
					changeBGImage("header","url('components/images/news.jpg')");
				}
				if(template=='audio'){
					changeBGImage("body","url('components/images/giovanca_back_audio.gif')");
					changeBGImage("header","url('components/images/audio.jpg')");					
				}
				if(template=='video'){
					changeBGImage("body","url('components/images/giovanca_back_video.gif')");
					changeBGImage("header","url('components/images/video.jpg')");
				}
				if(template=='gallery'){
					changeBGImage("body","url('components/images/giovanca_back_gallery.gif')");
					changeBGImage("header","url('components/images/gallery.jpg')");
				}
				if(template=='tourdates'){
					changeBGImage("body","url('components/images/giovanca_back_tourdates.gif')");
					changeBGImage("header","url('components/images/tourdates.jpg')");
				}
				if(template=='biography'){
					changeBGImage("body","url('components/images/giovanca_back_biography.gif')");
					changeBGImage("header","url('components/images/biography.jpg')");
				}
				if(template=='shop'){
					changeBGImage("body","url('components/images/giovanca_back_shop.gif')");
					changeBGImage("header","url('components/images/shop.jpg')");
				}
				if(template=='press'){
					changeBGImage("body","url('components/images/giovanca_back_press.gif')");
					changeBGImage("header","url('components/images/press.jpg')");
				}
				if(template=='contact'){
					changeBGImage("body","url('components/images/giovanca_back_contact.gif')");
					changeBGImage("header","url('components/images/contact.jpg')");
				}
				if(template=='links'){
					changeBGImage("body","url('components/images/giovanca_back_links.gif')");
					changeBGImage("header","url('components/images/links.jpg')");
				}
		}
	}
	xmlhttp.send(null);
}
